using Muchinfo.MTPClient.Bank.ViewModels; using Muchinfo.MTPClient.Data.Enums; using System; using System.Windows; using System.Windows.Controls; namespace Muchinfo.MTPClient.Bank.Views { /// /// AmountManagerView.xaml 的交互逻辑 /// public partial class AmountManagerView : Window { public AmountManagerView(FundsApplyType applyType) { InitializeComponent(); this.DataContext = new AmountManagerViewModel(applyType); this.Closed += AmountManagerView_Closed; } void AmountManagerView_Closed(object sender, EventArgs e) { var viewmodel = this.DataContext as AmountManagerViewModel; if (viewmodel != null) { viewmodel.Cleanup(); } } private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { try { //屏蔽中文输入和非法字符粘贴输入 TextBox textBox = sender as TextBox; TextChange[] change = new TextChange[e.Changes.Count]; e.Changes.CopyTo(change, 0); int offset = change[0].Offset; decimal numb = 0; if (change[0].AddedLength > 0) { if (!decimal.TryParse(textBox.Text, out numb)) { textBox.Text = textBox.Text.Remove(offset, change[0].AddedLength); textBox.Select(offset, 0); } string[] strArray = textBox.Text.Split('.'); if (strArray != null && strArray.Length == 2) { if (strArray[1].Length > 2) { textBox.Text = textBox.Text.Remove(offset, change[0].AddedLength); textBox.Select(offset, 0); } } } } catch (System.Exception ex) { } } private void TextBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { TextBox textBox = sender as TextBox; if (string.IsNullOrEmpty(textBox.Text)) { textBox.Text = "0"; textBox.SelectAll(); } } private void GetFocus(object sender, System.Windows.RoutedEventArgs e) { TextBox textB = sender as TextBox; if (textB.Text == "0") { textB.SelectAll(); } } private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var window = new InMoneyGuide() { Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; window.Show(); } } }