public SettingsDialog(ISettingsViewModel vm, CushWindow owningWindow, DialogSettings settings) : base(owningWindow, settings) { DataContext = vm; InitializeComponent(); _originalScheme = new ColorScheme(this.ColorScheme); if (vm.ConfigFileHasPassword) InitializePassword(); //Apply.IsEnabled = false; var cvs = CollectionViewSource.GetDefaultView(FontCombo.ItemsSource); cvs.SortDescriptions.Clear(); cvs.SortDescriptions.Add(new SortDescription("Source", ListSortDirection.Ascending)); cvs.Refresh(); }
public AboutDialog(IAboutViewModel vm, CushWindow owningWindow, DialogSettings settings) : base(owningWindow, settings) { DataContext = vm; InitializeComponent(); }
/// <summary> /// Initializes a new DialogBase with the given settings and no owning window. /// </summary> protected DialogBase(DialogSettings settings) : this(null, settings) { }
/// <summary> /// Initializes a new DialogBase. /// </summary> /// <param name="owningWindow">The window that is the parent of the dialog.</param> /// <param name="settings"></param> protected DialogBase(CushWindow owningWindow, DialogSettings settings) { DialogSettings = settings ?? owningWindow?.DialogOptions ?? new DialogSettings(); OwningWindow = owningWindow; Initialize(); }
/// <summary> /// Creates a ContentDialog inside of the current window. /// </summary> /// <param name="window">The CushWindow.</param> /// <param name="content">The ContentDialog to display.</param> /// <param name="settings">Optional settings that override the global metro dialog settings.</param> /// <returns>A task promising the result of which button was pressed.</returns> public static Task<MessageDialogResult> ShowDialogAsync(this CushWindow window, ContentDialog content, DialogSettings settings = null) { ThrowHelper.IfNullThenThrow(() => content); if (settings == null) settings = content.DialogSettings ?? window.DialogOptions ?? new DialogSettings(); window.Dispatcher.VerifyAccess(); return HandleOverlayOnShow(settings, window).ContinueWith(z => window.Dispatcher.Invoke(() => { var dialog = GetDialog(window, content, settings); var sizeHandler = SetupAndOpenDialog(window, dialog); dialog.SizeChangedHandler = sizeHandler; return dialog.WaitForLoadAsync().ContinueWith(x => { window.OnDialogOpened(); return dialog.WaitForButtonPressAsync().ContinueWith(y => { //once a button as been clicked, begin removing the dialog. dialog.OnClose(); window.OnDialogClosed(); var closingTask = window.Dispatcher.Invoke(dialog.WaitForCloseAsync); return closingTask.ContinueWith(a => (window.Dispatcher.Invoke(() => { window.SizeChanged -= sizeHandler; window.DialogContainer.Children.Remove(dialog); //remove the dialog from the container return HandleOverlayOnHide(settings, window); //window.overlayBox.Visibility = System.Windows.Visibility.Hidden; //deactive the overlay effect })).ContinueWith(y3 => y).Unwrap()); }).Unwrap(); }).Unwrap().Unwrap(); })).Unwrap(); }
private static Task HandleOverlayOnShow(DialogSettings settings, CushWindow window) { return (settings == null || settings.AnimateShow ? window.ShowOverlayAsync() : Task.Factory.StartNew(() => window.Dispatcher.Invoke(window.ShowOverlay))); }
private static ContentDialog GetDialog(CushWindow window, ContentDialog content, DialogSettings settings) { // Return the existing dialog, if it exists. // Otherwise, create a new one. return window.DialogContainer.Children.Cast<ContentDialog>() .FirstOrDefault(item => item.Guid == content.Guid) ?? CreateDialog(window, content, settings); }
private static ContentDialog CreateDialog(CushWindow window, ContentDialog content, DialogSettings settings) { if (settings == null) settings = window.DialogOptions; // Pull the content out of the dialog and put it into a new dialog. // (For some reason, using the dialog directly doesn't work.) var body = content; var bodyContext = (content).DataContext; //create the dialog control var dialog = new ContentDialog(window, settings) { Content = body, Guid = content.Guid, DataContext = bodyContext }; return dialog; }
/// <summary> /// Initializes a new ContentDialog. /// </summary> /// <param name="owningWindow">The window that is the parent of the dialog.</param> /// <param name="settings"></param> public ContentDialog(CushWindow owningWindow, DialogSettings settings) : base(owningWindow, settings) { Initialize(); }