using HxModel; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; 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.Navigation; using System.Windows.Shapes; using XHandler.Class; using HxUserManagement.Classes; using HxUserManagement.HxBLL; namespace HxUserManagement.Views { /// /// ResetPassword.xaml 的交互逻辑 /// public partial class ResetPassword : UserControl { public event EventHandler closeEvent; public event EventHandler okEvent; private UserInfoModel userInfoModel = null; private UserInfoBLL userInfoBLL = new UserInfoBLL(); private string Id; public ResetPassword() { InitializeComponent(); } public ResetPassword(string id) { InitializeComponent(); Id = id; userInfoModel = userInfoBLL.GetInfodById(id); } private void UserControl_Loaded(object sender, RoutedEventArgs e) { Storyboard storyboard = new Storyboard(); DoubleAnimation doubleAnimation = new DoubleAnimation(0, 500, new Duration(TimeSpan.FromSeconds(0.25))); Storyboard.SetTarget(doubleAnimation, border);//Target对象 Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Width"));//Target属性 storyboard.Children.Add(doubleAnimation); ObjectAnimationUsingKeyFrames showAnimation = new ObjectAnimationUsingKeyFrames(); showAnimation.BeginTime = TimeSpan.FromSeconds(0); Storyboard.SetTarget(showAnimation, border); Storyboard.SetTargetProperty(showAnimation, new PropertyPath("(UIElement.Visibility)")); DiscreteObjectKeyFrame closeKeyFrame = new DiscreteObjectKeyFrame(Visibility.Visible, TimeSpan.FromSeconds(0.01)); showAnimation.KeyFrames.Add(closeKeyFrame); storyboard.Children.Add(showAnimation); storyboard.Begin(); } private void root_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (e.OriginalSource is Grid) { Grid grid = e.OriginalSource as Grid; if (grid.Name == "root") Button_Click(this, null); } } private void Button_Click(object sender, RoutedEventArgs e) { if (EventResponseController.Instance.CanExecute() == false) return; Storyboard storyboard = new Storyboard(); DoubleAnimation doubleAnimation = new DoubleAnimation(500, 0, new Duration(TimeSpan.FromSeconds(0.25))); Storyboard.SetTarget(doubleAnimation, border);//Target对象 Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Width"));//Target属性 storyboard.Children.Add(doubleAnimation); ObjectAnimationUsingKeyFrames showAnimation = new ObjectAnimationUsingKeyFrames(); showAnimation.BeginTime = TimeSpan.FromSeconds(0); Storyboard.SetTarget(showAnimation, border); Storyboard.SetTargetProperty(showAnimation, new PropertyPath("(UIElement.Visibility)")); DiscreteObjectKeyFrame closeKeyFrame = new DiscreteObjectKeyFrame(Visibility.Collapsed, TimeSpan.FromSeconds(0.26)); showAnimation.KeyFrames.Add(closeKeyFrame); storyboard.Children.Add(showAnimation); storyboard.Completed += delegate { closeEvent?.Invoke(this, EventArgs.Empty); }; storyboard.Begin(); } private void textboxNewPswd_TextChanged(object sender, TextChangedEventArgs e) { textboxNewPswd.BorderBrush = Brushes.DarkGray; pswdTips.Visibility = Visibility.Collapsed; } private void textboxConfirmPswd_TextChanged(object sender, TextChangedEventArgs e) { textboxConfirmPswd.BorderBrush = Brushes.DarkGray; pswdConfirmTips.Visibility = Visibility.Collapsed; } private void btnCancel_Click(object sender, RoutedEventArgs e) { Button_Click(this, null); } private void btnSave_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(textboxNewPswd.Password)) { textboxNewPswd.BorderBrush = Brushes.Red; pswdTips.Text = Properties.Resources.strPswdLenght; pswdTips.Visibility = Visibility.Visible; return; } if (textboxNewPswd.Password.Length < 6) { textboxNewPswd.BorderBrush = Brushes.Red; pswdTips.Text = Properties.Resources.strPswdLenght; pswdTips.Visibility = Visibility.Visible; return; } textboxNewPswd.BorderBrush = Brushes.DarkGray; pswdTips.Visibility = Visibility.Collapsed; if (string.Compare(textboxNewPswd.Password, textboxConfirmPswd.Password)!=0) { textboxConfirmPswd.BorderBrush = Brushes.Red; pswdConfirmTips.Text = Properties.Resources.strPswdNotSame; pswdConfirmTips.Visibility = Visibility.Visible; return; } userInfoModel.UserPwd = Utilities.GetMD5(textboxConfirmPswd.Password); userInfoModel.ModifyName = UserManagement.currentUser.UserName; userInfoModel.ModifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); UserInfoModel user= userInfoBLL.Update(userInfoModel); if(user!=null) MessageBox.Show(Properties.Resources.strResetPswdSuccess, "Tips"); else MessageBox.Show(Properties.Resources.strResetPswdFailed, "Tips"); } private void textboxNewPswd_LostFocus(object sender, RoutedEventArgs e) { //if (string.IsNullOrEmpty(textboxNewPswd.Password)) //{ // textboxNewPswd.BorderBrush = Brushes.Red; // pswdTips.Text = Properties.Resources.strPswdLenght; // pswdTips.Visibility = Visibility.Visible; // return; //} //if(textboxNewPswd.Password.Length<6) //{ // textboxNewPswd.BorderBrush = Brushes.Red; // pswdTips.Text = Properties.Resources.strPswdLenght; // pswdTips.Visibility = Visibility.Visible; // return; //} } private void textboxConfirmPswd_LostFocus(object sender, RoutedEventArgs e) { // if() } private void textboxNewPswd_PasswordChanged(object sender, EventArgs e) { textboxNewPswd.BorderBrush = Brushes.DarkGray; pswdTips.Visibility = Visibility.Collapsed; } private void textboxConfirmPswd_PasswordChanged(object sender, EventArgs e) { textboxConfirmPswd.BorderBrush = Brushes.DarkGray; pswdConfirmTips.Visibility = Visibility.Collapsed; } } }