// Load from *.cuo file (in calc) private void Load() { if (dataToSave) { string text = "Load file? \n" + "Any unsaved changes will be lost."; MessageBoxReturn.SetStrings(text, "OK", "Cancel"); CustomMessageBox customMessageBox = new CustomMessageBox(); customMessageBox.ShowDialog(); if (!MessageBoxReturn.Return) { return; } } // Load file using FileDialog. OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Cutting Optimizer File (*.cuo)|*.cuo"; if (openFileDialog.ShowDialog() == true) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read); calc = (Calc)formatter.Deserialize(stream); ShowOnCanvas(); UpdateTextboxes(); infobox.Text = "Loaded."; } }
// Click Close Button private void ClickClose(object sender, RoutedEventArgs e) { MessageBoxReturn.SetStrings("Close?", "OK", "Cancel"); CustomMessageBox customMessageBox = new CustomMessageBox(); customMessageBox.ShowDialog(); if (MessageBoxReturn.Return) { this.Close(); } }
// Close-Event to ask if changes should be saved private void CloseWindow(object sender, CancelEventArgs e) { if (dataToSave) { MessageBoxReturn.SetStrings("Save before Exit?", "Yes", "No"); CustomMessageBox customMessageBox = new CustomMessageBox(); customMessageBox.ShowDialog(); if (MessageBoxReturn.Return) { Save(); } } }
// Delete all Boards from list. // Open OK-Cancel Messagebox before. private void ClickDelAllBoards(object sender, RoutedEventArgs e) { // Return when ne elements in list. if (Board_List.Count == 0) { return; } MessageBoxReturn.SetStrings("Remove all boards?", "OK", "Cancel"); CustomMessageBox customMessageBox = new CustomMessageBox(); customMessageBox.ShowDialog(); if (MessageBoxReturn.Return) { Board_List.Clear(); } }
private void ClickSave(object sender, RoutedEventArgs e) { try { Options.MaxStage = Int32.Parse(box.Text); } catch { } if (Options.MaxStage >= 10000) { MessageBoxReturn.SetStrings("More Recursion Steps as recommended.\n" + "Continue?", "OK", "Cancel"); CustomMessageBox customMessageBox = new CustomMessageBox(); customMessageBox.Width += 50; customMessageBox.MinWidth += 50; customMessageBox.MaxWidth += 50; customMessageBox.Button1.Width += 25; customMessageBox.Button2.Width += 25; customMessageBox.ShowDialog(); if (!MessageBoxReturn.Return) { return; } } Options.ShowParttables = (showTablesbox.IsChecked == true); Options.ShowPrices = (showPricesbox.IsChecked == true); Options.SumParts = (sumPartsbox.IsChecked == true); Options.SumBoards = (sumBoardsbox.IsChecked == true); Options.Shift = (shiftbox.IsChecked == true); switch (closeHolesBox.SelectedIndex) { case 0: Options.CloseHolesEvery = true; Options.CloseHolesEnd = false; break; case 1: Options.CloseHolesEvery = false; Options.CloseHolesEnd = true; break; case 2: Options.CloseHolesEvery = false; Options.CloseHolesEnd = false; break; } Options.SimpleMode = (simplebox.IsChecked == true); Options.SortParts = (sortPartsbox.IsChecked == true); bool run = true; while (run) { try { using (StreamWriter sw = new StreamWriter("c:/Cutting_Optimizer_Options/Options.txt")) { sw.WriteLine(box.Text); char c = (Options.ShowParttables) ? '1' : '0'; sw.WriteLine(c); c = (Options.ShowPrices) ? '1' : '0'; sw.WriteLine(c); c = (Options.SumParts) ? '1' : '0'; sw.WriteLine(c); c = (Options.SumBoards) ? '1' : '0'; sw.WriteLine(c); c = (Options.Shift) ? '1' : '0'; sw.WriteLine(c); c = (Options.CloseHolesEvery) ? '1' : '0'; sw.WriteLine(c); c = (Options.CloseHolesEnd) ? '1' : '0'; sw.WriteLine(c); c = (Options.SimpleMode) ? '1' : '0'; sw.WriteLine(c); c = (Options.SortParts) ? '1' : '0'; sw.WriteLine(c); } run = false; } catch { string text = "Can't save options to file.\n" + "Please create empty folder:\n\n" + "c:/Cutting_Optimizer_Options"; MessageBoxReturn.SetStrings(text, "Try again", "Close without \n" + "saving to file."); CustomMessageBox customMessageBox = new CustomMessageBox(); customMessageBox.Height += 50; customMessageBox.Width += 30; customMessageBox.MinHeight += 50; customMessageBox.MinWidth += 30; customMessageBox.MaxHeight += 50; customMessageBox.MaxWidth += 30; customMessageBox.Button1.Width += 18; customMessageBox.Button2.Width += 18; customMessageBox.Button2.Height *= 2; customMessageBox.stackPanel.Height += 50; customMessageBox.border.Height += 30; customMessageBox.ShowDialog(); if (!MessageBoxReturn.Return) { run = false; } } } this.Close(); }