Przeglądaj źródła

20251020001 修改Control位置,View界面分层优化,主界面部分已经制作好的自定义控件展示

向羽 孟 1 miesiąc temu
rodzic
commit
a6b92c6871

+ 1 - 1
MvvmScaffoldFrame48.DLL/AuditTrail/OperationRecordManagement.cs

@@ -1,5 +1,5 @@
 //值变更记录管理
-using MvvmScaffoldFrame48.Model.AuditTrail;
+using MvvmScaffoldFrame48.Model.StorageModel.AuditTrail;
 using System;
 using System.Collections.Generic;
 using System.Data.SQLite;

+ 1 - 1
MvvmScaffoldFrame48.DLL/CameraTools/HikCamera.cs

@@ -1,6 +1,6 @@
 // 海康相机实例类
 using MvCameraControl;
-using MvvmScaffoldFrame48.Model.HikVisionCamera;
+using MvvmScaffoldFrame48.Model.StorageModel.HikVisionCamera;
 using System;
 using System.Collections.Generic;
 using System.Linq;

+ 1 - 1
MvvmScaffoldFrame48.DLL/CameraTools/HikVision.cs

@@ -1,6 +1,6 @@
 //海康相机操作类
 using MvCameraControl;
-using MvvmScaffoldFrame48.Model.HikVisionCamera;
+using MvvmScaffoldFrame48.Model.StorageModel.HikVisionCamera;
 using System.Collections.Generic;
 
 namespace MvvmScaffoldFrame48.DLL.CameraTools

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

@@ -60,7 +60,6 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Controller\MainController.cs" />
     <Compile Include="ViewModel\BaseViewModel.cs" />
     <Compile Include="ViewModel\MainViewModel.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />

+ 1 - 1
MvvmScaffoldFrame48.VIEWMODEL/ViewModel/MainViewModel.cs

@@ -3,7 +3,7 @@ using MvvmScaffoldFrame48.DLL;
 using MvvmScaffoldFrame48.DLL.AuditTrail;
 using MvvmScaffoldFrame48.DLL.WindowsTools;
 using MvvmScaffoldFrame48.Model;
-using MvvmScaffoldFrame48.Model.AuditTrail;
+using MvvmScaffoldFrame48.Model.StorageModel.AuditTrail;
 using System;
 using System.Collections.ObjectModel;
 using System.Windows.Input;

+ 1 - 1
MvvmScaffoldFrame48/App.xaml

@@ -2,7 +2,7 @@
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:local="clr-namespace:MvvmScaffoldFrame48"
-             StartupUri="MainWindow.xaml">
+             StartupUri="WPFFroms/MainWindow.xaml">
     <Application.Resources>
          
     </Application.Resources>

+ 1 - 1
MvvmScaffoldFrame48.VIEWMODEL/controller/MainController.cs → MvvmScaffoldFrame48/Controller/MainController.cs

@@ -4,7 +4,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace MvvmScaffoldFrame48.ViewModel.Controller
+namespace MvvmScaffoldFrame48.Controller
 {
     internal class MainController
     {

+ 0 - 41
MvvmScaffoldFrame48/MainWindow.xaml

@@ -1,41 +0,0 @@
-<Window x:Class="MvvmScaffoldFrame48.MainWindow"
-        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:MvvmScaffoldFrame48"
-        mc:Ignorable="d"
-        Title="MainWindow" Height="450" Width="800">
-    <Grid>
-        <StackPanel Margin="0,0,0,40">
-            <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 VerticalAlignment="Bottom" Height="40">
-            <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>
-        </Grid>
-    </Grid>
-</Window>

+ 6 - 2
MvvmScaffoldFrame48/MvvmScaffoldFrame48.csproj

@@ -75,7 +75,7 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
-    <Page Include="MainWindow.xaml">
+    <Page Include="WPFFroms\MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
@@ -83,7 +83,8 @@
       <DependentUpon>App.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="MainWindow.xaml.cs">
+    <Compile Include="Controller\MainController.cs" />
+    <Compile Include="WPFFroms\MainWindow.xaml.cs">
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
@@ -124,5 +125,8 @@
       <Name>MvvmScaffoldFrame48.ViewModel</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="WPFPage\" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 135 - 0
MvvmScaffoldFrame48/WPFFroms/MainWindow.xaml

@@ -0,0 +1,135 @@
+<Window x:Class="MvvmScaffoldFrame48.MainWindow"
+        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:MvvmScaffoldFrame48"
+        mc:Ignorable="d"
+        Title="MainWindow" Height="450" Width="800">
+    <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>
+    </Grid>
+</Window>

+ 1 - 1
MvvmScaffoldFrame48/MainWindow.xaml.cs → MvvmScaffoldFrame48/WPFFroms/MainWindow.xaml.cs

@@ -1,4 +1,4 @@
-using MvvmScaffoldFrame48.ViewModel;
+using MvvmScaffoldFrame48.ViewModel.ViewModel;
 using System.Windows;