public partial class AppendSettingDialog : OTBaseForm
{
private static AppendSettingDialog _instance = new AppendSettingDialog();
- private Twitter tw;
- private ProxyType _MyProxyType;
+ internal Twitter tw;
private bool _ValidationError = false;
- private MyCommon.EVENTTYPE _MyEventNotifyFlag;
- private MyCommon.EVENTTYPE _isMyEventNotifyFlag;
- private string _MyTranslateLanguage;
-
- public bool EnableImgAzyobuziNet { get; set; }
- public bool ImgAzyobuziNetDisabledInDM { get; set; }
- public MapProvider MapThumbnailProvider;
- public int MapThumbnailHeight;
- public int MapThumbnailWidth;
- public int MapThumbnailZoom;
- public List<UserAccount> UserAccounts;
+
private long? InitialUserId;
- public bool IsRemoveSameEvent;
public TwitterConfiguration TwitterConfiguration = TwitterConfiguration.DefaultConfiguration();
public void LoadConfig(SettingCommon settingCommon, SettingLocal settingLocal)
{
+ this.BasedPanel.LoadConfig(settingCommon);
this.GetPeriodPanel.LoadConfig(settingCommon);
this.StartupPanel.LoadConfig(settingCommon);
this.TweetPrvPanel.LoadConfig(settingCommon);
this.FontPanel2.LoadConfig(settingLocal);
this.PreviewPanel.LoadConfig(settingCommon);
this.GetCountPanel.LoadConfig(settingCommon);
+ this.ShortUrlPanel.LoadConfig(settingCommon);
+ this.ProxyPanel.LoadConfig(settingLocal);
+ this.CooperatePanel.LoadConfig(settingCommon);
+ this.ConnectionPanel.LoadConfig(settingCommon);
+ this.NotifyPanel.LoadConfig(settingCommon);
+
+ var activeUser = settingCommon.UserAccounts.FirstOrDefault(x => x.UserId == this.tw.UserId);
+ if (activeUser != null)
+ {
+ this.BasedPanel.AuthUserCombo.SelectedItem = activeUser;
+ this.InitialUserId = activeUser.UserId;
+ }
}
public void SaveConfig(SettingCommon settingCommon, SettingLocal settingLocal)
{
+ this.BasedPanel.SaveConfig(settingCommon);
this.GetPeriodPanel.SaveConfig(settingCommon);
this.StartupPanel.SaveConfig(settingCommon);
this.TweetPrvPanel.SaveConfig(settingCommon);
this.FontPanel2.SaveConfig(settingLocal);
this.PreviewPanel.SaveConfig(settingCommon);
this.GetCountPanel.SaveConfig(settingCommon);
+ this.ShortUrlPanel.SaveConfig(settingCommon);
+ this.ProxyPanel.SaveConfig(settingLocal);
+ this.CooperatePanel.SaveConfig(settingCommon);
+ this.ConnectionPanel.SaveConfig(settingCommon);
+ this.NotifyPanel.SaveConfig(settingCommon);
+
+ var userAccountIdx = this.BasedPanel.AuthUserCombo.SelectedIndex;
+ if (userAccountIdx != -1)
+ {
+ var u = settingCommon.UserAccounts[userAccountIdx];
+ this.tw.Initialize(u.Token, u.TokenSecret, u.Username, u.UserId);
+
+ if (u.UserId == 0)
+ {
+ this.tw.VerifyCredentials();
+ u.UserId = this.tw.UserId;
+ }
+ }
+ else
+ {
+ this.tw.ClearAuthInfo();
+ this.tw.Initialize("", "", "", 0);
+ }
}
private void TreeViewSetting_BeforeSelect(object sender, TreeViewCancelEventArgs e)
_ValidationError = false;
}
- this.UserAccounts.Clear();
- foreach (object u in this.BasedPanel.AuthUserCombo.Items)
- {
- this.UserAccounts.Add((UserAccount)u);
- }
- if (this.BasedPanel.AuthUserCombo.SelectedIndex > -1)
- {
- foreach (UserAccount u in this.UserAccounts)
- {
- if (u.Username.ToLower() == ((UserAccount)this.BasedPanel.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)
string ret = tw.PostFollowCommand(ApplicationSettings.FeedbackTwitterName);
}
#endif
- try
- {
- TinyUrlResolve = this.ShortUrlPanel.CheckTinyURL.Checked;
- ShortUrl.Instance.DisableExpanding = !TinyUrlResolve;
- if (this.ProxyPanel.RadioProxyNone.Checked)
- {
- _MyProxyType = ProxyType.None;
- }
- else if (this.ProxyPanel.RadioProxyIE.Checked)
- {
- _MyProxyType = ProxyType.IE;
- }
- else
- {
- _MyProxyType = ProxyType.Specified;
- }
- ProxyAddress = this.ProxyPanel.TextProxyAddress.Text.Trim();
- ProxyPort = int.Parse(this.ProxyPanel.TextProxyPort.Text.Trim());
- ProxyUser = this.ProxyPanel.TextProxyUser.Text.Trim();
- ProxyPassword = this.ProxyPanel.TextProxyPassword.Text.Trim();
- UrlConvertAuto = this.ShortUrlPanel.CheckAutoConvertUrl.Checked;
- ShortenTco = this.ShortUrlPanel.ShortenTcoCheck.Checked;
-
- Nicoms = this.CooperatePanel.CheckNicoms.Checked;
- DefaultTimeOut = int.Parse(this.ConnectionPanel.ConnectionTimeOut.Text);
- EventNotifyEnabled = this.NotifyPanel.CheckEventNotify.Checked;
- GetEventNotifyFlag(ref _MyEventNotifyFlag, ref _isMyEventNotifyFlag);
- ForceEventNotify = this.NotifyPanel.CheckForceEventNotify.Checked;
- FavEventUnread = this.NotifyPanel.CheckFavEventUnread.Checked;
- TranslateLanguage = Bing.GetLanguageEnumFromIndex(this.CooperatePanel.ComboBoxTranslateLanguage.SelectedIndex);
- EventSoundFile = (string)this.NotifyPanel.ComboBoxEventNotifySound.SelectedItem;
- AutoShortUrlFirst = (MyCommon.UrlConverter)this.ShortUrlPanel.ComboBoxAutoShortUrlFirst.SelectedIndex;
- BitlyUser = this.ShortUrlPanel.TextBitlyId.Text;
- BitlyPwd = this.ShortUrlPanel.TextBitlyPw.Text;
- TwitterApiUrl = this.ConnectionPanel.TwitterAPIText.Text.Trim();
- UserAppointUrl = this.CooperatePanel.UserAppointUrlText.Text;
- this.EnableImgAzyobuziNet = this.CooperatePanel.EnableImgAzyobuziNetCheckBox.Checked;
- this.ImgAzyobuziNetDisabledInDM = this.CooperatePanel.ImgAzyobuziNetDisabledInDMCheckBox.Checked;
- this.MapThumbnailProvider = (MapProvider)this.CooperatePanel.MapThumbnailProviderComboBox.SelectedIndex;
- this.MapThumbnailHeight = int.Parse(this.CooperatePanel.MapThumbnailHeightTextBox.Text);
- this.MapThumbnailWidth = int.Parse(this.CooperatePanel.MapThumbnailWidthTextBox.Text);
- this.MapThumbnailZoom = int.Parse(this.CooperatePanel.MapThumbnailZoomTextBox.Text);
- this.IsRemoveSameEvent = this.NotifyPanel.IsRemoveSameFavEventCheckBox.Checked;
- }
- catch(Exception)
- {
- MessageBox.Show(Properties.Resources.Save_ClickText3);
- this.DialogResult = DialogResult.Cancel;
- return;
- }
}
private void Setting_FormClosing(object sender, FormClosingEventArgs e)
{
if (MyCommon._endingFlag) return;
- if (this.DialogResult == DialogResult.Cancel)
- {
- //キャンセル時は画面表示時のアカウントに戻す
- //キャンセル時でも認証済みアカウント情報は保存する
- this.UserAccounts.Clear();
- foreach (object u in this.BasedPanel.AuthUserCombo.Items)
- {
- this.UserAccounts.Add((UserAccount)u);
- }
- //アクティブユーザーを起動時のアカウントに戻す(起動時アカウントなければ何もしない)
- bool userSet = false;
- if (this.InitialUserId != null)
- {
- foreach (UserAccount u in this.UserAccounts)
- {
- if (u.UserId == this.InitialUserId)
- {
- tw.Initialize(u.Token, u.TokenSecret, u.Username, u.UserId);
- userSet = true;
- break;
- }
- }
- }
- //認証済みアカウントが削除されていた場合、もしくは起動時アカウントがなかった場合は、
- //アクティブユーザーなしとして初期化
- if (!userSet)
- {
- tw.ClearAuthInfo();
- tw.Initialize("", "", "", 0);
- }
- }
-
if (tw != null && string.IsNullOrEmpty(tw.Username) && e.CloseReason == CloseReason.None)
{
if (MessageBox.Show(Properties.Resources.Setting_FormClosing1, "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
private void Setting_Load(object sender, EventArgs e)
{
- tw = ((TweenMain)this.Owner).TwitterInstance;
- //this.AuthStateLabel.Enabled = true;
- //this.AuthUserLabel.Enabled = true;
- this.BasedPanel.AuthClearButton.Enabled = true;
-
- //if (tw.Username == "")
- //{
- // //this.AuthStateLabel.Text = Properties.Resources.AuthorizeButton_Click4
- // //this.AuthUserLabel.Text = ""
- // //this.Save.Enabled = false
- //}
- //else
- //{
- // //this.AuthStateLabel.Text = Properties.Resources.AuthorizeButton_Click3;
- // //if (TwitterApiInfo.AccessLevel == ApiAccessLevel.ReadWrite)
- // //{
- // // this.AuthStateLabel.Text += "(xAuth)";
- // //}
- // //else if (TwitterApiInfo.AccessLevel == ApiAccessLevel.ReadWriteAndDirectMessage)
- // //{
- // // this.AuthStateLabel.Text += "(OAuth)";
- // //}
- // //this.AuthUserLabel.Text = tw.Username;
- //}
-
- this.BasedPanel.AuthUserCombo.Items.Clear();
- if (this.UserAccounts.Count > 0)
- {
- this.BasedPanel.AuthUserCombo.Items.AddRange(this.UserAccounts.ToArray());
- foreach (UserAccount u in this.UserAccounts)
- {
- if (u.UserId == tw.UserId)
- {
- this.BasedPanel.AuthUserCombo.SelectedItem = u;
- this.InitialUserId = u.UserId;
- break;
- }
- }
- }
-
- this.ShortUrlPanel.CheckTinyURL.Checked = TinyUrlResolve;
- switch (_MyProxyType)
- {
- case ProxyType.None:
- this.ProxyPanel.RadioProxyNone.Checked = true;
- break;
- case ProxyType.IE:
- this.ProxyPanel.RadioProxyIE.Checked = true;
- break;
- default:
- this.ProxyPanel.RadioProxySpecified.Checked = true;
- break;
- }
- bool chk = this.ProxyPanel.RadioProxySpecified.Checked;
- this.ProxyPanel.LabelProxyAddress.Enabled = chk;
- this.ProxyPanel.TextProxyAddress.Enabled = chk;
- this.ProxyPanel.LabelProxyPort.Enabled = chk;
- this.ProxyPanel.TextProxyPort.Enabled = chk;
- this.ProxyPanel.LabelProxyUser.Enabled = chk;
- this.ProxyPanel.TextProxyUser.Enabled = chk;
- this.ProxyPanel.LabelProxyPassword.Enabled = chk;
- this.ProxyPanel.TextProxyPassword.Enabled = chk;
-
- this.ProxyPanel.TextProxyAddress.Text = ProxyAddress;
- this.ProxyPanel.TextProxyPort.Text = ProxyPort.ToString();
- this.ProxyPanel.TextProxyUser.Text = ProxyUser;
- this.ProxyPanel.TextProxyPassword.Text = ProxyPassword;
-
- this.ShortUrlPanel.CheckAutoConvertUrl.Checked = UrlConvertAuto;
- this.ShortUrlPanel.ShortenTcoCheck.Checked = ShortenTco;
- this.ShortUrlPanel.ShortenTcoCheck.Enabled = this.ShortUrlPanel.CheckAutoConvertUrl.Checked;
-
- this.CooperatePanel.CheckNicoms.Checked = Nicoms;
- this.ConnectionPanel.ConnectionTimeOut.Text = DefaultTimeOut.ToString();
-
- ApplyEventNotifyFlag(EventNotifyEnabled, EventNotifyFlag, IsMyEventNotifyFlag);
- this.NotifyPanel.CheckForceEventNotify.Checked = ForceEventNotify;
- this.NotifyPanel.CheckFavEventUnread.Checked = FavEventUnread;
- this.CooperatePanel.ComboBoxTranslateLanguage.SelectedIndex = Bing.GetIndexFromLanguageEnum(TranslateLanguage);
- SoundFileListup();
- this.ShortUrlPanel.ComboBoxAutoShortUrlFirst.SelectedIndex = (int)AutoShortUrlFirst;
- this.ShortUrlPanel.TextBitlyId.Text = BitlyUser;
- this.ShortUrlPanel.TextBitlyPw.Text = BitlyPwd;
- this.ShortUrlPanel.TextBitlyId.Modified = false;
- this.ShortUrlPanel.TextBitlyPw.Modified = false;
- this.ConnectionPanel.TwitterAPIText.Text = TwitterApiUrl;
-
- this.CooperatePanel.UserAppointUrlText.Text = UserAppointUrl;
- this.CooperatePanel.EnableImgAzyobuziNetCheckBox.Checked = this.EnableImgAzyobuziNet;
- this.CooperatePanel.ImgAzyobuziNetDisabledInDMCheckBox.Checked = this.ImgAzyobuziNetDisabledInDM;
- this.CooperatePanel.MapThumbnailProviderComboBox.SelectedIndex = (int)this.MapThumbnailProvider;
- this.CooperatePanel.MapThumbnailHeightTextBox.Text = this.MapThumbnailHeight.ToString();
- this.CooperatePanel.MapThumbnailWidthTextBox.Text = this.MapThumbnailWidth.ToString();
- this.CooperatePanel.MapThumbnailZoomTextBox.Text = this.MapThumbnailZoom.ToString();
- this.NotifyPanel.IsRemoveSameFavEventCheckBox.Checked = this.IsRemoveSameEvent;
-
this.TreeViewSetting.Nodes["BasedNode"].Tag = BasedPanel;
this.TreeViewSetting.Nodes["BasedNode"].Nodes["PeriodNode"].Tag = GetPeriodPanel;
this.TreeViewSetting.Nodes["BasedNode"].Nodes["StartUpNode"].Tag = StartupPanel;
}
public string RecommendStatusText { get; set; }
- public bool TinyUrlResolve { get; set; }
-
- public ProxyType SelectedProxyType
- {
- get {
- return _MyProxyType;
- }
- set {
- _MyProxyType = value;
- }
- }
-
- public string ProxyAddress { get; set; }
- public int ProxyPort { get; set; }
- public string ProxyUser { get; set; }
- public string ProxyPassword { get; set; }
- public bool UrlConvertAuto { get; set; }
- public bool ShortenTco { get; set; }
- public bool Nicoms { get; set; }
- public MyCommon.UrlConverter AutoShortUrlFirst { get; set; }
- public int DefaultTimeOut { get; set; }
- public string BitlyUser { get; set; }
- public string BitlyPwd { get; set; }
- public string TwitterApiUrl { get; set; }
-
- public bool EventNotifyEnabled { get; set; }
-
- public MyCommon.EVENTTYPE EventNotifyFlag
- {
- get
- {
- return _MyEventNotifyFlag;
- }
- set
- {
- _MyEventNotifyFlag = value;
- }
- }
-
- public MyCommon.EVENTTYPE IsMyEventNotifyFlag
- {
- get
- {
- return _isMyEventNotifyFlag;
- }
- set
- {
- _isMyEventNotifyFlag = value;
- }
- }
-
- public bool ForceEventNotify { get; set; }
- public bool FavEventUnread { get; set; }
-
- public string TranslateLanguage
- {
- get
- {
- return _MyTranslateLanguage;
- }
- set
- {
- _MyTranslateLanguage = value;
- this.CooperatePanel.ComboBoxTranslateLanguage.SelectedIndex = Bing.GetIndexFromLanguageEnum(value);
- }
- }
-
- public string EventSoundFile { get; set; }
- public string UserAppointUrl { get; set; }
private bool StartAuth()
{
// ApplyEventNotifyFlag(EventNotifyEnabled, EventNotifyFlag, IsMyEventNotifyFlag);
//}
- private class EventCheckboxTblElement
- {
- public CheckBox CheckBox;
- public MyCommon.EVENTTYPE Type;
- }
-
- private EventCheckboxTblElement[] GetEventCheckboxTable()
- {
- EventCheckboxTblElement[] _eventCheckboxTable = new EventCheckboxTblElement[8];
-
- _eventCheckboxTable[0] = new EventCheckboxTblElement();
- _eventCheckboxTable[0].CheckBox = this.NotifyPanel.CheckFavoritesEvent;
- _eventCheckboxTable[0].Type = MyCommon.EVENTTYPE.Favorite;
-
- _eventCheckboxTable[1] = new EventCheckboxTblElement();
- _eventCheckboxTable[1].CheckBox = this.NotifyPanel.CheckUnfavoritesEvent;
- _eventCheckboxTable[1].Type = MyCommon.EVENTTYPE.Unfavorite;
-
- _eventCheckboxTable[2] = new EventCheckboxTblElement();
- _eventCheckboxTable[2].CheckBox = this.NotifyPanel.CheckFollowEvent;
- _eventCheckboxTable[2].Type = MyCommon.EVENTTYPE.Follow;
-
- _eventCheckboxTable[3] = new EventCheckboxTblElement();
- _eventCheckboxTable[3].CheckBox = this.NotifyPanel.CheckListMemberAddedEvent;
- _eventCheckboxTable[3].Type = MyCommon.EVENTTYPE.ListMemberAdded;
-
- _eventCheckboxTable[4] = new EventCheckboxTblElement();
- _eventCheckboxTable[4].CheckBox = this.NotifyPanel.CheckListMemberRemovedEvent;
- _eventCheckboxTable[4].Type = MyCommon.EVENTTYPE.ListMemberRemoved;
-
- _eventCheckboxTable[5] = new EventCheckboxTblElement();
- _eventCheckboxTable[5].CheckBox = this.NotifyPanel.CheckBlockEvent;
- _eventCheckboxTable[5].Type = MyCommon.EVENTTYPE.Block;
-
- _eventCheckboxTable[6] = new EventCheckboxTblElement();
- _eventCheckboxTable[6].CheckBox = this.NotifyPanel.CheckUserUpdateEvent;
- _eventCheckboxTable[6].Type = MyCommon.EVENTTYPE.UserUpdate;
-
- _eventCheckboxTable[7] = new EventCheckboxTblElement();
- _eventCheckboxTable[7].CheckBox = this.NotifyPanel.CheckListCreatedEvent;
- _eventCheckboxTable[7].Type = MyCommon.EVENTTYPE.ListCreated;
-
- return _eventCheckboxTable;
- }
-
- private void GetEventNotifyFlag(ref MyCommon.EVENTTYPE eventnotifyflag, ref MyCommon.EVENTTYPE isMyeventnotifyflag)
- {
- MyCommon.EVENTTYPE evt = MyCommon.EVENTTYPE.None;
- MyCommon.EVENTTYPE myevt = MyCommon.EVENTTYPE.None;
-
- foreach (EventCheckboxTblElement tbl in GetEventCheckboxTable())
- {
- switch (tbl.CheckBox.CheckState)
- {
- case CheckState.Checked:
- evt = evt | tbl.Type;
- myevt = myevt | tbl.Type;
- break;
- case CheckState.Indeterminate:
- evt = evt | tbl.Type;
- break;
- case CheckState.Unchecked:
- break;
- }
- }
- eventnotifyflag = evt;
- isMyeventnotifyflag = myevt;
- }
-
- private void ApplyEventNotifyFlag(bool rootEnabled, MyCommon.EVENTTYPE eventnotifyflag, MyCommon.EVENTTYPE isMyeventnotifyflag)
- {
- MyCommon.EVENTTYPE evt = eventnotifyflag;
- MyCommon.EVENTTYPE myevt = isMyeventnotifyflag;
-
- this.NotifyPanel.CheckEventNotify.Checked = rootEnabled;
-
- foreach (EventCheckboxTblElement tbl in GetEventCheckboxTable())
- {
- if ((evt & tbl.Type) != 0)
- {
- if ((myevt & tbl.Type) != 0)
- {
- tbl.CheckBox.CheckState = CheckState.Checked;
- }
- else
- {
- tbl.CheckBox.CheckState = CheckState.Indeterminate;
- }
- }
- else
- {
- tbl.CheckBox.CheckState = CheckState.Unchecked;
- }
- tbl.CheckBox.Enabled = rootEnabled;
- }
-
- }
-
- private void CheckEventNotify_CheckedChanged(object sender, EventArgs e)
- {
- foreach (EventCheckboxTblElement tbl in GetEventCheckboxTable())
- {
- tbl.CheckBox.Enabled = this.NotifyPanel.CheckEventNotify.Checked;
- }
- }
-
//private void CheckForceEventNotify_CheckedChanged(object sender, EventArgs e)
//{
// _MyForceEventNotify = CheckEventNotify.Checked;
// _MyTranslateLanguage = (new Google()).GetLanguageEnumFromIndex(ComboBoxTranslateLanguage.SelectedIndex);
//}
- private void SoundFileListup()
- {
- if (EventSoundFile == null) EventSoundFile = "";
- this.NotifyPanel.ComboBoxEventNotifySound.Items.Clear();
- this.NotifyPanel.ComboBoxEventNotifySound.Items.Add("");
- DirectoryInfo oDir = new DirectoryInfo(Application.StartupPath + Path.DirectorySeparatorChar);
- if (Directory.Exists(Path.Combine(Application.StartupPath, "Sounds")))
- {
- oDir = oDir.GetDirectories("Sounds")[0];
- }
- foreach (FileInfo oFile in oDir.GetFiles("*.wav"))
- {
- this.NotifyPanel.ComboBoxEventNotifySound.Items.Add(oFile.Name);
- }
- int idx = this.NotifyPanel.ComboBoxEventNotifySound.Items.IndexOf(EventSoundFile);
- if (idx == -1) idx = 0;
- this.NotifyPanel.ComboBoxEventNotifySound.SelectedIndex = idx;
- }
-
//private void ComboBoxEventNotifySound_VisibleChanged(object sender, EventArgs e)
//{
// SoundFileListup();
this.BasedPanel.StartAuthButton.Click += this.StartAuthButton_Click;
this.BasedPanel.CreateAccountButton.Click += this.CreateAccountButton_Click;
- this.NotifyPanel.CheckEventNotify.CheckedChanged += this.CheckEventNotify_CheckedChanged;
this.GetPeriodPanel.CheckPostAndGet.CheckedChanged += this.CheckPostAndGet_CheckedChanged;
this.ActionPanel.UReadMng.CheckedChanged += this.UReadMng_CheckedChanged;
this.FontPanel.btnUnread.Click += this.btnFontAndColor_Click;