private void NcButtonClick(object sender, RoutedEventArgs e) { BsXncSocketServer.Document doc = new BsXncSocketServer.Document(); BppCodeTabItem item = (BppCodeTabItem)Vkladki.SelectedItem; if (item.fileName != "") { doc.ProgramSelect(item.fileName, ""); } }
private void SaveButtonCommand() { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.DefaultExt = "bpp"; string initDir = @"C:\WNC\home\d_xnc\p_p\prog\"; if (Directory.Exists(initDir)) { saveFileDialog.InitialDirectory = initDir; } if (saveFileDialog.ShowDialog() == true) { bppCodeFile = saveFileDialog.FileName; } using (StreamWriter outputFile = new StreamWriter(bppCodeFile)) { BppCodeTabItem item = (BppCodeTabItem)Vkladki.SelectedItem; outputFile.WriteLine(item.bppCode.Text); item.fileName = saveFileDialog.FileName; item.Header = System.IO.Path.GetFileName(item.fileName); } }
private void NewButtonClick(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { gcodeFile = openFileDialog.FileName; Title = gcodeFile; string gCode = ""; try { // Open the text file using a stream reader. using (var sr = new StreamReader(gcodeFile)) { // Read the stream as a string, and write the string to the console. gCode = sr.ReadToEnd(); } } catch (IOException e1) { MessageBox.Show("The file could not be read:\n" + e1.Message); } //GCode.Text = gCode; BppCodeTabItem item = new BppCodeTabItem(gCode); Vkladki.Items.Add(item); //BppCodeTabItem item = (BppCodeTabItem)Vkladki.SelectedContent; item.fileName = gcodeFile; item.Header = System.IO.Path.GetFileName(gcodeFile); PieceDialogCommand(); ToolButtonCommand(); ShiftButtonCommand(); } else { MessageBox.Show("You need choise a Gcode file!!!"); } }