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); }
public Options() { this.InitializeComponent(); AlertSelectedOnlyCheckBox.IsChecked = AppSettings.AlertSelectedOnly; twitter = new TwitterNet(AppSettings.Username, TwitterNet.DecryptString(AppSettings.Password)); LayoutRoot.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new NoArgDelegate(BindFriendsDropDown)); #region Initialize Options UsernameTextBox.Text = AppSettings.Username; PasswordTextBox.Password = AppSettings.Password; TwitterHostTextBox.Text = AppSettings.TwitterHost; RefreshComboBox.Items.Add(1); RefreshComboBox.Items.Add(2); RefreshComboBox.Items.Add(5); RefreshComboBox.Items.Add(10); RefreshComboBox.Items.Add(15); RefreshComboBox.Items.Add(20); RefreshComboBox.Items.Add(30); RefreshComboBox.Items.Add(60); if (!string.IsNullOrEmpty(AppSettings.RefreshInterval)) { Double refreshInterval = Double.Parse(AppSettings.RefreshInterval); if (refreshInterval < 1) { refreshInterval = 1; //Previously the options screen allowed setting to 0 } RefreshComboBox.Text = refreshInterval.ToString(); } RetweetComboBox.Items.Add("RT"); RetweetComboBox.Items.Add("Retweet"); RetweetComboBox.Items.Add("\u267A"); RetweetComboBox.Items.Add("\u00BB"); if (!string.IsNullOrEmpty(AppSettings.RetweetPrefix)) { RetweetComboBox.Text = AppSettings.RetweetPrefix; } ReplyComboBox.Items.Add("r"); ReplyComboBox.Items.Add("-"); ReplyComboBox.Items.Add("."); ReplyComboBox.Items.Add(">"); ReplyComboBox.Items.Add("\u00BB"); if (!string.IsNullOrEmpty(AppSettings.ReplyPrefix)) { ReplyComboBox.Text = AppSettings.ReplyPrefix; } isInitializing = true; SkinsComboBox.ItemsSource = SkinsManager.GetSkins(); // select the current skin if (!string.IsNullOrEmpty(AppSettings.Skin)) { SkinsComboBox.SelectedItem = AppSettings.Skin; } UrlServiceComboBox.ItemsSource = Enum.GetValues(typeof(TwitterLib.ShorteningService)); if (!string.IsNullOrEmpty(AppSettings.UrlShorteningService)) { UrlServiceComboBox.Text = AppSettings.UrlShorteningService; } else { UrlServiceComboBox.Text = TwitterLib.ShorteningService.TinyUrl.ToString(); } // select number of tweets to keep KeepLatestComboBox.Text = AppSettings.KeepLatest.ToString(); isInitializing = false; AlwaysOnTopCheckBox.IsChecked = AppSettings.AlwaysOnTop; PlaySounds = AppSettings.PlaySounds; MinimizeToTray = AppSettings.MinimizeToTray; MinimizeOnClose = AppSettings.MinimizeOnClose; PersistLogin = AppSettings.PersistLogin; SmoothScrollingCheckBox.IsChecked = AppSettings.SmoothScrolling; RunAtStartupCheckBox.IsChecked = AppSettings.RunAtStartup; UseProxyCheckBox.IsChecked = AppSettings.UseProxy; ProxyServerTextBox.Text = AppSettings.ProxyServer; ProxyPortTextBox.Text = AppSettings.ProxyPort.ToString(); ProxyUsernameTextBox.Text = AppSettings.ProxyUsername; FilterRegex.Text = AppSettings.FilterRegex; HightlightRegex.Text = AppSettings.HighlightRegex; #endregion // JMF: Thinking about the user experience here, rolling out something that // may very well invalidate their stored settings. I'll just flag // values that are now encrypted with a prefix when saved to the AppSetting. if (!AppSettings.ProxyPassword.StartsWith("WittyEncrypted:")) { ProxyPasswordTextBox.Password = AppSettings.ProxyPassword; } else { ProxyPasswordTextBox.Password = DecryptString(AppSettings.ProxyPassword); } ToggleProxyFieldsEnabled(AppSettings.UseProxy); if (!string.IsNullOrEmpty(AppSettings.MaximumIndividualAlerts)) { MaxIndSlider.Value = Double.Parse(AppSettings.MaximumIndividualAlerts); } DisplayNotificationsCheckBox.IsChecked = AppSettings.DisplayNotifications; if (!string.IsNullOrEmpty(AppSettings.NotificationDisplayTime)) { NotificationDisplayTimeSlider.Value = Double.Parse(AppSettings.NotificationDisplayTime); } //TODO:Figure out how to get auto-start working with ClickOnce and Vista //Until then, don't show the auto-start option if (Environment.OSVersion.Version.Major > 5 && ClickOnce.Utils.IsApplicationNetworkDeployed) { RunAtStartupCheckBox.Visibility = Visibility.Collapsed; } }