Exemplo n.º 1
0
        static void Main(string[] args)
        {
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator = ".";

            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;
            try
            {
                int num;

                if (int.TryParse(args[2], out num))
                {
                    Module_Main.StartConversion(args[0], args[1], double.Parse(args[2]));
                }
                else if (args[2] != null)
                {
                    if (File.Exists(args[0]) && Directory.Exists(args[1].Substring(0, args[1].LastIndexOf("\\"))))
                    {
                        if (Module_Main.IsHPGL(args[0]) && !args[0].Contains(".cnc") && !args[0].Contains(".nc"))
                        {
                            Module_Main.StartConversion(args[0], args[1], double.Parse(args[2]));
                        }
                        else
                        {
                            Module_Main.RelativeArc = (args[2].ToLower() == "true") ? true : false;

                            Converter conv = new Converter(new FileReader(args[0]).Lines, double.Parse(args[3]));
                            ErrorHandler.FileName = args[0].Substring(0, args[0].IndexOf('.')) + ".txt";
                            conv.CreateProgram();
                            Class_Output outp = new Class_Output();
                            outp.OpenFile(args[1]);
                            outp.OutputFileHeader(args[1]);

                            for (int i = 0; i < conv.GetProgram.Count; i++)
                            {
                                conv.GetProgram[i].Write(outp);
                            }

                            outp.OutputFileEnd();
                            outp.CloseFile();
                            ErrorHandler.WriteOutputFile();
                        }
                    }
                }
                else
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form_Main());
                }
            }
            catch
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form_Main());
            }
        }
Exemplo n.º 2
0
 public Conversion(string FileName, Class_Program Prog, Class_Output Output, BaseFunctions Functions, Dictionary <string, Func <string, bool> > FunctionDic)
 {
     this.FileName    = FileName;
     this.Prog        = Prog;
     this.Output      = Output;
     TextHndlr        = new HPGLTextHandler();
     this.Functions   = Functions;
     this.FunctionDic = FunctionDic;
     LogFile          = new LogFileOutput(FileName);
 }
Exemplo n.º 3
0
 public Conversion(string FileName, Class_Program Prog, Class_Output Output)
 {
     this.FileName = FileName;
     this.Prog     = Prog;
     this.Output   = Output;
     TextHndlr     = new HPGLTextHandler();
     Functions     = new BaseFunctions(this.Output);
     FunctionDic   = TextHndlr.ConstructDictionary(Functions);
     LogFile       = new LogFileOutput(FileName);
 }
Exemplo n.º 4
0
 public Conversion(string FileName, Class_Program Prog, Class_Output Ouput, BaseFunctions Functions)
 {
     this.FileName  = FileName;
     this.Prog      = Prog;
     this.Output    = Module_Main.outp;
     TextHndlr      = new HPGLTextHandler();
     this.Functions = Functions;
     FunctionDic    = TextHndlr.ConstructDictionary(Functions);
     LogFile        = new LogFileOutput(FileName.Substring(0, FileName.IndexOf('.')) + ".txt");
 }
Exemplo n.º 5
0
 public BaseFunctions(Class_Output Output)
 {
     TextHndlr     = new TextHandler();
     this.Output   = Output;
     PenDown       = false;
     RelativeCoord = false;
     SubFirst      = true;
     SubOpen       = false;
     BoxOpen       = true;
     SubColors     = new Dictionary <string, int>();
     SubColors.Add("Zero", 0);
 }
Exemplo n.º 6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (File.Exists(txtboxInput.Text) && Directory.Exists(txtboxOutput.Text.Substring(0, txtboxOutput.Text.LastIndexOf("\\"))))
                {
                    if (Module_Main.IsHPGL(txtboxInput.Text) && !txtboxInput.Text.Contains(".cnc") && !txtboxInput.Text.Contains(".nc"))
                    {
                        Module_Main.StartConversion(txtboxInput.Text, txtboxOutput.Text, double.Parse(txtboxScaling.Text));
                    }
                    else
                    {
                        CNCType = cBoxCNC.Text;
                        Converter conv = new Converter(new FileReader(txtboxInput.Text).Lines, double.Parse(txtboxScaling.Text));
                        ErrorHandler.FileName = txtboxInput.Text.Substring(0, txtboxInput.Text.IndexOf('.')) + ".txt";
                        conv.CreateProgram();
                        Class_Output outp = new Class_Output();
                        outp.OpenFile(txtboxOutput.Text);
                        outp.OutputFileHeader(txtboxOutput.Text);

                        for (int i = 0; i < conv.GetProgram.Count; i++)
                        {
                            conv.GetProgram[i].Write(outp);
                        }

                        outp.OutputFileEnd();
                        outp.CloseFile();
                        ErrorHandler.WriteOutputFile();
                    }
                    MessageBox.Show("File succesfully converted.\nSaved file as " + txtboxOutput.Text + "\nLogfile saved as:" + txtboxOutput.Text.Substring(0, txtboxOutput.Text.Length - 1) + "txt\nDate: " + DateTime.UtcNow.ToLocalTime().ToString(), "(C) BCSI Systems BV CNC and HPGL Converter");
                }
                else
                {
                    MessageBox.Show("Input file or output folder was not found.", "(C) BCSI Systems BV CNC and HPGL Converter");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            Module_Main.types.Clear();
            //Application.Restart();
        }
Exemplo n.º 7
0
 public CNCFunctions(Class_Output Output)
     : base(Output)
 {
     this.Output = Output;
 }
Exemplo n.º 8
0
 public override void Write(Class_Output output)
 {
     output.OutputLine(Origen.X, Origen.Y, Destination.X, Destination.Y, Color, Depth);
 }
Exemplo n.º 9
0
 public override void Write(Class_Output output)
 {
     output.OutputArc(LastOrigen.X, LastOrigen.Y, Origen.X, Origen.Y, Distance.X, Distance.Y, Radius, Color, Depth);
 }
Exemplo n.º 10
0
 public virtual void Write(Class_Output output)
 {
 }
Exemplo n.º 11
0
 public HPGLFunctions(Class_Output Output, double Factor)
     : base(Output)
 {
     this.Factor = Factor;
     TextHndlr   = new HPGLTextHandler();
 }
Exemplo n.º 12
0
 public HPGLFunctions(Class_Output Output)
     : base(Output)
 {
     Factor    = 100d;
     TextHndlr = new HPGLTextHandler();
 }
Exemplo n.º 13
0
        public override void Write(Class_Output output)
        {
            try
            {
                switch (Program)
                {
                case SubPrograms.BOX:
                    output.OutputBoxStart(Name.ToString());

                    if (InitializeNull)
                    {
                        output.OutputNullInstance();
                    }

                    if (InnerSection)
                    {
                        output.OutputSectionStart(Name, Name);
                    }
                    break;

                case SubPrograms.SECTION:
                    output.OutputSectionStart(Name, Name);
                    break;

                default:
                    output.OutputSectionStart(Name, Name);
                    break;
                }

                for (int i = 0; i < Content.Length; i++)
                {
                    if (Content[i] != null)
                    {
                        Content[i].Write(output);
                    }
                }

                switch (Program)
                {
                case SubPrograms.BOX:
                    if (InnerSection)
                    {
                        output.OutputSectionEnd();
                    }

                    output.OutputBoxEnd();
                    break;

                case SubPrograms.SECTION:
                    output.OutputSectionEnd();
                    break;

                default:
                    output.OutputSectionEnd();
                    break;
                }
            }
            catch (Exception e)
            {
                ErrorHandler.AddMessage(e);
            }
        }
Exemplo n.º 14
0
 public override void Write(Class_Output output)
 {
     output.OutputInstance(Index, Origen.X, Origen.Y);
 }