private void AddNewIdentity(UserIdentity ui) { if (ui == null) { throw new ArgumentNullException("ui"); } if (string.IsNullOrEmpty(ui.Name)) { ui.Name = "New"; // SR.NewUserIdentityNameTemplate"]; } if (this.userIdentities.Contains(ui.Name)) { do { unnamedUserIdentityCounter++; } while(this.userIdentities.Contains(ui.Name + " #" + unnamedUserIdentityCounter)); ui.Name += " #" + unnamedUserIdentityCounter; } this.userIdentities.Add(ui.Name, ui); try { listAccounts.BeginUpdate(); ListViewItem newItem = listAccounts.Items.Add(new ListViewItem(ui.Name, 0)); newItem.Tag = ui.Name; newItem.Selected = true; // cause event fired } finally { listAccounts.EndUpdate(); } }
private void PopulateIdentity(string identityID) { if (identityID != null && this.userIdentities.Contains(identityID)) { UserIdentity ui = (UserIdentity)this.userIdentities[identityID]; txtIdentityName.Text = ui.Name; txtUserName.Text = (ui.RealName == null ? String.Empty: ui.RealName); txtUserOrg.Text = (ui.Organization == null ? String.Empty: ui.Organization); txtUserMail.Text = (ui.MailAddress == null ? String.Empty: ui.MailAddress); txtUserMailResponse.Text = (ui.ResponseAddress == null ? String.Empty: ui.ResponseAddress); txtRefererUrl.Text = (ui.ReferrerUrl == null ? String.Empty: ui.ReferrerUrl); txtSignature.Text = (ui.Signature == null ? String.Empty: ui.Signature); } }
private void OnDeleteItemToolActivate(object sender, EventArgs e) { if (currentView == NewsgroupSettingsView.Identity) { if (listAccounts.SelectedItems.Count > 0) { string key = (string)listAccounts.SelectedItems[0].Tag; if (key != null && this.userIdentities.Contains(key)) { UserIdentity ui = (UserIdentity)this.userIdentities[key]; this.userIdentities.Remove(key); // remove from default identities list AND assigned nntp servers: this.cboDefaultIdentities.Items.Remove(ui.Name); foreach (string serverKey in this.nntpServers.Keys) { NntpServerDefinition sd = (NntpServerDefinition)this.nntpServers[serverKey]; if (sd.DefaultIdentity == ui.Name) { sd.DefaultIdentity = String.Empty; } } this.listAccounts.Items.Remove(listAccounts.SelectedItems[0]); } } } else { if (treeServers.SelectedNode != null) { TreeNode n = null; if (treeServers.SelectedNode.Parent != null) { n = treeServers.SelectedNode.Parent; } else { n = treeServers.SelectedNode; } string key = (string)n.Tag; if (key != null && this.nntpServers.Contains(key)) { //NntpServerDefinition sd = (NntpServerDefinition)this.nntpServers[key]; this.nntpServers.Remove(key); this.treeServers.Nodes.Remove(n); } } } }
private void OnWidgetValidating(object sender, System.ComponentModel.CancelEventArgs e) { // general widget validating this.btnApply.Enabled = false; if (sender == txtIdentityName) { txtIdentityName.Text = txtIdentityName.Text.Trim(); if (txtIdentityName.Text.Length == 0) { errorProvider.SetError(txtIdentityName, "Empty value is not allowed here"); e.Cancel = true; } string myKey = (string)listAccounts.SelectedItems[0].Tag; UserIdentity me = (UserIdentity)this.userIdentities[myKey]; foreach (UserIdentity ui in this.userIdentities.Values) { if (ReferenceEquals(ui, me) == false && ui.Name.Equals(txtIdentityName.Text)) { errorProvider.SetError(txtIdentityName, "There is already a user identity defined with this name. Please use a different one."); e.Cancel = true; } } } else if (sender == txtNewsAccountName) { txtNewsAccountName.Text = txtNewsAccountName.Text.Trim(); if (txtNewsAccountName.Text.Length == 0) { errorProvider.SetError(txtNewsAccountName, "Empty value is not allowed here"); e.Cancel = true; } } if (!e.Cancel) { errorProvider.SetError((Control)sender, null); } }
public void MigrateOrMergeIdentities(List <NewsComponents.Feed.UserIdentity> oldVersionIdentities, bool replace) { if (oldVersionIdentities != null && oldVersionIdentities.Count > 0) { IdentitiesDictionary migrated = new IdentitiesDictionary(oldVersionIdentities.Count); foreach (NewsComponents.Feed.UserIdentity oldIdent in oldVersionIdentities) { UserIdentity newIdent = new UserIdentity(); newIdent.Name = oldIdent.Name; newIdent.MailAddress = oldIdent.MailAddress; newIdent.Organization = oldIdent.Organization; newIdent.RealName = oldIdent.RealName; newIdent.ReferrerUrl = oldIdent.ReferrerUrl; newIdent.ResponseAddress = oldIdent.ResponseAddress; newIdent.Signature = oldIdent.Signature; migrated.Add(newIdent.Name, newIdent); } if (replace) { Identities = migrated; } else { foreach (UserIdentity identity in migrated.Values) { if (Identities.ContainsKey(identity.Name)) { Identities[identity.Name] = identity; } else { Identities.Add(identity.Name, identity); } } } Save(); } }
private void OnWidgetValidated(object sender, System.EventArgs e) { // general widget validated. UserIdentity selectedUser = this.GetSelectedUserIdentity(); NntpServerDefinition selectedServer = this.GetSelectedNntpServerDefinition(); if (sender == this.txtIdentityName) { if (selectedUser != null) { selectedUser.Name = this.txtIdentityName.Text; } } if (sender == this.txtUserName) { if (selectedUser != null) { selectedUser.RealName = this.txtUserName.Text; } } if (sender == this.txtUserOrg) { if (selectedUser != null) { selectedUser.Organization = this.txtUserOrg.Text; } } if (sender == this.txtUserMail) { if (selectedUser != null) { selectedUser.MailAddress = this.txtUserMail.Text; } } if (sender == this.txtUserMailResponse) { if (selectedUser != null) { selectedUser.ResponseAddress = this.txtUserMailResponse.Text; } } if (sender == this.txtRefererUrl) { if (selectedUser != null) { selectedUser.ReferrerUrl = this.txtRefererUrl.Text; } } if (sender == this.txtSignature) { if (selectedUser != null) { selectedUser.Signature = this.txtSignature.Text; } } // Nntp server def. takeover if (sender == this.txtNewsAccountName) { if (selectedServer != null) { selectedServer.Name = this.txtNewsAccountName.Text; } } if (sender == this.cboDefaultIdentities) { if (selectedServer != null) { selectedServer.DefaultIdentity = this.cboDefaultIdentities.Text; } } if (sender == this.chkConsiderServerOnRefresh) { if (selectedServer != null) { selectedServer.PreventDownloadOnRefreshSpecified = (!this.chkConsiderServerOnRefresh.Checked); selectedServer.PreventDownloadOnRefresh = !this.chkConsiderServerOnRefresh.Checked; } } if (sender == this.txtNewsServerName) { if (selectedServer != null) { selectedServer.Server = this.txtNewsServerName.Text; } } if (sender == this.txtServerAuthName) { if (selectedServer != null) { selectedServer.AuthUser = this.txtServerAuthName.Text; } } if (sender == this.txtServerAuthPassword) { if (selectedServer != null) { FeedSource.SetNntpServerCredentials( selectedServer, this.txtServerAuthName.Text, txtServerAuthPassword.Text); } } if (sender == this.txtServerPort) { if (selectedServer != null) { int port = Int32.Parse(this.txtServerPort.Text); if (port > 0 && port != NntpWebRequest.NntpDefaultServerPort) { selectedServer.Port = port; selectedServer.PortSpecified = true; } else { selectedServer.PortSpecified = false; } } } if (sender == this.chkUseSSL) { if (selectedServer != null) { selectedServer.UseSSLSpecified = (this.chkUseSSL.Checked); selectedServer.UseSSL = this.chkUseSSL.Checked; } } if (sender == this.trackBarServerTimeout) { if (selectedServer != null) { selectedServer.TimeoutSpecified = false; if (trackBarServerTimeout.Value > 0) { selectedServer.TimeoutSpecified = true; selectedServer.Timeout = trackBarServerTimeout.Value; } } } this.btnApply.Enabled = true; }