Beispiel #1
0
        private void CleanUpAll()
        {
            ConvertPCBDoc.OutputString("Removing generated content");

            for (var i = 0; i < FileHistory.Items.Count; i++)
            {
                CleanOutput(FileHistory.GetItemText(FileHistory.Items[i]));
            }
            ConvertPCBDoc.OutputString("Finished");
            CheckOutputDir();
        }
Beispiel #2
0
        private void LaunchPCBNew_Click(object sender, EventArgs e)
        {
            busy.Select();
            var p = new Process();

            if (FileHistory.Text != "" && File.Exists(FileHistory.Text))
            {
                string filename        = FileHistory.Text;
                string CM              = (filename.Contains("CMPCBDoc")) ? "-CM" : "";
                string UnpackDirectory = filename.Substring(0, filename.LastIndexOf('.')) + CM + "-Kicad";
                if (Directory.Exists(UnpackDirectory))
                {
                    int    index = FileHistory.Text.LastIndexOf('.');
                    string FileName;
                    FileName = FileHistory.Text.Substring(FileHistory.Text.LastIndexOf('\\') + 1);
                    FileName = FileName.Substring(0, FileName.LastIndexOf('.'));

                    string output_filename = UnpackDirectory + "\\" + FileName + ".kicad_pcb";

                    if (File.Exists(output_filename))
                    {
                        try
                        {
                            if (File.Exists(PcbnewLocation))
                            {
                                p.StartInfo = new ProcessStartInfo(PcbnewLocation, "\"" + output_filename + "\"")
                                {
                                    RedirectStandardOutput = false,
                                    RedirectStandardError  = true,
                                    UseShellExecute        = false
                                };
                                p.Start();
                            }
                        }
                        catch (System.ComponentModel.Win32Exception)
                        {
                            ConvertPCBDoc.OutputError("Couldn't launch PcbNew");
                        }
                    }
                    else
                    {
                        ConvertPCBDoc.OutputError($"Launch failed as file \"{output_filename}\" doesn't exist");
                    }
                }
                else
                {
                    ConvertPCBDoc.OutputError($"Directory \"{UnpackDirectory}\" doesn't exist");
                }
            }
            else
            {
                ConvertPCBDoc.OutputError($"Launch failed as file \"{FileHistory.Text}\"doesn't exist");
            }
        }
Beispiel #3
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (button1.BackColor == Color.Green)
     {
         button1.BackColor = Color.FromArgb(224, 224, 224);
     }
     else
     {
         button1.BackColor = Color.Green;
     }
     if (t == null || t.IsAlive == false)
     {
         button1.Text = "Convert";
         EnableControls();
         timer1.Enabled = false;
         Cursor.Current = Cursors.Default;
         busy.Enabled   = false;
         busy.Visible   = false;
         busy.Hide();
         button1.BackColor = Color.FromArgb(224, 224, 224);
         this.Update();
         if (Globals.ReportLines != 0 && Properties.Settings.Default.ShowWarningsDialog)
         {
             if (File.Exists(Form1.TextEditorLoc))
             {
                 if (ShowWarnings() == DialogResult.OK)
                 {
                     var p = new Process
                     {
                         StartInfo = new ProcessStartInfo(Form1.TextEditorLoc, "\"" + Globals.ReportFilename + "\"")
                         {
                             RedirectStandardOutput = false,
                             RedirectStandardError  = true,
                             UseShellExecute        = false
                         }
                     };
                     p.Start();
                 }
             }
             else
             {
                 ConvertPCBDoc.OutputString($"No editor set, warnings can be found in {Globals.ReportFilename}");
             }
         }
     }
     else
     {
         busy.Enabled = true;
         busy.Visible = false;
     }
 }
Beispiel #4
0
        private void Edit_Click(object sender, EventArgs e)
        {
            busy.Select();
            var p = new Process();

            if (FileHistory.Text != "" && File.Exists(FileHistory.Text))
            {
                string UnpackDirectory = FileHistory.Text.Substring(0, FileHistory.Text.LastIndexOf('.')) + "-Kicad";
                if (!Directory.Exists(UnpackDirectory))
                {
                    ConvertPCBDoc.OutputError($"Directory \"{UnpackDirectory}\" doesn't exist");
                }
                else
                {
                    int    index = FileHistory.Text.LastIndexOf('.');
                    string FileName;
                    FileName = FileHistory.Text.Substring(FileHistory.Text.LastIndexOf('\\') + 1);
                    FileName = FileName.Substring(0, FileName.LastIndexOf('.'));

                    string output_filename = UnpackDirectory + "\\" + FileName + ".kicad_pcb";

                    if (File.Exists(output_filename))
                    {
                        try
                        {
                            if (File.Exists(TextEditorLoc))
                            {
                                p.StartInfo = new ProcessStartInfo(TextEditorLoc, "\"" + output_filename + "\"")
                                {
                                    RedirectStandardOutput = false,
                                    RedirectStandardError  = true,
                                    UseShellExecute        = false
                                };
                                p.Start();
                            }
                        }
                        catch (System.ComponentModel.Win32Exception)
                        {
                            ConvertPCBDoc.OutputError("Couldn't launch PcbNew");
                        }
                    }
                }
            }
        }
Beispiel #5
0
        private void CleanOutput(string filename)
        {
            if (busy != null)
            {
                busy.Select();
            }
            string CM = (filename.Contains("CMPCBDoc")) ? "-CM" : "";
            string UnpackDirectory = filename.Substring(0, filename.LastIndexOf('.')) + CM + "-Kicad";

            if (Directory.Exists(UnpackDirectory))
            {
                ConvertPCBDoc.OutputString($"Removing \"{UnpackDirectory}\"'s contents");
                ConvertPCBDoc.ClearFolder(UnpackDirectory);
                ConvertPCBDoc.OutputString($"Deleting \"{UnpackDirectory}\"");
                try
                {
                    Directory.Delete(UnpackDirectory);
                }
                catch (Exception Ex)
                {
                }
            }
            CheckOutputDir();
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            ConvertPCB = new ConvertPCBDoc();
            ConvertPCBDoc.ExtractFiles = false;
            ConvertPCBDoc.CreateLib    = false;
            if (args.Length > 0)
            {
                // run as console app
                ConsoleApp = true;
                // parse command line parameters
                for (var i = 0; i < args.Length; i++)
                {
                    if (args[i].Substring(0, 1) == "-")
                    {
                        // this is a command line option
                        if (args[i] == "-e")
                        {
                            ConvertPCBDoc.ExtractFiles = true;
                        }
                        if (args[i] == "-l")
                        {
                            ConvertPCBDoc.CreateLib = true;
                        }
                        if (args[i] == "-v")
                        {
                            ConvertPCBDoc.Verbose = true;
                        }
                    }
                    else
                    {
                        ConvertPCBDoc.filename = args[i];
                    }
                }

                if (!File.Exists(ConvertPCBDoc.filename))
                {
                    Console.Error.WriteLine($"File {ConvertPCBDoc.filename} doesn't exist");
                    System.Environment.Exit(0);
                }

                if ((ConvertPCBDoc.filename.Length - ConvertPCBDoc.filename.IndexOf(".pcbdoc", StringComparison.OrdinalIgnoreCase)) != 7)
                {
                    Console.Error.WriteLine($"File {ConvertPCBDoc.filename} should end in '.pcbdoc'");
                    System.Environment.Exit(0);
                }

                int index = ConvertPCBDoc.filename.IndexOf('.');
                ConvertPCBDoc.output_filename = ConvertPCBDoc.filename.Substring(0, index) + ".kicad_pcb";
                if (index == -1)
                {
                    Console.Error.WriteLine($"File {ConvertPCBDoc.filename} is not valid pcb file");
                    System.Environment.Exit(0);
                }

                if (ConvertPCBDoc.filename.Substring(index, ConvertPCBDoc.filename.Length - index).ToLower() != ".pcbdoc")
                {
                    Console.Error.WriteLine($"File {ConvertPCBDoc.filename} is not valid pcb file");
                    System.Environment.Exit(0);
                }

                ConvertPCB.ConvertFile(ConvertPCBDoc.filename, ConvertPCBDoc.ExtractFiles, ConvertPCBDoc.CreateLib);
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Form = new Form1();
                Application.Run(Form);
            }
        }