/// <summary> /// Creates the property manager page and populates it with controls /// </summary> private void SetupPage() { int errors = 0; //Create a property manager page and throw exceptions if an error occurs page = (PropertyManagerPage2)swApp.CreatePropertyManagerPage("Edit Robot Frame of Reference", (int)swPropertyManagerPageOptions_e.swPropertyManagerOptions_OkayButton, this, ref errors); if (errors == -1) //Creation failed throw new InternalSolidworksException("SldWorks::CreatePropertyManagerPage", "Failed to create property manager page"); else if (errors == -2) //No open document throw new ProgramErrorException("Tried to open a property manager page when no document was open"); else if (errors == 1) //Invlaid hanlder throw new ProgramErrorException("Tried to pass in and invalid page hanlder when creating a property manager page"); //Helper variables for setup options //control type short labelCT = (int)swPropertyManagerPageControlType_e.swControlType_Label; short selectionboxCT = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox; short buttonCT = (int)swPropertyManagerPageControlType_e.swControlType_CheckableBitmapButton; // align short leftAlign = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_Indent; short buttonAlign = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; // options int groupboxOptions = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded | (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible; // for group box int controlOptions = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; // for controls // object filters int[] linefilter = new int[] { (int)swSelectType_e.swSelDATUMAXES, (int)swSelectType_e.swSelEDGES }; int[] pointfilter = new int[] { (int)swSelectType_e.swSelDATUMPOINTS, (int)swSelectType_e.swSelVERTICES }; int[] planefilter = new int[] { (int)swSelectType_e.swSelDATUMPLANES, (int)swSelectType_e.swSelFACES }; //Setup and create the robot properties group robotPropertiesGroup = (PropertyManagerPageGroup)page.AddGroupBox( robotPropertiesGroupID, "Robot Frame of Reference Properties", groupboxOptions); //Setup and create the label for the origin point selection box originPointLabel = (PropertyManagerPageLabel)robotPropertiesGroup.AddControl( originPointLabelID, labelCT, "Robot origin point", leftAlign, controlOptions, "Select the origin point for this robot"); //Setup and create the origin point selectionbox originPointSelectionbox = (PropertyManagerPageSelectionbox)robotPropertiesGroup.AddControl( originPointSelectionboxID, selectionboxCT, "Robot origin point", leftAlign, controlOptions, "Use this box to select a point"); originPointSelectionbox.AllowSelectInMultipleBoxes = false; originPointSelectionbox.SingleEntityOnly = true; originPointSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem1); originPointSelectionbox.Mark = 2; originPointSelectionbox.SetSelectionFilters(pointfilter); //Setup and create the label for the base plane selection box basePlaneLabel = (PropertyManagerPageLabel)robotPropertiesGroup.AddControl( basePlaneLabelID, labelCT, "Base plane", leftAlign, controlOptions, "Select the base plane for this robot"); //create baseplane flip checkbox flipPlaneDirectionButton = (PropertyManagerPageBitmapButton)robotPropertiesGroup.AddControl( flipPlaneDirectionButtonID, buttonCT, "Flip plane normal", buttonAlign, controlOptions, "Check to flip the direction of the normal of the base plane"); flipPlaneDirectionButton.SetStandardBitmaps((int)swPropertyManagerPageBitmapButtons_e.swBitmapButtonImage_reverse_direction); flipPlaneDirectionButton.Checked = false; //Setup and create the base plane selectionbox basePlaneSelectionbox = (PropertyManagerPageSelectionbox)robotPropertiesGroup.AddControl( basePlaneSelectionboxID, selectionboxCT, "Base plane", leftAlign, controlOptions, "Use this box to select a plane"); basePlaneSelectionbox.AllowSelectInMultipleBoxes = false; basePlaneSelectionbox.SingleEntityOnly = true; basePlaneSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2); basePlaneSelectionbox.Mark = 4; basePlaneSelectionbox.SetSelectionFilters(planefilter); ((PropertyManagerPageControl)basePlaneSelectionbox).Top = 75; ((PropertyManagerPageControl)flipPlaneDirectionButton).Top = (short)(((PropertyManagerPageControl)basePlaneSelectionbox).Top+3); //Setup and create the label for the direction axis selection box directionAxisLabel = (PropertyManagerPageLabel)robotPropertiesGroup.AddControl( directionAxisLabelID, labelCT, "Direction axis", leftAlign, controlOptions, "Select the axis along which the robot faces"); //Setup and create the axis flip checkbox flipAxisDirectionButton = (PropertyManagerPageBitmapButton)robotPropertiesGroup.AddControl( flipAxisDirectionButtonID, buttonCT, "Flip axis direction", buttonAlign, controlOptions, "Check to flip the direction of the axis to the direction that the robot is facing"); flipAxisDirectionButton.SetStandardBitmaps((int)swPropertyManagerPageBitmapButtons_e.swBitmapButtonImage_reverse_direction); flipAxisDirectionButton.Checked = false; //Setup and create the direction axis selection box directionAxisSelectionbox = (PropertyManagerPageSelectionbox)robotPropertiesGroup.AddControl( directionAxisSelectionboxID, selectionboxCT, "Direction axis", leftAlign, controlOptions, "Use this box to select an axis"); directionAxisSelectionbox.AllowSelectInMultipleBoxes = false; directionAxisSelectionbox.SingleEntityOnly = true; directionAxisSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem3); directionAxisSelectionbox.Mark = 8; directionAxisSelectionbox.SetSelectionFilters(linefilter); ((PropertyManagerPageControl)directionAxisSelectionbox).Top = 125; ((PropertyManagerPageControl)flipAxisDirectionButton).Top = (short)(((PropertyManagerPageControl)directionAxisSelectionbox).Top + 3); }
/// <summary> /// sets up all the controls on the page /// </summary> public void SetupPage() { //Helper variables int options; short controlType, align; int errors = 0; System.Diagnostics.Debug.WriteLine(this is PropertyManagerPage2Handler9); //Create a property manager page and throw exceptions if an error occurs page = (PropertyManagerPage2)swApp.CreatePropertyManagerPage("Attachment Selection", (int)swPropertyManagerPageOptions_e.swPropertyManagerOptions_OkayButton, this, ref errors); if (errors == -1) //Creation failed throw new InternalSolidworksException("SldWorks::CreatePropertyManagerPage", "Failed to create property manager page"); else if (errors == -2) //No open document throw new ProgramErrorException("Tried to open a property manager page when no document was open"); else if (errors == 1) //Invlaid hanlder throw new ProgramErrorException("Tried to pass in and invalid page hanlder when creating a property manager page"); //Sets the page's message page.SetMessage3("Select the origin and direction for this attachment.", (int)swPropertyManagerPageMessageVisibility.swMessageBoxVisible, (int)swPropertyManagerPageMessageExpanded.swMessageBoxExpand, "Message"); //create the selection group options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded | (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible; selectionGroup = (PropertyManagerPageGroup)page.AddGroupBox(selectionGroupID, "Attachment Selections", options); //create the Origin selection Label controlType = (int)swPropertyManagerPageControlType_e.swControlType_Label; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_Indent; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; originLabel = (PropertyManagerPageLabel)selectionGroup.AddControl(originLabelID, controlType, "Attachment Origin", align, options, "Select the orgin point of the Attachment"); //create Orgin selectionbox controlType = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_Indent; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; originSelectionbox = (PropertyManagerPageSelectionbox)selectionGroup.AddControl(originSelectionboxID, controlType, "Attachment Origin", align, options, "Select the origin point of the Attachment"); originSelectionbox.AllowSelectInMultipleBoxes = false; originSelectionbox.SingleEntityOnly = true; originSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2); originSelectionbox.Mark = 2; int[] filter = { (int)swSelectType_e.swSelVERTICES, (int)swSelectType_e.swSelDATUMPOINTS}; originSelectionbox.SetSelectionFilters(filter); //create the axis selection Label controlType = (int)swPropertyManagerPageControlType_e.swControlType_Label; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_Indent; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; axisLabel = (PropertyManagerPageLabel)selectionGroup.AddControl(axisLabelID, controlType, "Attachment Axis", align, options, "Select the viewing axis of the Attachment"); //create axis selectionbox controlType = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_Indent; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; axisSelectionbox = (PropertyManagerPageSelectionbox)selectionGroup.AddControl(axisSelectionboxID, controlType, "Attachment Axis", align, options, "Select the viewing axis of the Attachment"); axisSelectionbox.AllowSelectInMultipleBoxes = false; axisSelectionbox.SingleEntityOnly = true; axisSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2); axisSelectionbox.Mark = 4; filter = new int[] { (int)swSelectType_e.swSelEDGES, (int)swSelectType_e.swSelDATUMAXES}; axisSelectionbox.SetSelectionFilters(filter); //Setup and create axis flip checkbox controlType = (int)swPropertyManagerPageControlType_e.swControlType_CheckableBitmapButton; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; flipAxisButton = (PropertyManagerPageBitmapButton)selectionGroup.AddControl(flipAxisButtonID, controlType, "Flip direction axis", align, options, "Check to flip the direction of viewing"); flipAxisButton.Checked = currentAttachment.FlipAxis; flipAxisButton.SetStandardBitmaps((int)swPropertyManagerPageBitmapButtons_e.swBitmapButtonImage_reverse_direction); ((PropertyManagerPageControl)flipAxisButton).Top = 75; ((PropertyManagerPageControl)axisSelectionbox).Top = 75; //create FOV label controlType = (int)swPropertyManagerPageControlType_e.swControlType_Label; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; FOVLabel = (PropertyManagerPageLabel)selectionGroup.AddControl(FOVLabelID, controlType, "Field of View", align, options, "Select Field of View"); //create FOV slider controlType = (int)swPropertyManagerPageControlType_e.swControlType_Slider; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; FOVSlider = (PropertyManagerPageSlider)selectionGroup.AddControl(FOVSliderID, controlType, "FOV Slider", align, options, "Slide to adjust FOV"); if (currentAttachment.FOV > 0) { FOVSlider.SetRange(5,175); //corresponds to radius of 5 to 175 meters FOVSlider.TickFrequency = 5; FOVSlider.Position = (int)currentAttachment.FOV; } else { FOVSlider.SetRange(5, 100); //after conversion corresponds to radius of 5 to 100 centimeters FOVSlider.TickFrequency = 5; FOVSlider.Position = (int)(-currentAttachment.FOV * 100); } FOVSlider.Style = (int)swPropMgrPageSliderStyle_e.swPropMgrPageSliderStyle_AutoTicks | (int)swPropMgrPageSliderStyle_e.swPropMgrPageSliderStyle_BottomLeftTicks | (int)swPropMgrPageSliderStyle_e.swPropMgrPageSliderStyle_NotifyWhileTracking; //create manual angle checkbox controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; manualAngleCheckbox = (PropertyManagerPageCheckbox)selectionGroup.AddControl(manualAngleCheckboxID, controlType, "Manual Rotations", align, options, "Check to manually define angle rotations"); manualAngleCheckbox.Checked = currentAttachment.UseManualAngles; //create the roll text Label controlType = (int)swPropertyManagerPageControlType_e.swControlType_Label; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; rollLabel = (PropertyManagerPageLabel)selectionGroup.AddControl(rollLabelID, controlType, "Roll", align, options, "Rotation about the X axis"); //create roll textbox controlType = (int)swPropertyManagerPageControlType_e.swControlType_Textbox; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Visible; rollTextbox = (PropertyManagerPageTextbox)selectionGroup.AddControl(rollTextboxID, controlType, "0.0", align, options, "Enter the rotation about the X axis"); //create the pitch text Label controlType = (int)swPropertyManagerPageControlType_e.swControlType_Label; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; pitchLabel = (PropertyManagerPageLabel)selectionGroup.AddControl(pitchLabelID, controlType, "Pitch", align, options, "Rotation about the Y axis"); //create pitch textbox controlType = (int)swPropertyManagerPageControlType_e.swControlType_Textbox; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Visible; pitchTextbox = (PropertyManagerPageTextbox)selectionGroup.AddControl(pitchTextboxID, controlType, "0.0", align, options, "Enter the rotation about the Y axis"); //create the yaw text Label controlType = (int)swPropertyManagerPageControlType_e.swControlType_Label; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; yawLabel = (PropertyManagerPageLabel)selectionGroup.AddControl(yawLabelID, controlType, "Yaw", align, options, "Rotation about the Z axis"); //create roll textbox controlType = (int)swPropertyManagerPageControlType_e.swControlType_Textbox; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Visible; yawTextbox = (PropertyManagerPageTextbox)selectionGroup.AddControl(yawTextboxID, controlType, "0.0", align, options, "Enter the rotation about the Z axis"); ToggleManualAngles(currentAttachment.UseManualAngles); page.Show(); //ModelViewManager swModViewMgr = modelDoc.ModelViewManager; //IMathUtility mathUtil = ((IMathUtility)swApp.GetMathUtility()); //swManip = swModViewMgr.CreateManipulator((int)swManipulatorType_e.swTriadManipulator, this); //rotManipulator = (TriadManipulator)swManip.GetSpecificManipulator(); //rotManipulator.DoNotShow = (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowXYPlane //+ (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowYZPlane + (int)swTriadManipulatorDoNotShow_e.swTriadManipulatorDoNotShowZXPlane;// 127;//hides all exept for rotations SelectOrigin(); rollTextbox.Text = (currentAttachment.RotRoll * 180 / Math.PI).ToString(); pitchTextbox.Text = (currentAttachment.RotPitch * 180 / Math.PI).ToString(); yawTextbox.Text = (currentAttachment.RotYaw * 180 / Math.PI).ToString(); }