public override void AddPropertiesToSWPage(JointPMPage page, ref int id, ref int mark)
 {
     modelDoc.ClearSelection2(true);
     Axis1.AddAxisToPage(ref id, ref mark, page, ref AxisSelBoxID);
     if(!Axis1.UseCustomMovementLimits && !((RotationalJointAxis)Axis1).IsContinuous)
         Axis1.AddLimitsToPage(ref id, ref mark, page);
 }
        /// <summary>
        /// Adds the limit Selection Boxes to the page
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="mark"></param>
        /// <param name="page"></param>
        public override void AddLimitsToPage(ref int Id, ref int mark, JointPMPage page)
        {
            LimitSelBoxIds = new int[4];
            LimitButtonIds = new int[4];
            LimitButtons = new Dictionary<int, PropertyManagerPageBitmapButton>();
            limitLabels = new List<object>();

            List<SelectData> marks = new List<SelectData>();
            List<object> selectionObjects = new List<object>();

            short labelCT = (int)swPropertyManagerPageControlType_e.swControlType_Label;
            short selectionboxCT = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox;
            short checkboxCT = (int)swPropertyManagerPageControlType_e.swControlType_CheckableBitmapButton;
            // align
            short indentAlign = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_Indent;
            short leftAlign = (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
            int[] allfilter = new int[] { (int)swSelectType_e.swSelDATUMAXES, (int)swSelectType_e.swSelEDGES, (int)swSelectType_e.swSelFACES, (int)swSelectType_e.swSelVERTICES, (int)swSelectType_e.swSelDATUMPLANES, (int)swSelectType_e.swSelDATUMPOINTS };

            PropertyManagerPageGroup jointMovementLimitsGroup = (PropertyManagerPageGroup)page.page.AddGroupBox(Id++, "Joint Movement Limits", groupboxOptions);

            PMPgroups.Add(jointMovementLimitsGroup);
            //Setup and create joint lower edgelabel
            PropertyManagerPageLabel jointLinkLowerEdgeLabel = (PropertyManagerPageLabel)jointMovementLimitsGroup.AddControl(Id++, labelCT, "Lower Link Edge", indentAlign, controlOptions, "Select a lower edge for this joint");
            limitLabels.Add(jointLinkLowerEdgeLabel);

            //setup and create joint lower edge selection box
            PropertyManagerPageSelectionbox jointLinkLowerEdgeSelectionbox = (PropertyManagerPageSelectionbox)jointMovementLimitsGroup.AddControl(Id, selectionboxCT, "Lower Link Edge", indentAlign, controlOptions, "Use this box to select the lower edge of the link");
            jointLinkLowerEdgeSelectionbox.AllowSelectInMultipleBoxes = true;
            jointLinkLowerEdgeSelectionbox.SingleEntityOnly = true;
            jointLinkLowerEdgeSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2);
            jointLinkLowerEdgeSelectionbox.Mark = mark;
            jointLinkLowerEdgeSelectionbox.SetSelectionFilters(allfilter);

            SelectionMgr selMgr = modelDoc.SelectionManager;
            selMgr.SelectionColor[mark] = (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2;

            if (LowerLimitEdge != null)
            {
                SelectData limitData = selMgr.CreateSelectData();
                limitData.Mark = mark;
                selectionObjects.Add(LowerLimitEdge);
                marks.Add(limitData);
                //((IEntity)LowerLimitEdge).Select4(true, limitData);
            }

            SelBoxes.Add(Id, jointLinkLowerEdgeSelectionbox);
            LimitSelBoxIds[1] = Id;
            mark = mark << 1;
            Id++;

            PropertyManagerPageBitmapButton
                flipLowerLimitEdgeDirectionButton = (PropertyManagerPageBitmapButton)jointMovementLimitsGroup.AddControl(Id, checkboxCT, "flipAxisDirection", leftAlign, controlOptions, "Check to flip the direction of movement for this joint");
            flipLowerLimitEdgeDirectionButton.Checked = FlipVectors[1]==1;
            flipLowerLimitEdgeDirectionButton.SetStandardBitmaps((int)swPropertyManagerPageBitmapButtons_e.swBitmapButtonImage_reverse_direction);
            LimitButtons.Add(Id, flipLowerLimitEdgeDirectionButton);
            LimitButtonIds[1] = Id;

            ((PropertyManagerPageControl)flipLowerLimitEdgeDirectionButton).Top = 20;
            ((PropertyManagerPageControl)jointLinkLowerEdgeSelectionbox).Top = 20;
            Id++;

            //Setup and create joint lower limit stop label
            PropertyManagerPageLabel jointLowerLimitStopLabel = (PropertyManagerPageLabel)jointMovementLimitsGroup.AddControl(Id++, labelCT, "Lower Motion Limit", indentAlign, controlOptions, "Select a lower limit for this joint");
            limitLabels.Add(jointLowerLimitStopLabel);
            //setup and create joint lower limit selection box
            PropertyManagerPageSelectionbox jointLowerLimitStopSelectionbox = (PropertyManagerPageSelectionbox)jointMovementLimitsGroup.AddControl(Id, selectionboxCT, "LowerMotionLimit", indentAlign, controlOptions, "Use this box to select the lower limit of the link");
            jointLowerLimitStopSelectionbox.AllowSelectInMultipleBoxes = true;
            jointLowerLimitStopSelectionbox.SingleEntityOnly = true;
            jointLowerLimitStopSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem3);
            jointLowerLimitStopSelectionbox.Mark = mark;
            jointLowerLimitStopSelectionbox.SetSelectionFilters(allfilter);

            selMgr.SelectionColor[mark] = (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem3;
            if (LowerLimitStop != null)
            {
                if (selectionObjects.Contains(LowerLimitStop))
                {
                    int index = selectionObjects.IndexOf(LowerLimitStop);
                    marks[index].Mark |= mark;
                }
                else
                {
                    SelectData limitData = selMgr.CreateSelectData();
                    limitData.Mark = mark;
                    selectionObjects.Add(LowerLimitStop);
                    marks.Add(limitData);
                }

                //((IEntity)LowerLimitStop).Select4(true, limitData);
            }
            SelBoxes.Add(Id, jointLowerLimitStopSelectionbox);
            LimitSelBoxIds[0] = Id;
            mark = mark << 1;
            Id++;

            PropertyManagerPageBitmapButton
                flipLowerLimitDirectionButton = (PropertyManagerPageBitmapButton)jointMovementLimitsGroup.AddControl(Id, checkboxCT, "flipAxisDirection", leftAlign, controlOptions, "Check to flip the direction of movement for this joint");
            flipLowerLimitDirectionButton.Checked = FlipVectors[0] == 1; ;
            flipLowerLimitDirectionButton.SetStandardBitmaps((int)swPropertyManagerPageBitmapButtons_e.swBitmapButtonImage_reverse_direction);
            LimitButtons.Add(Id, flipLowerLimitDirectionButton);
            LimitButtonIds[0] = Id;

            ((PropertyManagerPageControl)flipLowerLimitDirectionButton).Top = 120;
            ((PropertyManagerPageControl)jointLowerLimitStopSelectionbox).Top = 120;

            Id++;

            //Setup and create joint upper edgelabel
            PropertyManagerPageLabel jointLinkUpperEdgeLabel = (PropertyManagerPageLabel)jointMovementLimitsGroup.AddControl(Id++, labelCT, "Upper Link Edge", indentAlign, controlOptions, "Select a Upper edge for this joint");
            limitLabels.Add(jointLinkUpperEdgeLabel);
            //setup and create joint Upper edge selection box
            PropertyManagerPageSelectionbox jointLinkUpperEdgeSelectionbox = (PropertyManagerPageSelectionbox)jointMovementLimitsGroup.AddControl(Id, selectionboxCT, "Upper Link Edge", indentAlign, controlOptions, "Use this box to select the upper edge of the link");
            jointLinkUpperEdgeSelectionbox.AllowSelectInMultipleBoxes = true;
            jointLinkUpperEdgeSelectionbox.SingleEntityOnly = true;
            jointLinkUpperEdgeSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2);
            jointLinkUpperEdgeSelectionbox.Mark = mark;
            jointLinkUpperEdgeSelectionbox.SetSelectionFilters(allfilter);

            selMgr.SelectionColor[mark] = (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2;
            if (UpperLimitEdge != null)
            {
                if (selectionObjects.Contains(UpperLimitEdge))
                {
                    int index = selectionObjects.IndexOf(UpperLimitEdge);
                    marks[index].Mark |= mark;
                }
                else
                {
                    SelectData limitData = selMgr.CreateSelectData();
                    limitData.Mark = mark;
                    selectionObjects.Add(UpperLimitEdge);
                    marks.Add(limitData);
                }
            }
            SelBoxes.Add(Id, jointLinkUpperEdgeSelectionbox);
            LimitSelBoxIds[3] = Id;
            mark = mark << 1;
            Id++;

            PropertyManagerPageBitmapButton
                flipUpperLimitEdgeDirectionButton = (PropertyManagerPageBitmapButton)jointMovementLimitsGroup.AddControl(Id, checkboxCT, "flipAxisDirection", leftAlign, controlOptions, "Check to flip the direction of movement for this joint");
            flipUpperLimitEdgeDirectionButton.Checked = FlipVectors[3] == 1; ;
            flipUpperLimitEdgeDirectionButton.SetStandardBitmaps((int)swPropertyManagerPageBitmapButtons_e.swBitmapButtonImage_reverse_direction);
            LimitButtons.Add(Id, flipUpperLimitEdgeDirectionButton);
            LimitButtonIds[3] = Id;

            ((PropertyManagerPageControl)flipUpperLimitEdgeDirectionButton).Top = 220;
            ((PropertyManagerPageControl)jointLinkUpperEdgeSelectionbox).Top = 220;

            //Setup and create joint Upper limit stop label
            PropertyManagerPageLabel jointUpperLimitStopLabel = (PropertyManagerPageLabel)jointMovementLimitsGroup.AddControl(Id++, labelCT, "Upper Motion Limit", indentAlign, controlOptions, "Select an Upper limit for this joint");
            limitLabels.Add(jointUpperLimitStopLabel);
            //Setup and create joint upper limit selectionbox
            PropertyManagerPageSelectionbox jointUpperLimitStopSelectionbox = (PropertyManagerPageSelectionbox)jointMovementLimitsGroup.AddControl(Id, selectionboxCT, "Upper Motion Limit", indentAlign, controlOptions, "Use this box to select the upper limit of the joint");
            jointUpperLimitStopSelectionbox.AllowSelectInMultipleBoxes = true;
            jointUpperLimitStopSelectionbox.SingleEntityOnly = true;
            jointUpperLimitStopSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem3);
            jointUpperLimitStopSelectionbox.Mark = mark;
            jointUpperLimitStopSelectionbox.SetSelectionFilters(allfilter);

            selMgr.SelectionColor[mark] = (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem3;
            if (UpperLimitStop != null)
            {
                if (selectionObjects.Contains(UpperLimitStop))
                {
                    int index = selectionObjects.IndexOf(UpperLimitStop);
                    marks[index].Mark |= mark;
                }
                else
                {
                    SelectData limitData = selMgr.CreateSelectData();
                    limitData.Mark = mark;
                    selectionObjects.Add(UpperLimitStop);
                    marks.Add(limitData);
                }
            }
            SelBoxes.Add(Id, jointUpperLimitStopSelectionbox);
            LimitSelBoxIds[2] = Id;
            mark = mark << 1;
            Id++;

            PropertyManagerPageBitmapButton
                flipUpperLimitDirectionButton = (PropertyManagerPageBitmapButton)jointMovementLimitsGroup.AddControl(Id, checkboxCT, "flipAxisDirection", leftAlign, controlOptions, "Check to flip the direction of movement for this joint");
            flipUpperLimitDirectionButton.Checked = FlipVectors[2] == 1; ;
            flipUpperLimitDirectionButton.SetStandardBitmaps((int)swPropertyManagerPageBitmapButtons_e.swBitmapButtonImage_reverse_direction);
            LimitButtons.Add(Id, flipUpperLimitDirectionButton);
            LimitButtonIds[2] = Id;

            ((PropertyManagerPageControl)flipUpperLimitDirectionButton).Top = 320;
            ((PropertyManagerPageControl)jointUpperLimitStopSelectionbox).Top = 320;

            Id++;

            for (int i = 0; i < selectionObjects.Count;i++ )
            {
                ((IEntity)selectionObjects[i]).Select4(true, marks[i]);
            }

            //((PropertyManagerPageControl)Buttons[ButtonIds[0]]).Enabled = false;
        }
        /// <summary>
        /// Adds the limit Selection Boxes to the page
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="mark"></param>
        /// <param name="page"></param>
        public virtual void AddLimitsToPage(ref int Id, ref int mark, JointPMPage page)
        {
            LimitSelBoxIds = new int[4];
            short labelCT = (int)swPropertyManagerPageControlType_e.swControlType_Label;
            short selectionboxCT = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox;
            // align
            short leftAlign = (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
            int[] allfilter = new int[] { (int)swSelectType_e.swSelDATUMAXES, (int)swSelectType_e.swSelEDGES, (int)swSelectType_e.swSelFACES, (int)swSelectType_e.swSelVERTICES, (int)swSelectType_e.swSelDATUMPLANES, (int)swSelectType_e.swSelDATUMPOINTS };

            PropertyManagerPageGroup jointMovementLimitsGroup = (PropertyManagerPageGroup)page.page.AddGroupBox(Id++, "Joint Movement Limits", groupboxOptions);

            PMPgroups.Add(jointMovementLimitsGroup);
            //Setup and create joint lower edgelabel
            PropertyManagerPageLabel jointLinkLowerEdgeLabel = (PropertyManagerPageLabel)jointMovementLimitsGroup.AddControl(Id++, labelCT, "Lower Link Edge", leftAlign, controlOptions, "Select a lower edge for this joint");
            labels.Add(jointLinkLowerEdgeLabel);

            //setup and create joint lower edge selection box
            PropertyManagerPageSelectionbox jointLinkLowerEdgeSelectionbox = (PropertyManagerPageSelectionbox)jointMovementLimitsGroup.AddControl(Id, selectionboxCT, "Lower Link Edge", leftAlign, controlOptions, "Use this box to select the lower edge of the link");
            jointLinkLowerEdgeSelectionbox.AllowSelectInMultipleBoxes = false;
            jointLinkLowerEdgeSelectionbox.SingleEntityOnly = true;
            jointLinkLowerEdgeSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2);
            jointLinkLowerEdgeSelectionbox.Mark = mark;
            jointLinkLowerEdgeSelectionbox.SetSelectionFilters(allfilter);

            SelectionMgr selMgr = modelDoc.SelectionManager;
            selMgr.SelectionColor[mark] = (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2;

            if (LowerLimitEdge != null)
            {
                SelectData limitData = selMgr.CreateSelectData();
                limitData.Mark = mark;
                ((IEntity)LowerLimitEdge).Select4(true, limitData);
            }

            SelBoxes.Add(Id, jointLinkLowerEdgeSelectionbox);
            LimitSelBoxIds[1] = Id;
            mark = mark << 1;
            Id++;

            //Setup and create joint lower limit stop label
            PropertyManagerPageLabel jointLowerLimitStopLabel = (PropertyManagerPageLabel)jointMovementLimitsGroup.AddControl(Id++, labelCT, "Lower Motion Limit", leftAlign, controlOptions, "Select a lower limit for this joint");
            labels.Add(jointLowerLimitStopLabel);

            //setup and create joint lower limit selection box
            PropertyManagerPageSelectionbox jointLowerLimitStopSelectionbox = (PropertyManagerPageSelectionbox)jointMovementLimitsGroup.AddControl(Id, selectionboxCT, "LowerMotionLimit", leftAlign, controlOptions, "Use this box to select the lower limit of the link");
            jointLowerLimitStopSelectionbox.AllowSelectInMultipleBoxes = false;
            jointLowerLimitStopSelectionbox.SingleEntityOnly = true;
            jointLowerLimitStopSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem3);
            jointLowerLimitStopSelectionbox.Mark = mark;
            jointLowerLimitStopSelectionbox.SetSelectionFilters(allfilter);

            selMgr.SelectionColor[mark] = (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem3;
            if (LowerLimitStop != null)
            {
                SelectData limitData = selMgr.CreateSelectData();
                limitData.Mark = mark;
                ((IEntity)LowerLimitStop).Select4(true, limitData);
            }
            SelBoxes.Add(Id, jointLowerLimitStopSelectionbox);
            LimitSelBoxIds[0] = Id;
            mark = mark << 1;
            Id++;

            //Setup and create joint upper edgelabel
            PropertyManagerPageLabel jointLinkUpperEdgeLabel = (PropertyManagerPageLabel)jointMovementLimitsGroup.AddControl(Id++, labelCT, "Upper Link Edge", leftAlign, controlOptions, "Select a Upper edge for this joint");
            labels.Add(jointLinkUpperEdgeLabel);

            //setup and create joint Upper edge selection box
            PropertyManagerPageSelectionbox jointLinkUpperEdgeSelectionbox = (PropertyManagerPageSelectionbox)jointMovementLimitsGroup.AddControl(Id, selectionboxCT, "Upper Link Edge", leftAlign, controlOptions, "Use this box to select the upper edge of the link");
            jointLinkUpperEdgeSelectionbox.AllowSelectInMultipleBoxes = false;
            jointLinkUpperEdgeSelectionbox.SingleEntityOnly = true;
            jointLinkUpperEdgeSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2);
            jointLinkUpperEdgeSelectionbox.Mark = mark;
            jointLinkUpperEdgeSelectionbox.SetSelectionFilters(allfilter);

            selMgr.SelectionColor[mark] = (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2;
            if (UpperLimitEdge != null)
            {
                SelectData limitData = selMgr.CreateSelectData();
                limitData.Mark = mark;
                ((IEntity)UpperLimitEdge).Select4(true, limitData);
            }
            SelBoxes.Add(Id, jointLinkUpperEdgeSelectionbox);
            LimitSelBoxIds[3] = Id;
            mark = mark << 1;
            Id++;

            //Setup and create joint Upper limit stop label
            PropertyManagerPageLabel jointUpperLimitStopLabel = (PropertyManagerPageLabel)jointMovementLimitsGroup.AddControl(Id++, labelCT, "Upper Motion Limit", leftAlign, controlOptions, "Select an Upper limit for this joint");
            labels.Add(jointUpperLimitStopLabel);

            //Setup and create joint upper limit selectionbox
            PropertyManagerPageSelectionbox jointUpperLimitStopSelectionbox = (PropertyManagerPageSelectionbox)jointMovementLimitsGroup.AddControl(Id, selectionboxCT, "Upper Motion Limit", leftAlign, controlOptions, "Use this box to select the upper limit of the joint");
            jointUpperLimitStopSelectionbox.AllowSelectInMultipleBoxes = false;
            jointUpperLimitStopSelectionbox.SingleEntityOnly = true;
            jointUpperLimitStopSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem3);
            jointUpperLimitStopSelectionbox.Mark = mark;
            jointUpperLimitStopSelectionbox.SetSelectionFilters(allfilter);

            selMgr.SelectionColor[mark] = (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem3;
            if (UpperLimitStop != null)
            {
                SelectData limitData = selMgr.CreateSelectData();
                limitData.Mark = mark;
                ((IEntity)UpperLimitStop).Select4(true, limitData);
            }
            SelBoxes.Add(Id, jointUpperLimitStopSelectionbox);
            LimitSelBoxIds[2] = Id;
            mark = mark << 1;
            Id++;

            ((PropertyManagerPageControl)Buttons[ButtonIds[0]]).Enabled = false;
        }
        /// <summary>
        /// Adds the axis selections to the page
        /// </summary>
        /// <param name="Id">Starting ID for the box. Will be incremented to the next avalible ID after</param>
        /// <param name="mark">Starting mark to be used, will be incremented to next avalible mark afterwards</param>
        /// <param name="page">Joint page to be added to</param>
        /// <param name="refAxisSelBoxId">The Id of the axis selection box</param>
        public void AddAxisToPage(ref int Id, ref int mark, JointPMPage page, ref int refAxisSelBoxId)
        {
            SelBoxes = new Dictionary<int, PropertyManagerPageSelectionbox>();
            Buttons = new Dictionary<int, PropertyManagerPageBitmapButton>();
            labels = new List<object>();
            ButtonIds = new int[1];

            //Helper variables for setup options
            //control type
            short labelCT = (int)swPropertyManagerPageControlType_e.swControlType_Label;
            short selectionboxCT = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox;
            short checkboxCT = (int)swPropertyManagerPageControlType_e.swControlType_CheckableBitmapButton;
            // align
            short leftAlign = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            short shiftedAlign = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_Indent;
            // 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
            int[] linefilter = { (int)swSelectType_e.swSelDATUMAXES, (int)swSelectType_e.swSelEDGES };

            //Setup and create the joint properties group
            PropertyManagerPageGroup jointPropertiesGroup = (PropertyManagerPageGroup)page.page.AddGroupBox(Id++, "Joint Properties", groupboxOptions);

            PMPgroups.Add(jointPropertiesGroup);
            //Setup and create the label for the joint axis 1 selection box
            PropertyManagerPageLabel jointAxis1Label = (PropertyManagerPageLabel)jointPropertiesGroup.AddControl(Id++, labelCT, "Axis", shiftedAlign, controlOptions, "Select an axis for this joint");
            labels.Add(jointAxis1Label);
            //Setup and create the joint axis 1 selectionbox
            PropertyManagerPageSelectionbox jointAxis1Selectionbox = (PropertyManagerPageSelectionbox)jointPropertiesGroup.AddControl(Id, selectionboxCT, "Axis 1", shiftedAlign, controlOptions, "Use this box to select the axis of movment of this joint");
            jointAxis1Selectionbox.AllowSelectInMultipleBoxes = false;
            jointAxis1Selectionbox.SingleEntityOnly = true;
            jointAxis1Selectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem1);
            jointAxis1Selectionbox.Mark = mark;

            jointAxis1Selectionbox.SetSelectionFilters(linefilter);
            SelectionMgr selMgr = modelDoc.SelectionManager;
            selMgr.SelectionColor[mark] = (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem1;

            if (Axis != null)
            {
                SelectData axisData = selMgr.CreateSelectData();
                axisData.Mark = mark;
                ((IEntity)Axis).Select4(true, axisData);
            }
            page.PrevSelectId = Id;

            SelBoxes.Add(Id, jointAxis1Selectionbox);
            AxisSelBoxId = Id;
            refAxisSelBoxId = Id;
            page.SelectionObservers.Add(this);
            mark = mark << 1;
            Id++;

            //Setup and create the axis flip checkbox
            PropertyManagerPageBitmapButton
                flipAxisDirectionButton = (PropertyManagerPageBitmapButton)jointPropertiesGroup.AddControl(Id, checkboxCT, "flipAxisDirection", leftAlign, controlOptions, "Check to flip the direction of movement for this joint");
            flipAxisDirectionButton.Checked = AxisIsFlipped;
            flipAxisDirectionButton.SetStandardBitmaps((int)swPropertyManagerPageBitmapButtons_e.swBitmapButtonImage_reverse_direction);

            ((PropertyManagerPageControl)flipAxisDirectionButton).Top = 20;
            ((PropertyManagerPageControl)jointAxis1Selectionbox).Top = 20;

            Buttons.Add(Id, flipAxisDirectionButton);
            ButtonIds[0] = Id;
            page.ButtonObservers.Add(this);
            Id++;
            LimitSelBoxIds = null;
        }
 /// <summary>
 /// Adds the properties of this joint to the solidwoprks page
 /// </summary>
 /// <param name="page">Page to add the properties to</param>
 /// <param name="id">Id to start numbering new controls with. Will be returned with the next avaliable ID</param>
 /// <param name="mark">The mark to start with for any new selection boxes. Will be returned with the next avalible mark</param>
 public abstract void AddPropertiesToSWPage(JointPMPage page, ref int id, ref int mark);
 /// <summary>
 /// Creates and fills a new solidworks property page
 /// </summary>
 /// <returns>The newly created proprerty page</returns>
 public virtual JointPMPage FillPropertyPage()
 {
     JointPMPage page = new JointPMPage(robot, joint, (AssemblyDoc)modelDoc, swApp);
     return page;
 }
        /// <summary>
        /// Adds the joint pose selections to the pmpage
        /// <param name="page">The page to add the boxes too</param>
        /// </summary>
        public void AddJointPoseToPMPage(JointPMPage page)
        {
            if (!page.CheckboxObservers.Contains(this))
                page.CheckboxObservers.Add(this);
            if (!page.SelectionObservers.Contains(this))
                page.SelectionObservers.Add(this);
            if (!page.ButtonObservers.Contains(this))
                page.ButtonObservers.Add(this);

            labels = new List<object>();
            selBoxes = new Dictionary<int, PropertyManagerPageSelectionbox>();
            selBoxIDs = new int[3];
            flipButtons = new Dictionary<int, PropertyManagerPageBitmapButton>();
            flipButtonIds = new int[2];
            checkBoxes = new Dictionary<int, PropertyManagerPageCheckbox>();
            checkboxIds = new int[2];

            //Helper variables for setup options
            //control type
            short labelCT = (int)swPropertyManagerPageControlType_e.swControlType_Label;
            short selectionboxCT = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox;
            short checkboxCT = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
            short buttonCT = (int)swPropertyManagerPageControlType_e.swControlType_CheckableBitmapButton;
            // align
            short leftAlign = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            short shiftedAlign = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_Indent;
            // options
            int groupboxOptions = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded |
                                  (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible |
                                  (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Checkbox; // for group box
            int controlOptions = (int)swAddControlOptions_e.swControlOptions_Enabled |
                                 (int)swAddControlOptions_e.swControlOptions_Visible; // for controls
            int[] selectionfilter = { (int)swSelectType_e.swSelDATUMAXES, (int)swSelectType_e.swSelEDGES, (int)swSelectType_e.swSelFACES,(int)swSelectType_e.swSelDATUMPLANES };
            int[] originfilter = { (int)swSelectType_e.swSelDATUMPOINTS, (int)swSelectType_e.swSelVERTICES };

            //Setup and create the joint pose group
            groupBox = (PropertyManagerPageGroup)page.page.AddGroupBox(page.currentId++, "Joint Pose", groupboxOptions);
            groupBox.Expanded = groupBox.Checked;

            //Setup and create the label for the origin point selection box
            PropertyManagerPageLabel originPointLabel = (PropertyManagerPageLabel)groupBox.AddControl(
                page.currentId++, labelCT, "Joint origin point", shiftedAlign, controlOptions, "Select the origin point for this joint");
            labels.Add(originPointLabel);
            //Setup and create the origin point selectionbox
            PropertyManagerPageSelectionbox originPointSelectionbox = (PropertyManagerPageSelectionbox)groupBox.AddControl(
                page.currentId, selectionboxCT, "Joint origin point", shiftedAlign, controlOptions, "Use this box to select a point");
            originPointSelectionbox.AllowSelectInMultipleBoxes = false;
            originPointSelectionbox.SingleEntityOnly = true;
            originPointSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem1);
            originPointSelectionbox.Mark = page.currentMark;
            originPointSelectionbox.SetSelectionFilters(originfilter);

            selBoxes.Add(page.currentId, originPointSelectionbox);
            selBoxIDs[0] = page.currentId++;
            page.currentMark = page.currentMark << 1;

            //Setup and create the align to x-axis checkbox
            PropertyManagerPageCheckbox alignToXaxisCheckbox = (PropertyManagerPageCheckbox)groupBox.AddControl(
                page.currentId, checkboxCT, "Align X-axis to movement axis", leftAlign, controlOptions, "");
            checkBoxes.Add(page.currentId,alignToXaxisCheckbox);
            checkboxIds[0] = page.currentId++;

            //Setup and create the label for the x-axis selection box
            PropertyManagerPageLabel XAxisLabel = (PropertyManagerPageLabel)groupBox.AddControl(
                page.currentId++, labelCT, "X-axis", shiftedAlign, controlOptions, "Select X-axis for this joint");
            labels.Add(XAxisLabel);
            //create x-axis flipbutton
            PropertyManagerPageBitmapButton flipXAxisButton = (PropertyManagerPageBitmapButton)groupBox.AddControl(
                page.currentId, buttonCT, "Flip X-axis", leftAlign, controlOptions, "Check to flip the direction of the x-axis");
            flipXAxisButton.SetStandardBitmaps((int)swPropertyManagerPageBitmapButtons_e.swBitmapButtonImage_reverse_direction);
            flipXAxisButton.Checked = false;
            flipButtons.Add(page.currentId, flipXAxisButton);
            flipButtonIds[0] = page.currentId++;
            //Setup and create the x-axis selectionbox
            PropertyManagerPageSelectionbox XAxisSelectionbox = (PropertyManagerPageSelectionbox)groupBox.AddControl(
                page.currentId, selectionboxCT, "X-axis", shiftedAlign, controlOptions, "Use this box to select an axis");
            XAxisSelectionbox.AllowSelectInMultipleBoxes = false;
            XAxisSelectionbox.SingleEntityOnly = true;
            XAxisSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2);
            XAxisSelectionbox.Mark = page.currentMark;
            XAxisSelectionbox.SetSelectionFilters(selectionfilter);

            selBoxes.Add(page.currentId, XAxisSelectionbox);
            selBoxIDs[1] = page.currentId++;
            page.currentMark = page.currentMark << 1;

            ((PropertyManagerPageControl)XAxisSelectionbox).Top = 110;
            ((PropertyManagerPageControl)flipXAxisButton).Top = (short)(((PropertyManagerPageControl)XAxisSelectionbox).Top + 3);

            //Setup and create the label for the y-axis selection box
            PropertyManagerPageLabel YAxisLabel = (PropertyManagerPageLabel)groupBox.AddControl(
                page.currentId++, labelCT, "Y-axis", shiftedAlign, controlOptions, "Select the Y-axis of the joint");
            labels.Add(YAxisLabel);
            //Setup and create the y-axis flipbutton
            PropertyManagerPageBitmapButton flipYAxisButton = (PropertyManagerPageBitmapButton)groupBox.AddControl(
                page.currentId, buttonCT, "Flip axis direction", leftAlign, controlOptions, "Check to flip the direction of the axis to the direction of the x-axis");
            flipYAxisButton.SetStandardBitmaps((int)swPropertyManagerPageBitmapButtons_e.swBitmapButtonImage_reverse_direction);
            flipYAxisButton.Checked = false;
            flipButtons.Add(page.currentId, flipYAxisButton);
            flipButtonIds[1] = page.currentId++;
            //Setup and create the y-axis selection box
            PropertyManagerPageSelectionbox YAxisSelectionbox = (PropertyManagerPageSelectionbox)groupBox.AddControl(
                page.currentId, selectionboxCT, "Y-axis", shiftedAlign, controlOptions, "Use this box to select an axis");
            YAxisSelectionbox.AllowSelectInMultipleBoxes = false;
            YAxisSelectionbox.SingleEntityOnly = true;
            YAxisSelectionbox.SetSelectionColor(true, (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem4);
            YAxisSelectionbox.Mark = page.currentMark;
            YAxisSelectionbox.SetSelectionFilters(selectionfilter);
            selBoxes.Add(page.currentId, YAxisSelectionbox);
            selBoxIDs[2] = page.currentId++;
            page.currentMark = page.currentMark << 1;

            ((PropertyManagerPageControl)YAxisSelectionbox).Top = 160;
            ((PropertyManagerPageControl)flipYAxisButton).Top = (short)(((PropertyManagerPageControl)YAxisSelectionbox).Top + 3);
            LoadPMPValues();
        }