コード例 #1
0
        private void worldTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            for (int i = toolStrip1.Items.Count - 1; i >= 0; i--)
            {
                ToolStripItem item = toolStrip1.Items[i];
                if (item.Alignment == System.Windows.Forms.ToolStripItemAlignment.Right)
                {
                    toolStrip1.Items.Remove(item);
                }
            }
            if (SelectedObject.Count == 1)
            {
                WorldTreeNode node = SelectedNodes[0];

                if (SelectedObject[0].ButtonBar != null)
                {
                    for (int i = SelectedObject[0].ButtonBar.Count - 1; i >= 0; i--)
                    {
                        ToolStripItem button = (ToolStripItem)(SelectedObject[0].ButtonBar[i]);
                        toolStrip1.Items.Add(button);
                    }
                }
                // set the propertyGrid to the selected object
                nodePropertyGrid.SelectedObject = SelectedObject[0];

                // enable and update position panel
                if (SelectedObject[0] is IObjectPosition)
                {
                    positionPanel.Enabled = true;

                    // enable/disable y up/down buttons
                    yUpButton.Enabled = SelectedPositionObject.AllowYChange;
                    yDownButton.Enabled = SelectedPositionObject.AllowYChange;
                    positionYTextBox.Enabled = SelectedPositionObject.AllowYChange;

                    UpdatePositionPanel(SelectedPositionObject.Position);
                }
                else
                {
                    positionPanel.Enabled = false;
                    UpdatePositionPanel(Vector3.Zero);
                }

                // enable and update scale panel
                if (SelectedObject[0] is IObjectScale)
                {
                    scalePanel.Enabled = true;
                    UpdateScalePanel(SelectedScaleObject.Scale);
                }
                else
                {
                    scalePanel.Enabled = false;
                    UpdateScalePanel(1);
                }

                // enable and update rotation panel
                if (SelectedObject[0] is IObjectRotation)
                {
                    rotationPanel.Enabled = true;
                    UpdateRotationPanel(SelectedRotationObject.Rotation);
                }
                else
                {
                    rotationPanel.Enabled = false;
                    UpdateRotationPanel(0);
                }

                // enable and update Orientation panel
                if (SelectedObject[0] is IObjectOrientation)
                {
                    orientationPanel.Enabled = true;
                    UpdateOrientationPanel(SelectedOrientationObject.Azimuth, SelectedOrientationObject.Zenith);
                }
                else
                {
                    orientationPanel.Enabled = false;
                    UpdateOrientationPanel(0, 0);
                }
                if (SelectedObject[0] is IObjectCameraLockable && lockCameraToObject)
                {
                    PositionCameraToObject(SelectedObject[0]);
                }
            }
            else
            {
                if (SelectedObject.Count > 1 || SelectedObject.Count == 0)
                {
                    nodePropertyGrid.SelectedObject = null;
                    orientationPanel.Enabled = false;
                    UpdateOrientationPanel(0, 0);
                    rotationPanel.Enabled = false;
                    UpdateRotationPanel(0);
                    scalePanel.Enabled = false;
                    UpdateScalePanel(1);
                    positionPanel.Enabled = false;
                    UpdatePositionPanel(Vector3.Zero);
                    CommandMenuBuilder menuBuilder = new CommandMenuBuilder();
                    foreach (ToolStripButton button in menuBuilder.MultiSelectButtonBar())
                    {
                        toolStrip1.Items.Add(button);
                    }
                }
            }
        }
コード例 #2
0
 public void UpdateButtonBar()
 {
     for (int i = toolStrip1.Items.Count - 1; i >= 0; i--)
     {
         ToolStripItem item = toolStrip1.Items[i];
         if (item.Alignment == System.Windows.Forms.ToolStripItemAlignment.Right)
         {
             toolStrip1.Items.Remove(item);
         }
     }
     if (SelectedObject.Count == 1)
     {
         if (SelectedObject[0].ButtonBar != null)
         {
             for (int i = SelectedObject[0].ButtonBar.Count - 1; i >= 0; i--)
             {
                 ToolStripItem button = (ToolStripItem)(SelectedObject[0].ButtonBar[i]);
                 toolStrip1.Items.Add(button);
             }
         }
     }
     else
     {
         if (SelectedObject.Count > 1)
         {
             CommandMenuBuilder menuBuilder = new CommandMenuBuilder();
             foreach (ToolStripButton button in menuBuilder.MultiSelectButtonBar())
             {
                 toolStrip1.Items.Add(button);
             }
         }
     }
 }