public void showerror(Hashtable errors,UserControl a) { foreach (DictionaryEntry error in errors) { String check = error.Key.ToString(); if (error.Value.ToString() == "text") { if (check.Substring(check.Length - 1, 1) != "!" ) { TextBox e = (TextBox)a.FindName("txt" + check); e.BorderBrush = Brushes.Red; } else { TextBox e = (TextBox)a.FindName("txt"+check.Substring(0,check.Length-1)); e.BorderBrush = Brushes.SkyBlue; } } if (error.Value.ToString() == "password") { if (check.Substring(check.Length - 1, 1) != "!") { PasswordBox e = (PasswordBox)a.FindName("pb" + error.Key); e.BorderBrush = Brushes.Red; } else { PasswordBox e = (PasswordBox)a.FindName("pb" + check.Substring(0, check.Length - 1)); e.ClearValue(TextBox.BorderBrushProperty); e.Password = ""; } } if (error.Value.ToString() == "duplicate") { TextBox e = (TextBox)a.FindName("txt" + check.Substring(0, check.Length - 1)); e.BorderBrush = Brushes.Red; } } }
public void DragSourcePieMenuPreviewMouseLeftButtonDown(UserControl diagramUserControl, StylusEventArgs e) { try { _topUserControl = diagramUserControl; _initialMousePosition = e.GetPosition(_topUserControl); _adornerLayer = (Canvas)_topUserControl.FindName("adornerLayer"); _dropTarget = (UIElement)_topUserControl.FindName("inkCanvas"); } catch (Exception exc) { Console.WriteLine("Exception in DragDropHelper: " + exc.InnerException.ToString()); } }
public void DragSource_UserControl_PreviewMouseLeftButtonDown(UserControl diagramUserControl, object sender, MouseButtonEventArgs e) { try { _topUserControl = diagramUserControl; _initialMousePosition = e.GetPosition(_topUserControl); _adornerLayer = (Canvas)_topUserControl.FindName("adornerLayer"); _dropTarget = (UIElement)_topUserControl.FindName("inkCanvas"); _draggedData = (sender as FrameworkElement).DataContext; } catch (Exception exc) { Console.WriteLine("Exception in DragDropHelper: " + exc.InnerException.ToString()); } }
private int ReadSampleCount(UserControl ControlUI) { var container = ControlUI.FindName("txtSampleCnt"); TextBox txtSampleCnt = (TextBox)container; if (txtSampleCnt == null) throw new Exception("无法找到样本数textbox!"); if (txtSampleCnt.Text == "") { throw new Exception("请先设置样本数!"); } int val = int.Parse(txtSampleCnt.Text); if (val <= 0) { throw new Exception("样本数必须大于0!"); } return val; }