Exemple #1
0
        public FormMain() {
            InitializeComponent();
            setupQueuedMessages(); //error handling

            Do_Upgrade();

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            // setup objects
            Cnc = new CNC(this);
            CNC.SquareCorrection = Properties.Settings.Default.CNC_SquareCorrection;

            Needle = new NeedleClass(this);
            Tapes = new TapesClass(Tapes_dataGridView, Needle, Cnc, this);
            Cad = new CAD(this);
            Locations = new LocationManager();

            Global.Instance.cnc = Cnc;
            Global.Instance.needle = Needle;
            Global.Instance.mainForm = this;
            Global.Instance.Locations = Locations;

            // open camera form
            // show the camera view stuff right away
            cameraView = new CameraView();
            cameraView.Show();
            cameraView.SetDownCameraDefaults();
            cameraView.SetUpCameraDefaults();
            cameraView.downClickDelegate = DownClickDelegate;
            cameraView.upClickDelegate = UpClickDelegate;

            //setup location jumps
            UpdateGoToPulldownMenu();
            Locations.GetList().ListChanged += delegate { 
                UpdateGoToPulldownMenu();
                Locations.Save();
            }; //update if list changed
            Locations.LocationChangeEvent += (s, e) => {
                if (e.PropertyName.Equals("Name")) UpdateGoToPulldownMenu();
                Locations.Save();
            }; //update if name on list changes

            //setup table entry dragging
            componentDrag = new DataGridDrag(CadData_GridView);
            locationDrag = new DataGridDrag(locations_dataGridView);
            tapeDrag = new DataGridDrag(Tapes_dataGridView);
            jobDrag = new DataGridDrag(JobData_GridView);

            //setup table bindings
            CadData_GridView.DataSource = Cad.ComponentData;
            locations_dataGridView.DataSource = Locations.GetList();            
            Tapes_dataGridView.DataSource = Tapes.tapeObjs;
            OriginalPartOrientation.DataSource = TapeObj.Orientation;
            OriginalTapeOrientation.DataSource = TapeObj.Orientation;
            UpdateTapeTypesBinding();
            PartType.DataSource = Enum.GetNames(typeof(ComponentType));

            //jobs table
            JobData_GridView.DataSource = Cad.JobData;
            methodDataGridViewComboBoxColumn.DataSource = new[] {"?", "Place", "LoosePlace", "Change Needle", "Recalibrate", "Ignore", "Pause", "Fiducial", "Place With UpCam"};
            // apply changes to multiple placement types at once
            JobData_GridView.CellValueChanged += (o, e) => {
                if (e.ColumnIndex != 3) return;
                for (int i = 0; i < JobData_GridView.SelectedCells.Count; i++) {
                    if (JobData_GridView.SelectedCells[i].ColumnIndex == 3) {
                        ((JobData)JobData_GridView.SelectedCells[i].OwningRow.DataBoundItem).Method =
                            ((JobData)JobData_GridView.Rows[e.RowIndex].DataBoundItem).Method;

                    }
                }
            };

            // right click context menu
            CadData_GridView.CellMouseDown += CadData_CellMouseDown;
            JobData_GridView.CellMouseDown += JobData_CellMouseDown;
            Tapes_dataGridView.CellMouseDown += Tapes_CellMouseDown;

            // setup key handling
            KeyPreview = true;
            SetupCursorNavigation(Controls);
            KeyUp += My_KeyUp;

            instructions_label.Text = "";
            instructions_label.Visible = false;

            // setup a bunch of stuff on the forms
            LightPlacerFormsSetup();
        }
Exemple #2
0
        public FormMain() {
            InitializeComponent();
            setupQueuedMessages(); //error handling

            Do_Upgrade();

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            // setup objects
            Cnc = new CNC(this);
            CNC.SquareCorrection = Properties.Settings.Default.CNC_SquareCorrection;

            Needle = new NeedleClass(this);
            Tapes = new TapesClass(Tapes_dataGridView, Needle, Cnc, this);
            Cad = new CAD(this);
            Locations = new LocationManager();

            Global.Instance.cnc = Cnc;
            Global.Instance.needle = Needle;
            Global.Instance.mainForm = this;
            Global.Instance.Locations = Locations;

            // open camera form
            // show the camera view stuff right away
            cameraView = new CameraView();
            cameraView.Show();
            cameraView.SetDownCameraDefaults();
            cameraView.SetUpCameraDefaults();
            cameraView.downClickDelegate = DownClickDelegate;
            cameraView.upClickDelegate = UpClickDelegate;

            nozzleChanger = new NozzleChanger();
            nozzleChanger.InitializeObject(dataGridNozzes, datagridLoadSequence, Needle, Cnc, this);
            //listNozzles.DataSource = nozzleChanger.nozzles;
            nozzleChanger.ReLoad();
            dataGridNozzes.DataSource = nozzleChanger.nozzles;
            textBoxNozzleSpeed.Text = nozzleChanger.Speed;

            (dataGridNozzes.Columns[2] as DataGridViewComboBoxColumn).DataSource =
                new BindingSource { DataSource = cameraView.upSet.GetNames() };
            Needle.nozzleChanger = nozzleChanger;
            nozzleChangerEnabled.Checked = nozzleChanger.Enabled;

            //setup location jumps
            UpdateGoToPulldownMenu();
            Locations.GetList().ListChanged += delegate { 
                UpdateGoToPulldownMenu();
                Locations.Save();
            }; //update if list changed
            Locations.LocationChangeEvent += (s, e) => {
                if (e.PropertyName.Equals("Name")) UpdateGoToPulldownMenu();
                Locations.Save();
            }; //update if name on list changes

            //setup table entry dragging
            componentDrag = new DataGridDrag(CadData_GridView);
            locationDrag = new DataGridDrag(locations_dataGridView);
            tapeDrag = new DataGridDrag(Tapes_dataGridView);
            jobDrag = new DataGridDrag(JobData_GridView);

            //setup table bindings
            CadData_GridView.DataSource = Cad.ComponentData;
            locations_dataGridView.DataSource = Locations.GetList();            
            Tapes_dataGridView.DataSource = Tapes.tapeObjs;
            OriginalPartOrientation.DataSource = TapeObj.Orientation;
            OriginalTapeOrientation.DataSource = TapeObj.Orientation;
            UpdateTapeTypesBinding();
            PartType.DataSource = Enum.GetNames(typeof(ComponentType));

            (Tapes_dataGridView.Columns["Nozzle"] as DataGridViewComboBoxColumn).DataSource =
                new BindingSource { DataSource = nozzleChanger.getIDs() };

            //jobs table
            JobData_GridView.DataSource = Cad.JobData;
            methodDataGridViewComboBoxColumn.DataSource = new[] {"?", "Place", "LoosePlace", "Change Needle", "Recalibrate", "Ignore", "Pause", "Fiducial", "Place With UpCam", "Change nozzle", "ERROR" };
            // apply changes to multiple placement types at once
            JobData_GridView.CellValueChanged += (o, e) => {
                if (e.ColumnIndex != 3) return;
                for (int i = 0; i < JobData_GridView.SelectedCells.Count; i++) {
                    if (JobData_GridView.SelectedCells[i].ColumnIndex == 3) {
                        ((JobData)JobData_GridView.SelectedCells[i].OwningRow.DataBoundItem).Method =
                            ((JobData)JobData_GridView.Rows[e.RowIndex].DataBoundItem).Method;

                    }
                }
            };

            // right click context menu
            CadData_GridView.CellMouseDown += CadData_CellMouseDown;
            JobData_GridView.CellMouseDown += JobData_CellMouseDown;
            Tapes_dataGridView.CellMouseDown += Tapes_CellMouseDown;

            // setup key handling
            KeyPreview = true;
            SetupCursorNavigation(Controls);
            KeyUp += My_KeyUp;

            instructions_label.Text = "";
            instructions_label.Visible = false;

            // setup a bunch of stuff on the forms
            LightPlacerFormsSetup();

            VisibilityGraph = new visibilitygraph();
            VisibilityGraph = VisibilityGraph.ReLoad();
            if (VisibilityGraph == null) { VisibilityGraph = new visibilitygraph(); }
            VisibilityGraph.drawingSurface = this.pictureBox1;
            VisibilityGraph.setBounds(0, 0, Locations.GetLocation("Max Machine").X, Locations.GetLocation("Max Machine").Y);
            /*
            VisibilityGraph.insertGuard(50, 0, 50, 50);
            VisibilityGraph.insertGuard(50, 50, Locations.GetLocation("Max Machine").X, 50);

            VisibilityGraph.insertGuard(200, 200, 200, 150);
            VisibilityGraph.insertGuard(200, 150, 500, 150);
            VisibilityGraph.insertGuard(500, 150, 500, 200);
            VisibilityGraph.insertGuard(500, 200, 200, 200);
            */
            dataGridGuards.DataSource = VisibilityGraph.Guards;
            checkBoxUseGuards.Checked = VisibilityGraph.Enabled;
            updateDataGridGuard();

            Cnc.RawWrite("{\"gc\":\"G1 F100 Y0\"}");
            Thread.Sleep(100);
            Cnc.RawWrite("!%");
            
        }