NewLife/XCoder

打开正则窗口
大石头 authored at 2020-05-08 00:44:52
4e3ba0c
Tree
1 Parent(s) 09d49ca
Summary: 6 changed files with 29 additions and 10 deletions.
Modified +3 -3
Modified +5 -0
Modified +2 -0
Modified +14 -2
Renamed +3 -3
CrazyCoder/Views/Regex.xaml → CrazyCoder/Views/RegexWindow.xaml
Renamed +2 -2
CrazyCoder/Views/Regex.xaml.cs → CrazyCoder/Views/RegexWindow.xaml.cs
Modified +3 -3
diff --git a/CrazyCoder/CrazyCoder.csproj b/CrazyCoder/CrazyCoder.csproj
index 530e4ab..3b0fe83 100644
--- a/CrazyCoder/CrazyCoder.csproj
+++ b/CrazyCoder/CrazyCoder.csproj
@@ -62,8 +62,8 @@
     <Compile Include="Models\MenuModel.cs" />
     <Compile Include="Setting.cs" />
     <Compile Include="ViewModels\MainViewModel.cs" />
-    <Compile Include="Views\Regex.xaml.cs">
-      <DependentUpon>Regex.xaml</DependentUpon>
+    <Compile Include="Views\RegexWindow.xaml.cs">
+      <DependentUpon>RegexWindow.xaml</DependentUpon>
     </Compile>
     <Page Include="MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
@@ -77,7 +77,7 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
-    <Page Include="Views\Regex.xaml">
+    <Page Include="Views\RegexWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
Modified +5 -0
diff --git a/CrazyCoder/MainWindow.xaml.cs b/CrazyCoder/MainWindow.xaml.cs
index 6b6f68a..b36faff 100644
--- a/CrazyCoder/MainWindow.xaml.cs
+++ b/CrazyCoder/MainWindow.xaml.cs
@@ -2,6 +2,7 @@
 using System.Windows;
 using System.Windows.Input;
 using CrazyCoder.ViewModels;
+using CrazyCoder.Views;
 
 namespace CrazyCoder
 {
@@ -21,6 +22,8 @@ namespace CrazyCoder
         private void Regex_Click(Object sender, RoutedEventArgs e)
         {
             //frame.Navigate(new Uri("Views\\Regex.xaml", UriKind.Relative));
+            var frm = new RegexWindow();
+            frm.Show();
         }
 
         private void Ico_Click(Object sender, RoutedEventArgs e)
@@ -59,6 +62,7 @@ namespace CrazyCoder
         }
         #endregion
 
+        #region 窗口控制
         private void Nav_MouseDown(Object sender, MouseButtonEventArgs e)
         {
             if (e.LeftButton == MouseButtonState.Pressed) DragMove();
@@ -81,5 +85,6 @@ namespace CrazyCoder
         {
             Close();
         }
+        #endregion
     }
 }
\ No newline at end of file
Modified +2 -0
diff --git a/CrazyCoder/Models/MenuModel.cs b/CrazyCoder/Models/MenuModel.cs
index 5086c55..938c2a6 100644
--- a/CrazyCoder/Models/MenuModel.cs
+++ b/CrazyCoder/Models/MenuModel.cs
@@ -9,5 +9,7 @@ namespace CrazyCoder.Models
         public String Title { get; set; }
 
         public String BackColor { get; set; }
+
+        public Type Type { get; set; }
     }
 }
\ No newline at end of file
Modified +14 -2
diff --git a/CrazyCoder/ViewModels/MainViewModel.cs b/CrazyCoder/ViewModels/MainViewModel.cs
index ff0dcb8..8007f39 100644
--- a/CrazyCoder/ViewModels/MainViewModel.cs
+++ b/CrazyCoder/ViewModels/MainViewModel.cs
@@ -1,7 +1,10 @@
 using System.Collections.ObjectModel;
+using System.Windows;
 using CrazyCoder.Models;
+using CrazyCoder.Views;
 using GalaSoft.MvvmLight;
 using GalaSoft.MvvmLight.Command;
+using NewLife.Reflection;
 
 namespace CrazyCoder.ViewModels
 {
@@ -15,7 +18,7 @@ namespace CrazyCoder.ViewModels
             menus.Add(new MenuModel() { IconFont = "\xe6e1", Title = "RPC工具", BackColor = "#218868" });
             menus.Add(new MenuModel() { IconFont = "\xe614", Title = "串口工具", BackColor = "#EE3B3B" });
             menus.Add(new MenuModel() { IconFont = "\xe755", Title = "地图接口", BackColor = "#218868" });
-            menus.Add(new MenuModel() { IconFont = "\xe635", Title = "正则表达式", BackColor = "#218868" });
+            menus.Add(new MenuModel() { IconFont = "\xe635", Title = "正则表达式", BackColor = "#218868", Type = typeof(RegexWindow) });
             menus.Add(new MenuModel() { IconFont = "\xe6b6", Title = "图标水印", BackColor = "#EE3B3B" });
             menus.Add(new MenuModel() { IconFont = "\xe6e1", Title = "加密解密", BackColor = "#218868" });
             menus.Add(new MenuModel() { IconFont = "\xe614", Title = "语音助手", BackColor = "#EE3B3B" });
@@ -45,6 +48,15 @@ namespace CrazyCoder.ViewModels
 
         public RelayCommand<MenuModel> SelectedCommand { get; set; }
 
-        private void Select(MenuModel model) => SelectedMenu = model;
+        private void Select(MenuModel model)
+        {
+            SelectedMenu = model;
+
+            if (model.Type != null)
+            {
+                var window = model.Type.CreateInstance() as Window;
+                window?.Show();
+            }
+        }
     }
 }
\ No newline at end of file
Renamed +3 -3
CrazyCoder/Views/Regex.xaml → CrazyCoder/Views/RegexWindow.xaml
diff --git a/CrazyCoder/Views/Regex.xaml b/CrazyCoder/Views/RegexWindow.xaml
similarity index 78%
rename from CrazyCoder/Views/Regex.xaml
rename to CrazyCoder/Views/RegexWindow.xaml
index e843960..9a5465d 100644
--- a/CrazyCoder/Views/Regex.xaml
+++ b/CrazyCoder/Views/RegexWindow.xaml
@@ -1,12 +1,12 @@
-<Window x:Class="CrazyCoder.Views.Regex"
+<Window x:Class="CrazyCoder.Views.RegexWindow"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:CrazyCoder.Views"
         mc:Ignorable="d"
-        Title="Regex" Height="450" Width="800">
+        Title="正则表达式" Height="450" Width="800">
     <Grid>
-        
+        <TextBlock Text="正则表达式"/>
     </Grid>
 </Window>
Renamed +2 -2
CrazyCoder/Views/Regex.xaml.cs → CrazyCoder/Views/RegexWindow.xaml.cs
diff --git a/CrazyCoder/Views/Regex.xaml.cs b/CrazyCoder/Views/RegexWindow.xaml.cs
similarity index 92%
rename from CrazyCoder/Views/Regex.xaml.cs
rename to CrazyCoder/Views/RegexWindow.xaml.cs
index 718d9a8..5265977 100644
--- a/CrazyCoder/Views/Regex.xaml.cs
+++ b/CrazyCoder/Views/RegexWindow.xaml.cs
@@ -17,9 +17,9 @@ namespace CrazyCoder.Views
     /// <summary>
     /// Regex.xaml 的交互逻辑
     /// </summary>
-    public partial class Regex : Window
+    public partial class RegexWindow : Window
     {
-        public Regex()
+        public RegexWindow()
         {
             InitializeComponent();
         }