Beispiel #1
0
        private void ManageCommandLineArgs(string[] args)
        {
            if (args != null && args.Length == 1)
            {
                string filename = args[0];
                if (System.IO.File.Exists(filename))
                {
                    Application.DoEvents();

                    if (System.IO.Path.GetExtension(filename).ToLower() == ".zbn")                     //zipped button
                    {
                        PreviewForm.ImportButton(filename);
                    }
                    else
                    {
                        if (Core.CanLoadNewFile)
                        {
                            Core.OpenFile(this, filename, false);
                        }
                        else
                        {
                            MessageBox.Show(Strings.MsgboxCannotOpenFileNow);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 生成gcode
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnGcode_Click(object sender, EventArgs e)
        {
            if (!CheckPos(Preview.manualLBPos, Preview.manualRBPos, Preview.manualLTPos, Preview.manualRTPos))
            {
                MessageBox.Show("质控点定位有误,请重新定位!", "提示");
                return;
            }

            StringBuilder sb = CalcPos();

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter           = "gcode文件(*.gcode)|*.gcode";
            sfd.FileName         = "Cut" + DateTime.Now.ToString("yyyyMMddHHmmss");
            sfd.RestoreDirectory = true;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string filename         = sfd.FileName.ToString();
                System.IO.FileStream fs = (System.IO.FileStream)sfd.OpenFile();
                byte[] array            = Encoding.ASCII.GetBytes(sb.ToString());
                fs.Write(array, 0, array.Length);
                fs.Close();

                // 打开文件
                Core.OpenFile(ParentForm, filename);
            }
        }
Beispiel #3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            UpdateTimer.Enabled = true;


            if (Settings.GetObject("Auto Update", true))
            {
                GitHub.CheckVersion(false);
            }

            SuspendLayout();
            //restore last size and position
            Object[]        msp   = Settings.GetObject <Object[]>("Mainform Size and Position", null);
            FormWindowState state = msp == null ? FormWindowState.Maximized : (FormWindowState)msp[2] != FormWindowState.Minimized ? (FormWindowState)msp[2] : FormWindowState.Maximized;

            if (state == FormWindowState.Normal)
            {
                WindowState = state; Size = (Size)msp[0]; Location = (Point)msp[1];
            }
            ResumeLayout();

            ManageMessage();


            if (args != null && args.Length == 1)
            {
                string filename = args[0];
                if (System.IO.File.Exists(filename))
                {
                    Application.DoEvents();

                    if (System.IO.Path.GetExtension(filename).ToLower() == ".zbn")                     //zipped button
                    {
                        PreviewForm.ImportButton(filename);
                    }
                    else
                    {
                        Core.OpenFile(this, filename, false);
                    }
                }
            }
        }
Beispiel #4
0
 private void MnFileOpen_Click(object sender, EventArgs e)
 {
     Core.OpenFile(this);
 }
Beispiel #5
0
        private bool PerformAction(HotKey.Actions action)
        {
            switch (action)
            {
            case HotKey.Actions.ConnectDisconnect:
                mCore.HKConnectDisconnect(); break;

            case HotKey.Actions.Connect:
                mCore.HKConnect(); break;

            case HotKey.Actions.Disconnect:
                mCore.HKDisconnect(); break;

            case HotKey.Actions.OpenFile:
                mCore.OpenFile(Application.OpenForms[0]); break;

            case HotKey.Actions.ReopenLastFile:
                mCore.ReOpenFile(Application.OpenForms[0]); break;

            case HotKey.Actions.SaveFile:
                mCore.SaveProgram(); break;

            case HotKey.Actions.ExecuteFile:
                mCore.RunProgram(); break;

            case HotKey.Actions.AbortFile:
                mCore.AbortProgram(); break;

            case HotKey.Actions.HelpOnline:
                mCore.HelpOnLine(); break;

            case HotKey.Actions.Reset:
                mCore.GrblReset(); break;

            case HotKey.Actions.Homing:
                mCore.GrblHoming(); break;

            case HotKey.Actions.Unlock:
                mCore.GrblUnlock(); break;

            case HotKey.Actions.PauseJob:
                mCore.FeedHold(); break;

            case HotKey.Actions.ResumeJob:
                mCore.CycleStartResume(); break;

            case HotKey.Actions.SetNewZero:
                mCore.SetNewZero(); break;

            case HotKey.Actions.JogHome:
                RequestJog(GrblCore.JogDirection.Home); break;

            case HotKey.Actions.JogN:
                RequestJog(GrblCore.JogDirection.N); break;

            case HotKey.Actions.JogNE:
                RequestJog(GrblCore.JogDirection.NE); break;

            case HotKey.Actions.JogE:
                RequestJog(GrblCore.JogDirection.E); break;

            case HotKey.Actions.JogSE:
                RequestJog(GrblCore.JogDirection.SE); break;

            case HotKey.Actions.JogS:
                RequestJog(GrblCore.JogDirection.S); break;

            case HotKey.Actions.JogSW:
                RequestJog(GrblCore.JogDirection.SW); break;

            case HotKey.Actions.JogW:
                RequestJog(GrblCore.JogDirection.W); break;

            case HotKey.Actions.JogNW:
                RequestJog(GrblCore.JogDirection.NW); break;

            case HotKey.Actions.OverridePowerDefault:
            case HotKey.Actions.OverridePowerUp:
            case HotKey.Actions.OverridePowerDown:
            case HotKey.Actions.OverrideLinearDefault:
            case HotKey.Actions.OverrideLinearUp:
            case HotKey.Actions.OverrideLinearDown:
            case HotKey.Actions.OverrideRapidDefault:
            case HotKey.Actions.OverrideRapidUp:
            case HotKey.Actions.OverrideRapidDown:
                mCore.HotKeyOverride(action); break;

            case HotKey.Actions.CustomButton1:
                EmulateCustomButtonDown(0); break;

            case HotKey.Actions.CustomButton2:
                EmulateCustomButtonDown(1); break;

            case HotKey.Actions.CustomButton3:
                EmulateCustomButtonDown(2); break;

            case HotKey.Actions.CustomButton4:
                EmulateCustomButtonDown(3); break;

            case HotKey.Actions.CustomButton5:
                EmulateCustomButtonDown(4); break;

            case HotKey.Actions.CustomButton6:
                EmulateCustomButtonDown(5); break;

            case HotKey.Actions.CustomButton7:
                EmulateCustomButtonDown(6); break;

            case HotKey.Actions.CustomButton8:
                EmulateCustomButtonDown(7); break;

            case HotKey.Actions.CustomButton9:
                EmulateCustomButtonDown(8); break;

            case HotKey.Actions.CustomButton10:
                EmulateCustomButtonDown(9); break;

            default:
                break;
            }

            //ConnectDisconnect = 10, Connect = 11, Disconnect = 12,
            //OpenFile = 20, ReopenLastFile = 21, SaveFile = 22, ExecuteFile = 23,
            //HelpOnline = 30,
            //Reset = 100, Homing = 101, Unlock = 102,  PauseJob = 103, ResumeJob = 104, SetNewZero = 105,
            //JogHome = 1000, JogN = 1001, JogNE = 1002, JogE = 1003, JogSE = 1004, JogS = 1005, JogSO = 1006, JogO = 1007, JogNO = 1008,
            //CustomButton1 = 2000, CustomButton2 = 2001, CustomButton3 = 2002, CustomButton4 = 2003, CustomButton5 = 2004, CustomButton6 = 2005, CustomButton7 = 2006, CustomButton8 = 2007, CustomButton9 = 2008, CustomButton10 = 2009

            return(true);
        }
Beispiel #6
0
 void BtnOpenClick(object sender, EventArgs e)
 {
     Core.OpenFile(ParentForm);
 }