private void Dock_MouseDown(object sender, MouseButtonEventArgs e) // clicked some date on the calendar { #region Changing selected element on the calendar DockPanel d = (DockPanel)sender; for (int j = 1; j < 7; j++) { for (int i = start; i < 7; i++) { if (dock[j, i] != null) { dock[j, i].Background = Brushes.White; } } } d.Background = Brushes.LightGray; #endregion #region Ovveride all label, table ect Label label = (Label)d.Children[0]; DateTime dt = new DateTime(CurrentYear, CurrentMonth, Convert.ToInt32(label.Content)); Date_label.Content = dt.ToShortDateString(); DataWorking.GetData(out list_note, "data.xml"); TableWorking.FillTable(Date_label, list_note, dataGrid); #endregion #region Loading diary try { Diary.Load(richTextBox, Date_label); } catch (Exception ex) { richTextBox.Document.Blocks.Clear(); } #endregion }
private void Button_Click_1(object sender, RoutedEventArgs e) { bool name = true; bool email = true; try { MailAddress m = new MailAddress(textBox2.Text); if (textBox3.Password == textBox4.Password) { User user = new User(); user.email = textBox2.Text; user.name = textBox1.Text; user.password = Sha_512.GetHash(textBox3.Password); user.islocal = (bool)radioButton1.IsChecked; DataWorking.GetData(out user_list, "users.xml"); for (int i = 0; i < user_list.Count; i++) { if (user_list[i].name == user.name) { name = false; } if (user_list[i].email == user.email) { email = false; } } if (name == true && email == true) { user_list.Add(user); DataWorking.WriteData(user_list, "users.xml"); MessageBox.Show("Учетная запись была создана"); } if (name == false) { MessageBox.Show("Это имя уже занято"); } if (email == false) { MessageBox.Show("Этот email уже занят"); } } else { MessageBox.Show("Пароли не совпадают"); } } catch { MessageBox.Show("Некорректный email."); } }
}// добавляем заметку public static void Delete(List <Note> list_note, Label label2, DataGrid dataGridView1, Note Selected_Note) { Note note = new Note(); DateTime dt; DateTime.TryParse(Selected_Note.date.ToString(), out dt); note.date = dt; note.text = Selected_Note.text; DataWorking.GetData(out list_note, "data.xml"); list_note.Remove(note); // удаляем из списка File.WriteAllText("data.xml", string.Empty); // очищаем файл DataWorking.WriteData(list_note, "data.xml"); TableWorking.FillTable(label2, list_note, dataGridView1); } //удаляем заметку
public static void Add(List <Note> list_note, Label label2, TextBox textBox1, TextBox textBox2, DataGrid dataGrid, CheckBox checkBox1, ComboBox comboBox1) { try { Note note = new Note(); DateTime dt; DateTime.TryParse(label2.Content + " " + textBox1.Text, out dt); note.date = dt; note.text = textBox2.Text; note.state = comboBox1.Text; note.login = AuthorizationWindow.user.name; note.notify = (bool)checkBox1.IsChecked; DataWorking.GetData(out list_note, "data.xml"); list_note.Add(note);//добавляет в список DataWorking.WriteData(list_note, "data.xml"); TableWorking.RefreshTable(label2, list_note, dataGrid); } catch (Exception ex) { MessageBox.Show(ex.Message); } }// добавляем заметку
}//перезагрузить таблицу public static void time(System.ComponentModel.BackgroundWorker backgroundWorker1, List <Note> list_note) { DateTime now = DateTime.Now; backgroundWorker1.WorkerSupportsCancellation = true; while (true) { DataWorking.GetData(out list_note, "data.xml"); for (int i = 0; i < list_note.Count; i++) { if ((list_note[i].date.Day == DateTime.Now.Day) && (list_note[i].date.Hour == DateTime.Now.Hour) && (list_note[i].date.Minute == DateTime.Now.Minute) && (list_note[i].state == "В процессе") && (list_note[i].login == AuthorizationWindow.user.name) && (list_note[i].notify == true)) { backgroundWorker1.WorkerReportsProgress = true; backgroundWorker1.ReportProgress(0, list_note[i].text); break; } } Thread.Sleep(10000); } }
private void toolStripMenuItem1_Click(object sender, EventArgs e) { DataWorking.GetData(out list_note, "data.xml"); this.Show(); Note note = new Note(); DateTime dt = note.date; DateTime.TryParse(DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":00", out dt); note.date = dt; note.text = message; note.notify = true; note.state = "В процессе"; note.login = AuthorizationWindow.user.name; list_note.Remove(note);// удаляем из списка note.state = "Завершено"; note.notify = false; list_note.Add(note); File.WriteAllText("data.xml", string.Empty);// очищаем файл DataWorking.WriteData(list_note, "data.xml"); TableWorking.RefreshTable(Date_label, list_note, dataGrid); }
public static void Local_Authorize(out List <User> user_list, User user) { bool a = false; DataWorking.GetData(out user_list, "users.xml"); for (int i = 0; i < user_list.Count; i++) { if ((user_list[i].name == user.name) && (user_list[i].password == user.password)) { a = true; MessageBox.Show("Выполнен успешный вход"); MainWindow f = new Orginizer.MainWindow(); f.Show(); break; } } if (a == false) { MessageBox.Show("Неверный логин или пароль."); } }
public MainWindow() { InitializeComponent(); #region Calendar initialization FillCalendar(CurrentYear, CurrentMonth); ShowDayNames(Mo, Tu, We, Th, Fr, Sa, Su); ShowMonthNamesAndCurrentYear(CurrentMonth, CurrentYear, label3); int a = (DateTime.Now.Day + start2) % 8; int b = (DateTime.Now.Day + start2) / 8 + 1; dock[b, a].Background = Brushes.LightGray; #endregion #region Task tab's item initialization Date_label.Content = DateTime.Now.ToShortDateString(); DataWorking.GetData(out list_note, "data.xml"); for (int i = 0; i < list_note.Count; i++) { if ((list_note[i].date < DateTime.Now) && (list_note[i].state == "В процессе") && (list_note[i].login == AuthorizationWindow.user.name) && (list_note[i].notify == true)) { list_note[i].state = "Не выполнено"; DataWorking.WriteData(list_note, "data.xml"); } } TableWorking.FillTable(Date_label, list_note, dataGrid); State_comboBox.Items.Add("В процессе"); State_comboBox.Items.Add("Завершено"); #endregion #region Diary tab's item initialization InstalledFontCollection ifc = new InstalledFontCollection(); System.Drawing.FontFamily[] families = ifc.Families; for (int i = 0; i < families.Length; i++) { Label lb = new Label(); lb.Content = families[i].Name; lb.FontFamily = new FontFamily(families[i].Name); comboBox1.Items.Add(lb); } comboBox1.Text = "Times New Roman"; int[] FontSizes = { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }; for (int i = 0; i < FontSizes.Length; i++) { comboBox2.Items.Add(FontSizes[i]); } comboBox2.Text = "14"; comboBox3.ItemsSource = typeof(Colors).GetProperties(); try { Diary.Load(richTextBox, Date_label); } catch (Exception ex) { richTextBox.Document.Blocks.Clear(); } #endregion #region NotifyIcon initialization System.Drawing.Icon icon = new System.Drawing.Icon(@"G:\Orinizer_WPF_Project\Orginizer\Orginizer\Images\calendar.ico"); notifyIcon1.Icon = icon; notifyIcon1.Visible = true; notifyIcon1.BalloonTipClicked += new System.EventHandler(notifyIcon1_BalloonTipClicked); #endregion #region BackgroundWorker initialization backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(backgroundWorker1_DoWork); backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(backgroundWorker1_ProgressChanged); backgroundWorker1.RunWorkerAsync(); #endregion contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem1, toolStripMenuItem2 }); contextMenuStrip1.Visible = true; contextMenuStrip1.Size = new System.Drawing.Size(138, 48); toolStripMenuItem1.Text = "Завершено"; toolStripMenuItem1.Click += new System.EventHandler(toolStripMenuItem1_Click); contextMenuStrip1.Size = new System.Drawing.Size(138, 48); toolStripMenuItem2.Text = "Отложить"; toolStripMenuItem2.Click += new System.EventHandler(toolStripMenuItem2_Click); toolStripMenuItem2.Size = new System.Drawing.Size(137, 22); }
public static void RefreshTable(Label label2, List <Note> list_note, DataGrid dataGridView1) { DataWorking.GetData(out list_note, "data.xml"); TableWorking.FillTable(label2, list_note, dataGridView1); }//перезагрузить таблицу