Exemplo n.º 1
0
 public void ClearWindow()
 {
     Ts.Cancel();
     T?.Wait(Ts.Token);
     DataSource.Path  = "FirstTimeNotSet";
     DataSource.Title = "";
     WindowTitle      = "Minimal CS Manga Reader";
     DataSource.ImageList.Clear();
     DataSource.ChapterList.Clear();
     ImageHeight.Clear();
     ImageDimension.Clear();
     //Save
     Config.Path = DataSource.Path;
     Config.Save();
 }
 private void SaveSettings()
 {
     Config.InterpolationMode       = SelectedInterpolationMode;
     Config.SmoothingMode           = SelectedSmoothingMode;
     Config.PixelOffsetMode         = SelectedPixelOffsetMode;
     Config.FitImagesToScreen       = FitImagesToScreen;
     Config.IsScrollBarVisible      = IsScrollBarVisible;
     Config.OpenChapterOnLoadChoice = OpenChapterOnLoad;
     Config.Background  = SelectedBackground;
     Config.Theme       = SelectedTheme;
     Config.AccentColor = SelectedColor;
     Config.Save();
     if (_initialContextIntegrated != ContextIntegrated)
     {
         try
         {
             RegistryContextManager.ChangeContextIntegrated(ContextIntegrated);
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.Print(e.ToString());
         }
     }
 }
        public SettingViewModel(Action <SettingViewModel, bool> closeCallback, IUserConfig config)
        {
            Config                    = config ?? Locator.Current.GetService <IUserConfig>();
            ContextIntegrated         = RegistryContextManager.IsContextRegistry();
            _initialContextIntegrated = ContextIntegrated;
            FitImagesToScreen         = Config.FitImagesToScreen;
            IsScrollBarVisible        = Config.IsScrollBarVisible;
            OpenChapterOnLoad         = Config.OpenChapterOnLoadChoice;
            SelectedBackground        = Config.Background;
            SelectedTheme             = Config.Theme;

            try
            {
                SelectedInterpolationMode = Config.InterpolationMode;
                SelectedSmoothingMode     = Config.SmoothingMode;
                SelectedPixelOffsetMode   = Config.PixelOffsetMode;
            }
            catch (Exception)
            {
                SelectedInterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
                SelectedSmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.Default;
                SelectedPixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.Default;
                Config.InterpolationMode  = SelectedInterpolationMode;
                Config.SmoothingMode      = SelectedSmoothingMode;
                Config.PixelOffsetMode    = SelectedPixelOffsetMode;
                Config.Save();
            }
            _closeCallback = closeCallback;

            Save = ReactiveCommand.Create(() =>
            {
                SaveSettings();
                _closeCallback(this, false);
            });

            SaveAndRefresh = ReactiveCommand.Create(() =>
            {
                SaveSettings();
                _closeCallback(this, true);
            });

            Close = ReactiveCommand.Create(() =>
            {
                _closeCallback(this, false);
                if (SelectedTheme != Config.Theme)
                {
                    // Restore theme
                    ThemeEditor.ModifyTheme(Config.Theme);
                }
                ThemeEditor.ChangePrimaryColor(Config.AccentColor);
            });

            SetAccentColor = ReactiveCommand.Create(() =>
            {
                InitialAccentColor = SelectedColor;
                ThemeEditor.ChangePrimaryColor(SelectedColor);
                IsPopupOpen = false;
            });

            CancelAccentColor = ReactiveCommand.Create(() =>
            {
                SelectedColor = Config.AccentColor;
                IsPopupOpen   = false;
            });

            ResetAccentColor = ReactiveCommand.Create(() =>
            {
                InitialAccentColor = Color.FromArgb(255, 154, 103, 234);
                SelectedColor      = InitialAccentColor;
                ThemeEditor.ChangePrimaryColor(InitialAccentColor);
                IsPopupOpen = false;
            });

            this.WhenValueChanged(x => x.SelectedTheme).Subscribe(x =>
            {
                ThemeEditor.ModifyTheme(x);
            });

            this.WhenAnyValue(x => x.SelectedColor).Subscribe(x =>
            {
                SelectedBrush = new SolidColorBrush(SelectedColor);
            });
        }
Exemplo n.º 4
0
 protected override void OnExit(ExitEventArgs e)
 {
     base.OnExit(e);
     config.Save();
     bookmarks.SaveAsync();
 }