Browse Source

打开正则窗口

net45
大石头 5 years ago
parent
commit
4e3ba0c4c7
  1. 6
      CrazyCoder/CrazyCoder.csproj
  2. 5
      CrazyCoder/MainWindow.xaml.cs
  3. 2
      CrazyCoder/Models/MenuModel.cs
  4. 16
      CrazyCoder/ViewModels/MainViewModel.cs
  5. 6
      CrazyCoder/Views/RegexWindow.xaml
  6. 4
      CrazyCoder/Views/RegexWindow.xaml.cs

6
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>

5
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
}
}

2
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; }
}
}

16
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();
}
}
}
}

6
CrazyCoder/Views/Regex.xaml → 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>

4
CrazyCoder/Views/Regex.xaml.cs → 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();
}
Loading…
Cancel
Save