@@ -7,13 +7,13 @@ | |||
<SolidColorBrush x:Key="foreground" Color="#a2c2e8" /> | |||
<SolidColorBrush x:Key="borderBrush" Color="#FF074B92" /> | |||
<SolidColorBrush x:Key="Titleforeground" Color="#FF07D7FF" /> | |||
<SolidColorBrush x:Key="DataGridColumnHeaderColor" Color="#00c2f4"/> | |||
<SolidColorBrush x:Key="LabelColor" Color="#FF00EEF3"/> | |||
<SolidColorBrush x:Key="MainTitleforeground" Color="#feffff"/> | |||
<SolidColorBrush x:Key="ButtonSelectForeground" Color="#4fade8"/> | |||
<SolidColorBrush x:Key="ButtonUnSelectForeground" Color="#3afdff"/> | |||
<SolidColorBrush x:Key="MeunSelectForeground" Color="#8f723c"/> | |||
<SolidColorBrush x:Key="MeunUnSelectForeground" Color="White"/> | |||
<SolidColorBrush x:Key="DataGridColumnHeaderColor" Color="#00c2f4" /> | |||
<SolidColorBrush x:Key="LabelColor" Color="#FF00EEF3" /> | |||
<SolidColorBrush x:Key="MainTitleforeground" Color="#feffff" /> | |||
<SolidColorBrush x:Key="ButtonSelectForeground" Color="#4fade8" /> | |||
<SolidColorBrush x:Key="ButtonUnSelectForeground" Color="#3afdff" /> | |||
<SolidColorBrush x:Key="MeunSelectForeground" Color="#8f723c" /> | |||
<SolidColorBrush x:Key="MeunUnSelectForeground" Color="White" /> | |||
<!--<SolidColorBrush x:Key="foreground" Color="Red" /> | |||
<SolidColorBrush x:Key="borderBrush" Color="Red" /> | |||
@@ -172,7 +172,7 @@ | |||
<ImageBrush x:Key="imageBJ" ImageSource="/BPASmartClient.CustomResource;component/Image/图层1.png" /> | |||
<ImageBrush x:Key="image1" ImageSource="/BPASmartClient.CustomResource;component/Image/shape.png" /> | |||
<ImageBrush x:Key="image2" ImageSource="/BPASmartClient.CustomResource;component/Image/shape1.png" /> | |||
<Style TargetType="Image"> | |||
<Style.Setters> | |||
<Setter Property="UseLayoutRounding" Value="True" /> | |||
@@ -981,7 +981,10 @@ | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border x:Name="BD" Cursor="Hand"> | |||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal" Cursor="Hand"> | |||
<StackPanel | |||
HorizontalAlignment="Center" | |||
Cursor="Hand" | |||
Orientation="Horizontal"> | |||
<!--<Border Width="16" Margin="5"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/顶部切图/返回按钮图标.png" /> | |||
@@ -1668,7 +1671,7 @@ | |||
</Style> | |||
<Style x:Key="数码管Text" TargetType="TextBlock"> | |||
<Setter Property="FontFamily" Value="../Fonts/#Quartz M"></Setter> | |||
<Setter Property="FontFamily" Value="../Fonts/#Quartz M" /> | |||
<Setter Property="FontSize" Value="18" /> | |||
<Setter Property="Foreground" Value="{DynamicResource foreground}" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
@@ -1758,5 +1761,5 @@ | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</ResourceDictionary> |
@@ -22,15 +22,26 @@ | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel Grid.Row="0" Orientation="Horizontal"> | |||
<TextBlock x:Name="time" FontSize="16" FontFamily="../Fonts/#Quartz M">14:48:30</TextBlock> | |||
<TextBlock | |||
x:Name="time" | |||
FontFamily="../Fonts/#Quartz M" | |||
FontSize="16"> | |||
14:48:30 | |||
</TextBlock> | |||
<Image Margin="10,0,0,0" Style="{DynamicResource timeImage}" /> | |||
</StackPanel> | |||
<StackPanel Grid.Row="1" Orientation="Horizontal"> | |||
<TextBlock x:Name="dateRL" FontSize="10" FontFamily="../Fonts/#Quartz M">星期一</TextBlock> | |||
<TextBlock | |||
x:Name="dateRL" | |||
FontFamily="../Fonts/#Quartz M" | |||
FontSize="10"> | |||
星期一 | |||
</TextBlock> | |||
<TextBlock | |||
x:Name="date" FontFamily="../Fonts/#Quartz M" | |||
x:Name="date" | |||
Margin="10,0,0,0" | |||
FontFamily="../Fonts/#Quartz M" | |||
FontSize="10"> | |||
2021-11-13 | |||
</TextBlock> | |||
@@ -12,7 +12,7 @@ | |||
mc:Ignorable="d"> | |||
<UserControl.Resources> | |||
<Style x:Key="btnNum" TargetType="{x:Type Button}"> | |||
<Setter Property="Cursor" Value="Hand"></Setter> | |||
<Setter Property="Cursor" Value="Hand" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
@@ -63,7 +63,7 @@ | |||
</Setter> | |||
</Style> | |||
<Style x:Key="btnFunc" TargetType="{x:Type Button}"> | |||
<Setter Property="Cursor" Value="Hand"></Setter> | |||
<Setter Property="Cursor" Value="Hand" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<!--<Setter Property="Padding" Value="1"/>--> | |||
@@ -72,12 +72,10 @@ namespace BPASmartClient.Helper | |||
if (actions.ContainsKey(key)) | |||
if (par == null) | |||
{ | |||
//if (actions[key].FuncObj != null) | |||
return actions[key].FuncObj?.Invoke(); | |||
} | |||
else | |||
{ | |||
//if (actions[key].FuncPar != null) | |||
return actions[key].FuncPar?.Invoke(par); | |||
} | |||
return default; | |||
@@ -0,0 +1,85 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Security.Cryptography; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Helper | |||
{ | |||
public static class Aes128Helper | |||
{ | |||
/// <summary> | |||
/// AES 加密 | |||
/// </summary> | |||
/// <param name="str">明文(待加密)</param> | |||
/// <param name="aesSecretKey">密钥</param> | |||
/// <returns></returns> | |||
//public static string AESEncrypt(this string str, string aesSecretKey = "bpa20210418bpa20210418bpa*******") | |||
//{ | |||
// try | |||
// { | |||
// if (string.IsNullOrEmpty(str)) return null; | |||
// byte[] toEncryptArray = Encoding.UTF8.GetBytes(str); | |||
// byte[] keyArray = UTF8Encoding.UTF8.GetBytes(aesSecretKey); | |||
// RijndaelManaged rm = new RijndaelManaged | |||
// { | |||
// Key = keyArray, | |||
// Mode = CipherMode.ECB, | |||
// Padding = PaddingMode.PKCS7 | |||
// }; | |||
// ICryptoTransform cTransform = rm.CreateEncryptor(); | |||
// Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); | |||
// string strs = ""; | |||
// for (var x = 0; x < resultArray.Length; x++) | |||
// { | |||
// var i = Convert.ToString(resultArray[x], 16); | |||
// strs += i.PadLeft(2, '0'); | |||
// } | |||
// return strs; | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// return ""; | |||
// } | |||
//} | |||
/// <summary> | |||
/// AES 解密 | |||
/// </summary> | |||
/// <param name="str">密文(待解密)</param> | |||
/// <param name="aesSecretKey">密钥</param> | |||
/// <returns></returns> | |||
//public static string AESDecrypt(this string str, string aesSecretKey = "bpa20210418bpa20210418bpa*******") | |||
//{ | |||
// try | |||
// { | |||
// if (string.IsNullOrEmpty(str)) return null; | |||
// byte[] keyArray = UTF8Encoding.UTF8.GetBytes(aesSecretKey); | |||
// byte[] toEncryptArray = new byte[str.Length / 2]; | |||
// for (var x = 0; x < toEncryptArray.Length; x++) | |||
// { | |||
// var i = Convert.ToInt32(str.Substring(x * 2, 2), 16); | |||
// toEncryptArray[x] = (byte)i; | |||
// } | |||
// RijndaelManaged rDel = new RijndaelManaged(); | |||
// rDel.Key = keyArray; | |||
// rDel.Mode = CipherMode.ECB; | |||
// rDel.Padding = PaddingMode.PKCS7; | |||
// ICryptoTransform cTransform = rDel.CreateDecryptor(); | |||
// byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); | |||
// return UTF8Encoding.UTF8.GetString(resultArray); | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// return ""; | |||
// } | |||
//} | |||
} | |||
} |
@@ -0,0 +1,188 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Diagnostics; | |||
using System.Linq; | |||
using System.Reflection; | |||
using System.Runtime.InteropServices; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Helper | |||
{ | |||
public class SystemUtils | |||
{ | |||
//private static ILogger logger = NLog.LogManager.GetCurrentClassLogger(); | |||
public static bool isShowNumBoard = false; | |||
[DllImport("kernel32.dll", SetLastError = true)] | |||
public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr); | |||
[DllImport("kernel32.dll", SetLastError = true)] | |||
public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr); | |||
public static IntPtr ptr = new IntPtr(); | |||
public static void ShowScreenKeyboard() | |||
{ | |||
try | |||
{ | |||
//ProcessStartInfo psi = new ProcessStartInfo(); | |||
//psi.FileName = @"C:\Windows\System32\osk.exe"; | |||
//psi.UseShellExecute = false; | |||
//psi.CreateNoWindow = true; | |||
//Process.Start(psi); | |||
Process kbpr = System.Diagnostics.Process.Start(@"C:\Windows\System32\osk.exe"); // 打开系统键盘 | |||
////判断软键盘是否进程是否已经存在,如果不存在进行调用 | |||
//Process[] pro = Process.GetProcessesByName("osk"); | |||
//bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr); | |||
////键盘如果已经打开则重新打开,防止最小化无法显示 | |||
//if (pro != null && pro.Length > 0) | |||
//{ | |||
// Process kbpr = pro[0]; | |||
// kbpr.Kill(); | |||
// if (isWow64FsRedirectionDisabled) | |||
// { | |||
// Process.Start(@"C:WINDOWSsystem32osk.exe"); | |||
// Wow64RevertWow64FsRedirection(ptr); | |||
// } | |||
// return; | |||
//} | |||
////if (isWow64FsRedirectionDisabled) | |||
////{ | |||
//Process.Start(@"C:WINDOWSsystem32osk.exe"); | |||
//Wow64RevertWow64FsRedirection(ptr); | |||
//} | |||
} | |||
catch (Exception ex) | |||
{ | |||
//logger.Error(ex.Message); | |||
} | |||
} | |||
//[DllImport("kernel32.dll", SetLastError = true)] | |||
//private static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr); | |||
//[DllImport("kernel32.dll", SetLastError = true)] | |||
//public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr); | |||
//private const UInt32 WM_SYSCOMMAND = 0x112; | |||
//private const UInt32 SC_RESTORE = 0xf120; | |||
//[DllImport("user32.dll", CharSet = CharSet.Auto)] | |||
//static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam); | |||
//private const string OnScreenKeyboadApplication = "osk.exe"; | |||
///// <summary> | |||
///// 启用系统软键盘 | |||
///// </summary> | |||
//public static void OpenKeyBoardFun() | |||
//{ | |||
// try | |||
// { | |||
// //判断软键盘是否进程是否已经存在,如果不存在进行调用 | |||
// Process[] pro = Process.GetProcessesByName("osk"); | |||
// //如果键盘已打开,则进行关闭操作 | |||
// if (pro != null && pro.Length > 0) | |||
// { | |||
// CloseKeyBoardFun(); | |||
// return; | |||
// } | |||
// // Get the name of the On screen keyboard | |||
// string processName = System.IO.Path.GetFileNameWithoutExtension(OnScreenKeyboadApplication); | |||
// // Check whether the application is not running | |||
// var query = from process in Process.GetProcesses() | |||
// where process.ProcessName == processName | |||
// select process; | |||
// var keyboardProcess = query.FirstOrDefault(); | |||
// // launch it if it doesn't exist | |||
// if (keyboardProcess == null) | |||
// { | |||
// IntPtr ptr = new IntPtr(); ; | |||
// bool sucessfullyDisabledWow64Redirect = false; | |||
// // Disable x64 directory virtualization if we're on x64, | |||
// // otherwise keyboard launch will fail. | |||
// if (System.Environment.Is64BitOperatingSystem) | |||
// { | |||
// sucessfullyDisabledWow64Redirect = Wow64DisableWow64FsRedirection(ref ptr); | |||
// } | |||
// // osk.exe is in windows/system folder. So we can directky call it without path | |||
// using (Process osk = new Process()) | |||
// { | |||
// osk.StartInfo.FileName = OnScreenKeyboadApplication; | |||
// osk.Start(); | |||
// //osk.WaitForInputIdle(2000); | |||
// } | |||
// // Re-enable directory virtualisation if it was disabled. | |||
// if (System.Environment.Is64BitOperatingSystem) | |||
// if (sucessfullyDisabledWow64Redirect) | |||
// Wow64RevertWow64FsRedirection(ptr); | |||
// } | |||
// else | |||
// { | |||
// // Bring keyboard to the front if it's already running | |||
// var windowHandle = keyboardProcess.MainWindowHandle; | |||
// SendMessage(windowHandle, WM_SYSCOMMAND, new IntPtr(SC_RESTORE), new IntPtr(0)); | |||
// } | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// //LogUtil.WriteLog(MethodBase.GetCurrentMethod().Name, LogUtil.ERROE, ex.Message); | |||
// //LogUtil.WriteLog(MethodBase.GetCurrentMethod().Name, LogUtil.ERROE, ex.StackTrace); | |||
// } | |||
//} | |||
///// <summary> | |||
///// 关闭系统软键盘 | |||
///// </summary> | |||
//public static void CloseKeyBoardFun() | |||
//{ | |||
// try | |||
// { | |||
// Process[] pros = Process.GetProcessesByName("osk"); | |||
// foreach (Process p in pros) | |||
// { | |||
// p.Kill(); | |||
// } | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// //LogUtil.WriteLog(MethodBase.GetCurrentMethod().Name, LogUtil.ERROE, ex.Message); | |||
// //LogUtil.WriteLog(MethodBase.GetCurrentMethod().Name, LogUtil.ERROE, ex.StackTrace); | |||
// } | |||
//} | |||
} | |||
} |
@@ -64,6 +64,12 @@ namespace BPASmartClient.Modbus | |||
} | |||
public void Dispose() | |||
{ | |||
master.Dispose(); | |||
Disconnect?.Invoke(); | |||
} | |||
private void Connect() | |||
{ | |||
bool ErrorFlag = false; | |||
@@ -51,6 +51,24 @@ namespace BPASmartClient.MorkS | |||
} | |||
} | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
Random rd = new Random(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
int NoodleLoc = rd.Next(1, 6); | |||
int BowlLoc = rd.Next(10, 11); | |||
string guid = new Guid().ToString(); | |||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)NoodleLoc, SuborderId = guid }); | |||
MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】"); | |||
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)BowlLoc, SuborderId = guid }); | |||
MessageLog.GetInstance.Show($"添加订单:碗位置【{BowlLoc}】"); | |||
Thread.Sleep(60000); | |||
}), "ForOrder"); | |||
}), "EnableForOrder"); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value); | |||
@@ -367,21 +385,21 @@ namespace BPASmartClient.MorkS | |||
/// </summary> | |||
private void TurntableControl() | |||
{ | |||
//if (GeneralConfig.EnableLocalSimOrder) | |||
//{ | |||
// //不做轮询,直接取面,模拟订单使用 | |||
// if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) | |||
// { | |||
// if (mORKS.TurntableLowerLimit) | |||
// { | |||
// TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc); | |||
// mORKS.TurntableLocLists.Clear(); | |||
// mORKS.AllowTakeNoodle = true; | |||
// DeviceProcessLogShow($"控制机器人去转台【{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面"); | |||
// } | |||
// } | |||
//} | |||
//else | |||
if (Global.EnableLocalSimOrder) | |||
{ | |||
//不做轮询,直接取面,模拟订单使用 | |||
if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) | |||
{ | |||
if (mORKS.TurntableLowerLimit) | |||
{ | |||
TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc); | |||
mORKS.TurntableLocLists.Clear(); | |||
mORKS.AllowTakeNoodle = true; | |||
DeviceProcessLogShow($"控制机器人去转台【{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面"); | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
//正常轮询 | |||
if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) | |||
@@ -0,0 +1,13 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkS.Model | |||
{ | |||
public class Global | |||
{ | |||
public static bool EnableLocalSimOrder { get; set; } | |||
} | |||
} |
@@ -7,14 +7,14 @@ | |||
<add key="IsEnableTest" value="false"/> | |||
<!--开发环境--> | |||
<add key="apollouri" value="http://10.2.1.21:28080/"/> | |||
<!--<add key="apollouri" value="http://10.2.1.21:28080/"/> | |||
<add key="AppId" value="dev1_common"/> | |||
<add key ="Namespaces" value="DEV.Config"/> | |||
<add key ="Namespaces" value="DEV.Config"/>--> | |||
<!--正式环境--> | |||
<!--<add key="apollouri" value="http://47.108.65.220:28080/"/> | |||
<add key="apollouri" value="http://47.108.65.220:28080/"/> | |||
<add key="AppId" value="order"/> | |||
<add key ="Namespaces" value="TEST1.Config"/>--> | |||
<add key ="Namespaces" value="TEST1.Config"/> | |||
<!--阿里云上报启动方式:API 或者 LOCAL--> | |||
<!--API :通过客户端ID,调用接口查询“设备连接信息”--> | |||
@@ -5,10 +5,18 @@ | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<UseWPF>true</UseWPF> | |||
<ApplicationManifest>app.manifest</ApplicationManifest> | |||
<ApplicationIcon>hbl.ico</ApplicationIcon> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Content Include="hbl.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Message" Version="1.0.39" /> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -16,4 +24,10 @@ | |||
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Page Update="View\AdminstratorsView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,23 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace DosingSystem.Model | |||
{ | |||
public class ActionMenu : ObservableObject | |||
{ | |||
public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } } | |||
private string _mCommandParameter; | |||
public Permission[] permission { get { return _mpermission; } set { _mpermission = value; OnPropertyChanged(); } } | |||
private Permission[] _mpermission; | |||
public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } } | |||
private string _mMenuName; | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
using BPA.Message; | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace DosingSystem.Model | |||
{ | |||
public class Config | |||
{ | |||
private volatile static Config _Instance; | |||
public static Config GetInstance => _Instance ?? (_Instance = new Config()); | |||
private Config() { } | |||
public void Init() | |||
{ | |||
if (File.Exists("up.hbl")) | |||
{ | |||
var result = JsonConvert.DeserializeObject<UserManager>(File.ReadAllText("up.hbl").AESDecrypt()); | |||
if (result == null || (result != null && result.userInfos.Count <= 0)) | |||
{ | |||
AddData(); | |||
} | |||
else | |||
{ | |||
Global.userManager = result; | |||
} | |||
} | |||
else | |||
{ | |||
AddData(); | |||
} | |||
} | |||
private void AddData() | |||
{ | |||
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.管理员, UserName = "admin", Password = "admin" }); | |||
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.操作员, UserName = "czy", Password = "123456" }); | |||
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.观察员, UserName = "gcy", Password = "654321" }); | |||
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.技术员, UserName = "jsy", Password = "88888888" }); | |||
File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace DosingSystem.Model | |||
{ | |||
public class Global | |||
{ | |||
public static UserManager userManager { get; set; } = new UserManager(); | |||
} | |||
} |
@@ -0,0 +1,30 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace DosingSystem.Model | |||
{ | |||
public class UserManager | |||
{ | |||
public List<UserInfo> userInfos { get; set; } = new List<UserInfo>(); | |||
} | |||
public class UserInfo | |||
{ | |||
public Permission permission { get; set; } | |||
public string UserName { get; set; } | |||
public string Password { get; set; } | |||
} | |||
public enum Permission : int | |||
{ | |||
管理员 = 1, | |||
操作员 = 2, | |||
观察员 = 3, | |||
技术员=4 | |||
} | |||
} |
@@ -0,0 +1,178 @@ | |||
<UserControl | |||
x:Class="DosingSystem.View.AdminstratorsView" | |||
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:helper="clr-namespace:DosingSystem.View.Helper" | |||
xmlns:local="clr-namespace:DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:uc="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||
d:DesignHeight="600" | |||
d:DesignWidth="800" | |||
Loaded="UserControl_Loaded" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:AdminstratorsViewModel /> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<Style x:Key="TxLogin" TargetType="TextBlock"> | |||
<Setter Property="FontSize" Value="20" /> | |||
<Setter Property="Foreground" Value="#ddd" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
</Style> | |||
</UserControl.Resources> | |||
<Grid> | |||
<!--<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="7*" /> | |||
<ColumnDefinition Width="10*" /> | |||
</Grid.ColumnDefinitions>--> | |||
<!--<Grid.RowDefinitions> | |||
<RowDefinition Height="5*" /> | |||
<RowDefinition Height="5*" /> | |||
<RowDefinition Height="5*" /> | |||
<RowDefinition Height="4*" /> | |||
<RowDefinition Height="8*" /> | |||
<RowDefinition Height="20*" /> | |||
</Grid.RowDefinitions>--> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--#region 登录--> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.7*"/> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="#feffff" | |||
Style="{StaticResource TxLogin}" | |||
Text="权限:" /> | |||
<ComboBox | |||
Grid.Column="1" | |||
Width="230" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF074B92" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
IsEditable="False" | |||
ItemsSource="{Binding permission}" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding SelectText}" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="#feffff" | |||
Style="{StaticResource TxLogin}" | |||
Text="账号:" /> | |||
<TextBox | |||
x:Name="tbx_admin" | |||
Grid.Row="1" | |||
Grid.Column="1" | |||
Width="230" | |||
Height="28" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Top" | |||
Background="Transparent" | |||
BorderBrush="White" | |||
BorderThickness="0,0,0,1" | |||
FontSize="20" | |||
Foreground="#F8F8FF" | |||
GotFocus="TextBox_GotFocus" | |||
Text="{Binding Admin, Mode=TwoWay}" /> | |||
<TextBlock | |||
Grid.Row="2" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="#feffff" | |||
Style="{StaticResource TxLogin}" | |||
Text="密码:" /> | |||
<PasswordBox | |||
x:Name="password" | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Width="230" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Top" | |||
helper:PasswordBoxHelper.PasswordContent="{Binding Password, Mode=TwoWay}" | |||
Background="Transparent" | |||
BorderBrush="White" | |||
BorderThickness="0,0,0,1" | |||
CaretBrush="White" | |||
FontSize="16" | |||
Foreground="#F8F8FF" | |||
GotFocus="Password_GotFocus" /> | |||
<TextBlock | |||
Grid.Row="3" | |||
Grid.ColumnSpan="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontFamily="楷体" | |||
FontSize="16" | |||
Foreground="#FFE2415C" | |||
Text="{Binding ErrorMessage}" | |||
TextWrapping="Wrap" /> | |||
<Button | |||
Grid.Row="4" | |||
Grid.ColumnSpan="2" | |||
Width="120" | |||
Height="40" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="#ff19b7ec" | |||
BorderThickness="2" | |||
Command="{Binding AdminLoginCommand}" | |||
Content="登 录" | |||
FontSize="28" | |||
Foreground="#9934F7F7" | |||
IsDefault="True" /> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 密码修改--> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
</Grid> | |||
<!--#endregion--> | |||
<uc:UserKeyBoard | |||
x:Name="myKeyboard" | |||
Grid.Row="5" | |||
Grid.ColumnSpan="2" | |||
Margin="100,10,100,50" | |||
Focusable="False" /> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,91 @@ | |||
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; | |||
using static BPASmartClient.CustomResource.UserControls.UserKeyBoard; | |||
namespace DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// AdministratorsView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class AdminstratorsView : UserControl | |||
{ | |||
public AdminstratorsView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
private void UserControl_Loaded(object sender, RoutedEventArgs e) | |||
{ | |||
this.tbx_admin.Focus(); | |||
} | |||
private void MyKeyDown_Admin(object _key) | |||
{ | |||
EKeyitem key = EKeyitem.A; | |||
if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key; | |||
switch (key) | |||
{ | |||
case EKeyitem.DEL: | |||
if (tbx_admin.Text.Length > 0) | |||
{ | |||
tbx_admin.Text = tbx_admin.Text.Substring(0, tbx_admin.Text.Length - 1); | |||
} | |||
break; | |||
case EKeyitem.AC: | |||
tbx_admin.Text = string.Empty; | |||
break; | |||
case EKeyitem.OK: | |||
break; | |||
default: | |||
tbx_admin.Text += _key.ToString(); | |||
break; | |||
} | |||
this.tbx_admin.Focus(); | |||
} | |||
private void MyKeyDown_Password(object _key) | |||
{ | |||
EKeyitem key = EKeyitem.A; | |||
if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key; | |||
switch (key) | |||
{ | |||
case EKeyitem.DEL: | |||
if (password.Password.Length > 0) | |||
{ | |||
password.Password = password.Password.Substring(0, password.Password.Length - 1); | |||
} | |||
break; | |||
case EKeyitem.AC: | |||
password.Password = string.Empty; | |||
break; | |||
case EKeyitem.OK: | |||
break; | |||
default: | |||
password.Password += _key.ToString(); | |||
break; | |||
} | |||
} | |||
private void TextBox_GotFocus(object sender, RoutedEventArgs e) | |||
{ | |||
myKeyboard.MyKeyDown = MyKeyDown_Admin; | |||
} | |||
private void Password_GotFocus(object sender, RoutedEventArgs e) | |||
{ | |||
myKeyboard.MyKeyDown = MyKeyDown_Password; | |||
} | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
namespace DosingSystem.View.Helper | |||
{ | |||
/// <summary> | |||
/// 为PasswordBox控件的Password增加绑定功能 | |||
/// </summary> | |||
public static class PasswordBoxHelper | |||
{ | |||
public static string GetPasswordContent(DependencyObject obj) => (string)obj.GetValue(PasswordContentProperty); | |||
public static void SetPasswordContent(DependencyObject obj, string value) => obj.SetValue(PasswordContentProperty, value); | |||
public static readonly DependencyProperty PasswordContentProperty = | |||
DependencyProperty.RegisterAttached("PasswordContent", typeof(string), typeof(PasswordBoxHelper), | |||
new PropertyMetadata(string.Empty, OnPasswordContentPropertyChanged)); | |||
private static void OnPasswordContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
var box = d as PasswordBox; | |||
box.PasswordChanged -= OnPasswordChanged; | |||
var password = (string)e.NewValue; | |||
if (box != null && box.Password != password) | |||
box.Password = password; | |||
box.PasswordChanged += OnPasswordChanged; | |||
} | |||
private static void OnPasswordChanged(object sender, RoutedEventArgs e) | |||
{ | |||
var box = sender as PasswordBox; | |||
SetPasswordContent(box, box.Password); | |||
} | |||
} | |||
} |
@@ -23,6 +23,29 @@ | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||
<ResourceDictionary> | |||
<!--#region ListBox样式--> | |||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> | |||
<Setter Property="OverridesDefaultStyle" Value="True" /> | |||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||
<Setter Property="BorderBrush" Value="{x:Null}" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="FontSize" Value="20" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||
<Border x:Name="border" CornerRadius="8"> | |||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Window.Resources> | |||
@@ -56,33 +79,29 @@ | |||
Style="{DynamicResource imagetop_Title}" /> | |||
<Grid Grid.Column="1"> | |||
<StackPanel Orientation="Horizontal"> | |||
<RadioButton | |||
Command="{Binding TogglePag}" | |||
CommandParameter="RecipeSettingsView.配方设置" | |||
Content="配方设置" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
<RadioButton | |||
Command="{Binding TogglePag}" | |||
CommandParameter="DeviceListView.设备列表" | |||
Content="设备列表" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
<RadioButton | |||
Command="{Binding TogglePag}" | |||
CommandParameter="HardwareStatusView.硬件状态" | |||
Content="硬件状态" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
<RadioButton | |||
Command="{Binding TogglePag}" | |||
CommandParameter="AlarmRecordView.报警记录" | |||
Content="报警记录" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
<RadioButton | |||
Command="{Binding TogglePag}" | |||
CommandParameter="RecipeControlView.配方控制" | |||
Content="配方控制" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
</StackPanel> | |||
<ListBox | |||
x:Name="lstEnt" | |||
Background="{x:Null}" | |||
BorderBrush="{x:Null}" | |||
BorderThickness="0" | |||
ItemContainerStyle="{StaticResource ResourceKey=ListBoxItemStyle1}" | |||
ItemsSource="{Binding Menus}"> | |||
<ListBox.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<StackPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListBox.ItemsPanel> | |||
<ListBox.ItemTemplate> | |||
<DataTemplate> | |||
<RadioButton | |||
Command="{Binding DataContext.TogglePag, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" | |||
CommandParameter="{Binding CommandParameter}" | |||
Content="{Binding MenuName}" | |||
GroupName="all" | |||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||
</DataTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListBox> | |||
</Grid> | |||
<StackPanel | |||
@@ -92,21 +111,61 @@ | |||
VerticalAlignment="Top" | |||
Orientation="Horizontal"> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<StackPanel | |||
Margin="5" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center"> | |||
<TextBlock FontSize="12">网</TextBlock> | |||
<TextBlock FontSize="12">络</TextBlock> | |||
</StackPanel> | |||
<ToggleButton | |||
Margin="5" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Cursor="Hand" | |||
IsChecked="{Binding NetworkConnectState}" | |||
Style="{DynamicResource StatusBtnStyle网络连接状态}" | |||
ToolTip="网络连接状态" /> | |||
<Grid> | |||
<ToggleButton | |||
Name="tb" | |||
Margin="5" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Cursor="Hand" | |||
IsChecked="{Binding UserManagement}" | |||
Style="{DynamicResource StatusBtnStyle网络连接状态}" | |||
ToolTip="用户管理" /> | |||
<!-- 当 StaysOpen 设置为 True 时 popup失去焦点的时候不会自动关闭 --> | |||
<Popup | |||
AllowsTransparency="True" | |||
Focusable="False" | |||
IsOpen="{Binding IsChecked, ElementName=tb}" | |||
Placement="Bottom" | |||
PlacementTarget="{Binding ElementName=tb}" | |||
StaysOpen="False"> | |||
<Border Background="#081424" ClipToBounds="True"> | |||
<Grid Width="100" Margin="0"> | |||
<StackPanel Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}"> | |||
<Button | |||
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}" | |||
Margin="0,5,0,1" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Command="{Binding PasswordChange}" | |||
Content="密码修改" | |||
Cursor="Hand" /> | |||
<Button | |||
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}" | |||
Margin="0,5,0,1" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Command="{Binding Login}" | |||
Content="登录账号" | |||
Cursor="Hand" /> | |||
<Button | |||
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}" | |||
Margin="0,5,0,1" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Command="{Binding ExitLogin}" | |||
Content="退出登录" | |||
Cursor="Hand" /> | |||
</StackPanel> | |||
</Grid> | |||
</Border> | |||
</Popup> | |||
</Grid> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<ToggleButton | |||
HorizontalAlignment="Center" | |||
@@ -176,7 +235,16 @@ | |||
Foreground="#feffff" | |||
Text="{Binding WindowTitleName}" /> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<!--<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<Button | |||
Grid.Row="0" | |||
Width="70" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Command="{Binding Login}" | |||
Content="账号修改" | |||
Cursor="Hand" /> | |||
<Button | |||
Name="login" | |||
Grid.Row="0" | |||
@@ -184,7 +252,7 @@ | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Click="Button_Login" | |||
Command="{Binding Login}" | |||
Content="登录" | |||
Cursor="Hand" /> | |||
<Button | |||
@@ -197,7 +265,7 @@ | |||
Command="{Binding LogoutCommand}" | |||
Content="注销" | |||
Cursor="Hand" /> | |||
</StackPanel> | |||
</StackPanel>--> | |||
</Grid> | |||
@@ -40,18 +40,5 @@ namespace DosingSystem.View | |||
if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); | |||
}; | |||
} | |||
private void Button_Login(object sender, RoutedEventArgs e) | |||
{ | |||
} | |||
private void Button_LogOut(object sender, RoutedEventArgs e) | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
namespace DosingSystem.ViewModel | |||
{ | |||
public class AdminstratorsViewModel : ObservableObject | |||
{ | |||
public string Admin { get { return _admin; } set { _admin = value; OnPropertyChanged(); } } | |||
private string _admin; | |||
public string Password { get { return _password; } set { _password = value; OnPropertyChanged(); } } | |||
private string _password; | |||
public string ErrorMessage { get { return _errorMessage; } set { _errorMessage = value; OnPropertyChanged(); } } | |||
private string _errorMessage; | |||
public string SelectText { get { return _mSelectText; } set { _mSelectText = value; OnPropertyChanged(); } } | |||
private string _mSelectText; | |||
public RelayCommand AdminLoginCommand { get; set; } | |||
public ObservableCollection<string> permission { get; set; } = new ObservableCollection<string>(); | |||
public AdminstratorsViewModel() | |||
{ | |||
AdminLoginCommand = new RelayCommand(() => | |||
{ | |||
var rest = ActionManage.GetInstance.SendResult("LoginDosingSystem", $"{Admin}-={Password}-={SelectText}"); | |||
if (rest != null && rest is string str) | |||
{ | |||
ErrorMessage = str; | |||
} | |||
}); | |||
permission.Add("管理员"); | |||
permission.Add("操作员"); | |||
permission.Add("观察员"); | |||
permission.Add("技术员"); | |||
SelectText = permission[0]; | |||
} | |||
} | |||
} |
@@ -9,15 +9,108 @@ using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using DosingSystem.Model; | |||
using Newtonsoft.Json; | |||
using System.IO; | |||
namespace DosingSystem.ViewModel | |||
{ | |||
public class MainViewModel : ObservableObject | |||
{ | |||
ObservableCollection<ActionMenu> menus = new ObservableCollection<ActionMenu>(); | |||
private Permission _permission; | |||
public Permission permission | |||
{ | |||
get { return _permission; } | |||
set | |||
{ | |||
var res = menus.Where(p => Array.FindIndex(p.permission, s => s == value) >= 0).ToList(); | |||
if (res != null && res.Count > 0) | |||
{ | |||
Menus.Clear(); | |||
res.ForEach((item) => { Menus.Add(item); }); | |||
} | |||
_permission = value; | |||
} | |||
} | |||
public MainViewModel() | |||
{ | |||
DoNavChanged("HardwareStatusView.硬件状态"); | |||
TogglePag = new RelayCommand<object>(DoNavChanged); | |||
Login = new RelayCommand(() => { DoNavChanged("AdminstratorsView.用户登录"); UserManagement = false; }); | |||
PasswordChange = new RelayCommand(() => | |||
{ | |||
//DoNavChanged("PasswordChangeView.密码修改"); | |||
UserManagement = false; | |||
}); | |||
ExitLogin = new RelayCommand(() => | |||
{ | |||
//DoNavChanged("LoginView.退出登录"); | |||
UserManagement = false; | |||
}); | |||
Config.GetInstance.Init(); | |||
LoginRegister(); | |||
MenuInit(); | |||
permission = Permission.观察员; | |||
if (Menus.Count > 0) DoNavChanged(Menus.ElementAt(0).CommandParameter); | |||
} | |||
private void LoginRegister() | |||
{ | |||
ActionManage.GetInstance.Register(new Func<object, object>((o) => | |||
{ | |||
if (o != null && o is string str) | |||
{ | |||
var strs = str.Split("-="); | |||
if (strs != null && strs.Length == 3) | |||
{ | |||
var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0]); | |||
if (us != null && strs[1] == us.Password && strs[2] == us.permission.ToString()) | |||
{ | |||
permission = us.permission; | |||
return string.Empty; | |||
} | |||
} | |||
} | |||
return "用户名或密码错误"; | |||
}), "LoginDosingSystem"); | |||
} | |||
private void MenuInit() | |||
{ | |||
menus.Add(new ActionMenu() | |||
{ | |||
MenuName = "配方设置", | |||
CommandParameter = "RecipeSettingsView.配方设置", | |||
permission = new Permission[] { Permission.管理员, Permission.技术员 }, | |||
}); | |||
menus.Add(new ActionMenu() | |||
{ | |||
MenuName = "设备列表", | |||
CommandParameter = "DeviceListView.设备列表", | |||
permission = new Permission[] { Permission.管理员, Permission.技术员 }, | |||
}); | |||
menus.Add(new ActionMenu() | |||
{ | |||
MenuName = "硬件状态", | |||
CommandParameter = "HardwareStatusView.硬件状态", | |||
permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
}); | |||
menus.Add(new ActionMenu() | |||
{ | |||
MenuName = "报警记录", | |||
CommandParameter = "AlarmRecordView.报警记录", | |||
permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||
}); | |||
menus.Add(new ActionMenu() | |||
{ | |||
MenuName = "配方下发", | |||
CommandParameter = "RecipeControlView.配方控制", | |||
permission = new Permission[] { Permission.管理员, Permission.操作员 }, | |||
}); | |||
} | |||
public void DoNavChanged(object obj) | |||
@@ -36,12 +129,24 @@ namespace DosingSystem.ViewModel | |||
} | |||
public RelayCommand<object> TogglePag { get; set; } | |||
public RelayCommand Login { get; set; } | |||
public RelayCommand PasswordChange { get; set; } | |||
public RelayCommand ExitLogin { get; set; } | |||
public ObservableCollection<ActionMenu> Menus { get; set; } = new ObservableCollection<ActionMenu>(); | |||
public FrameworkElement MyWindow { get { return _mMyWindow; } set { _mMyWindow = value; OnPropertyChanged(); } } | |||
private FrameworkElement _mMyWindow; | |||
public string WindowTitleName { get { return _mWindowTitleName; } set { _mWindowTitleName = value; OnPropertyChanged(); } } | |||
private string _mWindowTitleName; | |||
public bool UserManagement { get { return _mUserManagement; } set { _mUserManagement = value; OnPropertyChanged(); } } | |||
private bool _mUserManagement; | |||
public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } } | |||
} | |||
} |
@@ -0,0 +1,79 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> | |||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | |||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | |||
<security> | |||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | |||
<!-- UAC 清单选项 | |||
如果想要更改 Windows 用户帐户控制级别,请使用 | |||
以下节点之一替换 requestedExecutionLevel 节点。 | |||
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> | |||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | |||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> | |||
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。 | |||
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此 | |||
元素。 | |||
--> | |||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | |||
</requestedPrivileges> | |||
</security> | |||
</trustInfo> | |||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | |||
<application> | |||
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的 | |||
Windows 版本的列表。取消评论适当的元素, | |||
Windows 将自动选择最兼容的环境。 --> | |||
<!-- Windows Vista --> | |||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />--> | |||
<!-- Windows 7 --> | |||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />--> | |||
<!-- Windows 8 --> | |||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />--> | |||
<!-- Windows 8.1 --> | |||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />--> | |||
<!-- Windows 10 --> | |||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />--> | |||
</application> | |||
</compatibility> | |||
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行 | |||
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需 | |||
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应 | |||
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。 | |||
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation --> | |||
<!-- | |||
<application xmlns="urn:schemas-microsoft-com:asm.v3"> | |||
<windowsSettings> | |||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> | |||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware> | |||
</windowsSettings> | |||
</application> | |||
--> | |||
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) --> | |||
<!-- | |||
<dependency> | |||
<dependentAssembly> | |||
<assemblyIdentity | |||
type="win32" | |||
name="Microsoft.Windows.Common-Controls" | |||
version="6.0.0.0" | |||
processorArchitecture="*" | |||
publicKeyToken="6595b64144ccf1df" | |||
language="*" | |||
/> | |||
</dependentAssembly> | |||
</dependency> | |||
--> | |||
</assembly> |