{
try
if (listView1.SelectedItems.Count < 1) return;
if (MessageBox.Show("Ви впевнені, що хочете видалити запис,його потім не відновиш?", "Попередження", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return;
string id = listView1.SelectedItems[0].Name.Replace("Item", "");
var item = (from q in Variables.xDocument.Descendants("Item")
where q.Attribute("UserID").Value == Variables.CurrentUserID && q.Attribute("ID").Value == id
select q).First();
item.Remove();
TripleDES.EncryptToFile(Variables.xDocument.ToString(SaveOptions.DisableFormatting), Variables.DBFile, TripleDES.ByteKey, TripleDES.IV);
//Variables.xDocument.Save("debug.xml");
LoadPhoneBookItems();
int contactsNumbers = Variables.xDocument.Descendants("Item").Where(q => q.Attribute("UserID").Value == Variables.CurrentUserID).Count();
this.Text = Variables.Caption + Variables.CurrentUserName + ": " + contactsNumbers.ToString() + " Contacts";
}
catch (Exception ex)
StackFrame file_info = new StackFrame(true);
Messages.error(ref file_info, ex.Message, this);
#endregion
#region Menu Strip Events
#region Settings
void rightToLeftToolStripMenuItem_Click(object sender, EventArgs e)
rightToLeftToolStripMenuItem.Checked = true;
leftToRightToolStripMenuItem.Checked = false;
textBoxSearch.RightToLeft = RightToLeft.Yes;
listView1.RightToLeft = RightToLeft.Yes;
var query = (from q in Variables.xDocument.Descendants("Setting")
where q.Attribute("UserID").Value == Variables.CurrentUserID
query.Attribute("RightToLeft").Value = "Yes";
catch { }
void leftToRightToolStripMenuItem_Click(object sender, EventArgs e)
leftToRightToolStripMenuItem.Checked = true;
rightToLeftToolStripMenuItem.Checked = false;
textBoxSearch.RightToLeft = RightToLeft.No;
listView1.RightToLeft = RightToLeft.No;
query.Attribute("RightToLeft").Value = "NO";
void toolStripMenuItemFontSize_Click(object sender, EventArgs e)
toolStripMenuItemFontSize8.Checked = toolStripMenuItemFontSize10.Checked = toolStripMenuItemFontSize12.Checked = toolStripMenuItemFontSize14.Checked = toolStripMenuItemFontSize16.Checked = toolStripMenuItemFontSize18.Checked = false;
ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
menuItem.Checked = true;
this.FontSize = float.Parse(menuItem.Text.Trim());
if (this.Font.Size!= this.FontSize)
this.Font = new Font(this.Font.Name, this.FontSize, this.Font.Style, this.Font.Unit, this.Font.GdiCharSet, this.Font.GdiVerticalFont);
query.Attribute("FontSize").Value = this.FontSize.ToString();
void christianToolStripMenuItem_Click(object sender, EventArgs e)
christianToolStripMenuItem.Checked = true;
persianToolStripMenuItem.Checked = false;
query.Attribute("Dates").Value = "Christian";
void persianToolStripMenuItem_Click(object sender, EventArgs e)
christianToolStripMenuItem.Checked = false;
persianToolStripMenuItem.Checked = true;
query.Attribute("Dates").Value = "Persian";
void exitToolStripMenuItem_Click(object sender, EventArgs e)
this.Close();
void newUserToolStripMenuItem_Click(object sender, EventArgs e)
UserForm newUserForm = new UserForm(true, false, false);
newUserForm.Font = new Font(this.Font.Name, this.FontSize, this.Font.Style, this.Font.Unit, this.Font.GdiCharSet, this.Font.GdiVerticalFont);
newUserForm.ShowDialog();
ApplySettings();
if (Variables.CurrentUserName!= "" && Variables.CurrentUserID!= "")
DisableEnableControls(true);
else
DisableEnableControls(false);
void changeUserToolStripMenuItem_Click(object sender, EventArgs e)
UserForm userForm = new UserForm(false, true, false);
userForm.Font = new Font(this.Font.Name, this.FontSize, this.Font.Style, this.Font.Unit, this.Font.GdiCharSet, this.Font.GdiVerticalFont);
userForm.ShowDialog();
void changeInfoToolStripMenuItem_Click(object sender, EventArgs e)
UserForm changeInfoForm = new UserForm(false, false, true);
changeInfoForm.Font = new Font(this.Font.Name, this.FontSize, this.Font.Style, this.Font.Unit, this.Font.GdiCharSet, this.Font.GdiVerticalFont);
var userElement = from q in Variables.xDocument.Descendants("User")
where q.Attribute("ID").Value == Variables.CurrentUserID
select q;
string username = userElement.First().Attribute("UserName").Value;
string email = userElement.First().Attribute("Email").Value;
changeInfoForm.textBoxUsername.Text = username;
changeInfoForm.textBoxEmail.Text = email;
changeInfoForm.ShowDialog();
Страницы: 1, 2, 3, 4, 5, 6, 7, 8