private void OK(IDialogWindow window) { string inputtedCode = NumberBox1 + NumberBox2 + NumberBox3 + NumberBox4 + NumberBox5 + NumberBox6; CloseDialogWithResult(window, inputtedCode); }
protected void ConfigureDialogWindowProperties(IDialogWindow window, FrameworkElement dialogContent, IDialogAware viewModel) { var windowStyle = Prism.Services.Dialogs.Dialog.GetWindowStyle(dialogContent); if (windowStyle != null) { window.Style = windowStyle; } //TODO: add to prism if (window.Content == null) { window.Content = dialogContent; } else { Window w = window as Window; ContentControl _content = w.FindName("DialogPane") as ContentControl; _content.Content = dialogContent; //_content.Focus(); } if (viewModel != null) { window.DataContext = viewModel; //we want the host window and the dialog to share the same data contex } if (window.Owner == null) { window.Owner = Application.Current.Windows.OfType <Window>().FirstOrDefault(x => x.IsActive); } }
private async void ShowModalessDialog(IDialogWindow dialog) { await Application.Current.Dispatcher.InvokeAsync(() => { dialog.Show(); }); }
/// <summary> /// Configure <see cref="IDialogWindow"/> content. /// </summary> /// <param name="dialogName">The name of the dialog to show.</param> /// <param name="window">The hosting window.</param> /// <param name="parameters">The parameters to pass to the dialog.</param> protected virtual async Task ConfigureDialogWindowContent(string dialogName, IDialogWindow window, IDialogParameters parameters) { var content = _containerExtension.Resolve <object>(dialogName); if (!(content is FrameworkElement dialogContent)) { throw new NullReferenceException("A dialog's content must be a FrameworkElement"); } MvvmHelpers.AutowireViewModel(dialogContent); if (!(dialogContent.DataContext is IDialogAware viewModel)) { throw new NullReferenceException("A dialog's ViewModel must implement the IDialogAware interface"); } if (!(dialogContent.DataContext is IDialogAsyncAware asyncviewModel)) { throw new NullReferenceException("A dialog's ViewModel must implement the IDialogAsyncAware interface"); } if (viewModel != null) { ConfigureDialogWindowProperties(window, dialogContent, viewModel); viewModel.OnDialogOpened(parameters); } else if (asyncviewModel != null) { ConfigureDialogWindowProperties(window, dialogContent, asyncviewModel); await asyncviewModel.OnDialogOpenedAsync(parameters); } }
static void BuildDialogWindow(Factories.IFactory factory) { List <ISlider> sliderList = new List <ISlider>(); List <IButton> buttonList = new List <IButton>(); sliderList.Add(factory.GetSlider(1, 10, 2)); sliderList.Add(factory.GetSlider(10, 50, 3)); sliderList.Add(factory.GetSlider(0, 100, 5)); buttonList.Add(factory.GetButton("Cancel")); buttonList.Add(factory.GetButton("Accept")); IDialogWindow dialogWindow = factory.GetDialogWindow("UserSettings", sliderList, buttonList); foreach (var slider in sliderList) { for (int i = 1; i < 5; ++i) { slider.ChangeValue(i * 4); } } foreach (var button in buttonList) { button.ButtonPressed(); button.ButtonPressed(); } dialogWindow.DrawDialog(); }
public void CloseDialogWithResult(IDialogWindow window, T result) { DialogResult = result; if (window != null) { window.DialogResult = true; } }
public void CloseDialogWithResult(IDialogWindow dialog, bool?windowDialogResult = false, TResult result = default) { Result = result; if (dialog != null) { dialog.DialogResult = windowDialogResult; } }
public void CloseDialogWithResult(IDialogWindow dialog, T result) { DialogResult = result; if (dialog != null) { dialog.DialogResult = true; } }
void ShowDialogInternal(string name, IDialogParameters parameters, Action <IDialogResult> callback, bool isModal, string windowName = null) { parameters ??= new DialogParameters(); IDialogWindow dialogWindow = CreateDialogWindow(windowName); ConfigureDialogWindowEvents(dialogWindow, callback); ConfigureDialogWindowContent(name, dialogWindow, parameters); ShowDialogWindow(dialogWindow, isModal); }
public void CloseDialogWithResult(IDialogWindow dialog, DialogResults result) { DialogResult = result; if (dialog != null) { dialog.DialogResult = true; // Closes the Window if it was a WPF Window } }
protected override void ConfigureDialogWindowProperties(IDialogWindow window, FrameworkElement dialogContent, IDialogAware viewModel) { base.ConfigureDialogWindowProperties(window, dialogContent, viewModel); if (window is VideoDialogWindow) { window.Owner = null; } }
void ShowDialogInternal(string name, IDialogParameters parameters, Action <IDialogResult> callback, string windowName = null) { IDialogWindow contentDialog = CreateDialogWindow(windowName); ConfigureDialogWindowEvents(contentDialog, callback); ConfigureDialogWindowContent(name, contentDialog, parameters); _ = contentDialog.ShowAsync(); }
public void CloseDialogWithResult(IDialogWindow dialog, DialogResults <T> results) { NewStat = results.MyStat; DialogResult = results.decisions; if (dialog != null) { dialog.DialogResult = true; } }
public void CloseDialogWithResult(IDialogWindow dialog, T result, string item) { Equipment = item; DialogResult = result; if (dialog != null) { dialog.DialogResult = true; } }
public void CloseDialogWithResult(IDialogWindow dialog, T result, Stat obj) { NewStat = obj; DialogResult = result; if (dialog != null) { dialog.DialogResult = true; } }
/// <summary> /// Shows the dialog window. /// </summary> /// <param name="dialogWindow">The dialog window to show.</param> /// <param name="isModal">If true; dialog is shown as a modal</param> protected virtual void ShowDialogWindow(IDialogWindow dialogWindow, bool isModal) { if (isModal) { dialogWindow.ShowDialog(); } else { dialogWindow.Show(); } }
private void RemoveFromCache(object parentViewModel, IDialogWindow window) { if (window is Window) { RemoveWindowFromCache(parentViewModel); } else { RemoveModelWindowFromCache(parentViewModel); } }
/// <summary> /// Whether the dialog can be closed /// </summary> protected override bool CanCloseDialog(IDialogWindow dialog) { // Ensure an item is selected var selectedItem = GetSelectedItem(); if (selectedItem == null) { return false; } return selectedItem.IsSelectable; }
/// <summary> /// Whether the dialog can be closed /// </summary> protected override bool CanCloseDialog(IDialogWindow dialog) { // Ensure at least one item is selected var selectedItems = GetSelectedItems(); if (!selectedItems.Any()) { return(false); } return(selectedItems.Any(si => si.IsSelectable)); }
void ConfigureDialogWindowProperties(IDialogWindow window, FrameworkElement dialogContent, IDialogAware viewModel) { var windowStyle = Dialog.GetWindowStyle(dialogContent); if (windowStyle != null) { window.Style = windowStyle; } window.Content = dialogContent; window.DataContext = viewModel; }
/// <summary> /// Whether the dialog can be closed /// </summary> protected override bool CanCloseDialog(IDialogWindow dialog) { // Ensure an item is selected var selectedItem = GetSelectedItem(); if (selectedItem == null) { return(false); } return(selectedItem.IsSelectable); }
/// <summary> /// Configure <see cref="IDialogWindow"/> and <see cref="IDialogAware"/> events. /// </summary> /// <param name="dialogWindow">The hosting window.</param> /// <param name="callback">The action to perform when the dialog is closed.</param> internal static void ConfigureDialogWindowEvents(this IDialogWindow dialogWindow, Action <IDialogResult> callback) { Action <IDialogResult> requestCloseHandler = null; requestCloseHandler = (o) => { dialogWindow.Result = o; dialogWindow.Close(); }; RoutedEventHandler loadedHandler = null; loadedHandler = (o, e) => { dialogWindow.Loaded -= loadedHandler; dialogWindow.GetDialogViewModel().RequestClose += requestCloseHandler; }; dialogWindow.Loaded += loadedHandler; CancelEventHandler closingHandler = null; closingHandler = (o, e) => { if (!dialogWindow.GetDialogViewModel().CanCloseDialog()) { e.Cancel = true; } }; dialogWindow.Closing += closingHandler; EventHandler closedHandler = null; closedHandler = (o, e) => { dialogWindow.Closed -= closedHandler; dialogWindow.Closing -= closingHandler; dialogWindow.GetDialogViewModel().RequestClose -= requestCloseHandler; dialogWindow.GetDialogViewModel().OnDialogClosed(); if (dialogWindow.Result == null) { dialogWindow.Result = new DialogResult(); } callback?.Invoke(dialogWindow.Result); dialogWindow.DataContext = null; dialogWindow.Content = null; }; dialogWindow.Closed += closedHandler; }
private void AddToCache(object parentViewModel, IDialogWindow window) { var w = window as Window; if (w != null) { AddWindowToCache(parentViewModel, w); } else { AddModelWindowToCache(parentViewModel, (ModelWindow)window); } }
/// <summary> /// Configure <see cref="IDialogWindow"/> properties. /// </summary> /// <param name="window">The hosting window.</param> /// <param name="dialogContent">The dialog to show.</param> /// <param name="viewModel">The dialog's ViewModel.</param> protected virtual void ConfigureDialogWindowProperties(IDialogWindow window, FrameworkElement dialogContent, IDialogAware viewModel) { var windowStyle = Dialog.GetWindowStyle(dialogContent); if (windowStyle != null) { window.Style = windowStyle; } window.Content = dialogContent; window.DataContext = viewModel; //we want the host window and the dialog to share the same data context window.Owner ??= Application.Current?.Windows.OfType <Window>().FirstOrDefault(x => x.IsActive); }
public void ShowDialogAsync <T>(IDialogModel model, Action closed = null) where T : IDialogWindow, new() { IDialogWindow dialog = CreateDialog <T>(model, closed); if (model.IsModal) { ShowModalDialog(dialog); } else { ShowModalessDialog(dialog); } }
public void ShowDialog <T>(IDialogModel model, Action closed = null) where T : IDialogWindow, new() { IDialogWindow dialog = CreateDialog <T>(model, closed); if (model.IsModal) { dialog.ShowDialog(); } else { dialog.Show(); } }
private static void CloseDialog(IDialogWindow dialog) { // For a TreeViewItem the double-click event bubbles up and fires for every ancestor TreeViewItem as well // We only want to handle it once to close the dialog (ignore repeated attempts to close dialog) if (dialog != null) { if (dialog.DialogResult != true) { dialog.DialogResult = true; dialog.Close(); } } }
private void MyEvents_OnStartup(object Sender, ExtenderEventArgs e) { ExtendedPropertyList properties = null;; ExtenderMenuItems menuItem; //MyApp.SystemSettings.WorkstationInfo.Touch.CompanyLogoPosition = 1; properties = (ExtendedPropertyList)e.get_data(); //this property will only be available in the backoffice if (properties.PropertyExists("ChildWindow")) { generalChildWindow = (IChildWindow)properties.get_Value("ChildWindow"); } //this property will only be available in the backoffice if (properties.PropertyExists("WorkspaceWindow")) { generalWorkspaceWindow = (IWorkspaceWindow)properties.get_Value("WorkspaceWindow"); } //this property will be available in both backoffice and frontoffice if (properties.PropertyExists("DialogWindow")) { generalDialogWindow = (IDialogWindow)properties.get_Value("DialogWindow"); } // CUSTOM MENUS // Definir os menus menuItem = new ExtenderMenuItems(); var childItems = menuItem.Add("miExtensibilidade", "&Extensibilidade").ChildItems; childItems.Add("miXItem1", "Item &1"); childItems.Add("miXItem2", "Item &2"); // // COM mandatories object oMenuItem = menuItem; properties.set_Value("ExtenderMenuItems", ref oMenuItem); //Use this property if you want Sage Retail to rebuild the permissions tree... //object rebuildPermissionsTree = true; //properties.set_Value("RebuildPermissionsTree", rebuildPermissionsTree); object oProps = properties; e.result.set_data(ref oProps); menuItem = null; }
private void CloseDialog(IDialogWindow dialog) { if (!this.patternManager.Products.Any(product => product.InstanceName.Equals(this.productName, StringComparison.OrdinalIgnoreCase))) { dialog.DialogResult = true; dialog.Close(); } else { this.userMessageService.ShowError(string.Format( CultureInfo.CurrentCulture, Resources.AddNewProductViewModel_ProductNameDuplicated, this.productName)); } }
/// <summary> /// Configure <see cref="IDialogWindow"/> content. /// </summary> /// <param name="dialogName">The name of the dialog to show.</param> /// <param name="window">The hosting window.</param> /// <param name="parameters">The parameters to pass to the dialog.</param> protected virtual void ConfigureDialogWindowContent(string dialogName, IDialogWindow window, IDictionary <string, object> args) { var content = _containerExtension.Resolve <object>(dialogName); if (!(content is FrameworkElement dialogContent)) { throw new NullReferenceException("A dialog's content must be a FrameworkElement"); } if (!(dialogContent.DataContext is IDialogAware viewModel)) { throw new NullReferenceException("A dialog's ViewModel must implement the IDialogAware interface"); } ConfigureDialogWindowProperties(window, dialogContent, viewModel); MVVMHelper.ViewAndViewModelAction <IDialogAware>(viewModel, d => d.OnDialogOpened(args)); }
void ShowDialogInternal(string name, IDialogParameters parameters, Action <IDialogResult> callback, bool isModal) { IDialogWindow dialogWindow = CreateDialogWindow(); ConfigureDialogWindowEvents(dialogWindow, callback); ConfigureDialogWindowContent(name, dialogWindow, parameters); if (isModal) { dialogWindow.ShowDialog(); } else { dialogWindow.Show(); } }
/// <summary> /// Whether the dialog can be closed /// </summary> protected override bool CanCloseDialog(IDialogWindow dialog) { // Ensure at least one item is selected var selectedItems = GetSelectedItems(); if (!selectedItems.Any()) { return false; } return selectedItems.Any(si => si.IsSelectable); }
/// <summary> /// Whether the dialog can be closed /// </summary> protected abstract bool CanCloseDialog(IDialogWindow dialog);
private void CloseDialog(IDialogWindow dialog) { if (!this.sibilings.Any(product => product.InstanceName.Equals(this.instanceName, StringComparison.OrdinalIgnoreCase))) { dialog.DialogResult = true; dialog.Close(); } else { this.userMessageService.ShowError(string.Format( CultureInfo.CurrentCulture, Resources.AddNewProductViewModel_ProductNameDuplicated, this.instanceName)); } }
private void CloseDialog(IDialogWindow dialog) { dialog.DialogResult = true; dialog.Close(); }