Ver código fonte

登录

样式分支
pry 2 anos atrás
pai
commit
94ea337eee
10 arquivos alterados com 225 adições e 178 exclusões
  1. +35
    -0
      BPASmartClient.CustomResource/Pages/View/LoginView.xaml
  2. +27
    -0
      BPASmartClient.CustomResource/Pages/View/LoginView.xaml.cs
  3. +18
    -0
      BPASmartClient.CustomResource/Pages/ViewModel/LoginViewModel.cs
  4. +124
    -175
      BPASmartClient.Helper/SystemUtils.cs
  5. +1
    -2
      DosingSystem/App.xaml
  6. +12
    -0
      DosingSystem/App.xaml.cs
  7. +1
    -0
      DosingSystem/BPASmartClient.DosingSystem.csproj
  8. +2
    -0
      DosingSystem/View/AdminstratorsView.xaml
  9. +4
    -0
      DosingSystem/View/MainWindow.xaml.cs
  10. +1
    -1
      DosingSystem/ViewModel/MainViewModel.cs

+ 35
- 0
BPASmartClient.CustomResource/Pages/View/LoginView.xaml Ver arquivo

@@ -0,0 +1,35 @@
<Window
x:Class="BPASmartClient.CustomResource.Pages.View.LoginView"
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:BPASmartClient.CustomResource.Pages.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel"
Title="LoginView"
Width="800"
Height="450"
AllowsTransparency="True"
Background="{x:Null}"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">

<Window.DataContext>
<vm:LoginViewModel />
</Window.DataContext>

<Window.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>
</Window.Resources>

<Grid />



</Window>

+ 27
- 0
BPASmartClient.CustomResource/Pages/View/LoginView.xaml.cs Ver arquivo

@@ -0,0 +1,27 @@
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 BPASmartClient.CustomResource.Pages.View
{
/// <summary>
/// LoginView.xaml 的交互逻辑
/// </summary>
public partial class LoginView : Window
{
public LoginView()
{
InitializeComponent();
}
}
}

+ 18
- 0
BPASmartClient.CustomResource/Pages/ViewModel/LoginViewModel.cs Ver arquivo

@@ -0,0 +1,18 @@
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 BPASmartClient.CustomResource.Pages.ViewModel
{
public class LoginViewModel : ObservableObject
{
public LoginViewModel()
{

}
}
}

+ 124
- 175
BPASmartClient.Helper/SystemUtils.cs Ver arquivo

@@ -9,25 +9,11 @@ using System.Threading.Tasks;
using System.ComponentModel;
using System.IO;


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 bool isShowNumBoard = false;
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
@@ -35,100 +21,65 @@ namespace BPASmartClient.Helper
public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);


public static void StartKeyBoardFun()
{
try
{

}
catch (Exception)
{

throw;
}


}


public static void ShowScreenKeyboard()
{
try
{

//string file = @"C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe";
////if (!System.IO.File.Exists(file))
//// return;
//Process.Start(file);

string path = "C:/Program Files/Common Files/microsoft shared/ink/TabTip.exe";
if (File.Exists(path))
{
Process p = Process.Start(path);
}
else
//获得当前登录的Windows用户标示
System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity);
//判断当前登录用户是否为管理员
if (principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))
{
try
{
//判断软键盘是否进程是否已经存在,如果不存在进行调用
Process[] pro = Process.GetProcessesByName("osk");
//说明已经存在,不再进行调用
if (pro != null && pro.Length > 0)
return;
IntPtr ptr = new IntPtr();
bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr);
if (isWow64FsRedirectionDisabled)
Process[] pros = Process.GetProcessesByName("TabTip");
string path = "C:/Program Files/Common Files/microsoft shared/ink/TabTip.exe";
if (File.Exists(path)) Process.Start(path);
else
{
Process.Start(@"C:\WINDOWS\system32\osk.exe");
bool isWow64FsRedirectionReverted = Wow64RevertWow64FsRedirection(ptr);
Process[] pro = Process.GetProcessesByName("osk");//判断软键盘是否进程是否已经存在,如果不存在进行调用
if (pro != null && pro.Length > 0) return;//说明已经存在,不再进行调用
IntPtr ptr = new IntPtr();
bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr);
if (isWow64FsRedirectionDisabled)
{
Process.Start(@"C:\WINDOWS\system32\osk.exe");
bool isWow64FsRedirectionReverted = Wow64RevertWow64FsRedirection(ptr);
}
}
}
catch (Exception)
{

throw;
}


//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)
else
{
//logger.Error(ex.Message);
}
}
//创建启动对象
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();

startInfo.FileName = "";//Application.ExecutablePath;//设置运行文件

startInfo.Arguments = "";// String.Join(" ", args); //设置启动参数

startInfo.Verb = "runas"; //设置启动动作,确保以管理员身份运行

System.Diagnostics.Process.Start(startInfo); //如果不是管理员,则启动UAC
//退出应用程序

}
}






}
}



@@ -136,113 +87,111 @@ namespace BPASmartClient.Helper



//[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();
//[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";

// // 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);
// }
///// <summary>
///// 启用系统软键盘
///// </summary>
//public static void OpenKeyBoardFun()
//{
// try
// {
// //判断软键盘是否进程是否已经存在,如果不存在进行调用
// Process[] pro = Process.GetProcessesByName("osk");
// //如果键盘已打开,则进行关闭操作
// if (pro != null && pro.Length > 0)
// {
// CloseKeyBoardFun();
// return;
// }

// // 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);
// }
// // Get the name of the On screen keyboard
// string processName = System.IO.Path.GetFileNameWithoutExtension(OnScreenKeyboadApplication);

// // 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));
// }
// // Check whether the application is not running
// var query = from process in Process.GetProcesses()
// where process.ProcessName == processName
// select process;

// }
// catch (Exception ex)
// {
// //LogUtil.WriteLog(MethodBase.GetCurrentMethod().Name, LogUtil.ERROE, ex.Message);
// //LogUtil.WriteLog(MethodBase.GetCurrentMethod().Name, LogUtil.ERROE, ex.StackTrace);
// }
// 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);
// }

///// <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);
// }

//}
// // 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);
// }

//}



}

+ 1
- 2
DosingSystem/App.xaml Ver arquivo

@@ -3,8 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource"
xmlns:local="clr-namespace:BPASmartClient.DosingSystem"
StartupUri="View/MainWindow.xaml">
xmlns:local="clr-namespace:BPASmartClient.DosingSystem">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>


+ 12
- 0
DosingSystem/App.xaml.cs Ver arquivo

@@ -5,6 +5,8 @@ using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using BPASmartClient.CustomResource.Pages.View;
using BPASmartClient.DosingSystem.View;

namespace BPASmartClient.DosingSystem
{
@@ -13,5 +15,15 @@ namespace BPASmartClient.DosingSystem
/// </summary>
public partial class App : Application
{
MainWindow mw = new MainWindow();

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
mw.Show();
//LoginView lv = new LoginView();
//var res = lv.ShowDialog();
//if (res != null && res == true) mw.Show();
}
}
}

+ 1
- 0
DosingSystem/BPASmartClient.DosingSystem.csproj Ver arquivo

@@ -7,6 +7,7 @@
<UseWPF>true</UseWPF>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>hbl.ico</ApplicationIcon>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<ItemGroup>


+ 2
- 0
DosingSystem/View/AdminstratorsView.xaml Ver arquivo

@@ -12,9 +12,11 @@
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" />


+ 4
- 0
DosingSystem/View/MainWindow.xaml.cs Ver arquivo

@@ -40,5 +40,9 @@ namespace BPASmartClient.DosingSystem.View
if (e.LeftButton == MouseButtonState.Pressed) this.DragMove();
};
}




}
}

+ 1
- 1
DosingSystem/ViewModel/MainViewModel.cs Ver arquivo

@@ -49,7 +49,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
});
ExitLogin = new RelayCommand(() =>
{
SystemUtils.ShowScreenKeyboard();
//SystemUtils.ShowScreenKeyboard();
//DoNavChanged("LoginView.退出登录");
UserManagement = false;
});


Carregando…
Cancelar
Salvar