private void SecurityPopupButton_OnPopupOpening(object sender, CancelRoutedEventArgs e) { var btn = sender as RibbonPopupButton; if (btn == null) return; var menu = btn.PopupContent as RibbonMenu; if (menu == null) return; var items = new List<Security> { CreateStubSecurity() }; var securities = _getSecurities().ToArray(); if (securities.Length > 0) { items.Add(null); // separator items.AddRange(securities); } menu.ItemsSource = items; }
private void PreviousButtonPressed(CancelRoutedEventArgs e) { var wizard = e.Source as Xceed.Wpf.Toolkit.Wizard; if (wizard != null) { string page = wizard.CurrentPage.Name.ToLower(); } }
private void Wizard_Previous(object sender, CancelRoutedEventArgs e) { var viewModel = this.GetStateControlViewModel(recognizeWizard.CurrentPage); if (viewModel != null) { Console.WriteLine("Wizard_Previous:" + viewModel.Title); } }
private void EditableTextBoxValidating(object sender, CancelRoutedEventArgs e) { // This may happens somehow when the template is refreshed. if (!ReferenceEquals(sender, editableTextBox)) { return; } // If we require a selected item but there is none, cancel the validation BindingExpression expression; if (RequireSelectedItemToValidate && SelectedItem == null) { e.Cancel = true; expression = GetBindingExpression(TextProperty); expression?.UpdateTarget(); editableTextBox.Cancel(); return; } validating = true; // Update the validated properties ValidatedValue = SelectedValue; ValidatedItem = SelectedItem; // If the dropdown is still open and something is selected, use the string from the selected item if (SelectedItem != null && IsDropDownOpen) { var displayValue = ResolveDisplayMemberValue(SelectedItem); editableTextBox.Text = displayValue?.ToString(); if (editableTextBox.Text != null) { editableTextBox.CaretIndex = editableTextBox.Text.Length; } } // Update the source of the text property binding expression = GetBindingExpression(TextProperty); expression?.UpdateSource(); // Close the dropdown if (IsDropDownOpen) { IsDropDownOpen = false; } validating = false; var cancelRoutedEventArgs = new CancelRoutedEventArgs(ValidatingEvent); RaiseEvent(cancelRoutedEventArgs); if (cancelRoutedEventArgs.Cancel) { e.Cancel = true; } }
private void Wizard_OnNext(object sender, CancelRoutedEventArgs e) { var wizard = ((Wizard)sender); string stepName = wizard.CurrentPage.Name; var vm = (MainViewModel)Window.DataContext; var nextPage = (WizardPage)Window.FindName(vm.GetNextStepName(stepName)); e.Cancel = true; wizard.CurrentPage = nextPage; }
void SearchLookUpEditModule_Closing(object sender, CancelRoutedEventArgs e) { bool?result = ((FloatingContainer)sender).DialogResult; if (result == null || !(bool)result) { return; } e.Cancel = !GetRecordValid(); }
private void Wizard_Next(object sender, CancelRoutedEventArgs e) { var viewModel = this.GetStateControlViewModel(recognizeWizard.CurrentPage); if (viewModel != null) { Console.WriteLine("Wizard_Next From:" + viewModel.Title); this.ViewModel.SetBusy("Processing:" + viewModel.Title); viewModel.StateCompleted(); } }
private void OnValidating(object sender, CancelRoutedEventArgs e) { if (textBoxAndAdorners != null) { var adorner = textBoxAndAdorners.FirstOrDefault(x => x.TextBox == sender).Adorner; if (adorner != null) { adorner.State = HighlightAdornerState.Hidden; } } }
protected override void OnEditEnding(CancelRoutedEventArgs e) { var editingContent = this.EditingContent; var content = this.Content; base.OnEditEnding(e); if (editingContent != content) { this.RequestSetRow(editingContent); } }
/// <summary> /// /// </summary> private void Keyword_dialog_ApplyingChanges(object sender, CancelRoutedEventArgs e) { Keyword_dialog.EndApplyChanges(e); return; #region Disabled, hopefully for good /* * // Validate keyword field * if (_keywordValueField.Text.Trim().Length < 1) * { * VisualTree.GetChild<TabControl>(Keyword_dialog).SelectedIndex = 0; * _keywordValueField.Focus(); * * MainWindow.MessageBoxError("Please enter a valid keyword", null); * e.Cancel = true; // No significance since we are not calling dialog.EndApplyChanges() * return; * } * * int currentAccountID = this.Window.CurrentAccount.ID; * string keywordValueFieldText = _keywordValueField.Text; * Oltp.KeywordDataTable tbl = null; * bool added = (Keyword_dialog.Content as Oltp.KeywordRow).RowState == DataRowState.Added; * * Window.AsyncOperation(delegate() * { * // When adding a new keyword, make sure it is unique * if (added) * { * using (OltpProxy proxy = new OltpProxy()) * { * tbl = proxy.Service.Keyword_Get(currentAccountID, false, keywordValueFieldText, true); * } * } * }, * delegate() * { * if (tbl != null && tbl.Rows.Count > 0) * { * MainWindow.MessageBoxError("Keyword already exists.", null); * e.Cancel = true; * return; * } * * Dialog_ApplyingChanges<Oltp.KeywordDataTable, Oltp.KeywordRow>( * _keywords, * Keyword_dialog, * typeof(IOltpLogic).GetMethod("Keyword_Save"), * e, null, true, null); * }); */ #endregion }
/// <summary> /// Processes the <see cref="PopupOpeningEvent"/> event. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">A <c>CancelRoutedEventArgs</c> that contains the event data.</param> private static void OnPopupOpeningEvent(object sender, CancelRoutedEventArgs e) { RibbonControls.PopupButton popupButton = e.OriginalSource as RibbonControls.PopupButton; if (popupButton is RibbonControls.Primitives.QuickAccessToolBarCustomizeButton) { RibbonControls.Menu menu = popupButton.PopupContent as RibbonControls.Menu; if (menu != null) { MainControl.AddCustomMenuItem(popupButton, menu); } } }
/// <summary> /// /// </summary> private void Keyword_dialog_ApplyingChanges(object sender, CancelRoutedEventArgs e) { // Validate keyword field if (_keywordValueField.Text.Trim().Length < 1) { Visual.GetDescendant <TabControl>(Keyword_dialog).SelectedIndex = 0; _keywordValueField.Focus(); MessageBoxError("Please enter a valid keyword", null); e.Cancel = true; // No significance since we are not calling dialog.EndApplyChanges() return; } int currentAccountID = this.Window.CurrentAccount.ID; string keywordValueFieldText = _keywordValueField.Text; Oltp.KeywordDataTable tbl = null; Window.AsyncOperation(delegate() { // When adding a new keyword, make sure it is unique if ((Keyword_dialog.Content as Oltp.KeywordRow).RowState == DataRowState.Added) { using (OltpProxy proxy = new OltpProxy()) { tbl = proxy.Service.Keyword_Get(currentAccountID, false, keywordValueFieldText, true); } if (tbl.Rows.Count > 0) { MessageBoxError("Keyword already exists.", null); e.Cancel = true; return; } } }, delegate() { if (tbl.Rows.Count > 0) { MessageBoxError("Keyword already exists.", null); e.Cancel = true; return; } Dialog_ApplyingChanges <Oltp.KeywordDataTable, Oltp.KeywordRow>( _keywords, Keyword_dialog, typeof(IOltpLogic).GetMethod("Keyword_Save"), e, null, true, null); }); }
public Tag() { CommandBindings.Add(new CommandBinding(ControlCommands.Close, (s, e) => { var argsClosing = new CancelRoutedEventArgs(ClosingEvent, this); RaiseEvent(argsClosing); if (argsClosing.Cancel) { return; } RaiseEvent(new RoutedEventArgs(ClosedEvent, this)); })); }
/// <summary> /// Occurs when the popup is opening. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void OnPopupButtonPopupOpening(object sender, CancelRoutedEventArgs e) { if (this.PreventPopups) { MessageBox.Show("The popup is temporarily blocked, please uncheck the prevent popups checkbox to enable it again.", "PopupButton", MessageBoxButton.OK, MessageBoxImage.Error); e.Cancel = true; return; } // NOTE: The PopupMenu or PopupContent can be fully initialized customized in this event before the popup/menu is opened // For this sample, we'll update the header of a menu item to show the current time customMenuItem.Header = "Opened at: " + DateTime.Now.ToLongTimeString(); }
/// <summary> /// /// </summary> private void Page_dialog_AppliedChanges(object sender, CancelRoutedEventArgs e) { // Call the univeral applied change handler Dialog_AppliedChanges <Oltp.PageRow>(Page_dialog, "Editing Page", _listTable._listView, e); // Disable editing page value //_urlField.IsReadOnly = true; // Set correct data template Oltp.PageRow dataItem = Page_dialog.TargetContent as Oltp.PageRow; ListViewItem item = _listTable._listView.ItemContainerGenerator.ContainerFromItem(dataItem) as ListViewItem; (this.Resources["NameTemplateSelector"] as MasterPagesLocal.NameTemplateSelector) .ApplyTemplate(dataItem, item); }
protected override void OnEditEnding(CancelRoutedEventArgs e) { var gridContext = DataGridControl.GetDataGridContext(this); var gridControl = gridContext.DataGridControl as ModernDataGridControl; if (gridControl.InvokeValueChangingEvent(this, this.EditingContent) == true) { this.Content = this.EditingContent; } else { this.EditingContent = this.Content; } base.OnEditEnding(e); }
/// <summary> /// /// </summary> private void Creative_dialog_Closing(object sender, CancelRoutedEventArgs e) { // Cancel if user regrets e.Cancel = MainWindow.MessageBoxPromptForCancel(Creative_dialog); if (!e.Cancel) { _creatives.RejectChanges(); } if (_assoc_Campaigns != null) { _assoc_Campaigns.ItemsSource = null; } }
private void ExecuteFinishWizard(object sender, ExecutedRoutedEventArgs e) { var eventArgs = new CancelRoutedEventArgs(Wizard.FinishEvent); this.RaiseEvent(eventArgs); if (eventArgs.Cancel) { return; } if (FinishButtonClosesWindow) { CloseParentWindow(true); } }
/// <summary> /// /// </summary> private void Keyword_dialog_AppliedChanges(object sender, CancelRoutedEventArgs e) { Oltp.KeywordRow dataItem = Keyword_dialog.TargetContent as Oltp.KeywordRow; // Call the univeral applied change handler Dialog_AppliedChanges <Oltp.KeywordRow>(Keyword_dialog, dataItem.Keyword, _listTable._listView, e); // Disable editing keyword value _keywordValueField.IsEnabled = false; // Set correct data template ListViewItem item = _listTable._listView.ItemContainerGenerator.ContainerFromItem(dataItem) as ListViewItem; (this.Resources["NameTemplateSelector"] as MasterKeywordsLocal.NameTemplateSelector) .ApplyTemplate(dataItem, item); }
///////////////////////////////////////////////////////////////////////////////////////////////////// // NON-PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Occurs when the popup is opening. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void OnDynamicPopupButtonPopupOpening(object sender, CancelRoutedEventArgs e) { var popupButton = (PopupButton)sender; // Create a new PopupMenu each time the button is clicked popupButton.PopupMenu = new ContextMenu() { Items = { new MenuItem() { Header = "Created at: " + DateTime.Now.ToLongTimeString() } } }; }
/// <summary> /// /// </summary> private void Keyword_dialog_Closing(object sender, CancelRoutedEventArgs e) { // Cancel if user regrets e.Cancel = MessageBoxPromptForCancel(Keyword_dialog); if (e.Cancel) { return; } _keywords.RejectChanges(); if (_assoc_Campaigns != null) { _assoc_Campaigns.ItemsSource = null; } }
private void PermissionCopy_dialog_ApplyingChanges(object sender, CancelRoutedEventArgs e) { if (MessageBox.Show("This will replace all permissions on selected accounts. Continue?", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning) != MessageBoxResult.OK) { e.Cancel = true; return; } List <int> accounts = new List <int>(); foreach (Oltp.AccountRow targetAccount in _copyToAccounts.Rows) { ListBoxItem listBoxItem = (ListBoxItem)_copyToAccountsListBox.ItemContainerGenerator.ContainerFromItem(targetAccount); if (listBoxItem == null) { continue; } CheckBox cb = VisualTree.GetChild <CheckBox>(listBoxItem); if (cb.IsChecked != null && cb.IsChecked.Value) { accounts.Add(targetAccount.ID); } } int accountID = Window.CurrentAccount.ID; Window.AsyncOperation(delegate() { using (OltpProxy proxy = new OltpProxy()) { proxy.Service.AccountPermission_Copy(accountID, accounts.ToArray()); } }, delegate(Exception ex) { MainWindow.MessageBoxError("Failed to copy permissions.", ex); return(false); }, delegate() { //MessageBox.Show("Done!", "Information", MessageBoxButton.OK, MessageBoxImage.Information); PermissionCopy_dialog.EndApplyChanges(e); }); }
/// <summary> /// /// </summary> private void Creative_dialog_ApplyingChanges(object sender, CancelRoutedEventArgs e) { if (_titleField.Text.Trim().Length < 1) { Visual.GetDescendant <TabControl>(Creative_dialog).SelectedIndex = 0; _titleField.Focus(); MessageBoxError("Please enter a valid title", null); e.Cancel = true; return; } Dialog_ApplyingChanges <Oltp.CreativeDataTable, Oltp.CreativeRow>( _creatives, Creative_dialog, typeof(IOltpLogic).GetMethod("Creative_Save"), e, null, true, null); }
/// <summary> /// Validates the current changes in the TextBox. Does nothing is there are no changes. /// </summary> public void Validate() { if (IsReadOnly || !HasChangesToValidate) { return; } var cancelRoutedEventArgs = new CancelRoutedEventArgs(ValidatingEvent); OnValidating(cancelRoutedEventArgs); if (cancelRoutedEventArgs.Cancel) { return; } RaiseEvent(cancelRoutedEventArgs); if (cancelRoutedEventArgs.Cancel) { return; } validating = true; var coercedText = CoerceTextForValidation(Text); SetCurrentValue(TextProperty, coercedText); BindingExpression expression = GetBindingExpression(TextProperty); expression?.UpdateSource(); ClearUndoStack(); var validatedArgs = new ValidationRoutedEventArgs <string>(ValidatedEvent, coercedText); OnValidated(); RaiseEvent(validatedArgs); if (ValidateCommand != null && ValidateCommand.CanExecute(ValidateCommandParameter)) { ValidateCommand.Execute(ValidateCommandParameter); } validating = false; HasChangesToValidate = false; }
private void Strategy_OnPopupOpening(object sender, CancelRoutedEventArgs e) { var btn = sender as RibbonPopupButton; if (btn == null) { return; } var menu = btn.PopupContent as RibbonMenu; if (menu == null) { return; } menu.ItemsSource = SelectedStrategyInfo .Strategies .ToArray(); }
/// <summary> /// /// </summary> private void PermissionTarget_dialog_Closing(object sender, CancelRoutedEventArgs e) { // Retrieve relevant parameters object[] parameters = PermissionTarget_dialog.Content as object[]; Oltp.AccountPermissionDataTable permissionsTable = parameters[1] as Oltp.AccountPermissionDataTable; if (permissionsTable.GetChanges() == null) { return; } MessageBoxResult result = MessageBox.Show( "Discard changes?", "Confirm", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel); e.Cancel = result == MessageBoxResult.Cancel; }
private void EditableTextBoxValidating(object sender, CancelRoutedEventArgs e) { // This may happens somehow when the template is refreshed. if (!ReferenceEquals(sender, editableTextBox)) { return; } validating = true; UpdateText(); validating = false; var cancelRoutedEventArgs = new CancelRoutedEventArgs(ValidatingEvent); RaiseEvent(cancelRoutedEventArgs); if (cancelRoutedEventArgs.Cancel) { e.Cancel = true; } }
private void FinishButtonPressed(CancelRoutedEventArgs e) { var settings = Settings.Default; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] buffer = new byte[1024]; rng.GetBytes(buffer); string salt = BitConverter.ToString(buffer); rng.Dispose(); settings.Entropy = salt; settings.DBHost = MySQLHost; settings.DBPort = MySQLPort; settings.DBUsername = MySQLUsername; settings.DBPassword = MySQLPassword.ToSecureString().EncryptString(Encoding.Unicode.GetBytes(salt)); settings.DBAuthName = SelectedAuthDB; settings.DBCharName = SelectedCharDB; settings.DBWorldName = SelectedWorldDB; if (ConnectLocally) { settings.ServerType = (int)ServerType.Local; settings.ServerFolder = ServerFolderLocation; } else { settings.ServerType = (int)ServerType.RemoteAccess; settings.RAUsername = Username; settings.RAPassword = Password.ToSecureString().EncryptString(Encoding.Unicode.GetBytes(salt)); settings.RAHost = Host; settings.RAPort = Port; } settings.Save(); SaveAndCloseViewModel(); }
private static void OnDialogClosing(object sender, CancelRoutedEventArgs e) { var closeDialogArgs = e as CloseDialogEventArgs; if (closeDialogArgs != null) { if (closeDialogArgs.DialogViewModel is AppointmentDialogViewModel) { if (closeDialogArgs.DialogResult.HasValue && closeDialogArgs.DialogResult == true) { IsAppointmentChangedThroughDialog = true; } else { if (closeDialogArgs.DialogResult == false) { IsAppointmentChangedThroughDialog = false; } } } } }
/// <summary> /// /// </summary> private void Keyword_dialog_AppliedChanges(object sender, CancelRoutedEventArgs e) { return; #region Disabled, hopefully for good /* * Oltp.KeywordRow dataItem = Keyword_dialog.TargetContent as Oltp.KeywordRow; * * // Call the univeral applied change handler * Dialog_AppliedChanges<Oltp.KeywordRow>(Keyword_dialog, dataItem.Keyword, _listTable.ListView, e); * * // Disable editing keyword value * _keywordValueField.IsEnabled = false; * * // Set correct data template * ListViewItem item = _listTable.ListView.ItemContainerGenerator.ContainerFromItem(dataItem) as ListViewItem; * (this.Resources["NameTemplateSelector"] as MasterKeywordsLocal.NameTemplateSelector) * .ApplyTemplate(dataItem, item); */ #endregion }
private void StrategyInfo_OnPopupOpening(object sender, CancelRoutedEventArgs e) { var btn = sender as RibbonPopupButton; if (btn == null) { return; } var menu = btn.PopupContent as RibbonMenu; if (menu == null) { return; } menu.ItemsSource = ConfigManager .GetService <IStudioEntityRegistry>() .Strategies .Where(s => s.IsStrategy()) .ToArray(); }
private void Strategy_OnPopupOpening(object sender, CancelRoutedEventArgs e) { var btn = sender as RibbonPopupButton; if (btn == null) return; var menu = btn.PopupContent as RibbonMenu; if (menu == null) return; menu.ItemsSource = SelectedStrategyInfo .Strategies .ToArray(); }
private void StrategyInfo_OnPopupOpening(object sender, CancelRoutedEventArgs e) { var btn = sender as RibbonPopupButton; if (btn == null) return; var menu = btn.PopupContent as RibbonMenu; if (menu == null) return; menu.ItemsSource = ConfigManager .GetService<IStudioEntityRegistry>() .Strategies .Where(s => s.IsStrategy()) .ToArray(); }
private void OnAutoCompleteBoxPopulating(object sender, CancelRoutedEventArgs e) { e.Cancel = this.isHandled; }
private void OnBeforeLayoutRefresh(object sender, CancelRoutedEventArgs e) { e.Cancel = grid.ShowLoadingPanel; }
private void OpenAnalyticsInfo_OnPopupOpening(object sender, CancelRoutedEventArgs e) { var btn = sender as RibbonPopupButton; if (btn == null) return; var menu = btn.PopupContent as RibbonMenu; if (menu == null) return; menu.ItemsSource = ConfigManager .GetService<IStudioEntityRegistry>() .Strategies .ReadByType(StrategyInfoTypes.Analytics) .ToList(); }