예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AppearanceManager"/> class.
 /// </summary>
 private AppearanceManager()
 {
     DarkThemeCommand = new RelayCommand(o => ThemeSource = DarkThemeSource, o => !DarkThemeSource.Equals(ThemeSource));
     LightThemeCommand = new RelayCommand(o => ThemeSource = LightThemeSource, o => !LightThemeSource.Equals(ThemeSource));
     SetThemeCommand = new RelayCommand(o => {
         var uri = NavigationHelper.ToUri(o);
         if (uri != null) {
             ThemeSource = uri;
         }
     }, o => o is Uri || o is string);
     LargeFontSizeCommand = new RelayCommand(o => FontSize = FontSize.Large);
     SmallFontSizeCommand = new RelayCommand(o => FontSize = FontSize.Small);
     AccentColorCommand = new RelayCommand(o => {
         if (o is Color) {
             AccentColor = (Color)o;
         }
         else {
             // parse color from string
             var str = o as string;
             if (str == null) return;
             var convertFromString = ColorConverter.ConvertFromString(str);
             if (convertFromString != null)
                 AccentColor = (Color)convertFromString;
         }
     }, o => o is Color || o is string);
 }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ModernDialog"/> class.
        /// </summary>
        public ModernDialog()
        {
            DefaultStyleKey = typeof(ModernDialog);
            WindowStartupLocation = WindowStartupLocation.CenterOwner;

            CloseCommand = new RelayCommand(o => {
                var result = o as MessageBoxResult?;
                if (result.HasValue)
                {
                    _messageBoxResult = result.Value;

                    // sets the Window.DialogResult as well
                    if (result.Value != MessageBoxResult.OK && result.Value != MessageBoxResult.Yes)
                    {
                        if (result.Value == MessageBoxResult.Cancel || result.Value == MessageBoxResult.No)
                        {
                            DialogResult = false;
                        }
                        else
                        {
                            DialogResult = null;
                        }
                    }
                    else
                    {
                        DialogResult = true;
                    }
                }
                                                      Close();
            });

            Buttons = new[] { CloseButton };

            // set the default owner to the app main window (if possible)
            if (Application.Current != null && !Equals(Application.Current.MainWindow, this)) {
                Owner = Application.Current.MainWindow;
            }
        }