添加项目文件。
This commit is contained in:
18
SamplePreSystemApp/App.config
Normal file
18
SamplePreSystemApp/App.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="SamplePreSystemApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<userSettings>
|
||||
<SamplePreSystemApp.Properties.Settings>
|
||||
<setting name="UserName" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</SamplePreSystemApp.Properties.Settings>
|
||||
</userSettings>
|
||||
|
||||
|
||||
|
||||
</configuration>
|
||||
46
SamplePreSystemApp/App.xaml
Normal file
46
SamplePreSystemApp/App.xaml
Normal file
@@ -0,0 +1,46 @@
|
||||
<Application
|
||||
x:Class="SamplePreSystemApp.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:SamplePreSystemApp"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
StartupUri="AppMainView.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
||||
|
||||
<materialDesign:BundledTheme
|
||||
BaseTheme="Light"
|
||||
PrimaryColor="Blue"
|
||||
SecondaryColor="Lime" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
|
||||
|
||||
|
||||
<ResourceDictionary Source="pack://application:,,,/SamplePreSystem.UI;component/Styles/BaseButtonStyle.xaml" />
|
||||
<!--<ResourceDictionary Source="/Styles/BaseDataGrid.xaml" />-->
|
||||
<ResourceDictionary Source="pack://application:,,,/SamplePreSystem.UI;component/Styles/BaseDataGrid.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/SamplePreSystem.UI;component/Styles/BaseWindowStyle.xaml" />
|
||||
|
||||
|
||||
|
||||
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Window.xaml" />
|
||||
|
||||
|
||||
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
|
||||
|
||||
<!-- ✅ 全局设置:表格表头样式 -->
|
||||
<Style TargetType="DataGridColumnHeader">
|
||||
<Setter Property="Background" Value="#F5F5F5" />
|
||||
<Setter Property="Foreground" Value="#333333" />
|
||||
<Setter Property="Height" Value="32" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
140
SamplePreSystemApp/App.xaml.cs
Normal file
140
SamplePreSystemApp/App.xaml.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using MaterialDesignColors;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Models;
|
||||
using Models.Const;
|
||||
using SamplePre.Common.Helper;
|
||||
using SamplePre.Communication;
|
||||
using SamplePre.ProcessBll.BLL;
|
||||
using SamplePre.UIWpf;
|
||||
using SamplePreSystem.UI;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SamplePreSystemApp
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
base.OnStartup(e);
|
||||
|
||||
//Window1 frm = new Window1();
|
||||
//frm.ShowDialog();
|
||||
//return;
|
||||
|
||||
// 1. 禁止关闭第一个窗口就退出
|
||||
ShutdownMode = ShutdownMode.OnExplicitShutdown;
|
||||
|
||||
|
||||
SetSkinColor();
|
||||
|
||||
///初始化系统数据
|
||||
InitSystemData();
|
||||
|
||||
LoginWindow loginWindow = new LoginWindow();
|
||||
if (loginWindow.ShowDialog() != true)
|
||||
{
|
||||
//关闭应用
|
||||
Application.Current.Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
loginWindow.Close();
|
||||
|
||||
AppMainView mainWindow;
|
||||
|
||||
|
||||
|
||||
///初始plc连接信息
|
||||
initPLC();
|
||||
|
||||
|
||||
|
||||
|
||||
mainWindow = new AppMainView();
|
||||
mainWindow.ShowDialog();
|
||||
|
||||
//关闭应用
|
||||
Application.Current.Shutdown();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void InitSystemData()
|
||||
{
|
||||
|
||||
// 获取XML配置文件路径
|
||||
string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SystemConfig.xml");
|
||||
// 反序列化为强类型对象
|
||||
SystemConst.SysConfigInfo = XmlSerializerHelper.DeserializeFromXml<SysConfigData>(configPath);
|
||||
|
||||
|
||||
SystemBll systemBll = new SystemBll();
|
||||
|
||||
//初始化字典数据
|
||||
SystemConst.dictDatas = systemBll.QueryDictData();
|
||||
}
|
||||
|
||||
public void initPLC()
|
||||
{
|
||||
//设置plc连接方式
|
||||
//SystemConst.ProtocolType = CommProtocolType.ModbusTcp;
|
||||
SystemConst.ProtocolType = CommProtocolType.S7;
|
||||
|
||||
|
||||
//初始化PLC
|
||||
var item = SystemConst.dictDatas.FirstOrDefault(p => p.id == "2");//主plc配置信息
|
||||
if (item != null)
|
||||
{
|
||||
if (SystemConst.ProtocolType == CommProtocolType.S7)
|
||||
{
|
||||
string connParam = item.data_value;//"192.168.10.2:0:1";
|
||||
SystemConst.MasterPLC = CommunicationFactory.CreateCommunication(CommProtocolType.S7, connParam);
|
||||
|
||||
}
|
||||
else if (SystemConst.ProtocolType == CommProtocolType.ModbusTcp)
|
||||
{
|
||||
string connParam = item.data_value;//"192.168.10.2:0:1";
|
||||
connParam = "127.0.0.1:502";
|
||||
SystemConst.MasterPLC = CommunicationFactory.CreateCommunication(CommProtocolType.ModbusTcp, connParam);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSkinColor()
|
||||
{
|
||||
// ========== 在这里自定义主题颜色 ==========
|
||||
var paletteHelper = new PaletteHelper();
|
||||
var theme = paletteHelper.GetTheme();
|
||||
|
||||
// 一、设置自定义 主颜色 Primary
|
||||
theme.PrimaryMid = new ColorPair(
|
||||
color: Color.FromRgb(0, 113, 203), // 你想要的RGB颜色
|
||||
foregroundColor: Colors.White); // 文字颜色
|
||||
|
||||
// 二、设置自定义 强调色 Secondary
|
||||
theme.SecondaryMid = new ColorPair(
|
||||
color: Color.FromRgb(33, 150, 243),
|
||||
foregroundColor: Colors.White);
|
||||
|
||||
// 三、设置浅色/深色
|
||||
theme.SetBaseTheme(BaseTheme.Light);
|
||||
|
||||
// 应用主题
|
||||
paletteHelper.SetTheme(theme);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
317
SamplePreSystemApp/AppMainView.xaml
Normal file
317
SamplePreSystemApp/AppMainView.xaml
Normal file
@@ -0,0 +1,317 @@
|
||||
<Window
|
||||
x:Class="SamplePreSystemApp.AppMainView"
|
||||
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:local="clr-namespace:SamplePreSystemApp"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
|
||||
Title="自动化样品前处理平台"
|
||||
Width="1200"
|
||||
Height="850"
|
||||
AllowsTransparency="True"
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
FontFamily="{DynamicResource MaterialDesignFont}"
|
||||
FontWeight="ExtraLight"
|
||||
Loaded="Window_Loaded"
|
||||
TextElement.FontSize="13"
|
||||
TextElement.FontWeight="Regular"
|
||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||
TextOptions.TextFormattingMode="Ideal"
|
||||
TextOptions.TextRenderingMode="Auto"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
WindowStyle="None"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Window.Resources>
|
||||
<sys:Double x:Key="LefBarFontSize">15</sys:Double>
|
||||
|
||||
<Style
|
||||
x:Key="CloseButtonCircleStyle"
|
||||
BasedOn="{StaticResource MaterialDesignFlatMidBgButton}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Width" Value="32" />
|
||||
<Setter Property="Height" Value="32" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="DarkRed" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome
|
||||
CaptionHeight="0"
|
||||
GlassFrameThickness="0"
|
||||
ResizeBorderThickness="6"
|
||||
UseAeroCaptionButtons="False" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<Border Background="White" CornerRadius="12">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect
|
||||
BlurRadius="20"
|
||||
Opacity="0.2"
|
||||
ShadowDepth="0" />
|
||||
</Border.Effect>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="25" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 顶部标题栏 -->
|
||||
<materialDesign:ColorZone
|
||||
Grid.Row="0"
|
||||
Padding="5"
|
||||
Mode="PrimaryMid"
|
||||
MouseMove="ColorZone_MouseMove">
|
||||
<Grid>
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||
<Border Background="White" CornerRadius="20">
|
||||
<TextBlock
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="6"
|
||||
FontWeight="Bold"
|
||||
Foreground="#0170cc"
|
||||
Text="RONCHON" />
|
||||
</Border>
|
||||
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Microsoft YaHei"
|
||||
FontSize="18"
|
||||
FontWeight="ExtraLight"
|
||||
Foreground="White"
|
||||
Text="自 动 化 样 品 前 处 理 平 台" />
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button
|
||||
x:Name="btnMonitor"
|
||||
Margin="20,0"
|
||||
Click="btnMonitor_Click"
|
||||
Content="{materialDesign:PackIcon Kind=CameraMeteringMatrix,
|
||||
Size=25}"
|
||||
Foreground="White"
|
||||
Style="{StaticResource MaterialDesignToolButton}"
|
||||
ToolTip="样品监控" />
|
||||
|
||||
<StackPanel VerticalAlignment="Center" ToolTip="{Binding UserInfo}">
|
||||
<Border
|
||||
Margin="10,0"
|
||||
BorderBrush="White"
|
||||
BorderThickness="2"
|
||||
CornerRadius="30"
|
||||
ToolTip="{Binding UserInfo}">
|
||||
<Button
|
||||
x:Name="btnUserInfo"
|
||||
Width="23"
|
||||
Height="23"
|
||||
Click="btnUserInfo_Click"
|
||||
Content="{materialDesign:PackIcon Kind=AccountOutline,
|
||||
Size=15}"
|
||||
Foreground="White"
|
||||
Style="{StaticResource MaterialDesignToolButton}"
|
||||
ToolTip="{Binding UserInfo}" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
<TextBlock
|
||||
Margin="0,0,20,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Foreground="White"
|
||||
Text="{Binding UserInfo}" />
|
||||
|
||||
<Button
|
||||
Name="btnMin"
|
||||
Click="btnMin_Click"
|
||||
Content="—"
|
||||
Style="{StaticResource MaterialDesignFlatMidBgButton}" />
|
||||
<Button
|
||||
Name="btnMax"
|
||||
Click="btnMax_Click"
|
||||
Content="🗖"
|
||||
Style="{StaticResource MaterialDesignFlatMidBgButton}" />
|
||||
<Button
|
||||
Name="btnClose"
|
||||
Click="btnClose_Click"
|
||||
Content="🗙"
|
||||
Style="{StaticResource CloseButtonCircleStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</materialDesign:ColorZone>
|
||||
|
||||
<!-- 中间区域:左侧菜单 + 主内容 -->
|
||||
<DockPanel Grid.Row="1" LastChildFill="True">
|
||||
<!-- 左侧菜单:展开占据区域,收缩隐藏 -->
|
||||
<Grid
|
||||
x:Name="MenuContainer"
|
||||
Width="200"
|
||||
Background="#4a5459"
|
||||
DockPanel.Dock="Left">
|
||||
<Grid x:Name="MenuContent">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="40,33,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="{StaticResource LefBarFontSize}"
|
||||
FontWeight="Bold"
|
||||
Foreground="White"
|
||||
Text="功能列表" />
|
||||
|
||||
<ListBox
|
||||
x:Name="FuncListbox"
|
||||
Grid.Row="1"
|
||||
Margin="0,30"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
FontWeight="ExtraLight"
|
||||
Foreground="White"
|
||||
ItemsSource="{Binding MenuBars}"
|
||||
SelectionChanged="FuncListbox_SelectionChanged">
|
||||
|
||||
<!-- 分组样式(带折叠/展开) -->
|
||||
<ListBox.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.ContainerStyle>
|
||||
<Style TargetType="GroupItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupItem">
|
||||
<StackPanel>
|
||||
<!-- 分组标题(可点击折叠) -->
|
||||
<Border
|
||||
Background="Transparent"
|
||||
Cursor="Hand"
|
||||
MouseLeftButtonUp="GroupHeader_MouseLeftButtonUp">
|
||||
<DockPanel LastChildFill="True">
|
||||
<!-- 折叠/展开箭头图标 -->
|
||||
<materialDesign:PackIcon
|
||||
Width="18"
|
||||
Height="18"
|
||||
Margin="10,5"
|
||||
VerticalAlignment="Center"
|
||||
Kind="ChevronDown"
|
||||
Tag="Expanded" />
|
||||
|
||||
<!-- 分组名称 -->
|
||||
<TextBlock
|
||||
Margin="5,5"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="{StaticResource LefBarFontSize}"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding Name}" />
|
||||
</DockPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 分组子项容器(折叠核心) -->
|
||||
<ItemsPresenter x:Name="PART_ItemsPresenter" />
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</GroupStyle.ContainerStyle>
|
||||
</GroupStyle>
|
||||
</ListBox.GroupStyle>
|
||||
|
||||
<!-- 菜单项模板 -->
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel
|
||||
Height="30"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<materialDesign:PackIcon
|
||||
Width="24"
|
||||
Height="24"
|
||||
Margin="10,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Kind="{Binding packIconKind}" />
|
||||
<TextBlock
|
||||
Margin="15,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="{StaticResource LefBarFontSize}"
|
||||
Text="{Binding name}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<!-- 主内容区域 -->
|
||||
<Grid Background="White">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="107*" />
|
||||
<ColumnDefinition Width="18*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<materialDesign:Snackbar
|
||||
x:Name="snackbar"
|
||||
Margin="356,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
MessageQueue="{materialDesign:MessageQueue}" />
|
||||
<Frame
|
||||
x:Name="MainFrame"
|
||||
Grid.ColumnSpan="2"
|
||||
NavigationUIVisibility="Hidden" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
|
||||
<!-- 悬浮开关按钮:永远显示 -->
|
||||
<Canvas
|
||||
Grid.Row="1"
|
||||
Margin="5,25,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top">
|
||||
|
||||
<ToggleButton
|
||||
x:Name="MenuToggleButton"
|
||||
Width="32"
|
||||
Height="32"
|
||||
Panel.ZIndex="9999"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Checked="MenuToggleButton_Checked"
|
||||
Foreground="White"
|
||||
Style="{StaticResource MaterialDesignHamburgerToggleButton}"
|
||||
Unchecked="MenuToggleButton_Unchecked" />
|
||||
|
||||
|
||||
</Canvas>
|
||||
|
||||
<!-- 底部状态栏 -->
|
||||
<Grid Grid.Row="2" Background="#F0F0F0">
|
||||
<StackPanel Margin="5,0" Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="自动化样品平台:" />
|
||||
<TextBlock VerticalAlignment="Center" Text="启动完成" />
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Margin="10,0"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="版本号:" />
|
||||
<TextBlock VerticalAlignment="Center" Text="1.0.0" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</Window>
|
||||
280
SamplePreSystemApp/AppMainView.xaml.cs
Normal file
280
SamplePreSystemApp/AppMainView.xaml.cs
Normal file
@@ -0,0 +1,280 @@
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using SamplePre.Models.Tables;
|
||||
using SamplePre.UIWpf;
|
||||
using SamplePre.UIWpf.ConfigManager;
|
||||
using SamplePre.UIWpf.ParamManager;
|
||||
using SamplePre.UIWpf.QueryManager;
|
||||
using SamplePre.UIWpf.SampleManager;
|
||||
using SamplePreSystem.UI;
|
||||
using SamplePreSystem.UI.ConfigManager;
|
||||
using SamplePreSystem.UI.ViewModel.Login;
|
||||
using SamplePreSystem.UI.Views;
|
||||
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.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SamplePreSystemApp
|
||||
{
|
||||
/// <summary>
|
||||
/// AppMainView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AppMainView : Window
|
||||
{
|
||||
|
||||
private bool _isMaximized = false; // 窗口是否最大化
|
||||
private Rect _normalWindowRect; // 记录还原时的位置大小
|
||||
|
||||
private MonitorView monitorView;
|
||||
|
||||
public AppMainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
AppMainViewModel vm = new AppMainViewModel();
|
||||
this.DataContext = vm;
|
||||
|
||||
var view = CollectionViewSource.GetDefaultView(vm.MenuBars) as ListCollectionView;
|
||||
//按照Name分组
|
||||
view.GroupDescriptions.Add(new PropertyGroupDescription("description"));
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MaximizeWindow();
|
||||
|
||||
//打开样品监控
|
||||
OpenSampleMonitor();
|
||||
}
|
||||
|
||||
private void btnMin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.WindowState = WindowState.Minimized;
|
||||
//MaximizeWindow();
|
||||
}
|
||||
|
||||
private void btnMax_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
MaximizeWindow();
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
if (MessageBox.Show("是否退出系统?", "退出提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btnUserInfo_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 打开用户信息窗口
|
||||
UserInfoWindow userInfoWindow = new UserInfoWindow();
|
||||
userInfoWindow.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void MaximizeWindow()
|
||||
{
|
||||
if (_isMaximized)
|
||||
{
|
||||
// 还原
|
||||
this.WindowState = WindowState.Normal;
|
||||
this.Left = _normalWindowRect.Left;
|
||||
this.Top = _normalWindowRect.Top;
|
||||
this.Width = _normalWindowRect.Width;
|
||||
this.Height = _normalWindowRect.Height;
|
||||
//BtnMaximize.Content = new PackIcon { Kind = PackIconKind.WindowMaximize, Width = 16, Height = 16, Foreground = Brushes.White };
|
||||
}
|
||||
else
|
||||
{
|
||||
// 先记录当前位置
|
||||
_normalWindowRect = new Rect(this.Left, this.Top, this.Width, this.Height);
|
||||
|
||||
// 工作区最大化(不挡任务栏)
|
||||
var workArea = SystemParameters.WorkArea;
|
||||
this.Left = workArea.Left;
|
||||
this.Top = workArea.Top;
|
||||
this.Width = workArea.Width;
|
||||
this.Height = workArea.Height;
|
||||
//BtnMaximize.Content = new PackIcon { Kind = PackIconKind.WindowRestore, Width = 16, Height = 16, Foreground = Brushes.White };
|
||||
}
|
||||
_isMaximized = !_isMaximized;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 拖拽标题栏
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ColorZone_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
this.DragMove();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开功能界面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void FuncListbox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
|
||||
// 获取 ListBox 本身
|
||||
ListBox listBox = sender as ListBox;
|
||||
|
||||
// 获取选中项
|
||||
var selectedItem = listBox.SelectedItem as MenuBarFuc;
|
||||
|
||||
//this.txt_currFunc.Text = selectedItem.name;
|
||||
|
||||
switch (selectedItem.id)
|
||||
{
|
||||
case 5:
|
||||
|
||||
OpenSampleMonitor();
|
||||
break;
|
||||
case 6:
|
||||
this.MainFrame.Navigate(new SampleExecView());
|
||||
break;
|
||||
case 8:
|
||||
this.MainFrame.Navigate(new SampleQueryView());
|
||||
|
||||
break;
|
||||
case 9:
|
||||
break;
|
||||
case 10:
|
||||
this.MainFrame.Navigate(new ParamManagerView());
|
||||
break;
|
||||
case 11:
|
||||
this.MainFrame.Navigate(new ActionManagerView());
|
||||
break;
|
||||
case 12:
|
||||
this.MainFrame.Navigate(new SopManagerView());
|
||||
break;
|
||||
case 13:
|
||||
this.MainFrame.Navigate(new UsersView());
|
||||
break;
|
||||
case 14:
|
||||
this.MainFrame.Navigate(new RoleView());
|
||||
break;
|
||||
case 15:
|
||||
this.MainFrame.Navigate(new SysConfigMangerView());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开首页,监控界面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnMonitor_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenSampleMonitor();
|
||||
}
|
||||
|
||||
public void OpenSampleMonitor()
|
||||
{
|
||||
if (monitorView == null)
|
||||
{
|
||||
monitorView = new MonitorView();
|
||||
}
|
||||
this.MainFrame.Navigate(monitorView);
|
||||
}
|
||||
|
||||
// 收缩菜单:宽度=0,内容隐藏
|
||||
private void MenuToggleButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MenuContent.Visibility = Visibility.Collapsed;
|
||||
MenuContainer.BeginAnimation(Grid.WidthProperty, new DoubleAnimation(0, TimeSpan.FromMilliseconds(200)));
|
||||
|
||||
//MenuToggleButton.Foreground = new SolidColorBrush(Color.FromArgb(1,0,113,203));
|
||||
|
||||
|
||||
MenuToggleButton.Foreground = new SolidColorBrush(Color.FromRgb(0, 113, 203));
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 展开菜单:宽度=220,内容显示
|
||||
private void MenuToggleButton_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MenuContainer.BeginAnimation(Grid.WidthProperty, new DoubleAnimation(200, TimeSpan.FromMilliseconds(200)));
|
||||
MenuContent.Visibility = Visibility.Visible;
|
||||
MenuToggleButton.Foreground = new SolidColorBrush(Colors.White);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 分组标题点击事件 → 折叠/展开子项
|
||||
/// </summary>
|
||||
private void GroupHeader_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
// 获取点击的标题容器
|
||||
var border = sender as Border;
|
||||
if (border == null) return;
|
||||
|
||||
// 获取箭头图标
|
||||
var icon = FindVisualChild<PackIcon>(border);
|
||||
// 获取子项容器
|
||||
var itemsPresenter = FindVisualChild<ItemsPresenter>(border.Parent as FrameworkElement);
|
||||
if (icon == null || itemsPresenter == null) return;
|
||||
|
||||
// 切换折叠/展开状态
|
||||
if (icon.Tag.ToString() == "Expanded")
|
||||
{
|
||||
// 折叠
|
||||
icon.Kind = PackIconKind.ChevronRight;
|
||||
icon.Tag = "Collapsed";
|
||||
itemsPresenter.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 展开
|
||||
icon.Kind = PackIconKind.ChevronDown;
|
||||
icon.Tag = "Expanded";
|
||||
itemsPresenter.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 可视化树查找子元素(通用工具方法)
|
||||
/// </summary>
|
||||
private T FindVisualChild<T>(DependencyObject parent) where T : DependencyObject
|
||||
{
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(parent, i);
|
||||
if (child is T result) return result;
|
||||
var childResult = FindVisualChild<T>(child);
|
||||
if (childResult != null) return childResult;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
10
SamplePreSystemApp/AssemblyInfo.cs
Normal file
10
SamplePreSystemApp/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
BIN
SamplePreSystemApp/Assets/app.ico
Normal file
BIN
SamplePreSystemApp/Assets/app.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
206
SamplePreSystemApp/LoginWindow.xaml
Normal file
206
SamplePreSystemApp/LoginWindow.xaml
Normal file
@@ -0,0 +1,206 @@
|
||||
<Window
|
||||
x:Class="SamplePreSystemApp.LoginWindow"
|
||||
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:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:local="clr-namespace:SamplePreSystemApp"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:pwd="clr-namespace:SamplePreSystem.UI.BaseControls;assembly=SamplePreSystem.UI"
|
||||
xmlns:selfBehavior="clr-namespace:SamplePreSystem.UI.Behaviors;assembly=SamplePreSystem.UI"
|
||||
Title="系统登录"
|
||||
Width="800"
|
||||
Height="480"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
WindowStyle="None"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Window.Resources>
|
||||
<Style x:Key="InputStyle" TargetType="TextBox">
|
||||
<Setter Property="Height" Value="42" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="10,0,10,0" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="BorderBrush" Value="#DCDFE6" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="6">
|
||||
<ScrollViewer x:Name="PART_ContentHost" Margin="{TemplateBinding Padding}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PwdInputStyle" TargetType="PasswordBox">
|
||||
<Setter Property="Height" Value="42" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="10,0,10,0" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="BorderBrush" Value="#DCDFE6" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="PasswordBox">
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="6">
|
||||
<ScrollViewer x:Name="PART_ContentHost" Margin="{TemplateBinding Padding}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Border
|
||||
Margin="10"
|
||||
Background="White"
|
||||
CornerRadius="12">
|
||||
|
||||
<i:Interaction.Behaviors>
|
||||
<selfBehavior:BorderMouseMoveBehavior />
|
||||
</i:Interaction.Behaviors>
|
||||
|
||||
<Border.Effect>
|
||||
<DropShadowEffect
|
||||
BlurRadius="20"
|
||||
Opacity="0.2"
|
||||
ShadowDepth="0" />
|
||||
</Border.Effect>
|
||||
|
||||
</Border>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image
|
||||
Width="300"
|
||||
Height="300"
|
||||
Source="/SamplePreSystem.UI;component/Assets/login.png" />
|
||||
|
||||
<StackPanel
|
||||
Grid.Column="1"
|
||||
Margin="40,60"
|
||||
VerticalAlignment="Center">
|
||||
<!-- 标题 -->
|
||||
<TextBlock
|
||||
Margin="0,0,0,20"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="26"
|
||||
FontWeight="Bold"
|
||||
Foreground="#303133"
|
||||
Text="系统登录" />
|
||||
|
||||
<!-- 账号 -->
|
||||
<TextBlock
|
||||
Margin="0,0,0,6"
|
||||
FontSize="14"
|
||||
Foreground="#606266"
|
||||
Text="账号" />
|
||||
<TextBox
|
||||
x:Name="txtAccount"
|
||||
Margin="0,0,0,10"
|
||||
Style="{StaticResource InputStyle}"
|
||||
Text="{Binding UserName}" />
|
||||
|
||||
<!-- 密码 -->
|
||||
<TextBlock
|
||||
Margin="0,0,0,6"
|
||||
FontSize="14"
|
||||
Foreground="#606266"
|
||||
Text="密码" />
|
||||
<PasswordBox
|
||||
x:Name="txtPwd"
|
||||
Margin="0,0,0,10"
|
||||
pwd:PasswordAttaExt.CustomPwd="{Binding UserPwd, Mode=TwoWay}"
|
||||
pwd:PasswordAttaExt.IsOpenPwdBading="True"
|
||||
Style="{StaticResource PwdInputStyle}">
|
||||
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="KeyDown">
|
||||
<i:InvokeCommandAction Command="{Binding PwdKeyDownCommand}" PassEventArgsToCommand="True" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
|
||||
</PasswordBox>
|
||||
|
||||
<!-- 记住我 -->
|
||||
<CheckBox
|
||||
x:Name="ckb_saveUser"
|
||||
Margin="0,0,0,10"
|
||||
HorizontalAlignment="Left"
|
||||
Content="记住用户"
|
||||
FontSize="13"
|
||||
Foreground="#909399"
|
||||
IsChecked="{Binding IsSaveUser}" />
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<Button
|
||||
Height="48"
|
||||
Background="#409EFE"
|
||||
BorderThickness="0"
|
||||
Command="{Binding LoginButtonClickCommand}"
|
||||
Content="登 录"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Foreground="White">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="6">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
|
||||
<!-- 取消按钮 -->
|
||||
<Button
|
||||
x:Name="btnCancel"
|
||||
Height="48"
|
||||
Margin="0,5"
|
||||
Background="White"
|
||||
Command="{Binding CancelClickCommand}"
|
||||
Content="取 消"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Foreground="Black">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="LightGray"
|
||||
BorderThickness="1"
|
||||
CornerRadius="6">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
<TextBlock
|
||||
FontSize="11"
|
||||
Foreground="Red"
|
||||
Text="{Binding ErrInfo}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
</Window>
|
||||
51
SamplePreSystemApp/LoginWindow.xaml.cs
Normal file
51
SamplePreSystemApp/LoginWindow.xaml.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using SamplePre.ProcessBll.BLL;
|
||||
using SamplePreSystem.UI.ViewModel.Login;
|
||||
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.Shapes;
|
||||
|
||||
namespace SamplePreSystemApp
|
||||
{
|
||||
/// <summary>
|
||||
/// LoginWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class LoginWindow : Window
|
||||
{
|
||||
|
||||
public LoginWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var vm = new LoginViewModel();
|
||||
|
||||
vm.ColseAction = (val) => DialogResult = val;
|
||||
|
||||
vm.SaveUserAction = (username)=>{
|
||||
|
||||
Properties.Settings.Default.UserName = username;
|
||||
// 用户持久化保存
|
||||
Properties.Settings.Default.Save();
|
||||
};
|
||||
|
||||
this.DataContext = vm;
|
||||
|
||||
// 读取项目设置中保存的用户名
|
||||
string savedUserName = Properties.Settings.Default.UserName;
|
||||
if(!string.IsNullOrEmpty(savedUserName))
|
||||
{
|
||||
vm.UserName = savedUserName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
28
SamplePreSystemApp/NLog.config
Normal file
28
SamplePreSystemApp/NLog.config
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<targets>
|
||||
<!--此部分中的所有目标将自动异步-->
|
||||
<target name="asyncFile" xsi:type="AsyncWrapper">
|
||||
<!--项目日志保存文件路径说明fileName="${basedir}/保存目录,以年月日的格式创建/${shortdate}/${记录器名称}-${单级记录}-${shortdate}.txt"-->
|
||||
<target name="log_file" xsi:type="File"
|
||||
fileName="${basedir}/SystemLogs/${shortdate}/${level}-${shortdate}.txt"
|
||||
layout="${longdate} | ${message} ${onexception:${exception:format=message} ${newline} ${stacktrace} ${newline}"
|
||||
archiveFileName="${basedir}/archives/${level}-${shortdate}-{#####}.txt"
|
||||
archiveAboveSize="102400"
|
||||
archiveNumbering="Sequence"
|
||||
concurrentWrites="true"
|
||||
keepFileOpen="false" />
|
||||
</target>
|
||||
<!--使用可自定义的着色将日志消息写入控制台-->
|
||||
<target name="colorConsole" xsi:type="ColoredConsole" layout="[${date:format=HH\:mm\:ss}]:${message} ${exception:format=message}" />
|
||||
</targets>
|
||||
|
||||
<!--规则配置,final - 最终规则匹配后不处理任何规则-->
|
||||
<rules>
|
||||
<logger name="Microsoft.*" minlevel="Info" writeTo="" final="true" />
|
||||
<logger name="*" minlevel="Info" writeTo="asyncFile" />
|
||||
<logger name="*" minlevel="Warn" writeTo="colorConsole" />
|
||||
</rules>
|
||||
</nlog>
|
||||
38
SamplePreSystemApp/Properties/Settings.Designer.cs
generated
Normal file
38
SamplePreSystemApp/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,38 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SamplePreSystemApp.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string UserName {
|
||||
get {
|
||||
return ((string)(this["UserName"]));
|
||||
}
|
||||
set {
|
||||
this["UserName"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
SamplePreSystemApp/Properties/Settings.settings
Normal file
9
SamplePreSystemApp/Properties/Settings.settings
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SamplePreSystemApp.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="UserName" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
52
SamplePreSystemApp/SamplePreSystemApp.csproj
Normal file
52
SamplePreSystemApp/SamplePreSystemApp.csproj
Normal file
@@ -0,0 +1,52 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\app.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SamplePreSystem.UI\SamplePreSystem.UI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Update="SystemConfig.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="Assets\app.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="LoginWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Properties\Settings.Designer.cs">
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
17
SamplePreSystemApp/SystemConfig.xml
Normal file
17
SamplePreSystemApp/SystemConfig.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- 系统配置XML文件 -->
|
||||
<SystemConfig>
|
||||
<!-- 数据库配置 -->
|
||||
<DbConfig>
|
||||
<SqlServer ConnStr="Data Source=.;Initial Catalog=fanghuayuan_test;User ID=sa;Password=123456;TrustServerCertificate=True" TimeOut="30"/>
|
||||
<MySql ConnStr="Data Source=localhost;Database=fanghuayuan_test;AllowLoadLocalInfile=true;User ID=root;Password=123;allowPublicKeyRetrieval=true;pooling=true;port=3306;" TimeOut="20"/>
|
||||
</DbConfig>
|
||||
|
||||
<!-- 系统基础配置 -->
|
||||
<AppConfig>
|
||||
<AppName>自 动 化 样 品 前 处 理 平 台</AppName>
|
||||
<Version>1.0.0</Version>
|
||||
<MaxLoginCount>5</MaxLoginCount>
|
||||
<IsDebug>true</IsDebug>
|
||||
</AppConfig>
|
||||
</SystemConfig>
|
||||
33
SamplePreSystemApp/Window1.xaml
Normal file
33
SamplePreSystemApp/Window1.xaml
Normal file
@@ -0,0 +1,33 @@
|
||||
<Window
|
||||
x:Class="SamplePreSystemApp.Window1"
|
||||
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:local="clr-namespace:SamplePreSystemApp"
|
||||
xmlns:local1="clr-namespace:SamplePreSystem.UI.BaseControls;assembly=SamplePreSystem.UI"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="Window1"
|
||||
Width="800"
|
||||
Height="450"
|
||||
mc:Ignorable="d">
|
||||
|
||||
|
||||
<Grid>
|
||||
|
||||
<StackPanel>
|
||||
<Ellipse Width="200" Height="200">
|
||||
<Ellipse.Fill>
|
||||
<RadialGradientBrush>
|
||||
<GradientStop Color="Gray" Offset="1"/>
|
||||
<GradientStop Color="White" Offset="0"/>
|
||||
</RadialGradientBrush>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
</Window>
|
||||
78
SamplePreSystemApp/Window1.xaml.cs
Normal file
78
SamplePreSystemApp/Window1.xaml.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Models.Models;
|
||||
using SamplePreSystem.UI.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
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.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using static MaterialDesignThemes.Wpf.Theme.ToolBar;
|
||||
|
||||
namespace SamplePreSystemApp
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Window1.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Window1 : Window,INotifyPropertyChanged
|
||||
{
|
||||
ListCollectionView view;
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = this;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 读取项目设置中保存的用户名
|
||||
string savedUserName = Properties.Settings.Default.UserName;
|
||||
|
||||
// 勾选:保存用户名到设置
|
||||
Properties.Settings.Default.UserName = "aaaaaaa";
|
||||
|
||||
// 2. 必须调用 Save() 才能持久化保存(关键!)
|
||||
Properties.Settings.Default.Save();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void btnRead_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 读取项目设置中保存的用户名
|
||||
string savedUserName = Properties.Settings.Default.UserName;
|
||||
|
||||
//// 如果不为空,自动回填到输入框,并勾选记住选项
|
||||
//if (!string.IsNullOrEmpty(savedUserName))
|
||||
//{
|
||||
// txtUserName.Text = savedUserName;
|
||||
// chkRemember.IsChecked = true;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user