예제 #1
0
        private void saveGcodeButton_Click(object sender, RoutedEventArgs e)
        {
            string  outputCode = string.Empty;
            Profile profile    = null;

            if (_hpgl.Commands.Count > 0)
            {
                if (manager.Profiles.Count == 1)
                {
                    profile = manager.Profiles[0];
                }
                else
                {
                    if (manager.Profiles.Count == 0)
                    {
                        MessageBox.Show("Please configure a new profile.");
                    }

                    ProfileWindow window = new ProfileWindow(manager, ProfileWindow.WindowMode.SelectData);
                    window.ShowDialog();

                    if (manager.Profiles.Count == 0)
                    {
                        return;
                    }

                    profile = window.SelectedProfile;
                }

                if (profile == null)
                {
                    MessageBox.Show("Error loading profile.");
                    return;
                }

                outputCode = CreateGcodeFromHpgl(_hpgl, profile);
            }
            else
            {
                MessageBox.Show("No HPGL file.");
            }

            if (outputCode.Length > 0)
            {
                string outFileName = hpglfile.Substring(hpglfile.LastIndexOf("\\") + 1);
                var    fileDialog  = new Microsoft.Win32.SaveFileDialog()
                {
                    DefaultExt = ".gcode",
                    Filter     = "GCODE Files (.gcode)|*.gcode",
                    FileName   = outFileName.Remove(outFileName.Length - 5, 5)
                };
                bool?result = fileDialog.ShowDialog();
                if (result == true)
                {
                    StreamWriter writer = new StreamWriter(fileDialog.FileName);
                    writer.WriteLine(outputCode);
                    writer.Flush();
                    writer.Close();
                }
            }
        }
예제 #2
0
        private void settingsButton_Click(object sender, RoutedEventArgs e)
        {
            ProfileWindow window = new ProfileWindow(manager, ProfileWindow.WindowMode.EditData);

            window.ShowDialog();
        }