|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace formula_manage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Login.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class Login : Window
|
|
|
|
|
{
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
|
|
|
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
|
|
|
|
|
public static void PressKey(Keys key, bool up)
|
|
|
|
|
{
|
|
|
|
|
const int KEYEVENTF_EXTENDEDKEY = 0x1;
|
|
|
|
|
const int KEYEVENTF_KEYUP = 0x2;
|
|
|
|
|
if (up)
|
|
|
|
|
{
|
|
|
|
|
keybd_event((byte)key, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
keybd_event((byte)key, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Login()
|
|
|
|
|
{
|
|
|
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Regex re = new Regex("^[1-9]+[0-9]*$");
|
|
|
|
|
|
|
|
|
|
e.Handled = !re.IsMatch(e.Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e) //退出按钮事件
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Button_Click_1(object sender, RoutedEventArgs e) //登录按钮事件
|
|
|
|
|
{
|
|
|
|
|
// if ((User.Text == "engineer" || User.Text == "ENGINEER") && (Pasword.Password == "engineer" || Pasword.Password == "ENGINEER"))
|
|
|
|
|
{
|
|
|
|
|
Window window = Window.GetWindow(this);
|
|
|
|
|
MainWindow Main = new MainWindow();
|
|
|
|
|
window.Close();
|
|
|
|
|
Main.ShowDialog();//实例化并置顶打开信息窗口
|
|
|
|
|
}
|
|
|
|
|
/* else
|
|
|
|
|
{
|
|
|
|
|
System.Windows.MessageBox.Show("账号或密码错误");
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SearchBox_OnKeyDownd(object sender, System.Windows.Input.KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Key == Key.Enter)
|
|
|
|
|
{
|
|
|
|
|
//SendKeys.SendWait("{Tab}");
|
|
|
|
|
PressKey(Keys.Tab, false);
|
|
|
|
|
PressKey(Keys.Tab, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PressKey(Keys.Tab, false);
|
|
|
|
|
PressKey(Keys.Tab, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|