Esempio n. 1
0
        static public void ReadSettingsFromFile()
        {
            try {
                XmlSerializer serializer = new XmlSerializer(typeof(SettingsSet));
                using FileStream file = File.OpenRead(_settingsFilepath);

                Settings = (SettingsSet)serializer.Deserialize(file);
                file.Close();
            } catch (Exception e) {
            }
        }
Esempio n. 2
0
        static Commands()
        {
            AllCommands = new Dictionary <string, ICommand>();

            AllCommands["ChangeLanguage"] = new Command((Object obj) => {
                Subtitles.ChangeLanguage((string)obj);
            });

            AllCommands["ChangeTheme"] = new Command((Object obj) => {
                Themes.ChangeTheme((string)obj);
            });

            AllCommands["Exit"] = new Command((Object obj) => {
                App.Current.Shutdown();
            });

            AllCommands["ChangePage"] = new Command((Object obj) => {
                if (obj is Type)
                {
                    PagesManager.Navigate((Type)obj);
                }
                else if (obj is string)
                {
                    PagesManager.Navigate((string)obj);
                }
            });

            AllCommands["GoBack"] = new Command((Object obj) => { PagesManager.GoBack(); },
                                                (object obj) => { return(PagesManager.CanGoBack()); });

            AllCommands["GoForward"] = new Command((Object obj) => { PagesManager.GoForward(); },
                                                   (object obj) => { return(PagesManager.CanGoForward()); });

            AllCommands["MinimizeToTray"] = new Command((Object obj) => Tray.MinimizeToTray());

            AllCommands["RestoreFromTray"] = new Command((Object obj) => Tray.RestoreFromTray());

            AllCommands["SaveSettings"] = new Command((Object obj) => {
                if (obj is SettingsSet)
                {
                    SettingsManager.Settings = (SettingsSet)obj;
                }
            });

            AllCommands["ChangeFontSize"] = new Command((Object obj) => {
                if (obj is string)
                {
                    int size;
                    if (int.TryParse((string)obj, out size))
                    {
                        var currentSettings = new SettingsSet(false)
                        {
                            FontSize = size
                        };
                        SettingsManager.Settings = currentSettings;
                    }
                }
            });

            AllCommands["RunProcess"] = new Command((object obj) => ProgramModel.Start(), (object obj) => !ProgramModel.IsRunning);

            AllCommands["StopProcess"] = new Command((object obj) => ProgramModel.Stop(), (object obj) => ProgramModel.IsRunning);
        }
Esempio n. 3
0
 public static void SetDefaultSettings()
 {
     _settings = new SettingsSet(true);
 }