Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 public AboutDialog(IAboutViewModel vm, CushWindow owningWindow, DialogSettings settings)
     : base(owningWindow, settings)
 {
     DataContext = vm;
     InitializeComponent();
 }
Esempio n. 3
0
 /// <summary>
 ///     Initializes a new DialogBase with the given settings and no owning window.
 /// </summary>
 protected DialogBase(DialogSettings settings)
     : this(null, settings)
 {
 }
Esempio n. 4
0
 /// <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();
 }
Esempio n. 5
0
        /// <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();
        }
Esempio n. 6
0
 private static Task HandleOverlayOnShow(DialogSettings settings, CushWindow window)
 {
     return (settings == null || settings.AnimateShow
         ? window.ShowOverlayAsync()
         : Task.Factory.StartNew(() => window.Dispatcher.Invoke(window.ShowOverlay)));
 }
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
 /// <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();
 }