예제 #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            DOMConfigurator.Configure();

            Logger.Info("Witty is starting.");

            CheckForCorruptedConfigFile();

            Properties.Settings appSettings = Witty.Properties.Settings.Default;
            if (appSettings.UpgradeSettings)
            {
                Witty.Properties.Settings.Default.Upgrade();
                appSettings.UpgradeSettings = false;
            }

            // Set the default proxy here once and for all (should then be used by
            // WPF controls, like images that fetch their source from the internet)
            if (appSettings.UseProxy)
            {
                HttpWebRequest.DefaultWebProxy = WebProxyHelper.GetConfiguredWebProxy();
            }


            if (!string.IsNullOrEmpty(appSettings.Skin))
            {
                try
                {
                    SkinsManager.ChangeSkin(appSettings.Skin);
                }
                catch
                {
                    Logger.Error("Selected skin " + appSettings.Skin + " + not found");
                    // REVIEW: Should witty do something smart here?
                }
            }

            base.OnStartup(e);
        }
예제 #2
0
        private void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            if (InputIsValid())
            {
                AppSettings.RefreshInterval = RefreshComboBox.Text;

                NotifyIfRestartNeeded();

                AppSettings.TwitterHost = TwitterHostTextBox.Text;

                if (!AppSettings.TwitterHost.EndsWith("/"))
                {
                    AppSettings.TwitterHost += "/";
                }

                AppSettings.SmoothScrolling = (bool)SmoothScrollingCheckBox.IsChecked;

                if (AppSettings.RunAtStartup != (bool)RunAtStartupCheckBox.IsChecked)
                {
                    Shortcut.SetStartupGroupShortcut((bool)RunAtStartupCheckBox.IsChecked);
                    AppSettings.RunAtStartup = (bool)RunAtStartupCheckBox.IsChecked;
                }

                AppSettings.UseProxy      = (bool)UseProxyCheckBox.IsChecked;
                AppSettings.ProxyServer   = ProxyServerTextBox.Text;
                AppSettings.ProxyPort     = int.Parse(ProxyPortTextBox.Text);
                AppSettings.ProxyUsername = ProxyUsernameTextBox.Text;
                AppSettings.ProxyPassword = "******" + EncryptString(ProxyPasswordTextBox.Password);

                AppSettings.MaximumIndividualAlerts = MaxIndTextBlock.Text;
                AppSettings.NotificationDisplayTime = NotificationDisplayTimeTextBlock.Text;
                AppSettings.AlertSelectedOnly       = (bool)AlertSelectedOnlyCheckBox.IsChecked;
                AppSettings.FilterRegex             = FilterRegex.Text;
                AppSettings.HighlightRegex          = HightlightRegex.Text;

                if (!string.IsNullOrEmpty(RetweetComboBox.Text))
                {
                    AppSettings.RetweetPrefix = RetweetComboBox.Text;
                }

                if (!string.IsNullOrEmpty(ReplyComboBox.Text))
                {
                    AppSettings.ReplyPrefix = ReplyComboBox.Text;
                }

                int setting;
                if (int.TryParse(((ComboBox)KeepLatestComboBox).Text, out setting))
                {
                    AppSettings.KeepLatest = setting;
                }
                else
                {
                    AppSettings.KeepLatest = 0;
                }

                AppSettings.Save();

                // Set (unset?) the default proxy here once and for all (should then be
                // used by WPF controls, like images that fetch their source from the
                // internet)
                HttpWebRequest.DefaultWebProxy = WebProxyHelper.GetConfiguredWebProxy();

                DialogResult = true;
                this.Close();
            }
        }