private void _fileSelectorButton_Click(object sender, EventArgs e) { try { switch (Mode) { case PathSelectionMode.OpenFile: ShowOpenDialog(); break; case PathSelectionMode.SaveFile: ShowSaveDialog(); break; case PathSelectionMode.File: ShowOpenSaveDialog(); break; case PathSelectionMode.Folder: ShowSelectFolderDialog(); break; } } catch (Exception error) { SystemLog.Exception(error); ExceptionDialog.Show(error); } }
private void _grid_MouseClick(object sender, MouseEventArgs e) { try { switch (e.Button) { case MouseButtons.Left: if (LeftClickToDeselect) { if (_grid.Selection.IsSelectedRow(_grid.PositionAtPoint(e.Location).Row) && DateTime.Now.Subtract(_selectedOn) > TimeSpan.FromMilliseconds(50)) { _grid.Selection.ResetSelection(false); _grid.SelectionMode = SourceGrid.GridSelectionMode.None; this.BeginInvokeEx(InitializeGridSelectionMode); } } break; case MouseButtons.Right: if (RightClickForContextMenu) { if (_grid.Selection.IsSelectedRow(_grid.PositionAtPoint(e.Location).Row)) { _selectionContextMenuStrip.Show(_grid.PointToScreen(e.Location)); } } break; } } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _filenameTextBox_Validating(object sender, CancelEventArgs e) { try { var textOnLeave = _filenameTextBox.Text; if (!string.IsNullOrEmpty(textOnLeave) && _textOnEnter != textOnLeave && ForcePathExists) { if (Mode.IsIn(PathSelectionMode.Folder)) { e.Cancel = !Directory.Exists(textOnLeave); } else { e.Cancel = !File.Exists(textOnLeave); } } if (e.Cancel) { return; } if (!string.IsNullOrEmpty(textOnLeave) && _textOnEnter != textOnLeave) { NotifyPathChanged(); } _textOnEnter = null; } catch (Exception error) { SystemLog.Exception(error); ExceptionDialog.Show(error); } }
private void _grid_Selection_CellGotFocus(SourceGrid.Selection.SelectionBase sender, SourceGrid.ChangeActivePositionEventArgs e) { try { } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _grid_Selection_SelectionChanged(object sender, SourceGrid.RangeRegionChangedEventArgs e) { try { if (!_updating) { if (e.RemovedRange != null && _selectedEntity != null && _selectedOn.TimeElapsed().TotalMilliseconds > 50) { RaiseEntityDeselectedEvent(_selectedEntity); _selectedEntity = null; } if (e.AddedRange != null) { var addedRows = e.AddedRange.GetRowsIndex(); if (addedRows.Length > 0 && _selectedOn.TimeElapsed().TotalMilliseconds > 50) { _selectedEntity = _rowToEntityMap[addedRows[0]]; _selectedOn = DateTime.Now; RaiseEntitySelectedEvent(_selectedEntity); } } } } catch (Exception error) { ExceptionDialog.Show(this, error); } }
public void SetCrudParameters <TEntity>(IEnumerable <ICrudGridColumn> gridBindings, Type entityEditorType, CrudCapabilities capabilities, ICrudDataSource <TEntity> dataSource) { var initializationAction = new Action(() => { try { if (entityEditorType != null) { _crudGrid.SetEntityEditor <TEntity>(entityEditorType); } _crudGrid.Capabilities = capabilities; _crudGrid.GridBindings = gridBindings; _crudGrid.SetDataSource(dataSource); } catch (Exception error) { ExceptionDialog.Show(this, error); } }); if (!IsHandleCreated) { _delayedInitializationAction = initializationAction; } else { initializationAction(); } }
private void _deleteToolStripMenuItem_Click(object sender, EventArgs e) { try { DeleteSelectedRecord(); } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _editToolStripMenuItem_Click(object sender, EventArgs e) { try { EditSelectedEntity(); } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _deselectToolStripMenuItem_Click(object sender, EventArgs e) { try { _grid.Selection.ResetSelection(false); } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _okButton_Click(object sender, EventArgs e) { try { LogonAsync(); } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void OptionsButton_Click(object sender, EventArgs e) { try { DatabaseOptionsContextMenu.Show(OptionsButton, new Point(0, OptionsButton.Height)); } catch (Exception error) { ExceptionDialog.Show(this, "Error", error); } }
private void _createButton_Click(object sender, EventArgs e) { try { CreateNewRecord(); } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _showPasswordCheckBox_CheckedChanged(object sender, EventArgs e) { try { _passwordTextBox.PasswordChar = _hidePasswordCheckBox.Checked ? '*' : (char)0; } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void PadLockButton_Click(object sender, EventArgs e) { try { ToggleLockState(); } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _filenameTextBox_Validated(object sender, EventArgs e) { try { } catch (Exception error) { SystemLog.Exception(error); ExceptionDialog.Show(error); } }
private void _cancelButton_Click(object sender, EventArgs e) { try { CancelChanges(); Close(); } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private async void _nextButton_Click(object sender, EventArgs e) { try { using (loadingCircle1.BeginAnimationScope(this)) { await WizardManager.Next(); } } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _cancelButton_Click(object sender, EventArgs e) { try { this.DialogResult = DialogResult.Cancel; Password = null; Close(); } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _deleteButton_Click(object sender, EventArgs e) { try { if (DeleteEntity()) { Close(); } } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _grid_MouseDoubleClick(object sender, MouseEventArgs e) { try { if (!LeftClickToDeselect) { EditSelectedEntity(); } } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _saveButton_Click(object sender, EventArgs e) { try { if (SaveChanges()) { Close(); } } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _cancelButton_Click(object sender, EventArgs e) { try { LogonResult = new AuthenticationResult { ResultCode = AuthenticationErrorCode.Aborted }; Close(); } catch (Exception error) { ExceptionDialog.Show(this, error); } }
protected override void OnEnabledChanged(EventArgs e) { try { base.OnEnabledChanged(e); _filenameTextBox.Enabled = _fileSelectorButton.Enabled = this.Enabled; } catch (Exception error) { SystemLog.Exception(error); ExceptionDialog.Show(error); } }
private void _filenameTextBox_Enter(object sender, EventArgs e) { try { if (_textOnEnter == null) { _textOnEnter = this._filenameTextBox.Text; } } catch (Exception error) { SystemLog.Exception(error); ExceptionDialog.Show(error); } }
private async void _pageNumberBox_ValueChanged(object sender, EventArgs e) { try { if (!_updating) { _pageNumber = GetVisiblePageNumberText(); await RefreshGrid(); } } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void _okButton_Click(object sender, EventArgs e) { try { if (ValidatePassword()) { this.DialogResult = DialogResult.OK; Password = _passwordTextBox.Text; Close(); } } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private async void _executeScriptButton_Click(object sender, EventArgs e) { try { using (LoadingCircle.EnterAnimationScope(this, disableControls: true)) { await Task.Run(() => DAC.ExecuteBatch(Script)); } this.DialogResult = DialogResult.OK; Close(); } catch (Exception error) { ExceptionDialog.Show("Error", error); } finally { } }
private void _artificialKeysMenuItem_Click(object sender, EventArgs e) { try { if (ArtificialKeysFile != null) { ArtificialKeysFile = null; _artificialKeysMenuItem.Text = "Artificial Keys"; } else { SelectArtificialKeysFile(); } } catch (Exception error) { ExceptionDialog.Show(this, "Error", error); } }
private Cell CreateDropDownListCell(ICrudGridColumn columnBinding, object entity, object cellValue) { var editor = new SourceGrid.Cells.Editors.DropDownList(columnBinding.DataType, columnBinding.DropDownItemDisplayMember); editor.Control.ValueMember = columnBinding.DropDownItemDisplayMember; editor.Control.DisplayMember = columnBinding.DropDownItemDisplayMember; editor.EditException += (o, e) => { ExceptionDialog.Show(this, e.Exception); e.Handled = true; editor.UndoEditValue(); }; var cell = new Cell(columnBinding.DataType, editor); editor.Control.DropDownStyle = ComboBoxStyle.DropDownList; cell.AddController(new AutoPopulateDropDownListOnEditStarting(editor, columnBinding, entity)); cell.Value = cellValue; return(cell); }
protected virtual async Task LogonAsync() { const int rtfHeightPerLine = 15; const int maxErrorsWithoutScrollbar = 10; var usernameText = _usernameTextBox.Text; var passwordText = _passwordTextBox.Text; using (_loadingCircle.BeginAnimationScope()) { try { LogonResult = await _authenticator(usernameText, passwordText); if (LogonResult == null) { throw new Exception("Authenticator returned null"); } if (LogonResult.ResultCode == AuthenticationErrorCode.Success) { Close(); } else { try { var errors = new List <string> { LogonResult.ResultCode.GetDescription() }; var extraHeight = rtfHeightPerLine * errors.Count().ClipTo(0, maxErrorsWithoutScrollbar) - _errorRichTextBox.Height; this.Size = new Size(this.Size.Width, (int)(this.Size.Height + extraHeight)); if (errors.Any()) { _errorRichTextBox.Lines = errors.ToArray(); } } catch (Exception error) { ExceptionDialog.Show(this, error); } } } catch (Exception error) { this.InvokeEx(() => ExceptionDialog.Show(this, error)); LogonResult = new AuthenticationResult { ResultCode = AuthenticationErrorCode.ServerUnavailable, UserObject = null }; } } }