Parcourir la source

开发中每日备份

djs il y a 4 mois
Parent
commit
7eb3b89072

BIN
MV485/Assest/run_config.png


+ 17 - 0
MV485/MV485.csproj

@@ -81,6 +81,12 @@
     </Compile>
     <Compile Include="helper\SerialHelper.cs" />
     <Compile Include="helper\Tools.cs" />
+    <Compile Include="uc\UCDeviceConfig.xaml.cs">
+      <DependentUpon>UCDeviceConfig.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="uc\UCRunConfig.xaml.cs">
+      <DependentUpon>UCRunConfig.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Upgrade\UpgradeHelper.cs" />
     <Compile Include="model\Constant.cs" />
     <Compile Include="model\PortModel.cs" />
@@ -112,6 +118,10 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Page Include="uc\UCDeviceConfig.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="uc\UCDeviceFinder.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -120,6 +130,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="uc\UCRunConfig.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Properties\AssemblyInfo.cs">
@@ -181,5 +195,8 @@
   <ItemGroup>
     <Resource Include="RS485.ico" />
   </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Assest\run_config.png" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 14 - 2
MV485/MainWindow.xaml

@@ -29,7 +29,7 @@
                             <!-- 图标 -->
                             <Image Source="Assest/data_monitor.png" Width="16" Height="16" Margin="0,0,5,0" />
                             <!-- 文字 -->
-                            <TextBlock x:Name="txtDataMonitor" Text="数据监控" FontSize="14" Foreground="Black" VerticalAlignment="Center" />
+                            <TextBlock x:Name="txtDataMonitor" Text="数据读取" FontSize="14" Foreground="Black" VerticalAlignment="Center" />
                         </StackPanel>
                     </Button.Content>
                 </Button>
@@ -41,7 +41,19 @@
                             <!-- 图标 -->
                             <Image Source="Assest/config2.png" Width="16" Height="16" Margin="0,0,5,0" />
                             <!-- 文字 -->
-                            <TextBlock x:Name="txtDeviceConfig" FontSize="14" FontWeight="Normal" Text="单点配置" Foreground="Black" VerticalAlignment="Center" />
+                            <TextBlock x:Name="txtDeviceConfig" FontSize="14" FontWeight="Normal" Text="基本参数配置" Foreground="Black" VerticalAlignment="Center" />
+                        </StackPanel>
+                    </Button.Content>
+                </Button>
+
+                <TextBlock Width="1" Background="#686868" Margin="5 5 5 5" Visibility="Visible" />
+                <Button x:Name="btnRunConfig" BorderThickness="0" Click="BtnRunConfig_Click" Background="Transparent" Margin="5 0 5 0" BorderBrush="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center">
+                    <Button.Content>
+                        <StackPanel Orientation="Horizontal">
+                            <!-- 图标 -->
+                            <Image Source="Assest/run_config.png" Width="16" Height="16" Margin="0,0,5,0" />
+                            <!-- 文字 -->
+                            <TextBlock x:Name="txtRunConfig" FontSize="14" FontWeight="Normal" Text="运行参数配置" Foreground="Black" VerticalAlignment="Center" />
                         </StackPanel>
                     </Button.Content>
                 </Button>

+ 30 - 0
MV485/MainWindow.xaml.cs

@@ -59,7 +59,36 @@ namespace MV485
 
         private void BtnDeviceConfig_Click(object sender, RoutedEventArgs e)
         {
+            ResetButtonForegrounds();
+            txtDeviceConfig.Foreground = SelectedForeground;
+            string key = "device_config";
+            if (pageCache.ContainsKey(key))
+            {
+                ContentArea.Content = pageCache[key];
+            }
+            else
+            {
+                var page = new UCDeviceConfig();
+                //pageCache[key] = page;        //缓存页面
+                ContentArea.Content = page;
+            }
+        }
 
+        private void BtnRunConfig_Click(object sender, RoutedEventArgs e)
+        {
+            ResetButtonForegrounds();
+            txtRunConfig.Foreground = SelectedForeground;
+            string key = "run_config";
+            if (pageCache.ContainsKey(key))
+            {
+                ContentArea.Content = pageCache[key];
+            }
+            else
+            {
+                var page = new UCRunConfig();
+                //pageCache[key] = page;        //缓存页面
+                ContentArea.Content = page;
+            }
         }
 
         private void BtnDeviceFind_Click(object sender, RoutedEventArgs e)
@@ -93,6 +122,7 @@ namespace MV485
         {
             txtDataMonitor.Foreground = Brushes.Black;
             txtDeviceConfig.Foreground = Brushes.Black;
+            txtRunConfig.Foreground = Brushes.Black;
             txtDeviceFind.Foreground = Brushes.Black;
         }
 

+ 122 - 0
MV485/uc/UCDeviceConfig.xaml

@@ -0,0 +1,122 @@
+<UserControl x:Class="MV485.uc.UCDeviceConfig"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:MV485.uc"
+             xmlns:zdfflatui="clr-namespace:ZdfFlatUI;assembly=WPF.UI"
+             mc:Ignorable="d" 
+             Padding="5,2,5,5"
+             Background="WhiteSmoke"
+             d:DesignHeight="800" d:DesignWidth="1024">
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto" />
+            <RowDefinition Height="*" />
+        </Grid.RowDefinitions>
+
+        <!-- 控制面板 -->
+        <StackPanel Orientation="Horizontal" Margin="10 10 10 5" >
+            <TextBlock Text="端口号: " VerticalAlignment="Center" FontSize="14px" Margin="0 0 0 0" />
+            <ComboBox x:Name="cmbPortNames" DisplayMemberPath="ModelName" SelectedValuePath="PortName" 
+                      Width="180"  Padding="5 0 0 0" Margin="2" FontSize="13px" VerticalContentAlignment="Center"/>
+            <zdfflatui:FlatButton x:Name="btnRefreshPorts" HorizontalAlignment="Center" Background="#2196F3" 
+                                  Foreground="White" Content="🔄" ToolTip="刷新并重新加载串口列表"
+                                  Click="btnRefreshPorts_Click" Margin="5 0 5 0" Width="30" Height="30" FontSize="20px"  />
+
+            <TextBlock Text="设备波特率: " VerticalAlignment="Center" FontSize="14" Margin="10 0 0 0" />
+            <ComboBox x:Name="cmbBaudrate"
+                      Width="100"  Padding="5 0 0 0" Margin="2" FontSize="13px" VerticalContentAlignment="Center"/>
+
+            <TextBlock Text="设备地址: " VerticalAlignment="Center" FontSize="14" Margin="10 0 0 0" />
+            <TextBox x:Name="txtDevId" Text="1" FontSize="13" Width="60" Margin="0 0 0 0" 
+                     PreviewTextInput="TextBox_PreviewTextInput" MaxLength="3"
+                     TextAlignment="Left" VerticalContentAlignment="Center" Height="24" />
+
+            <zdfflatui:FlatButton x:Name="btnReadConfig" Background="#4CAF50" Foreground="White" Content="读取485基本参数" Width="120"
+                                          Click="BtnReadConfig_Click"  Padding="10 0 10 0"  Height="28" FontSize="13" Margin="10 0 0 0" />
+
+            <!--<zdfflatui:FlatButton x:Name="btnClearLog" HorizontalAlignment="Center" Background="#FF4C4C" Foreground="White" Width="80" 
+                                  Content="清空日志" Click="btnClearLog_Click" Padding="10 0 10 0" Height="28" FontSize="13" Margin="10 0 0 0" />-->       
+        </StackPanel>
+
+        <Border Grid.Row="1" Margin="10" BorderBrush="DarkGray" BorderThickness="1">
+            <Grid>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="300" />
+                    <ColumnDefinition Width="*" />
+                </Grid.ColumnDefinitions>
+
+                <Border Grid.Column="0" BorderBrush="DarkGray" BorderThickness="0 0 1 0" Background="White" >
+                    <StackPanel Orientation="Vertical" Margin="10 0 0 0">
+                        <StackPanel Orientation="Horizontal" Height="50">
+                            <TextBlock Text="设备类型" Width="80" VerticalAlignment="Center" FontSize="14" />
+                            <TextBox IsEnabled="False" x:Name="txtDevType" VerticalContentAlignment="Center"
+                                     Text="0x4001" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
+                            <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
+                                       VerticalAlignment="Center" />
+                        </StackPanel>
+
+                        <StackPanel Orientation="Horizontal" Height="50">
+                            <TextBlock Text="设备序号" Width="80" VerticalAlignment="Center" FontSize="14" />
+                            <TextBox IsEnabled="False" x:Name="txtDevSn" VerticalContentAlignment="Center"
+                                     Text="240505102203" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
+                            <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
+                                       VerticalAlignment="Center" />
+                        </StackPanel>
+
+                        <StackPanel Orientation="Horizontal" Height="50">
+                            <TextBlock Text="校验和" Width="80" VerticalAlignment="Center" FontSize="14" />
+                            <TextBox IsEnabled="False" x:Name="txtParty" VerticalContentAlignment="Center"
+                                     Text="None" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
+                            <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
+                                       VerticalAlignment="Center" />
+                        </StackPanel>
+
+                        <StackPanel Orientation="Horizontal" Height="50">
+                            <TextBlock Text="数据位" Width="80" VerticalAlignment="Center" FontSize="14" />
+                            <TextBox IsEnabled="False" x:Name="txtDataBits" VerticalContentAlignment="Center"
+                                     Text="8" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
+                            <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
+                                       VerticalAlignment="Center" />
+                        </StackPanel>
+
+                        <StackPanel Orientation="Horizontal" Height="50">
+                            <TextBlock Text="停止位" Width="80" VerticalAlignment="Center" FontSize="14" />
+                            <TextBox IsEnabled="False" x:Name="txtStopBits" VerticalContentAlignment="Center"
+                                     Text="1" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
+                            <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
+                                       VerticalAlignment="Center" />
+                        </StackPanel>
+
+                        <StackPanel Orientation="Horizontal" Height="50">
+                            <TextBlock Text="设备波特率" Width="80" VerticalAlignment="Center" FontSize="14" />
+                            <!--<TextBox IsEnabled="True" x:Name="txtDevBaudrate" VerticalContentAlignment="Center"
+                                     Text="240505102203" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />-->
+                            <ComboBox x:Name="cmbDevBaudrate"  Width="120"  Padding="5 0 0 0" Margin="0" FontSize="14" 
+                                      VerticalContentAlignment="Center" Height="28" IsEditable="True"/>
+                            <zdfflatui:FlatButton x:Name="btnSetBaudrate" Background="#2196F3" Foreground="White" 
+                                                  Content="设置" Width="60" Click="BtnSetBaudrate_Click"  
+                                                  Padding="10 0 10 0"  Height="28" FontSize="14" Margin="10 0 0 0" />
+                        </StackPanel>
+
+                        <StackPanel Orientation="Horizontal" Height="50">
+                            <TextBlock Text="设备地址" Width="80" VerticalAlignment="Center" FontSize="14" />
+                            <TextBox IsEnabled="True" x:Name="txtDevAddress" VerticalContentAlignment="Center"
+                                     Text="1" FontSize="14" Width="40" Height="26" Padding="5 0 0 0" />
+                            <TextBlock Text="范围:1~247" Width="80" Foreground="OrangeRed" VerticalAlignment="Center" Padding="6 0 0 0" FontSize="14" />
+                            <zdfflatui:FlatButton x:Name="btnSetDevAddress" Background="#2196F3" Foreground="White" 
+                                                  Content="设置" Width="60" Click="BtnSetDevAddress_Click"  
+                                                  Padding="10 0 10 0"  Height="28" FontSize="14" Margin="10 0 0 0" />
+                        </StackPanel>
+
+                    </StackPanel>
+                </Border>
+
+            
+            </Grid>
+        </Border>
+        
+        
+    </Grid>
+</UserControl>

+ 54 - 0
MV485/uc/UCDeviceConfig.xaml.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace MV485.uc
+{
+    /// <summary>
+    /// UCDeviceConfig.xaml 的交互逻辑
+    /// </summary>
+    public partial class UCDeviceConfig : UserControl
+    {
+        public UCDeviceConfig()
+        {
+            InitializeComponent();
+        }
+
+        private void BtnReadConfig_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void BtnSetDevAddress_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void BtnSetBaudrate_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void btnRefreshPorts_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+        {
+
+        }
+        //-----------------------------------------------------------------------------
+    }
+}

+ 12 - 0
MV485/uc/UCRunConfig.xaml

@@ -0,0 +1,12 @@
+<UserControl x:Class="MV485.uc.UCRunConfig"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:MV485.uc"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+            
+    </Grid>
+</UserControl>

+ 28 - 0
MV485/uc/UCRunConfig.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace MV485.uc
+{
+    /// <summary>
+    /// UCRunConfig.xaml 的交互逻辑
+    /// </summary>
+    public partial class UCRunConfig : UserControl
+    {
+        public UCRunConfig()
+        {
+            InitializeComponent();
+        }
+    }
+}