//private void CloseBubbleSearch(object sender, RoutedEventArgs e) // this could be removed- always close //{ // //startColorSearch = false; // //FindListViewItem(listview); //} private void OpenOpenButton(object sender, RoutedEventArgs e) { Bubble operateBubble = (Bubble)listview.SelectedItem; if (operateBubble != null) { try { DisplayPage tempPage = new DisplayPage(); DisplayPage.dBubble = operateBubble; NavigationService.Navigate(tempPage); } catch (Exception) { try { throw new Exception("Error occured, please try againg.\nClick on details for more information."); } catch (Exception ex) { MessageBox.ShowError(ex); } //MessageBox.Show("Please try againg"); } } }
private void Cancel_Click(object sender, RoutedEventArgs e) { string pathFileXml = System.IO.Path.GetFullPath(Directory.GetCurrentDirectory() + @"\XMLFile1.xml"); try { // here grid is cleared dataGrid.ItemsSource = null; dataGrid.Items.Clear(); dataSet.Clear(); // loading to grid data from .xml file dataSet.ReadXml(@pathFileXml); DataView dataView = new DataView(dataSet.Tables[0]); dataGrid.ItemsSource = dataView; // button is disabled after erase it added row cancel_button.IsEnabled = false; MessageBox.ShowInformation("Canceled Changes!"); } catch (Exception ex) { MessageBox.ShowError(ex, "Cancel was't sucessful!"); } }
private void openButton_Click(object sender, RoutedEventArgs e) { StringNode operatedNode = (StringNode)listView1.SelectedItem; //new ListViewClass(value1, value2); if (operatedNode != null) { try { DateTime workDate = DateTime.Parse(operatedNode.Date); string workTitle = operatedNode.Title; string workDescription = operatedNode.Description; EventNode workNode = new EventNode(workDate, workTitle, workDescription); ReadingPage basicDateReadPage = new ReadingPage(); ReadingPage.workNodeTransfer = workNode; NavigationService.Navigate(basicDateReadPage); } catch (Exception) { try { throw new Exception("Error occured, please try againg.\nClick on details for more information."); } catch (Exception ex) { MessageBox.ShowError(ex); } //MessageBox.Show("Please try againg"); } } }
private void saveButton_Click(object sender, RoutedEventArgs e) { saveButton.IsEnabled = false; try { if (dataChanged) { SaveCurrentContent(); MessageBox.ShowInformation(String.Format("The schedule has been successfully saved!", titleTextBox.Text)); } } catch (Exception) { try { throw new Exception("Error occured, please try again!\nPlease check your events` dates."); } catch (Exception ex) { MessageBox.ShowError(ex); } } ShowData(); // saveButton.IsEnabled = true; }
/// <summary> /// Gets data from MyData.xml as rows. /// </summary> /// <returns></returns> public IEnumerable <object> GetRows() { List <StringNode> rows = new List <StringNode>(); if (File.Exists("MyData.xml")) { try { // Create the query var rowsFromFile = from c in XDocument.Load( "MyData.xml").Elements( "Data").Elements("Rows").Elements("Row") select c; // Execute the query foreach (var row in rowsFromFile) { rows.Add(new StringNode(row.Element("col1").Value, row.Element("col2").Value, row.Element("col3").Value)); } } catch (Exception) { try { throw new Exception("Error occured while reading the events archive.\nClick on details for more information."); } catch (Exception ex) { MessageBox.ShowError(ex); } //MessageBox.Show("Error occured while reading the events archive"); } } return(rows); }
private void ShowException_Click(object sender, RoutedEventArgs e) { try { throw new Exception("FUUUUUUUUUUUU!!!!!!!"); } catch (Exception ex) { MessageBox.ShowError(ex); } }
private void ShowData() { if (MainWindow.remindScheduler.scheduleStructure != null) { MainWindow.remindScheduler.scheduleStructure.Clear(); } MyData md = new MyData(); listView1.Items.Clear(); foreach (var row in md.GetRows()) { listView1.Items.Add(row); } if (MainWindow.mainScheduler.scheduleStructure != null && MainWindow.mainScheduler.scheduleStructure.Count > 0) { foreach (var eventNode in MainWindow.mainScheduler.scheduleStructure) { listView1.Items.Add(new StringNode(eventNode.DatetimeEvent.ToString(), eventNode.Title, eventNode.Description)); } SaveCurrentContent(); } MainWindow.mainScheduler.scheduleStructure.Clear(); foreach (var node in listView1.Items) { try { StringNode operatedNode = (StringNode)node; DateTime workDate = DateTime.Parse(operatedNode.Date); MainWindow.remindScheduler.scheduleStructure.Add(new EventNode(workDate, operatedNode.Title, operatedNode.Description)); } catch (Exception) { try { throw new Exception("The remainder may not working correctly!\nPlease check your events` dates."); } catch (Exception ex) { MessageBox.ShowError(ex); } //MessageBox.Show("The remainder may not working correctly!\nPlease check your events` dates."); } } }
private void OpenAddToSchedule(object sender, RoutedEventArgs e) { try { DateTime eventDate = DateTime.Parse(dateTextBox.Text); MainWindow.mainScheduler.Add(new EventNode(eventDate, titleTextBox.Text, descriptionTextBox.Text)); //MessageBox.Show("The event has been added successfully to the scheduler"); MessageBox.ShowInformation(String.Format("The event {0} has been added successfully to the scheduler!", titleTextBox.Text)); OpenSchedulePage(sender, e); } catch (Exception) { try { throw new Exception("The event can not be added to the scheduler.\nClick on details for more information."); } catch (Exception ex) { MessageBox.ShowError(ex); } //MessageBox.Show("The event can not be added to the scheduler due to invalid date format"); } }
private void ShowError_Click(object sender, RoutedEventArgs e) { MessageBox.ShowError("!World Hello"); }
private void Save_Click(object sender, RoutedEventArgs e) { // it is path to xml file string pathFileXml = System.IO.Path.GetFullPath(Directory.GetCurrentDirectory() + @"\XMLFile1.xml"); // it is to check empty cell, after error with save ableToSave = true; try { foreach (DataRowView row in dataGrid.Items) { if (row.Row.ItemArray[0].ToString() == "" || row.Row.ItemArray[0] == null) { ableToSave = false; break; } else if (row.Row.ItemArray[1].ToString() == "" || row.Row.ItemArray[1] == null) { ableToSave = false; break; } else if (row.Row.ItemArray[2].ToString() == "" || row.Row.ItemArray[2] == null) { ableToSave = false; break; } else if (row.Row.ItemArray[3].ToString() == "" || row.Row.ItemArray[3] == null) { ableToSave = false; break; } else if (row.Row.ItemArray[5].ToString() == "" || row.Row.ItemArray[5] == null) { ableToSave = false; break; } else if (row.Row.ItemArray[6].ToString() == "" || row.Row.ItemArray[6] == null) { ableToSave = false; break; } else if (row.Row.ItemArray[7].ToString() == "" || row.Row.ItemArray[7] == null) { ableToSave = false; break; } } } catch (Exception ex) { } try { if (ableToSave == true) { // after press Save button, grid will be saved dataSet.AcceptChanges(); dataSet.WriteXml(@pathFileXml); MessageBox.ShowInformation("Grid is saved!", "Success of save!"); } else { MessageBox.ShowError("Grid has empty cell!"); } } catch (Exception ex) { MessageBox.ShowError(ex, "It was error with exception!"); } }