Пример #1
0
        public PreferencesWindow(IEnumerable <string> availableBrowsers)
        {
            InitializeComponent();

            StartupCheckboxList.SetItemChecked(StartIconIndex,
                                               Properties.Settings.Default.StartIcon);
            StartupCheckboxList.SetItemChecked(StartFreenetIndex,
                                               Properties.Settings.Default.StartFreenet);

            // TODO: Localize?
            BrowserChoice.Items.Add(BrowserUtil.Auto);
            foreach (var browser in availableBrowsers)
            {
                BrowserChoice.Items.Add(browser);
            }
            BrowserChoice.Text = Properties.Settings.Default.UseBrowser;
            if (!BrowserChoice.Items.Contains(BrowserChoice.Text))
            {
                // TODO: User's preference not found. Worthy of a message box?
                BrowserChoice.Text = BrowserUtil.Auto;
            }

            SlowStartOption.Checked = Properties.Settings.Default.ShowSlowOpenTip;

            LogLevelChoice.Text = Properties.Settings.Default.LogLevel;

            CustomLocationDisplay.Text = Properties.Settings.Default.CustomLocation;
            _initialCustomLocation     = Properties.Settings.Default.CustomLocation;
        }
Пример #2
0
        private void Apply_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.StartIcon    = StartupCheckboxList.GetItemChecked(StartIconIndex);
            Properties.Settings.Default.StartFreenet = StartupCheckboxList.GetItemChecked(StartFreenetIndex);

            Properties.Settings.Default.UseBrowser = (string)BrowserChoice.SelectedItem;

            Properties.Settings.Default.ShowSlowOpenTip = SlowStartOption.Checked;

            Properties.Settings.Default.LogLevel = LogLevelChoice.Text;

            Properties.Settings.Default.CustomLocation = CustomLocationDisplay.Text;

            Properties.Settings.Default.Save();

            foreach (var rule in LogManager.Configuration.LoggingRules)
            {
                ChangeRuleMinLevel(rule, LogLevel.FromString(LogLevelChoice.Text));
            }

            if (Properties.Settings.Default.StartIcon)
            {
                // Start Freenet or just the icon.
                SetStartupArguments(Properties.Settings.Default.StartFreenet ? "-start" : "");
            }
            else if (Properties.Settings.Default.StartFreenet)
            {
                // Just start Freenet.
                SetStartupArguments("-start -hide");
            }
            else
            {
                // Do not start.
                SetStartupArguments(null);
            }

            if (_initialCustomLocation != CustomLocationDisplay.Text)
            {
                // TODO: Reload config without restart? What would be the difference?
                Application.Restart();
            }

            Close();
        }