public static void SetProxy(HttpConnection.ProxyType pType, string host, int port, string username, string password) { string proxy = null; switch (pType) { case HttpConnection.ProxyType.IE: proxy = null; break; case HttpConnection.ProxyType.None: proxy = ""; break; case HttpConnection.ProxyType.Specified: proxy = host + (port > 0 ? ":" + port.ToString() : ""); break; } RefreshProxySettings(proxy); RefreshProxyAccount(username, password); }
public static void SetProxy(HttpConnection.ProxyType pType, string host, int port, string username, string password) { string proxy = null; switch (pType) { case HttpConnection.ProxyType.IE: break; case HttpConnection.ProxyType.None: proxy = string.Empty; break; case HttpConnection.ProxyType.Specified: proxy = host + (port > 0 ? string.Format(":{0}", port) : string.Empty); break; } RefreshProxySettings(proxy); RefreshProxyAccount(username, password); }
private void Save_Click(object sender, EventArgs e) { if (MyCommon.IsNetworkAvailable() && (ComboBoxAutoShortUrlFirst.SelectedIndex == (int)MyCommon.UrlConverter.Bitly || ComboBoxAutoShortUrlFirst.SelectedIndex == (int)MyCommon.UrlConverter.Jmp)) { // bit.ly 短縮機能実装のプライバシー問題の暫定対応 // bit.ly 使用時はログインIDとAPIキーの指定を必須とする // 参照: http://sourceforge.jp/projects/opentween/lists/archive/dev/2012-January/000020.html if (string.IsNullOrEmpty(TextBitlyId.Text) || string.IsNullOrEmpty(TextBitlyPw.Text)) { MessageBox.Show("bit.ly のログイン名とAPIキーの指定は必須項目です。", Application.ProductName); _ValidationError = true; TreeViewSetting.SelectedNode = TreeViewSetting.Nodes["ConnectionNode"].Nodes["ShortUrlNode"]; // 動作タブを選択 TreeViewSetting.Select(); TextBitlyId.Focus(); return; } if (!BitlyValidation(TextBitlyId.Text, TextBitlyPw.Text)) { MessageBox.Show(Properties.Resources.SettingSave_ClickText1); _ValidationError = true; TreeViewSetting.SelectedNode = TreeViewSetting.Nodes["ConnectionNode"].Nodes["ShortUrlNode"]; // 動作タブを選択 TreeViewSetting.Select(); TextBitlyId.Focus(); return; } else { _ValidationError = false; } } else { _ValidationError = false; } this.UserAccounts.Clear(); foreach (object u in this.AuthUserCombo.Items) { this.UserAccounts.Add((UserAccount)u); } if (this.AuthUserCombo.SelectedIndex > -1) { foreach (UserAccount u in this.UserAccounts) { if (u.Username.ToLower() == ((UserAccount)this.AuthUserCombo.SelectedItem).Username.ToLower()) { tw.Initialize(u.Token, u.TokenSecret, u.Username, u.UserId); if (u.UserId == 0) { tw.VerifyCredentials(); u.UserId = tw.UserId; } break; } } } else { tw.ClearAuthInfo(); tw.Initialize("", "", "", 0); } #if UA //フォロー if (this.FollowCheckBox.Checked) { //現在の設定内容で通信 HttpConnection.ProxyType ptype; if (RadioProxyNone.Checked) { ptype = HttpConnection.ProxyType.None; } else if (RadioProxyIE.Checked) { ptype = HttpConnection.ProxyType.IE; } else { ptype = HttpConnection.ProxyType.Specified; } string padr = TextProxyAddress.Text.Trim(); int pport = int.Parse(TextProxyPort.Text.Trim()); string pusr = TextProxyUser.Text.Trim(); string ppw = TextProxyPassword.Text.Trim(); HttpConnection.InitializeConnection(20, ptype, padr, pport, pusr, ppw); string ret = tw.PostFollowCommand(ApplicationSettings.FeedbackTwitterName); } #endif IntervalChangedEventArgs arg = new IntervalChangedEventArgs(); bool isIntervalChanged = false; try { UserstreamStartup = this.StartupUserstreamCheck.Checked; if (UserstreamPeriodInt != int.Parse(UserstreamPeriod.Text)) { UserstreamPeriodInt = int.Parse(UserstreamPeriod.Text); arg.UserStream = true; isIntervalChanged = true; } if (TimelinePeriodInt != int.Parse(TimelinePeriod.Text)) { TimelinePeriodInt = int.Parse(TimelinePeriod.Text); arg.Timeline = true; isIntervalChanged = true; } if (DMPeriodInt != int.Parse(DMPeriod.Text)) { DMPeriodInt = int.Parse(DMPeriod.Text); arg.DirectMessage = true; isIntervalChanged = true; } if (PubSearchPeriodInt != int.Parse(PubSearchPeriod.Text)) { PubSearchPeriodInt = int.Parse(PubSearchPeriod.Text); arg.PublicSearch = true; isIntervalChanged = true; } if (ListsPeriodInt != int.Parse(ListsPeriod.Text)) { ListsPeriodInt = int.Parse(ListsPeriod.Text); arg.Lists = true; isIntervalChanged = true; } if (ReplyPeriodInt != int.Parse(ReplyPeriod.Text)) { ReplyPeriodInt = int.Parse(ReplyPeriod.Text); arg.Reply = true; isIntervalChanged = true; } if (UserTimelinePeriodInt != int.Parse(UserTimelinePeriod.Text)) { UserTimelinePeriodInt = int.Parse(UserTimelinePeriod.Text); arg.UserTimeline = true; isIntervalChanged = true; } if (isIntervalChanged && IntervalChanged != null) { IntervalChanged(this, arg); } Readed = StartupReaded.Checked; switch (IconSize.SelectedIndex) { case 0: IconSz = MyCommon.IconSizes.IconNone; break; case 1: IconSz = MyCommon.IconSizes.Icon16; break; case 2: IconSz = MyCommon.IconSizes.Icon24; break; case 3: IconSz = MyCommon.IconSizes.Icon48; break; case 4: IconSz = MyCommon.IconSizes.Icon48_2; break; } Status = StatusText.Text; PlaySound = PlaySnd.Checked; UnreadManage = UReadMng.Checked; OneWayLove = OneWayLv.Checked; FontUnread = lblUnread.Font; //未使用 ColorUnread = lblUnread.ForeColor; FontReaded = lblListFont.Font; //リストフォントとして使用 ColorReaded = lblListFont.ForeColor; ColorFav = lblFav.ForeColor; ColorOWL = lblOWL.ForeColor; ColorRetweet = lblRetweet.ForeColor; FontDetail = lblDetail.Font; ColorSelf = lblSelf.BackColor; ColorAtSelf = lblAtSelf.BackColor; ColorTarget = lblTarget.BackColor; ColorAtTarget = lblAtTarget.BackColor; ColorAtFromTarget = lblAtFromTarget.BackColor; ColorAtTo = lblAtTo.BackColor; ColorInputBackcolor = lblInputBackcolor.BackColor; ColorInputFont = lblInputFont.ForeColor; ColorListBackcolor = lblListBackcolor.BackColor; ColorDetailBackcolor = lblDetailBackcolor.BackColor; ColorDetail = lblDetail.ForeColor; ColorDetailLink = lblDetailLink.ForeColor; FontInputFont = lblInputFont.Font; switch (cmbNameBalloon.SelectedIndex) { case 0: NameBalloon = MyCommon.NameBalloonEnum.None; break; case 1: NameBalloon = MyCommon.NameBalloonEnum.UserID; break; case 2: NameBalloon = MyCommon.NameBalloonEnum.NickName; break; } switch (ComboBoxPostKeySelect.SelectedIndex) { case 2: PostShiftEnter = true; PostCtrlEnter = false; break; case 1: PostCtrlEnter = true; PostShiftEnter = false; break; case 0: PostCtrlEnter = false; PostShiftEnter = false; break; } CountApi = int.Parse(TextCountApi.Text); CountApiReply = int.Parse(TextCountApiReply.Text); BrowserPath = BrowserPathText.Text.Trim(); PostAndGet = CheckPostAndGet.Checked; UseRecommendStatus = CheckUseRecommendStatus.Checked; DispUsername = CheckDispUsername.Checked; CloseToExit = CheckCloseToExit.Checked; MinimizeToTray = CheckMinimizeToTray.Checked; switch (ComboDispTitle.SelectedIndex) { case 0: //None DispLatestPost = MyCommon.DispTitleEnum.None; break; case 1: //Ver DispLatestPost = MyCommon.DispTitleEnum.Ver; break; case 2: //Post DispLatestPost = MyCommon.DispTitleEnum.Post; break; case 3: //RepCount DispLatestPost = MyCommon.DispTitleEnum.UnreadRepCount; break; case 4: //AllCount DispLatestPost = MyCommon.DispTitleEnum.UnreadAllCount; break; case 5: //Rep+All DispLatestPost = MyCommon.DispTitleEnum.UnreadAllRepCount; break; case 6: //Unread/All DispLatestPost = MyCommon.DispTitleEnum.UnreadCountAllCount; break; case 7: //Count of Status/Follow/Follower DispLatestPost = MyCommon.DispTitleEnum.OwnStatus; break; } SortOrderLock = CheckSortOrderLock.Checked; ViewTabBottom = CheckViewTabBottom.Checked; TinyUrlResolve = CheckTinyURL.Checked; ShortUrlForceResolve = CheckForceResolve.Checked; ShortUrl.IsResolve = TinyUrlResolve; ShortUrl.IsForceResolve = ShortUrlForceResolve; if (RadioProxyNone.Checked) { _MyProxyType = HttpConnection.ProxyType.None; } else if (RadioProxyIE.Checked) { _MyProxyType = HttpConnection.ProxyType.IE; } else { _MyProxyType = HttpConnection.ProxyType.Specified; } ProxyAddress = TextProxyAddress.Text.Trim(); ProxyPort = int.Parse(TextProxyPort.Text.Trim()); ProxyUser = TextProxyUser.Text.Trim(); ProxyPassword = TextProxyPassword.Text.Trim(); PeriodAdjust = CheckPeriodAdjust.Checked; StartupVersion = CheckStartupVersion.Checked; StartupFollowers = CheckStartupFollowers.Checked; RestrictFavCheck = CheckFavRestrict.Checked; AlwaysTop = CheckAlwaysTop.Checked; UrlConvertAuto = CheckAutoConvertUrl.Checked; ShortenTco = ShortenTcoCheck.Checked; OutputzEnabled = CheckOutputz.Checked; OutputzKey = TextBoxOutputzKey.Text.Trim(); switch (ComboBoxOutputzUrlmode.SelectedIndex) { case 0: OutputzUrlmode = MyCommon.OutputzUrlmode.twittercom; break; case 1: OutputzUrlmode = MyCommon.OutputzUrlmode.twittercomWithUsername; break; } Nicoms = CheckNicoms.Checked; UseUnreadStyle = chkUnreadStyle.Checked; DateTimeFormat = CmbDateTimeFormat.Text; DefaultTimeOut = int.Parse(ConnectionTimeOut.Text); RetweetNoConfirm = CheckRetweetNoConfirm.Checked; LimitBalloon = CheckBalloonLimit.Checked; EventNotifyEnabled = CheckEventNotify.Checked; GetEventNotifyFlag(ref _MyEventNotifyFlag, ref _isMyEventNotifyFlag); ForceEventNotify = CheckForceEventNotify.Checked; FavEventUnread = CheckFavEventUnread.Checked; TranslateLanguage = (new Bing()).GetLanguageEnumFromIndex(ComboBoxTranslateLanguage.SelectedIndex); EventSoundFile = (string)ComboBoxEventNotifySound.SelectedItem; AutoShortUrlFirst = (MyCommon.UrlConverter)ComboBoxAutoShortUrlFirst.SelectedIndex; TabIconDisp = chkTabIconDisp.Checked; ReadOwnPost = chkReadOwnPost.Checked; GetFav = chkGetFav.Checked; IsMonospace = CheckMonospace.Checked; ReadOldPosts = CheckReadOldPosts.Checked; UseSsl = CheckUseSsl.Checked; BitlyUser = TextBitlyId.Text; BitlyPwd = TextBitlyPw.Text; ShowGrid = CheckShowGrid.Checked; UseAtIdSupplement = CheckAtIdSupple.Checked; UseHashSupplement = CheckHashSupple.Checked; PreviewEnable = CheckPreviewEnable.Checked; TwitterApiUrl = TwitterAPIText.Text.Trim(); TwitterSearchApiUrl = TwitterSearchAPIText.Text.Trim(); switch (ReplyIconStateCombo.SelectedIndex) { case 0: ReplyIconState = MyCommon.REPLY_ICONSTATE.None; break; case 1: ReplyIconState = MyCommon.REPLY_ICONSTATE.StaticIcon; break; case 2: ReplyIconState = MyCommon.REPLY_ICONSTATE.BlinkIcon; break; } switch (LanguageCombo.SelectedIndex) { case 0: Language = "OS"; break; case 1: Language = "ja"; break; case 2: Language = "en"; break; case 3: Language = "zh-CN"; break; default: Language = "en"; break; } HotkeyEnabled = this.HotkeyCheck.Checked; HotkeyMod = Keys.None; if (this.HotkeyAlt.Checked) HotkeyMod = HotkeyMod | Keys.Alt; if (this.HotkeyShift.Checked) HotkeyMod = HotkeyMod | Keys.Shift; if (this.HotkeyCtrl.Checked) HotkeyMod = HotkeyMod | Keys.Control; if (this.HotkeyWin.Checked) HotkeyMod = HotkeyMod | Keys.LWin; int.TryParse(HotkeyCode.Text, out HotkeyValue); HotkeyKey = (Keys)HotkeyText.Tag; BlinkNewMentions = ChkNewMentionsBlink.Checked; UseAdditionalCount = UseChangeGetCount.Checked; MoreCountApi = int.Parse(GetMoreTextCountApi.Text); FirstCountApi = int.Parse(FirstTextCountApi.Text); SearchCountApi = int.Parse(SearchTextCountApi.Text); FavoritesCountApi = int.Parse(FavoritesTextCountApi.Text); UserTimelineCountApi = int.Parse(UserTimelineTextCountApi.Text); ListCountApi = int.Parse(ListTextCountApi.Text); OpenUserTimeline = CheckOpenUserTimeline.Checked; ListDoubleClickAction = ListDoubleClickActionComboBox.SelectedIndex; UserAppointUrl = UserAppointUrlText.Text; this.HideDuplicatedRetweets = this.HideDuplicatedRetweetsCheck.Checked; this.IsPreviewFoursquare = this.IsPreviewFoursquareCheckBox.Checked; this.MapThumbnailProvider = (MapProvider)this.MapThumbnailProviderComboBox.SelectedIndex; this.MapThumbnailHeight = int.Parse(this.MapThumbnailHeightTextBox.Text); this.MapThumbnailWidth = int.Parse(this.MapThumbnailWidthTextBox.Text); this.MapThumbnailZoom = int.Parse(this.MapThumbnailZoomTextBox.Text); this.IsListStatusesIncludeRts = this.IsListsIncludeRtsCheckBox.Checked; this.TabMouseLock = this.TabMouseLockCheck.Checked; this.IsRemoveSameEvent = this.IsRemoveSameFavEventCheckBox.Checked; this.IsNotifyUseGrowl = this.IsNotifyUseGrowlCheckBox.Checked; } catch(Exception) { MessageBox.Show(Properties.Resources.Save_ClickText3); this.DialogResult = DialogResult.Cancel; return; } }