コード例 #1
0
        private void BtNew_Click(object sender, RoutedEventArgs e)
        {
            FileExclusions.Clear();
            DataContext      = null;
            Globals.Settings = new SchedulerSettings.Settings();
            DataContext      = Globals.Settings;

            Logger.Log($"User '{Environment.UserName}' Loaded default settings.", LogType.Info);
        }
コード例 #2
0
        private void BtOpen_Click(object sender, RoutedEventArgs e)
        {
            var d = new OpenFileDialog
            {
                Filter = "Settings files (*.xml)|*.xml",
            };

            if (d.ShowDialog() == true)
            {
                try
                {
                    Globals.Settings = SettingsUtils.GetSettingsFromFile(d.FileName);
                    DataContext      = Globals.Settings;
                    _fileName        = d.FileName;

                    FileExclusions.Clear();
                    var filetext = string.Empty;

                    foreach (var file in Globals.Settings.RestartChecks.PendingFileNameExclusions)
                    {
                        if (!string.IsNullOrEmpty(file))
                        {
                            filetext += file + Environment.NewLine;
                        }
                    }

                    if (!string.IsNullOrEmpty(filetext))
                    {
                        FileExclusions.Text = filetext.TrimEnd(Environment.NewLine.ToCharArray());
                    }

                    Logger.Log($"User '{Environment.UserName}' Opened settings file '{_fileName}'", LogType.Info);
                }
                catch (Exception ex)
                {
                    Logger.Log($"Failed to load file '{_fileName}', Exception: '{ex.Message}'", LogType.Error);
                }
            }
        }
コード例 #3
0
        private void Lw_SettingsLoaded(object sender, EventArguments.LoadEventArg e)
        {
            var obj = SettingsUtils.StringToSettings <SchedulerSettings.Settings>(e.Settings);

            DataContext      = null;
            Globals.Settings = obj;
            DataContext      = Globals.Settings;

            FileExclusions.Clear();
            var filetext = string.Empty;

            foreach (var file in Globals.Settings.RestartChecks.PendingFileNameExclusions)
            {
                if (!string.IsNullOrEmpty(file))
                {
                    filetext += file + Environment.NewLine;
                }
            }

            if (!string.IsNullOrEmpty(filetext))
            {
                FileExclusions.Text = filetext.TrimEnd(Environment.NewLine.ToCharArray());
            }
        }