Пример #1
0
 public void SaveCurrentSettings()
 {
     // Synchronize across processes with a Mutex to avoid partial reads/writes
     RunSynchronized(DoSaveSettings);
     LoggingHelper.ChangeLogLevel(_settingsProvider.Settings.ApplicationSettings.LoggingLevel);
     SettingsSaved?.Invoke(this, EventArgs.Empty);
 }
Пример #2
0
        public SettingsForm()
        {
            Title       = "Settings - arcdps Log Manager";
            ClientSize  = new Size(400, -1);
            MinimumSize = new Size(400, 300);

            var pages = new SettingsPage[]
            {
                new LogsSettingsPage(),
                new ApiSettingsPage(),
                new DpsReportUploadSettingsPage(),
                new UpdateSettingsPage()
            };

            var tabs = new TabControl();

            foreach (var page in pages)
            {
                tabs.Pages.Add(page);
            }

            var saveButton = new Button {
                Text = "Save"
            };

            saveButton.Click += (sender, args) =>
            {
                foreach (var page in pages)
                {
                    page.SaveSettings();
                }
                SettingsSaved?.Invoke(this, EventArgs.Empty);

                Close();
            };

            var layout = new DynamicLayout();

            layout.BeginVertical(new Padding(10));
            {
                layout.Add(tabs);
            }
            layout.EndVertical();
            layout.Add(null);
            layout.BeginVertical(new Padding(10));
            {
                layout.BeginHorizontal();
                {
                    layout.Add(null, xscale: true);
                    layout.Add(saveButton, xscale: false);
                }
                layout.EndHorizontal();
            }
            layout.EndVertical();

            Content = layout;
        }
Пример #3
0
        public void Save()
        {
            using (var fs = new FileStream(AppInformation.SettingsPath, FileMode.Create))
            {
                new BinaryFormatter().Serialize(fs, this);
            }

            SettingsSaved?.Invoke(this, EventArgs.Empty);
        }
Пример #4
0
        public void SaveSettings()
        {
            Logger.Log("Writing settings INI.");

            ForceLowestDetailLevel.Value = false;

            SettingsIni.WriteIniFile();

            SettingsSaved?.Invoke(this, EventArgs.Empty);
        }
Пример #5
0
        public void SaveSettings()
        {
            Logger.Log("Writing settings INI.");

            ApplyDefaults();

            SettingsIni.WriteIniFile();

            SettingsSaved?.Invoke(this, EventArgs.Empty);
        }
Пример #6
0
 private void Save()
 {
     _appSettings.WorkshopPath     = WorkshopPath;
     _appSettings.ModPath          = ModPath;
     _appSettings.ActiveFileName   = ActiveFileName;
     _appSettings.BakkesModPath    = BakkesModPath;
     _appSettings.RocketLeaguePath = RocketLeaguePath;
     _appSettings.SaveSettings();
     SettingsSaved?.Invoke(this, EventArgs.Empty);
 }
Пример #7
0
        public static void Save()
        {
            var settings = new SettingsData();

            settings.Record(Terraria3D.Instance);
            var json = JsonConvert.SerializeObject(settings, Formatting.Indented);

            FileUtils.SaveJSON(json, Terraria3D.Instance.DisplayName);
            SettingsSaved?.Invoke(settings);
        }
Пример #8
0
        private void SettingsViewModel_SettingsSaved(object sender, SettingsSavedEventArgs e)
        {
            this.toastView.InitToast();
            this.toastView.DisplayAction(ToastifyActionEnum.SettingsSaved);

            this.LstHotKeys.GetBindingExpression(ItemsControl.ItemsSourceProperty)?.UpdateTarget();
            this.HotkeyGrid.GetBindingExpression(DataContextProperty)?.UpdateTarget();

            SettingsSaved?.Invoke(sender, e);
        }
Пример #9
0
 private void btnDone_Click(object sender, EventArgs e)
 {
     if (Folders.Count > 0)
     {
         App.AppSettings = new Settings();
         App.AppSettings.ImageLocations = Folders.ToList();
         App.SaveSettings();
         SettingsSaved?.Invoke(this, EventArgs.Empty);
         Close();
     }
 }
Пример #10
0
        public void LoadAllSettings()
        {
            LoadAllSettingsSynchronized();

            var version = _versionHelper.ApplicationVersion.ToString();

            if (version != _settingsProvider.Settings.CreatorAppSettings.LastLoginVersion)
            {
                _settingsProvider.Settings.CreatorAppSettings.LastLoginVersion = version;
            }

            SettingsSaved?.Invoke(this, EventArgs.Empty);
        }
Пример #11
0
 public static bool Save()
 {
     try {
         File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(Settings, Formatting.Indented));
         Settings.LastModified = File.GetLastWriteTime(ConfigPath);
         SettingsSaved?.Invoke();
         return(true);
     }
     catch (Exception e) {
         Logger.Log(LogType.Error, $"Failed to save config file: {e.Message}");
         Logger.Log(LogType.Debug, $"Stacktrace: {e.StackTrace}");
         return(false);
     }
 }
Пример #12
0
        public override void Save()
        {
            // Disallow auto-start in debug mode to make things simpler
#if DEBUG
            IsAutoStartEnabled = false;
#endif

            base.Save();

            // Update values in the registry
            _extendedGammaRangeSwitch.IsSet = IsExtendedGammaRangeUnlocked;
            _autoStartSwitch.IsSet          = IsAutoStartEnabled;

            SettingsSaved?.Invoke(this, EventArgs.Empty);
        }
Пример #13
0
 public void Save(string valueName, object value)
 {
     try {
         if (registryKeyWritable == null)
         {
             registryKeyWritable = Registry.CurrentUser.CreateSubKey(registryPath);
         }
         registryKeyWritable.SetValue(valueName, value == null ? string.Empty : value.GetType() == typeof(bool) ? (bool)value ? 1 : 0 : value);
         SettingsSaved?.Invoke(this, registryKeyWritable);
     } catch (SecurityException exception) {
         Debug.WriteLine(exception);
         RegistryAccessFailed?.Invoke(this, registryKeyWritable);
     } catch (Exception exception) {
         Debug.WriteLine(exception);
     }
 }
Пример #14
0
        public static void SaveSettings(ISettings settings)
        {
            try
            {
                if (!store.CollectionExists(settings.Key))
                {
                    store.CreateCollection(settings.Key);
                }

                if (SaveSettingsIntoStore(settings))
                {
                    SettingsSaved?.Invoke();
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.Message);
            }
        }
        public bool SaveSettings(PlayerSettings settings)
        {
            _logger.Write("Saving settings file.");

            try
            {
                using (var writeStream = new StreamWriter(GetSettingsFilePath()))
                {
                    var xmlSerializer = GetSerializer();
                    xmlSerializer.Serialize(writeStream, settings);
                    writeStream.Close();

                    SettingsSaved?.Invoke(settings);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                _logger.Write(ex);
                _notificationService.ShowNotification("Settings", $"Failed to save settings. Error message: {ex.Message}", true);
            }

            return(false);
        }
Пример #16
0
 public void OnSettingsSaved(SettingsEventArgs e)
 {
     SettingsSaved?.Invoke(this, e);
 }
Пример #17
0
 protected virtual void OnSettingsSaved(string filePath, bool result)
 {
     SettingsSaved?.Invoke((T)this, filePath, result);
 }
Пример #18
0
        public SettingsForm(ManagerForm managerForm)
        {
            Title       = "Settings - arcdps Log Manager";
            ClientSize  = new Size(400, -1);
            MinimumSize = new Size(400, 300);

            var apiDataCheckbox = new CheckBox {
                Text = "Use the Guild Wars 2 API", Checked = Settings.UseGW2Api
            };
            var dialog = new SelectFolderDialog();

            var locationTextBox = new TextBox
            {
                ReadOnly        = true,
                PlaceholderText = "Log Location",
            };

            var locationDialogButton = new Button {
                Text = "Select Log Directory"
            };

            locationDialogButton.Click += (sender, args) =>
            {
                if (dialog.ShowDialog(this) == DialogResult.Ok)
                {
                    locationTextBox.Text = dialog.Directory;
                }
            };

            var saveButton = new Button {
                Text = "Save"
            };

            saveButton.Click += (sender, args) =>
            {
                Settings.UseGW2Api = apiDataCheckbox.Checked ?? false;
                if (locationTextBox.Text.Trim() != Settings.LogRootPaths.FirstOrDefault())
                {
                    Settings.LogRootPaths = new [] { locationTextBox.Text };
                    // TODO: Subscribe from the manager form, and pass if location was changed through event args
                    managerForm?.ReloadLogs();
                }

                SettingsSaved?.Invoke(this, EventArgs.Empty);

                Close();
            };

            var layout = new DynamicLayout();

            layout.BeginVertical(spacing: new Size(5, 5), padding: new Padding(10));
            {
                layout.BeginGroup("Logs", new Padding(5), new Size(5, 5));
                {
                    layout.AddRow(new Label
                    {
                        Text = "The directory in which your arcdps logs are stored. Subdirectories " +
                               "are also searched, do not choose a parent directory containing more " +
                               "irrelevant files unless you like extra waiting.",
                        Wrap   = WrapMode.Word,
                        Height = 50
                    });
                    layout.AddRow(locationTextBox);
                    layout.AddRow(locationDialogButton);
                }
                layout.EndGroup();
                layout.BeginGroup("Data", new Padding(5), new Size(5, 5));
                {
                    layout.AddRow(new Label
                    {
                        Text = "The program can use the official Guild Wars 2 API to retrieve guild data. " +
                               "No API key is required. If this is not enabled, guild names and " +
                               "tags will not be available.",
                        Wrap   = WrapMode.Word,
                        Height = 50
                    });
                    layout.AddRow(apiDataCheckbox);
                }
                layout.EndGroup();
            }
            layout.EndVertical();
            layout.Add(null);
            layout.BeginVertical(padding: new Padding(10));
            {
                layout.BeginHorizontal();
                {
                    layout.Add(null, xscale: true);
                    layout.Add(saveButton, xscale: false);
                }
                layout.EndHorizontal();
            }
            layout.EndVertical();

            Content = layout;

            if (Settings.LogRootPaths.Any())
            {
                if (Settings.LogRootPaths.Count > 1)
                {
                    // There is currently no interface for adding more than one log directory, so this would end up
                    // losing some quietly when that is implemented.
                    throw new NotImplementedException();
                }

                string logRootPath = Settings.LogRootPaths.Single();
                if (Directory.Exists(logRootPath))
                {
                    dialog.Directory = logRootPath;
                }

                locationTextBox.Text = logRootPath;
            }
            else
            {
                string defaultDirectory = GetDefaultLogDirectory();
                if (Directory.Exists(defaultDirectory))
                {
                    dialog.Directory     = defaultDirectory;
                    locationTextBox.Text = defaultDirectory;
                }
            }
        }
Пример #19
0
 private void SettingsViewModel_SettingsSaved(object sender, SettingsSavedEventArgs e)
 {
     this.toastView.InitToast();
     this.toastView.DisplayAction(ToastifyAction.SettingsSaved);
     SettingsSaved?.Invoke(sender, e);
 }
Пример #20
0
 private void HandleSettingsSaved()
 {
     _settingsWindowViewModel.SaveSettings();
     SettingsSaved?.Invoke(this, new SettingsSavedEventArgs(_settingsWindowViewModel.Settings));
 }
Пример #21
0
 /// <summary>
 ///     Fires the SettingsSaved event.
 /// </summary>
 private void OnSettingsSaved()
 {
     SettingsSaved?.Invoke(this, EventArgs.Empty);
 }
Пример #22
0
 private void SerialiseToFile(string saveLocation)
 {
     SettingsSaved?.Invoke(this, new EventArgs());
     File.WriteAllText(saveLocation, JsonConvert.SerializeObject(this, Formatting.Indented));
 }
 protected virtual void OnSettingsSaved(EventArgs e)
 {
     SettingsSaved?.Invoke(this, e);
 }