Sfoglia il codice sorgente

20251101001 View界面简单制作,报警界面盒功能制作

向羽 孟 2 settimane fa
parent
commit
4f26bb7c5a

+ 9 - 0
MvvmScaffoldFrame48.DLL/AlarmTools/AlarmMessageList.cs

@@ -0,0 +1,9 @@
+
+namespace MvvmScaffoldFrame48.DLL.AlarmTools
+{
+    public enum AlarmMessageList
+    {
+       系统异常 = 0,
+       异常测试1 = 1,
+    }
+}

+ 78 - 0
MvvmScaffoldFrame48.DLL/AlarmTools/SystemAlarm.cs

@@ -0,0 +1,78 @@
+using MvvmScaffoldFrame48.DLL.AuditTrail;
+using MvvmScaffoldFrame48.Model.StorageModel.SystemAlarm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace MvvmScaffoldFrame48.DLL.AlarmTools
+{
+    public static class SystemAlarm
+    {
+        private static ErrorMessageRecordManagement errorMessageRecord = new ErrorMessageRecordManagement();
+        private static List<AlarmMessModel> AlarmMessList = new List<AlarmMessModel>()
+        {
+            new AlarmMessModel()
+            {
+                ID = (int)AlarmMessageList.系统异常,
+                AlarmType = "SystemException",
+                AlarmMess = "系统异常",
+                IsAlarm =false
+            },
+        };
+
+        /// <summary>
+        /// 开启指定警告
+        /// </summary>
+        /// <param name="ID"></param>
+        public static void AlarmAlert(AlarmMessageList ID,string AlarmPath)
+        {
+            var alarm = AlarmMessList.Find(x => x.ID == (int)ID);
+            if (alarm.IsAlarm)
+            {
+                return;
+            }
+            else
+            {
+                errorMessageRecord.InsertErrorMessageRecord(new Model.StorageModel.AuditTrail.ErrorMessageRecordModel()
+                {
+                    Category = "SystemAlarm",
+                    Message = alarm.AlarmMess,
+                    MessageType = alarm.AlarmType,
+                    MessagePath = AlarmPath,
+                    userID = 0,
+                    LogLevel = 0,
+                    DateTime = DateTime.Now,
+                });
+
+                var ChanegAlarm = AlarmMessList.Find(x => x.ID == (int)ID);
+                ChanegAlarm.IsAlarm = true;
+                ChanegAlarm.AlarmDateTime = DateTime.Now;
+                ChanegAlarm.AlarmPath = AlarmPath;
+            }
+        }
+
+        /// <summary>
+        /// 关闭指定警告
+        /// </summary>
+        public static void AlarmCancel(AlarmMessageList ID)
+        {
+            AlarmMessList.Find(x => x.ID == (int)ID).IsAlarm = false;
+        }
+
+        /// <summary>
+        /// 获取所有警告
+        /// </summary>
+        public static List<AlarmMessModel> GetAllAlarm()
+        {
+            return AlarmMessList;
+        }
+
+        /// <summary>
+        /// 获取所有已触发警告
+        /// </summary>
+        public static List<AlarmMessModel> GetAlarm()
+        {
+            return AlarmMessList.Where(x => x.IsAlarm == true).ToList();
+        }
+    }
+}

+ 2 - 0
MvvmScaffoldFrame48.DLL/MvvmScaffoldFrame48.Dll.csproj

@@ -69,6 +69,8 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="AlarmTools\AlarmMessageList.cs" />
+    <Compile Include="AlarmTools\SystemAlarm.cs" />
     <Compile Include="AuditTrail\ErrorMessageRecordManagement.cs" />
     <Compile Include="AuditTrail\OperationRecordManagement.cs" />
     <Compile Include="CameraTools\HikCamera.cs" />

+ 2 - 0
MvvmScaffoldFrame48.MODEL/MvvmScaffoldFrame48.Model.csproj

@@ -67,6 +67,8 @@
     <Compile Include="StorageModel\HikVisionCamera\CameraInfoModel.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="StorageModel\ImageAlgorithm\BoundingRectangleMdoel.cs" />
+    <Compile Include="StorageModel\SystemAlarm\AlarmMessModel.cs" />
+    <Compile Include="StorageModel\SystemAlarm\AlarmTypes.cs" />
     <Compile Include="UserModel.cs" />
   </ItemGroup>
   <ItemGroup>

+ 41 - 0
MvvmScaffoldFrame48.MODEL/StorageModel/SystemAlarm/AlarmMessModel.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MvvmScaffoldFrame48.Model.StorageModel.SystemAlarm
+{
+    public class AlarmMessModel
+    {
+        /// <summary>
+        /// 报警信息ID
+        /// </summary>
+        public int ID { get; set; }
+
+        /// <summary>
+        /// 报警类型
+        /// </summary>
+        public string AlarmType { get; set; }
+
+        /// <summary>
+        /// 报警信息
+        /// </summary>
+        public string AlarmMess { get; set; }
+
+        /// <summary>
+        /// 报警信息路径
+        /// </summary>
+        public string AlarmPath { get; set; }
+        
+        /// <summary>
+        /// 报警时间
+        /// </summary>
+        public DateTime AlarmDateTime { get; set; }
+
+       /// <summary>
+        /// 是否处于报警状态
+        /// </summary>
+        public bool IsAlarm { get; set; } = false;
+    }
+}

+ 13 - 0
MvvmScaffoldFrame48.MODEL/StorageModel/SystemAlarm/AlarmTypes.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MvvmScaffoldFrame48.Model.StorageModel.SystemAlarm
+{
+    public enum AlarmTypes
+    {
+        SystemException = 0,
+    }
+}

+ 3 - 0
MvvmScaffoldFrame48.VIEWMODEL/MvvmScaffoldFrame48.ViewModel.csproj

@@ -60,6 +60,9 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="ViewModel\AlarmViewModel.cs" />
+    <Compile Include="ViewModel\CustomControlViewModel.cs" />
+    <Compile Include="ViewModel\TestViewModel.cs" />
     <Compile Include="ViewModel\BaseViewModel.cs" />
     <Compile Include="ViewModel\MainViewModel.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />

+ 67 - 0
MvvmScaffoldFrame48.VIEWMODEL/ViewModel/AlarmViewModel.cs

@@ -0,0 +1,67 @@
+using MvvmScaffoldFrame48.DLL.AlarmTools;
+using MvvmScaffoldFrame48.Model.StorageModel.SystemAlarm;
+using System.Collections.ObjectModel;
+using System.Windows.Input;
+using System.Xml.Serialization;
+
+namespace MvvmScaffoldFrame48.ViewModel.ViewModel
+{
+    public class AlarmViewModel:BaseViewModel
+    {
+        #region 界面绑定属性
+        public ObservableCollection<AlarmMessModel> Alarm { get; set; }
+        #endregion
+
+        #region 界面绑定事件
+        public ICommand AlarmTestCommond { get; set; }
+        public ICommand CancelAlarmTestCommond { get; set; }
+        #endregion
+
+        #region 属性与实例
+
+        #endregion
+
+        #region 绑定用Action方法
+        public void AlarmTest(object obj)
+        {
+            SystemAlarm.AlarmAlert(AlarmMessageList.系统异常, "ViewModel:ViewModel-AlarmViewModel-AlarmTest");
+            var Alarms = SystemAlarm.GetAlarm();
+            Alarm.Clear();
+            foreach (var alarm in Alarms)
+            {
+                Alarm.Add(alarm);
+            }
+        }
+        public void CancelAlarmTest(object obj)
+        {
+            SystemAlarm.AlarmCancel(AlarmMessageList.系统异常);
+            var Alarms = SystemAlarm.GetAlarm();
+            Alarm.Clear();
+            foreach (var alarm in Alarms)
+            {
+                Alarm.Add(alarm);
+            }
+        }
+        #endregion
+
+        #region 绑定用Predicate方法
+        private bool CanTrue(object obj)
+        {
+            return true;
+        }
+        private bool CanFalse(object obj)
+        {
+            return false;
+        }
+        #endregion
+
+        #region 其他方法
+        public AlarmViewModel()
+        {
+            Alarm = new ObservableCollection<AlarmMessModel>();
+            AlarmTestCommond = new RelayCommand(AlarmTest, CanTrue);
+            CancelAlarmTestCommond = new RelayCommand(CancelAlarmTest, CanTrue);
+        }
+        #endregion
+    }
+}

+ 64 - 0
MvvmScaffoldFrame48.VIEWMODEL/ViewModel/CustomControlViewModel.cs

@@ -0,0 +1,64 @@
+using MvvmScaffoldFrame48.DLL;
+using MvvmScaffoldFrame48.DLL.AuditTrail;
+using MvvmScaffoldFrame48.DLL.WindowsTools;
+using MvvmScaffoldFrame48.Model;
+using MvvmScaffoldFrame48.Model.StorageModel.AuditTrail;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace MvvmScaffoldFrame48.ViewModel.ViewModel
+{
+    public class CustomControlViewModel:BaseViewModel
+    {
+        #region 界面绑定属性
+        private bool _staticTest = false;
+        public bool StaticTest
+        {
+            get { return _staticTest; }
+            set
+            {
+                if (_staticTest != value)
+                {
+                    _staticTest = value;
+                    OnPropertyChanged(nameof(StaticTest));
+                }
+            }
+        }
+        #endregion
+
+        #region 界面绑定事件
+        public ICommand TestCommand { get; set; }
+        #endregion
+
+        #region 属性
+        #endregion
+
+        #region 绑定用Action方法
+
+        private void Test(object obj)
+        {
+            StaticTest = !StaticTest;
+        }
+        #endregion
+
+        #region 绑定用Predicate方法
+        private bool CanTest(object obj)
+        {
+            return true;
+        }
+        #endregion
+
+        #region 其他方法
+        public CustomControlViewModel()
+        {
+            TestCommand = new RelayCommand(Test, CanTest);
+        }
+        #endregion
+
+    }
+}

+ 3 - 88
MvvmScaffoldFrame48.VIEWMODEL/ViewModel/MainViewModel.cs

@@ -13,114 +13,29 @@ namespace MvvmScaffoldFrame48.ViewModel.ViewModel
     public class MainViewModel : BaseViewModel
     {
         #region 界面绑定属性
-        public ObservableCollection<UserModel> Users { get; set; }
-
-        private string _name;
-        public string Name
-        {
-            get { return _name; }
-            set
-            {
-                if (_name != value)
-                {
-                    _name = value;
-                    OnPropertyChanged(nameof(Name));
-                }
-            }
-        }
-
-        private string _email;
-        public string Email
-        {
-            get { return _email; }
-            set
-            {
-                if (_email != value)
-                {
-                    _email = value;
-                    OnPropertyChanged(nameof(Email));
-                }
-            }
-        }
-
-        private bool _staticTest = true;
-        public bool StaticTest
-        {
-            get { return _staticTest; }
-            set
-            {
-                if (_staticTest != value)
-                {
-                    _staticTest = value;
-                    OnPropertyChanged(nameof(StaticTest));
-                }
-            }
-        }
         #endregion
 
         #region 界面绑定事件
-        public ICommand AddUserCommand { get; set; }
-        public ICommand TestCommand { get; set; }
         #endregion
 
         #region 属性
-
         #endregion
 
         #region 绑定用Action方法
-        private void AddUser(object obj)
-        {
-            UserModel user = new UserModel();
-            user.Name = Name;
-            user.Email = Email;
-            UserManager.AddUser(user);
-
-            OnScreenKeyboardTools.KeyBoardShow();
-            OperationRecordManagement operationRecordManagement = new OperationRecordManagement();
-            operationRecordManagement.InsertOperationRecord(new OperationRecordModel()
-            {
-                Category = "用户管理",
-                OldMessage = "",
-                NewMessage = "添加用户:" + user.Name,
-                DateTime = DateTime.Now,
-                userID = 1,
-                IsDeleted = false
-            });
-            var OperationRecord = operationRecordManagement.GetAllOperationRecord();
-            foreach (var item in OperationRecord)
-            {
-                Console.WriteLine($"{item.Category}:{item.OldMessage}=>{item.NewMessage},Time:{item.DateTime.ToString("g")}");
-            }
-        }
-
-        private void Test(object obj)
-        {
-            Name = "小1";
-            Email = "111@qq.com";
-
-            StaticTest = !StaticTest;
-        }
         #endregion
 
         #region 绑定用Predicate方法
-        private bool CanAddUser(object obj)
+        private bool CanTrue(object obj)
         {
             return true;
         }
-
-        private bool CanTest(object obj)
+        private bool CanFalse(object obj)
         {
-            return true;
+            return false;
         }
         #endregion
 
         #region 其他方法
-        public MainViewModel()
-        {
-            Users = UserManager.GetUsers();
-            AddUserCommand = new RelayCommand(AddUser, CanAddUser);
-            TestCommand = new RelayCommand(Test, CanTest);
-        }
         #endregion
     }
 }

+ 114 - 0
MvvmScaffoldFrame48.VIEWMODEL/ViewModel/TestViewModel.cs

@@ -0,0 +1,114 @@
+using MvvmScaffoldFrame48.DLL;
+using MvvmScaffoldFrame48.DLL.AuditTrail;
+using MvvmScaffoldFrame48.DLL.WindowsTools;
+using MvvmScaffoldFrame48.Model;
+using MvvmScaffoldFrame48.Model.StorageModel.AuditTrail;
+using MvvmScaffoldFrame48.ViewModel.ViewModel;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace MvvmScaffoldFrame48.ViewModel
+{
+    public class TestViewModel:BaseViewModel
+    {
+        #region 界面绑定属性
+        public ObservableCollection<UserModel> Users { get; set; }
+
+        private string _name;
+        public string Name
+        {
+            get { return _name; }
+            set
+            {
+                if (_name != value)
+                {
+                    _name = value;
+                    OnPropertyChanged(nameof(Name));
+                }
+            }
+        }
+
+        private string _email;
+        public string Email
+        {
+            get { return _email; }
+            set
+            {
+                if (_email != value)
+                {
+                    _email = value;
+                    OnPropertyChanged(nameof(Email));
+                }
+            }
+        }
+        #endregion
+
+        #region 界面绑定事件
+        public ICommand AddUserCommand { get; set; }
+        public ICommand TestCommand { get; set; }
+        #endregion
+
+        #region 属性
+
+        #endregion
+
+        #region 绑定用Action方法
+        private void AddUser(object obj)
+        {
+            UserModel user = new UserModel();
+            user.Name = Name;
+            user.Email = Email;
+            UserManager.AddUser(user);
+
+            OnScreenKeyboardTools.KeyBoardShow();
+            OperationRecordManagement operationRecordManagement = new OperationRecordManagement();
+            operationRecordManagement.InsertOperationRecord(new OperationRecordModel()
+            {
+                Category = "用户管理",
+                OldMessage = "",
+                NewMessage = "添加用户:" + user.Name,
+                DateTime = DateTime.Now,
+                userID = 1,
+                IsDeleted = false
+            });
+            var OperationRecord = operationRecordManagement.GetAllOperationRecord();
+            foreach (var item in OperationRecord)
+            {
+                Console.WriteLine($"{item.Category}:{item.OldMessage}=>{item.NewMessage},Time:{item.DateTime.ToString("g")}");
+            }
+        }
+
+        private void Test(object obj)
+        {
+            Name = "小1";
+            Email = "111@qq.com";
+        }
+        #endregion
+
+        #region 绑定用Predicate方法
+        private bool CanAddUser(object obj)
+        {
+            return true;
+        }
+
+        private bool CanTest(object obj)
+        {
+            return true;
+        }
+        #endregion
+
+        #region 其他方法
+        public TestViewModel()
+        {
+            Users = UserManager.GetUsers();
+            AddUserCommand = new RelayCommand(AddUser, CanAddUser);
+            TestCommand = new RelayCommand(Test, CanTest);
+        }
+        #endregion
+    }
+}

+ 22 - 3
MvvmScaffoldFrame48/MvvmScaffoldFrame48.csproj

@@ -75,6 +75,15 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="WPFPage\AlarmPage.xaml.cs">
+      <DependentUpon>AlarmPage.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="WPFPage\CustomControlPage.xaml.cs">
+      <DependentUpon>CustomControlPage.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="WPFPage\TestPage.xaml.cs">
+      <DependentUpon>TestPage.xaml</DependentUpon>
+    </Compile>
     <Page Include="WPFFroms\MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -88,6 +97,18 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Page Include="WPFPage\AlarmPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="WPFPage\CustomControlPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="WPFPage\TestPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Properties\AssemblyInfo.cs">
@@ -125,8 +146,6 @@
       <Name>MvvmScaffoldFrame48.ViewModel</Name>
     </ProjectReference>
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="WPFPage\" />
-  </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 2 - 125
MvvmScaffoldFrame48/WPFFroms/MainWindow.xaml

@@ -5,131 +5,8 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:MvvmScaffoldFrame48"
         mc:Ignorable="d"
-        Title="MainWindow" Height="450" Width="800">
+        Title="MainWindow" Height="450" Width="800" Loaded="Window_Loaded">
     <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="*" />
-            <ColumnDefinition Width="*" />
-        </Grid.ColumnDefinitions>
-        <StackPanel Grid.Column="0">
-            <ToolBar>
-                <Label Content="姓名:"></Label>
-                <TextBox Text="{Binding Name}"  Width="50"></TextBox>
-                <Label Content="邮箱:"></Label>
-                <TextBox Text="{Binding Email}" Width="100"></TextBox>
-                <Button Content="添加"
-                    Command="{Binding AddUserCommand }"></Button>
-                <Button Content="测试"
-                    Command="{Binding TestCommand }"></Button>
-            </ToolBar>
-            <StackPanel>
-                <DataGrid ItemsSource="{Binding Users}"></DataGrid>
-
-            </StackPanel>
-        </StackPanel>
-        <Grid Grid.Column="1">
-            <StackPanel Height="30" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center">
-                <Label Content="红绿灯演示"></Label>
-                <Ellipse Width="20" Height="20" Margin="48,0,0,0" >
-                    <Ellipse.Style>
-                        <Style TargetType="Ellipse">
-                            <Setter Property="Fill" Value="Red" />
-                            <Style.Triggers>
-                                <DataTrigger Binding="{Binding StaticTest}" Value="True">
-                                    <Setter Property="Fill" Value="Green" />
-                                </DataTrigger>
-                            </Style.Triggers>
-                        </Style>
-                    </Ellipse.Style>
-                </Ellipse>
-            </StackPanel>
-            <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,40,0,0" Height="30">
-                <Label Content="可以更改背景颜色的ComboBox:"/>
-                <ComboBox Height="40" Width="140" ItemsSource="{Binding FormulationItems}" HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalContentAlignment="Center" FontSize="20">
-                    <ComboBox.Template>
-                        <ControlTemplate TargetType="ComboBox">
-                            <Grid>
-                                <ToggleButton
-                                                    Foreground="White"
-                                                    IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
-                                                    ClickMode="Press">
-                                    <ToggleButton.Template>
-                                        <ControlTemplate TargetType="ToggleButton">
-                                            <Border x:Name="Border" Background="#FF0087FF" BorderBrush="#FFABADB3" BorderThickness="1">
-                                                <Grid>
-                                                    <Grid.ColumnDefinitions>
-                                                        <ColumnDefinition />
-                                                        <ColumnDefinition Width="20" />
-                                                    </Grid.ColumnDefinitions>
-                                                    <ContentPresenter Grid.Column="0" Margin="3" />
-                                                    <Path x:Name="Arrow" Grid.Column="1" 
-                                                                    Fill="White"
-                                                                    HorizontalAlignment="Center" 
-                                                                    VerticalAlignment="Center"
-                                                                    Data="M 0 0 L 4 4 L 8 0 Z" />
-                                                </Grid>
-                                            </Border>
-                                            <ControlTemplate.Triggers>
-                                                <Trigger Property="IsMouseOver" Value="True">
-                                                    <Setter TargetName="Border" Property="Background" Value="LightBlue" />
-                                                </Trigger>
-                                            </ControlTemplate.Triggers>
-                                        </ControlTemplate>
-                                    </ToggleButton.Template>
-                                </ToggleButton>
-                                <ContentPresenter x:Name="ContentSite" 
-                                                    IsHitTestVisible="False"
-                                                    Content="{TemplateBinding SelectionBoxItem}"
-                                                    ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
-                                                    Margin="3,3,23,3"
-                                                    VerticalAlignment="Center"
-                                                    HorizontalAlignment="Left" 
-                                                    TextBlock.Foreground="White"/>
-                                <Popup x:Name="Popup" 
-                                                    Placement="Bottom"
-                                                    IsOpen="{TemplateBinding IsDropDownOpen}"
-                                                    AllowsTransparency="True" 
-                                                    Focusable="False"
-                                                    PopupAnimation="Slide">
-                                    <Border x:Name="DropDownBorder" 
-                                                         Background="#FF0087FF"
-                                                         BorderBrush="#FF0087FF"
-                                                         BorderThickness="1">
-                                        <ScrollViewer Margin="0,3,0,3" 
-                                                            SnapsToDevicePixels="True">
-                                            <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
-                                        </ScrollViewer>
-                                    </Border>
-                                </Popup>
-                            </Grid>
-                        </ControlTemplate>
-                    </ComboBox.Template>
-
-                    <ComboBox.ItemContainerStyle>
-                        <Style TargetType="ComboBoxItem">
-                            <Setter Property="Background" Value="#FF0087FF" />
-                            <Setter Property="Foreground" Value="White" />
-                            <Style.Triggers>
-                                <Trigger Property="IsHighlighted" Value="True">
-                                    <Setter Property="Background" Value="LightBlue" />
-                                </Trigger>
-                            </Style.Triggers>
-                        </Style>
-                    </ComboBox.ItemContainerStyle>
-                </ComboBox>
-            </StackPanel>
-            <StackPanel Orientation ="Horizontal"  HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,80,0,0">
-                <Label Content="圆角按钮:"/>
-                <Button Content="圆角按钮" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" Background="#FF0123FF" FontWeight="Bold" FontSize="20" Foreground="White" Cursor="Hand">
-                    <Button.Template>
-                        <ControlTemplate TargetType="Button">
-                            <Border CornerRadius="5"  Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"  BorderThickness="{TemplateBinding BorderThickness}">
-                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                            </Border>
-                        </ControlTemplate>
-                    </Button.Template>
-                </Button>
-            </StackPanel>
-        </Grid>
+        <Frame x:Name="ShowFrame" Margin="0,0,0,0" NavigationUIVisibility="Hidden"/>
     </Grid>
 </Window>

+ 7 - 2
MvvmScaffoldFrame48/WPFFroms/MainWindow.xaml.cs

@@ -1,4 +1,5 @@
 using MvvmScaffoldFrame48.ViewModel.ViewModel;
+using System;
 using System.Windows;
 
 
@@ -12,8 +13,12 @@ namespace MvvmScaffoldFrame48
         public MainWindow()
         {
             InitializeComponent();
-            MainViewModel mainViewModel = new MainViewModel();
-            this.DataContext = mainViewModel;
+        }
+
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+            Uri ShowUri = new Uri("WPFPage\\AlarmPage.xaml", UriKind.Relative);
+            ShowFrame.Navigate(ShowUri);
         }
     }
 }

+ 16 - 0
MvvmScaffoldFrame48/WPFPage/AlarmPage.xaml

@@ -0,0 +1,16 @@
+<Page x:Class="MvvmScaffoldFrame48.WPFPage.AlarmPage"
+      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:MvvmScaffoldFrame48.WPFPage"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="AlarmPage">
+
+    <Grid>
+        <Button Content="触发" Command="{Binding AlarmTestCommond}" Height="50" Width="80" HorizontalAlignment="Left" VerticalAlignment="Top" />
+        <Button Content="取消" Command="{Binding CancelAlarmTestCommond}" Height="50" Width="80" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="80,0,0,0" />
+        <DataGrid ItemsSource="{Binding Alarm}" Margin="0,50,0,0"></DataGrid>
+    </Grid>
+</Page>

+ 31 - 0
MvvmScaffoldFrame48/WPFPage/AlarmPage.xaml.cs

@@ -0,0 +1,31 @@
+using MvvmScaffoldFrame48.ViewModel.ViewModel;
+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 MvvmScaffoldFrame48.WPFPage
+{
+    /// <summary>
+    /// AlarmPage.xaml 的交互逻辑
+    /// </summary>
+    public partial class AlarmPage : Page
+    {
+        public AlarmPage()
+        {
+            InitializeComponent();
+            AlarmViewModel viewModel = new AlarmViewModel();
+            this.DataContext = viewModel;
+        }
+    }
+}

+ 121 - 0
MvvmScaffoldFrame48/WPFPage/CustomControlPage.xaml

@@ -0,0 +1,121 @@
+<Page x:Class="MvvmScaffoldFrame48.WPFPage.CustomControlPage"
+      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:MvvmScaffoldFrame48.WPFPage"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="CustomControlPage">
+
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*" />
+            <ColumnDefinition Width="*" />
+        </Grid.ColumnDefinitions>
+        <Grid Grid.Column="0">
+            <StackPanel Height="30" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center">
+                <Label Content="红绿灯演示"></Label>
+                <Ellipse Width="20" Height="20" Margin="48,0,0,0" >
+                    <Ellipse.Style>
+                        <Style TargetType="Ellipse">
+                            <Setter Property="Fill" Value="Red" />
+                            <Style.Triggers>
+                                <DataTrigger Binding="{Binding StaticTest}" Value="True">
+                                    <Setter Property="Fill" Value="Green" />
+                                </DataTrigger>
+                            </Style.Triggers>
+                        </Style>
+                    </Ellipse.Style>
+                </Ellipse>
+            </StackPanel>
+            <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,40,0,0" Height="30">
+                <Label Content="可以更改背景颜色的ComboBox:"/>
+                <ComboBox Height="40" Width="140" ItemsSource="{Binding FormulationItems}" HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalContentAlignment="Center" FontSize="20">
+                    <ComboBox.Template>
+                        <ControlTemplate TargetType="ComboBox">
+                            <Grid>
+                                <ToggleButton
+                                                    Foreground="White"
+                                                    IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
+                                                    ClickMode="Press">
+                                    <ToggleButton.Template>
+                                        <ControlTemplate TargetType="ToggleButton">
+                                            <Border x:Name="Border" Background="#FF0087FF" BorderBrush="#FFABADB3" BorderThickness="1">
+                                                <Grid>
+                                                    <Grid.ColumnDefinitions>
+                                                        <ColumnDefinition />
+                                                        <ColumnDefinition Width="20" />
+                                                    </Grid.ColumnDefinitions>
+                                                    <ContentPresenter Grid.Column="0" Margin="3" />
+                                                    <Path x:Name="Arrow" Grid.Column="1" 
+                                                                    Fill="White"
+                                                                    HorizontalAlignment="Center" 
+                                                                    VerticalAlignment="Center"
+                                                                    Data="M 0 0 L 4 4 L 8 0 Z" />
+                                                </Grid>
+                                            </Border>
+                                            <ControlTemplate.Triggers>
+                                                <Trigger Property="IsMouseOver" Value="True">
+                                                    <Setter TargetName="Border" Property="Background" Value="LightBlue" />
+                                                </Trigger>
+                                            </ControlTemplate.Triggers>
+                                        </ControlTemplate>
+                                    </ToggleButton.Template>
+                                </ToggleButton>
+                                <ContentPresenter x:Name="ContentSite" 
+                                                    IsHitTestVisible="False"
+                                                    Content="{TemplateBinding SelectionBoxItem}"
+                                                    ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
+                                                    Margin="3,3,23,3"
+                                                    VerticalAlignment="Center"
+                                                    HorizontalAlignment="Left" 
+                                                    TextBlock.Foreground="White"/>
+                                <Popup x:Name="Popup" 
+                                                    Placement="Bottom"
+                                                    IsOpen="{TemplateBinding IsDropDownOpen}"
+                                                    AllowsTransparency="True" 
+                                                    Focusable="False"
+                                                    PopupAnimation="Slide">
+                                    <Border x:Name="DropDownBorder" 
+                                                         Background="#FF0087FF"
+                                                         BorderBrush="#FF0087FF"
+                                                         BorderThickness="1">
+                                        <ScrollViewer Margin="0,3,0,3" 
+                                                            SnapsToDevicePixels="True">
+                                            <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
+                                        </ScrollViewer>
+                                    </Border>
+                                </Popup>
+                            </Grid>
+                        </ControlTemplate>
+                    </ComboBox.Template>
+
+                    <ComboBox.ItemContainerStyle>
+                        <Style TargetType="ComboBoxItem">
+                            <Setter Property="Background" Value="#FF0087FF" />
+                            <Setter Property="Foreground" Value="White" />
+                            <Style.Triggers>
+                                <Trigger Property="IsHighlighted" Value="True">
+                                    <Setter Property="Background" Value="LightBlue" />
+                                </Trigger>
+                            </Style.Triggers>
+                        </Style>
+                    </ComboBox.ItemContainerStyle>
+                </ComboBox>
+            </StackPanel>
+            <StackPanel Orientation ="Horizontal"  HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,80,0,0">
+                <Label Content="圆角按钮:"/>
+                <Button Content="圆角按钮" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" Background="#FF0123FF" FontWeight="Bold" FontSize="20" Foreground="White" Cursor="Hand" Command="{Binding TestCommand}">
+                    <Button.Template>
+                        <ControlTemplate TargetType="Button">
+                            <Border CornerRadius="5"  Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"  BorderThickness="{TemplateBinding BorderThickness}">
+                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                            </Border>
+                        </ControlTemplate>
+                    </Button.Template>
+                </Button>
+            </StackPanel>
+        </Grid>
+    </Grid>
+</Page>

+ 31 - 0
MvvmScaffoldFrame48/WPFPage/CustomControlPage.xaml.cs

@@ -0,0 +1,31 @@
+using MvvmScaffoldFrame48.ViewModel.ViewModel;
+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 MvvmScaffoldFrame48.WPFPage
+{
+    /// <summary>
+    /// CustomControlPage.xaml 的交互逻辑
+    /// </summary>
+    public partial class CustomControlPage : Page
+    {
+        public CustomControlPage()
+        {
+            InitializeComponent();
+            CustomControlViewModel viewModel = new CustomControlViewModel();
+            this.DataContext = viewModel;
+        }
+    }
+}

+ 29 - 0
MvvmScaffoldFrame48/WPFPage/TestPage.xaml

@@ -0,0 +1,29 @@
+<Page x:Class="MvvmScaffoldFrame48.WPFPage.TestPage"
+      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:MvvmScaffoldFrame48.WPFPage"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="TestPage">
+
+    <Grid Cursor="Hand">
+        <StackPanel Grid.Column="0" Margin="0,0,0,50">
+            <ToolBar>
+                <Label Content="姓名:"></Label>
+                <TextBox Text="{Binding Name}"  Width="50"></TextBox>
+                <Label Content="邮箱:"></Label>
+                <TextBox Text="{Binding Email}" Width="100"></TextBox>
+                <Button Content="添加"
+                    Command="{Binding AddUserCommand }"></Button>
+                <Button Content="测试"
+                    Command="{Binding TestCommand }"></Button>
+            </ToolBar>
+            <StackPanel>
+                <DataGrid ItemsSource="{Binding Users}"></DataGrid>
+
+            </StackPanel>
+        </StackPanel>
+    </Grid>
+</Page>

+ 31 - 0
MvvmScaffoldFrame48/WPFPage/TestPage.xaml.cs

@@ -0,0 +1,31 @@
+using MvvmScaffoldFrame48.ViewModel;
+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 MvvmScaffoldFrame48.WPFPage
+{
+    /// <summary>
+    /// TestPage.xaml 的交互逻辑
+    /// </summary>
+    public partial class TestPage : Page
+    {
+        public TestPage()
+        {
+            InitializeComponent();
+            TestViewModel testViewModel = new TestViewModel();
+            this.DataContext = testViewModel;
+        }
+    }
+}