In Twitter accounts using listbox instead of listview to make sure selection never becomes unselected

This commit is contained in:
Jaex 2015-09-02 18:41:02 +03:00
parent 2d2f1d6b77
commit fe59867930
5 changed files with 5687 additions and 1127 deletions

View file

@ -37,8 +37,6 @@ private void InitializeComponent()
this.tpOtherUploaders = new System.Windows.Forms.TabPage();
this.tcOtherUploaders = new System.Windows.Forms.TabControl();
this.tpTwitter = new System.Windows.Forms.TabPage();
this.lvTwitterAccounts = new ShareX.HelpersLib.MyListView();
this.chTwitterAccount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.lblTwitterDefaultMessage = new System.Windows.Forms.Label();
this.txtTwitterDefaultMessage = new System.Windows.Forms.TextBox();
this.cbTwitterSkipMessageBox = new System.Windows.Forms.CheckBox();
@ -452,6 +450,7 @@ private void InitializeComponent()
this.lblWidthHint = new System.Windows.Forms.Label();
this.ttlvMain = new ShareX.HelpersLib.TabToListView();
this.actRapidShareAccountType = new ShareX.UploadersLib.AccountTypeControl();
this.lbTwitterAccounts = new System.Windows.Forms.ListBox();
this.tpOtherUploaders.SuspendLayout();
this.tcOtherUploaders.SuspendLayout();
this.tpTwitter.SuspendLayout();
@ -569,7 +568,7 @@ private void InitializeComponent()
//
// tpTwitter
//
this.tpTwitter.Controls.Add(this.lvTwitterAccounts);
this.tpTwitter.Controls.Add(this.lbTwitterAccounts);
this.tpTwitter.Controls.Add(this.lblTwitterDefaultMessage);
this.tpTwitter.Controls.Add(this.txtTwitterDefaultMessage);
this.tpTwitter.Controls.Add(this.cbTwitterSkipMessageBox);
@ -582,26 +581,6 @@ private void InitializeComponent()
this.tpTwitter.Name = "tpTwitter";
this.tpTwitter.UseVisualStyleBackColor = true;
//
// lvTwitterAccounts
//
this.lvTwitterAccounts.AutoFillColumn = true;
this.lvTwitterAccounts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chTwitterAccount});
this.lvTwitterAccounts.DisableDeselect = true;
this.lvTwitterAccounts.FullRowSelect = true;
this.lvTwitterAccounts.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.lvTwitterAccounts.HideSelection = false;
resources.ApplyResources(this.lvTwitterAccounts, "lvTwitterAccounts");
this.lvTwitterAccounts.MultiSelect = false;
this.lvTwitterAccounts.Name = "lvTwitterAccounts";
this.lvTwitterAccounts.UseCompatibleStateImageBehavior = false;
this.lvTwitterAccounts.View = System.Windows.Forms.View.Details;
this.lvTwitterAccounts.SelectedIndexChanged += new System.EventHandler(this.lvTwitterAccounts_SelectedIndexChanged);
//
// chTwitterAccount
//
resources.ApplyResources(this.chTwitterAccount, "chTwitterAccount");
//
// lblTwitterDefaultMessage
//
resources.ApplyResources(this.lblTwitterDefaultMessage, "lblTwitterDefaultMessage");
@ -3594,6 +3573,13 @@ private void InitializeComponent()
this.actRapidShareAccountType.Name = "actRapidShareAccountType";
this.actRapidShareAccountType.SelectedAccountType = ShareX.UploadersLib.AccountType.Anonymous;
//
// lbTwitterAccounts
//
this.lbTwitterAccounts.FormattingEnabled = true;
resources.ApplyResources(this.lbTwitterAccounts, "lbTwitterAccounts");
this.lbTwitterAccounts.Name = "lbTwitterAccounts";
this.lbTwitterAccounts.SelectedIndexChanged += new System.EventHandler(this.lbTwitterAccounts_SelectedIndexChanged);
//
// UploadersConfigForm
//
resources.ApplyResources(this, "$this");
@ -4122,8 +4108,6 @@ private void InitializeComponent()
private System.Windows.Forms.Label lblTwitterDefaultMessage;
private System.Windows.Forms.TextBox txtTwitterDefaultMessage;
private System.Windows.Forms.CheckBox cbTwitterSkipMessageBox;
private HelpersLib.MyListView lvTwitterAccounts;
private System.Windows.Forms.ColumnHeader chTwitterAccount;
private System.Windows.Forms.Label lblCustomUploaderRegexTip;
private System.Windows.Forms.TabPage tpUp1;
private System.Windows.Forms.TextBox txtUp1Key;
@ -4149,5 +4133,6 @@ private void InitializeComponent()
private System.Windows.Forms.TextBox txtPolrAPIHostname;
private System.Windows.Forms.Label lblPolrAPIHostname;
private System.Windows.Forms.CheckBox cbImgurUseGIFV;
private System.Windows.Forms.ListBox lbTwitterAccounts;
}
}

View file

@ -618,14 +618,14 @@ public void LoadSettings()
// Twitter
lvTwitterAccounts.Items.Clear();
lbTwitterAccounts.Items.Clear();
foreach (OAuthInfo twitterOAuth in Config.TwitterOAuthInfoList)
{
lvTwitterAccounts.Items.Add(twitterOAuth.Description);
lbTwitterAccounts.Items.Add(twitterOAuth.Description);
}
lvTwitterAccounts.Select(Config.TwitterSelectedAccount);
lbTwitterAccounts.SelectedIndex = Config.TwitterSelectedAccount;
TwitterUpdateSelected();
@ -2229,31 +2229,31 @@ private void btnTwitterAdd_Click(object sender, EventArgs e)
{
OAuthInfo oauth = new OAuthInfo();
Config.TwitterOAuthInfoList.Add(oauth);
lvTwitterAccounts.Items.Add(oauth.Description);
lvTwitterAccounts.SelectLast();
lbTwitterAccounts.Items.Add(oauth.Description);
lbTwitterAccounts.SelectedIndex = lbTwitterAccounts.Items.Count - 1;
TwitterUpdateSelected();
}
private void btnTwitterRemove_Click(object sender, EventArgs e)
{
int selected = lvTwitterAccounts.SelectedIndex;
int selected = lbTwitterAccounts.SelectedIndex;
if (selected > -1)
{
lvTwitterAccounts.Items.RemoveAt(selected);
lbTwitterAccounts.Items.RemoveAt(selected);
Config.TwitterOAuthInfoList.RemoveAt(selected);
if (lvTwitterAccounts.Items.Count > 0)
if (lbTwitterAccounts.Items.Count > 0)
{
lvTwitterAccounts.SelectedIndex = selected >= lvTwitterAccounts.Items.Count ? lvTwitterAccounts.Items.Count - 1 : selected;
lbTwitterAccounts.SelectedIndex = selected >= lbTwitterAccounts.Items.Count ? lbTwitterAccounts.Items.Count - 1 : selected;
}
}
TwitterUpdateSelected();
}
private void lvTwitterAccounts_SelectedIndexChanged(object sender, EventArgs e)
private void lbTwitterAccounts_SelectedIndexChanged(object sender, EventArgs e)
{
TwitterUpdateSelected();
}
@ -2265,7 +2265,7 @@ private void txtTwitterDescription_TextChanged(object sender, EventArgs e)
if (oauth != null)
{
oauth.Description = txtTwitterDescription.Text;
lvTwitterAccounts.SelectedItems[0].Text = oauth.Description;
lbTwitterAccounts.SelectedItem = oauth.Description;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1470,7 +1470,7 @@ private bool CheckTwitterAccounts()
private bool TwitterUpdateSelected()
{
Config.TwitterSelectedAccount = lvTwitterAccounts.SelectedIndex;
Config.TwitterSelectedAccount = lbTwitterAccounts.SelectedIndex;
if (Config.TwitterSelectedAccount > -1)
{

View file

@ -105,11 +105,6 @@ public static bool CheckOAuth(OAuthInfo oauth)
&& !string.IsNullOrEmpty(oauth.UserToken) && !string.IsNullOrEmpty(oauth.UserSecret);
}
public override string ToString()
{
return Description;
}
public OAuthInfo Clone()
{
return MemberwiseClone() as OAuthInfo;
@ -119,5 +114,10 @@ object ICloneable.Clone()
{
return Clone();
}
public override string ToString()
{
return Description;
}
}
}