예제 #1
0
        private void PopulateOffsetSetting()
        {
            // Populate combos on first pass
            if (cboWCS.Items.Count == 0)
            {
                var offsets = OffsetType.GetAllGCodeIdentifiers(true);

                var wcsList = from o in offsets
                              where o.Category == OffsetType.Categories.WorkingCoordinateSystem
                              select o;

                cboWCS.Items.AddRange(wcsList.ToArray());

                var toolOffsetList = from o in offsets
                                     where o.Category == OffsetType.Categories.ToolHead
                                     select o;

                cboToolOffsets.Items.AddRange(toolOffsetList.ToArray());
            }

            // Select active Working Coordinate System
            foreach (var i in cboWCS.Items)
            {
                if (((OffsetType)i).GCodeIdentifier == _settings.ActiveWorkingCoordinateSystem)
                {
                    cboWCS.SelectedItem = i;
                }
            }

            // Select active Tool offset
            foreach (var i in cboToolOffsets.Items)
            {
                if (((OffsetType)i).GCodeIdentifier == _settings.ActiveToolOffset)
                {
                    cboToolOffsets.SelectedItem = i;
                }
            }

            chkToolLengthOffset.Checked = _settings.ToolLengthOffsetActive;

            SetMachineWorkingOffset();
        }
예제 #2
0
파일: Offsets.cs 프로젝트: buzzrama/DazCam
        private void PopulateWorkspaceOffsets()
        {
            // First, populate the list of GCode Identifiers if it isn't already loaded
            if (listBoxGCodeIdentifiers.Items.Count == 0)
            {
                listBoxGCodeIdentifiers.Items.AddRange(OffsetType.GetAllGCodeIdentifiers().ToArray());
                listBoxGCodeIdentifiers.SelectedIndex = 0;
            }

            // Next, populate the offsets based on the selected GCode Identifier
            listBoxOffsets.Items.Clear();
            var selectedOffsetType = listBoxGCodeIdentifiers.SelectedItem as OffsetType;

            if (selectedOffsetType != null)
            {
                var filteredOffsetList = from o in _machine.Settings.WorkspaceOffsets
                                         where o.Type.GCodeIdentifier == selectedOffsetType.GCodeIdentifier
                                         select o;

                listBoxOffsets.Items.AddRange(filteredOffsetList.ToArray());

                _suppressEvent = true;          // Prevent chain reactions
                for (int i = 0; i < listBoxOffsets.Items.Count; i++)
                {
                    if (((WorkspaceOffset)listBoxOffsets.Items[i]).Active)
                    {
                        listBoxOffsets.SetItemCheckState(i, CheckState.Checked);
                    }
                }
                _suppressEvent = false;

                if (listBoxOffsets.Items.Count > 0)
                {
                    listBoxOffsets.SelectedIndex = 0;
                }
            }

            PopulateCurrentWorkplaceOffset();
        }