public UIValidtion Len(int?minLength, int?maxLength) { if (!_result) { return(this); } if (string.IsNullOrEmpty(_lastValue) && !_lastRequired) { return(this); } if (minLength != null && minLength > 0 && _lastValue.Length < minLength) { Symbol.Forms.ProgramHelper.ShowInformation("{0}不能少于{1}个字符!", _lastName, minLength); _result = false; _lastControl.Focus(); } if (_result && maxLength != null && maxLength > 0 && _lastValue.Length > maxLength) { Symbol.Forms.ProgramHelper.ShowInformation("{0}不能超过{1}个字符!", _lastName, maxLength); _result = false; _lastControl.Focus(); } return(this); }
public static void ShowControlss(System.Windows.Forms.Control control, System.Windows.Forms.Control cont) { cont.Controls.Clear(); control.Dock = System.Windows.Forms.DockStyle.Fill; control.Focus(); cont.Controls.Add(control); }
public static void showControl(System.Windows.Forms.Control control, System.Windows.Forms.Control Content) { Content.Controls.Clear(); control.Dock = System.Windows.Forms.DockStyle.Fill; control.BringToFront(); control.Focus(); Content.Controls.Add(control); }
public static void SiguienteControl(System.Windows.Forms.Control control, ref System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == System.Windows.Forms.Keys.Enter) { e.Handled = true; e.SuppressKeyPress = true; control.Focus(); } }
/// <summary> /// Presses the enter. /// </summary> /// <param name="xControl">The x control.</param> public static void PressEnter(System.Windows.Forms.Control xControl) { if (xControl.InvokeRequired) { PressEnter_Delegate xFun = new PressEnter_Delegate(PressEnter); xControl.Invoke(xFun, new object[] { xControl }); return; } xControl.Focus(); System.Windows.Forms.SendKeys.SendWait("{ENTER}"); }
/// <summary> /// Steals the window from the desktop and embeds it. /// </summary> private void StealWindow() { // Create host surface _host = new System.Windows.Forms.Control(); wfh.Child = _host; _host.Focus(); Methods.SetParent(_process.MainWindowHandle, _host.Handle); Methods.SetWindowLongPtr(new HandleRef(null, _process.MainWindowHandle), Constants.GWL_STYLE, new IntPtr(Constants.WS_VISIBLE)); PositionWindow(); }
protected Boolean ValidateForm(System.Windows.Forms.Control control, Boolean condition, String errorMessage, Boolean canIgnore) { Boolean result = true; if (!condition) { if (!(result = System.Windows.Forms.MessageBox.Show(errorMessage, "Warning", canIgnore ? System.Windows.Forms.MessageBoxButtons.YesNo : System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)) { control.Focus(); } } return(result); }
public static void DisplayError(System.Windows.Forms.IWin32Window owner , string message , System.Windows.Forms.Control source) { System.Windows.Forms.MessageBox.Show(owner, message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); if (source != null) { if (source is System.Windows.Forms.TextBox) { ((System.Windows.Forms.TextBox)source).SelectAll(); } source.Focus(); } }
public GameControlHandler() { var control = new System.Windows.Forms.Control { Width = 100, Height = 100 }; control.HandleCreated += (sender, e) => { _game = CreateGame(control.Handle); System.Windows.Media.CompositionTarget.Rendering += OnRendering; }; control.MouseDown += (sender, e) => { control.Focus(); }; Control = new WindowsFormsHost { Child = control }; }
public void ShowDialog(System.Windows.Forms.Control owner, string text, string caption, Utils.ProgressDialog.Animations animation = ProgressDialog.Animations.None) { Exception workerException = null; var workerThread = new System.Threading.Thread(() => { try { WorkerAction.Invoke(); } catch (Exception e) { workerException = e; } }); workerThread.Name = "ProgressCounterDialog worker"; var dialogUpdateEvent = new AutoResetEvent(false); var dialogCloseEvent = new ManualResetEvent(false); using (var workerProgress = new ProgressCounter(workerThread, 1)) { workerProgress.StatusChanged += (List <string> status) => { dialogUpdateEvent.Set(); }; workerProgress.ProgressChanged += (double percent) => { dialogUpdateEvent.Set(); }; workerThread.Start(); var dialog = new Utils.ProgressDialog(); dialog.Title = caption; dialog.Line1 = text; dialog.Line2 = workerProgress.Status; dialog.Animation = animation; dialog.CancelMessage = "Please wait while the operation is cancelled"; dialog.Maximum = 100; dialog.Value = (uint)(workerProgress.GetProgress() * dialog.Maximum); dialog.Modal = true; dialog.NoTime = true; IntPtr handle = IntPtr.Zero; if (owner != null) { if (owner.InvokeRequired) { owner.Invoke(new Action(delegate { handle = owner.Handle; })); } else { handle = owner.Handle; } } dialog.ShowDialog(handle); while (workerThread.IsAlive) { if (dialog.HasUserCancelled) { workerProgress.Abort(); Cancelled = true; break; } int waitResult = WaitHandle.WaitAny(new WaitHandle[] { dialogUpdateEvent, dialogCloseEvent }, 50); if (waitResult == WaitHandle.WaitTimeout) { continue; } if (waitResult == 1) // dialogCloseEvent { break; } var statusList = workerProgress.GetStatusList(); if (statusList.Count >= 1) { dialog.Line2 = statusList[0]; if (statusList.Count >= 2) { dialog.Line3 = statusList[1]; } else { dialog.Line3 = ""; } } else { dialog.Line2 = ""; } dialog.Value = (uint)(workerProgress.GetProgress() * dialog.Maximum); } dialog.CloseDialog(); dialog = null; if (workerException != null) { throw new Exception(workerException.Message, workerException); } if (owner != null) { owner.Invoke(new Action(delegate { var form = owner as System.Windows.Forms.Form; if (form != null) { form.Activate(); } else { owner.Focus(); } })); } } }