| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- using ivf_tl_Operate.Converts;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Diagnostics;
- using System.Globalization;
- using System.Linq;
- using System.Reflection;
- using System.Speech.Synthesis;
- using System.Text;
- using System.Threading;
- 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 ivf_tl_Operate.Windows
- {
- /// <summary>
- /// LoginWindow.xaml 的交互逻辑
- /// </summary>
- public partial class LoginWindow : Window
- {
- // M4-04-3:原 KeyProcess 字段用于 Process.Start("osk.exe") 拉起系统软键盘,
- // 现已移除(需求 11:屏蔽系统软键盘)。账号/密码框改走内置 SoftKeyboard(见 LoginWindow.xaml 附加属性)。
- public LoginWindow(Window w)
- {
- InitializeComponent();
- this.Owner = w;
- this._userName.Text = ConfigurationManager.AppSettings["userName"].ToString();
- // M5-02-2:passWord 经解密回填(旧明文兼容:CryptoHelper.Decrypt 对明文原样返回,迁移已在 App_Startup 完成)。
- this.passwordClose.Password = ivf_tl_Operate.Helpers.CryptoHelper.Decrypt(ConfigurationManager.AppSettings["passWord"].ToString());
- this._tlNum.Text = ConfigurationManager.AppSettings["tlNum"].ToString();
- }
- private void StartDish_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- //TestSpeak();
- //return;
- string account = this._userName.Text.Trim();
- string passWord = null;
- if (this.eyeClose.Visibility == Visibility.Visible)
- {
- passWord = this.passwordClose.Password.Trim();
- }
- else
- {
- passWord = this.passwordOpen.Text.Trim();
- }
- if (string.IsNullOrEmpty(passWord) || string.IsNullOrEmpty(account))
- {
- //this._errorInfo.Text = "账号或密码不能为空";
- this._errorInfo.Text = KeyToStringConvert.GetLanguageStringByKey("C0228");
- return;
- }
- string tlNum = this._tlNum.Text.Trim();
- if (string.IsNullOrEmpty(tlNum))
- {
- this._errorInfo.Text = "设备编号不能为空";
- return;
- }
- if (AppData.Instance.CurrentUserInfo.account == account && AppData.Instance.CurrentUserInfo.password == passWord && AppData.Instance.TlNum == tlNum)
- {
- this.DialogResult = false;
- }
- else
- {
- if (AppData.Instance.AppDataInit(account, passWord, tlNum))
- {
- AppData.Instance.setAppConfig(account, passWord, tlNum);
- this.DialogResult = true;
- }
- else
- {
- //this._errorInfo.Text = "登录失败";
- this._errorInfo.Text = KeyToStringConvert.GetLanguageStringByKey("C0229");
- }
- }
- }
- catch (Exception ex)
- {
- //this._errorInfo.Text = $"登录异常:{ex.Message}";
- this._errorInfo.Text = $"{KeyToStringConvert.GetLanguageStringByKey("C0229")}:{ex.Message}";
- }
- }
- public void TestSpeak()
- {
- try
- {
- SpeechSynthesizer speech = new SpeechSynthesizer();
- speech.Volume = 100;
- var currentVoiceInfo = speech.GetInstalledVoices(CultureInfo.CurrentCulture).FirstOrDefault();
- if (currentVoiceInfo != null) speech.SelectVoice(currentVoiceInfo.VoiceInfo.Name);
- speech.Speak("sdfjksdlj四道口附近上空砥砺奋进圣诞快乐房价上课是独立访客帆帆帆帆帆帆帆帆帆帆帆帆帆帆顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶呱呱呱呱呱呱呱呱呱呱呱呱呱呱呱古古怪怪日日日日日日日日日日日日日日日日日日噢噢噢噢噢噢噢噢噢噢噢噢噢噢噢噢哦哦哦巅峰时刻记得付款冷热四点零分几位客人你说的,内分泌科看了看速度快角度上考虑附件为可容纳,魔法师。,的父母老师看对方反馈");
- }
- catch (Exception ex)
- {
- string ss = ex.Message;
- }
- }
- private void Cancel_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = false;
- }
- // M4-04-3:原此处 Process.Start("osk.exe") 拉起系统软键盘,现已停用(需求 11:屏蔽系统软键盘)。
- // 内置软键盘由 SoftKeyboardHost.Mode 附加属性在获焦/触控时自动弹出(见 LoginWindow.xaml),此处无需处理。
- private void TextBox_TouchUp(object sender, TouchEventArgs e)
- {
- }
- // M4-04-3:同上,原 osk.exe 启动逻辑已停用,改走内置软键盘。
- private void PasswordBox_TouchUp(object sender, TouchEventArgs e)
- {
- }
- private void Image_eyeClose(object sender, MouseButtonEventArgs e)
- {
- this.passwordOpen.Text = this.passwordClose.Password;
- eyeClose.Visibility = Visibility.Hidden;
- passwordClose.Visibility = Visibility.Hidden;
- eyeOpen.Visibility = Visibility.Visible;
- passwordOpen.Visibility = Visibility.Visible;
- passwordOpen.Focus();
- passwordOpen.SelectionStart = passwordOpen.Text.Length;
- }
- private void Image_eyeOpen(object sender, MouseButtonEventArgs e)
- {
- this.passwordClose.Password = this.passwordOpen.Text;
- eyeOpen.Visibility = Visibility.Hidden;
- passwordOpen.Visibility = Visibility.Hidden;
- eyeClose.Visibility = Visibility.Visible;
- passwordClose.Visibility = Visibility.Visible;
- passwordClose.Focus();
- SetSelection(passwordClose, passwordOpen.Text.Length, 0);
- }
- /// <summary>
- /// 设置光标位置
- /// </summary>
- /// <param name="passwordBox"></param>
- /// <param name="start">光标开始位置</param>
- /// <param name="length">选中长度</param>
- private void SetSelection(PasswordBox passwordBox, int start, int length)
- {
- passwordBox.GetType().GetMethod("Select", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(passwordBox, new object[] { start, length });
- }
- }
- }
|