//The selections under file in the menubar. private void menu_File(object sender, RoutedEventArgs e) { var menuitem = sender as MenuItem; if (menuitem.Header.Equals("_Save")) { Save(); } else if (menuitem.Header.Equals("_Save As")) { SaveAs(); } else if (menuitem.Header.Equals("_New")) { stackPanel.Children.Clear(); Ticket = new TicketClass(); DisableButtons(); AddDummyText(); TicketChanged = true; } else if (menuitem.Header.Equals("_Print")) { SaveTicket(); TicketManager.GetXml(Ticket); if (MainWindowInstance.Printer.Address != null) { HttpRequestAdapter.sendHttpPost(Ticket.Xml, MainWindowInstance.Printer); } else MainWindowInstance.showDeviceList(); } else if (menuitem.Header.Equals("_Close")) { if (TicketChanged) { PromptView Prompt = new PromptView(this); Prompt.Show(); } else this.Close(); } }
//Logic for closing the view when we are done, prompts if changes have been made. private void view_Closing(object sender, CancelEventArgs e) { if (TicketChanged) { PromptView Prompt = new PromptView(this); Prompt.Show(); e.Cancel = true; } else { e.Cancel = false; } MainWindowInstance.RefreshTicketList(); }