示例#1
0
        public PreferencesViewModel(ISettingsProvider settingsProvider, IScreenManager screenManager)
        {
            this.settingsProvider = settingsProvider;
            
            Screens = new ObservableCollection<DetailedScreen>(screenManager.GetScreens());

            Settings = settingsProvider.GetSettings<PopupSettings>();

            PlaceScreen();

            AvailableColors = new ObservableCollection<AvailableColor>();
            var properties = typeof(Colors).GetProperties(BindingFlags.Static | BindingFlags.Public);
            foreach (var prop in properties)
            {
                var name = prop.Name;
                var value = (Color)prop.GetValue(null, null);

                var availableColor = new AvailableColor(name, value);
                if (Settings.FontColor == name)
                    FontColor = availableColor;
                if (Settings.ItemBackgroundColor == name)
                    ItemBackgroundColor = availableColor;

                AvailableColors.Add(availableColor);
            }

            SaveCommand = new DelegateCommand(SaveSettings);
            ResetToDefaultsCommand = new DelegateCommand(() => settingsProvider.ResetToDefaults<PopupSettings>());
            VisitCommand = new DelegateCommand(Visit);
        }
示例#2
0
        public PreferencesViewModel(ISettingsProvider settingsProvider, IScreenManager screenManager)
        {
            this.settingsProvider = settingsProvider;

            Screens = new ObservableCollection <DetailedScreen>(screenManager.GetScreens());

            Settings = settingsProvider.GetSettings <PopupSettings>();

            PlaceScreen();

            AvailableColors = new ObservableCollection <AvailableColor>();
            var properties = typeof(Colors).GetProperties(BindingFlags.Static | BindingFlags.Public);

            foreach (var prop in properties)
            {
                var name  = prop.Name;
                var value = (Color)prop.GetValue(null, null);

                var availableColor = new AvailableColor(name, value);
                if (Settings.FontColor == name)
                {
                    FontColor = availableColor;
                }
                if (Settings.ItemBackgroundColor == name)
                {
                    ItemBackgroundColor = availableColor;
                }

                AvailableColors.Add(availableColor);
            }

            SaveCommand            = new DelegateCommand(SaveSettings);
            ResetToDefaultsCommand = new DelegateCommand(() => settingsProvider.ResetToDefaults <PopupSettings>());
            VisitCommand           = new DelegateCommand(Visit);
        }