Parcourir la source

优化了一个日期时间控件

djs il y a 3 mois
Parent
commit
5a4cb9cd56

+ 9 - 2
MV485/helper/Tools.cs

@@ -116,9 +116,16 @@ namespace MV485.helper
             { 0,0.0001},{1,0.001},{2,0.01},{3,0.1},{4,1},{5,10},{6,100},{7,1000},{8,10000}
         };
 
-        public static List<int> NumList = new List<int>
+        public static List<byte> NumList = new List<byte>
         {
-            0,1,2,3,4,5,6,7,8,9,10
+            //0,1,2,3,4,5,6,7,8,9,10
+            4,5,6,7,8,9,10
+        };
+
+        public static List<byte> IndList = new List<byte>
+        {
+            //0,1,2,3,4,5,6,7,8,9,10
+            1,2,3,4,5,6,7,8
         };
 
         public static List<float> BrightList = new List<float>

+ 4 - 4
MV485/uc/UCDeviceUpgrade.xaml

@@ -125,10 +125,10 @@
                                                           Content="回滚设备固件"  Click="BtnDeviceRollback_Click" 
                                                           Height="28" FontSize="14" Margin="10 0 10 0" />
                 </Grid>
-                <Grid Height="60" >
-                    <TextBlock Text="注意:要先读取到当前设备的版本信息后,再进行固件升级或回滚操作。" 
-                               TextWrapping="Wrap" Foreground="Red" Margin="5 0 5 0"
-                               FontSize="14" VerticalAlignment="Center"/>
+                <Grid Height="100" >
+                    <TextBlock x:Name="txtWarmInfo" Text="注意:要先读取到当前设备的版本信息后,再进行固件升级或回滚操作。" 
+                               TextWrapping="Wrap" Foreground="Red" Margin="5 5 5 0"
+                               FontSize="14" VerticalAlignment="Top"/>
                 </Grid>
             </StackPanel>
         </Border>

+ 4 - 0
MV485/uc/UCDeviceUpgrade.xaml.cs

@@ -35,6 +35,9 @@ namespace MV485.uc
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
         }
 
+        public const string _warnInfo = "注意:要先读取到当前设备的版本信息后,再进行固件升级或回滚操作。" +
+            "\n烧写固件时需认真核对烧写文件,错误的文件回导致设备无法启动";
+
         public int[] PageSizeOptions = new int[] { 10, 20, 50 };
 
         //private DeviceUpgrade _deviceUpgrade;
@@ -136,6 +139,7 @@ namespace MV485.uc
             {
 
             };
+            txtWarmInfo.Text = _warnInfo;
         }
 
         //读取并加载日志

+ 8 - 4
MV485/uc/UCRunConfig.xaml

@@ -231,8 +231,10 @@
                                     <ColumnDefinition Width="80" />
                                 </Grid.ColumnDefinitions>
                                 <TextBlock Grid.Column="0" Text="数字个数" VerticalAlignment="Center" FontSize="14" />
-                                <ComboBox Grid.Column="1" x:Name="cmbNumCount"  Height="26" FontSize="14px"
-                                          IsEditable="True" PreviewTextInput="TextBox_PreviewTextInput"/>
+                                <!--<ComboBox Grid.Column="1" x:Name="cmbNumCount"  Height="26" FontSize="14px"
+                                          IsEditable="True" PreviewTextInput="TextBox_PreviewTextInput"/>-->
+                                <ComboBox x:Name="cmbNumCount"  Height="26" FontSize="14px" Grid.Column="1" />
+
                                 <Button x:Name="btnNumCount" Click="BtnNumCount_Click"
                                         Grid.Column="2" Content="说明示例" BorderThickness="0 0 0 1" BorderBrush="Blue"
                                             Height="20" Width="60" Background="Transparent" Foreground="Blue" FontSize="14" />
@@ -245,8 +247,10 @@
                                     <ColumnDefinition Width="80" />
                                 </Grid.ColumnDefinitions>
                                 <TextBlock Grid.Column="0" Text="指针个数" VerticalAlignment="Center" FontSize="14" />
-                                <ComboBox Grid.Column="1" x:Name="cmbIndCount" Height="26" FontSize="14px"
-                                          IsEditable="True" PreviewTextInput="TextBox_PreviewTextInput"/>
+                                <!--<ComboBox Grid.Column="1" x:Name="cmbIndCount" Height="26" FontSize="14px"
+                                          IsEditable="True" PreviewTextInput="TextBox_PreviewTextInput"/>-->
+                                <ComboBox x:Name="cmbIndCount"  Height="26" FontSize="14px" Grid.Column="1" />
+                                
                                 <Button x:Name="btnIndCount" Click="BtnIndCount_Click" 
                                         Grid.Column="2" Content="说明示例" BorderThickness="0 0 0 1" BorderBrush="Blue"
                                             Height="20" Width="60" Background="Transparent" Foreground="Blue" FontSize="14" />

+ 49 - 18
MV485/uc/UCRunConfig.xaml.cs

@@ -12,6 +12,7 @@ using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
 using System.Windows.Data;
 using System.Windows.Documents;
 using System.Windows.Input;
@@ -140,15 +141,33 @@ namespace MV485.uc
             cmbMeterType.SelectedItem = null;
             //cmbFlowRate.Text = "";
             cmbDnValue.SelectedItem = null;
-            cmbNumCount.Text = "";
-            cmbIndCount.Text = "";
+            //cmbNumCount.Text = "";
+            cmbNumCount.SelectedItem = null;
+            //cmbIndCount.Text = "";
+            cmbIndCount.SelectedItem = null;
             //cmbBrightVal.Text = "";
             cmbLastUnit.SelectedItem = null;
             txtLastValue.Text = "";
-            dtpLastValueTime.Text = "";
+            //dtpLastValueTime.Text = "";
+            //dtpLastValueTime.Value = null;
+            //dtpLastValueTime.ClearValue(dtpLastValueTime.ValueProperty);
+            //dtpLastValueTime.SelectedDate = null;
+            //dtpLastValueTime.Value = null;  // 第一步:清空 Value 依赖属性
+            //dtpLastValueTime.SelectedDate = null;  // 清空基础类 DatePicker 的值
+
+            dtpLastValueTime.Value = null;
+
+            dtpLastValueTime.ApplyTemplate();
+            var tb = dtpLastValueTime.Template.FindName("PART_TextBox_New", dtpLastValueTime) as DatePickerTextBox;
+            var cal = dtpLastValueTime.Template.FindName("PART_Calendar", dtpLastValueTime) as Calendar;
+            if (tb != null) tb.Text = "";
+            if (cal != null) cal.SelectedDate = null;
+
+            //dtpLastValueTime.v
             txtMeterRegion.Text = "";
             txtFeatureRegion.Text = "";
 
+
             //cmbSampleInterval.Text = "";
             cmbSampleInterval.SelectedItem = null;
             //txtFirstHour.Text = "";
@@ -163,7 +182,7 @@ namespace MV485.uc
 
             cmbLastUnit.ItemsSource = Tools.LastUnitMap;    //.UnitList;
             cmbNumCount.ItemsSource = Tools.NumList;
-            cmbIndCount.ItemsSource = Tools.NumList;
+            cmbIndCount.ItemsSource = Tools.IndList;     //Tools.NumList;
             //cmbBrightVal.ItemsSource = Tools.BrightList;
             cmbSampleInterval.ItemsSource = Tools.SampleIntervalList;
             cmbFirstHour.ItemsSource = Enumerable.Range(0, 24).ToList();
@@ -722,14 +741,16 @@ namespace MV485.uc
             if (runConfig.DigitCountWRFlag && 
                 (runConfig.MeterType == Constant.METER_TYPE_NUM_IND || runConfig.MeterType == Constant.METER_TYPE_NUM))
             {
-                cmbNumCount.Text = runConfig.DigitCount.ToString();
+                //cmbNumCount.Text = runConfig.DigitCount.ToString();
+                cmbNumCount.SelectedItem = runConfig.DigitCount;
                 grdNumCount.Visibility = Visibility.Visible;
             }
 
             if (runConfig.IndCountWRFlag && 
                 (runConfig.MeterType == Constant.METER_TYPE_NUM_IND || runConfig.MeterType == Constant.METER_TYPE_IND ))
             {
-                cmbIndCount.Text = runConfig.IndCount.ToString();
+                //cmbIndCount.Text = runConfig.IndCount.ToString();
+                cmbIndCount.SelectedItem = runConfig.IndCount;
                 grdIndCount.Visibility = Visibility.Visible;
             }
 
@@ -861,30 +882,40 @@ namespace MV485.uc
 
             if (runConfig.MeterType == Constant.METER_TYPE_NUM_IND || runConfig.MeterType == Constant.METER_TYPE_NUM)
             {
-                if (string.IsNullOrWhiteSpace(cmbNumCount.Text) ||
-                    !byte.TryParse(cmbNumCount.Text, out byte digitCount) ||
-                    !(digitCount >0 && digitCount <= 10))
+                //if (string.IsNullOrWhiteSpace(cmbNumCount.Text) ||
+                //    !byte.TryParse(cmbNumCount.Text, out byte digitCount) ||
+                //    !(digitCount >0 && digitCount <= 10))
+                //{
+                //    MessageBox.Show(Application.Current.MainWindow, "请输入数字个数", "提示",
+                //        MessageBoxButton.OK, MessageBoxImage.Warning);
+                //    return;
+                //}
+                if(cmbNumCount.SelectedItem == null)
                 {
-                    MessageBox.Show(Application.Current.MainWindow, "请输入数字个数", "提示",
+                    MessageBox.Show(Application.Current.MainWindow, "请选择数字个数", "提示",
                         MessageBoxButton.OK, MessageBoxImage.Warning);
-                    return;
                 }
                 runConfig.DigitCountWRFlag = true;
-                runConfig.DigitCount = digitCount;
+                runConfig.DigitCount = (byte)cmbNumCount.SelectedItem;  //digitCount;
             }
 
             if(runConfig.MeterType == Constant.METER_TYPE_NUM_IND || runConfig.MeterType == Constant.METER_TYPE_IND)
             {
-                if(string.IsNullOrWhiteSpace(cmbIndCount.Text) ||
-                    !byte.TryParse(cmbIndCount.Text,out byte indCount) ||
-                    !(indCount >0 && indCount <=10))
+                //if(string.IsNullOrWhiteSpace(cmbIndCount.Text) ||
+                //    !byte.TryParse(cmbIndCount.Text,out byte indCount) ||
+                //    !(indCount >0 && indCount <=10))
+                //{
+                //    MessageBox.Show(Application.Current.MainWindow, "请输入指针个数", "提示",
+                //        MessageBoxButton.OK, MessageBoxImage.Warning);
+                //    return;
+                //}
+                if (cmbIndCount.SelectedItem == null)
                 {
-                    MessageBox.Show(Application.Current.MainWindow, "请输入指针个数", "提示",
+                    MessageBox.Show(Application.Current.MainWindow, "请选择指针个数", "提示",
                         MessageBoxButton.OK, MessageBoxImage.Warning);
-                    return;
                 }
                 runConfig.IndCountWRFlag = true;
-                runConfig.IndCount = indCount;
+                runConfig.IndCount = (byte)cmbIndCount.SelectedItem;  //indCount;
             }
 
             //此项已经不需要了