示例#1
0
        public override void Execute(object parameter)
        {
            object   instance = ToolInstance ?? Activator.CreateInstance(ToolType);
            ICommand command  = instance as ICommand;

            if (command != null)
            {
                ToolPanel.AddToolButton(DisplayInfo, command, ToolPanel.ToolPanelItems);
            }
            else
            {
                FrameworkElement frameworkElement = instance as FrameworkElement;
                if (frameworkElement != null)
                {
                    DropDownButton galleryButton = ToolPanel.AddToolGroupButton(DisplayInfo, null, ToolPanel.ToolPanelItems) as DropDownButton;
                    if (galleryButton != null)
                    {
                        Panel sp = galleryButton.PopupContent as Panel;
                        if (sp != null)
                        {
                            sp.Children.Add(frameworkElement);
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Builder
        /// </summary>
        public ToolBox()
            : base()
        {
            InitializeComponent();
            this.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;

            //Panels are created based on the categories defined
            List <Category> categories = Category.GetCategories();

            for (int i = 0; i < categories.Count; i++)
            {
                ToolPanel toolPanel = new ToolPanel(categories[i], ActionFactory.GetToolsAction(categories[i].Name), this.Location);
                //The panel is placed based on the previous
                try
                {
                    toolPanel.Location = new Point(0, this.toolPanels[i - 1].Bottom + PANEL_MARGIN);
                }
                catch
                {
                    //If it is the first one skips the exception and it is placed in the initial position
                    toolPanel.Location = new Point(0, 0);
                }
                toolPanel.InitInsert   += new ToolEventHandler(toolsPanel_InitInsert);
                toolPanel.DoInsert     += new PointEventHandler(toolsPanel_DoInsert);
                toolPanel.CancelInsert += new EventHandler(toolPanel_CancelInsert);
                toolPanel.ShowPanel    += new GroupPanelEventHandler(toolPanel_ShowPanel);
                toolPanel.ClosePanel   += new EventHandler(toolPanel_ClosePanel);
                this.pContainer.Controls.Add(toolPanel);
                this.toolPanels.Add(toolPanel);
            }
        }
示例#3
0
    void InitUI()
    {
        geoUI = new GeoUI();

        Transform canvasBack  = GameObject.Find("/UI/CanvasBack").transform;
        Transform canvasFront = GameObject.Find("/UI/CanvasFront").transform;

        NavPanel navPanel = canvasBack.Find("NavPanel").GetComponent <NavPanel>();

        navPanel.OnShadeButtonClick              = HandleClickShadeButton;
        navPanel.OnLockButtonClick               = HandleClickLockButton;
        navPanel.OnDisplayButtonClick            = HandleClickDisplayButton;
        navPanel.OnCoordinateButtonClick         = HandleClickCoordinateButton;
        navPanel.OnGridButtonClick               = HandleClickGridButton;
        navPanel.OnSnapButtonClick               = HandleClickSnapButton;
        geometryBehaviour.OnElementDisplayChange = HandleElementDisplayChange;
        navPanel.Init();

        ToolPanel toolPanel = canvasBack.Find("ToolPanel").GetComponent <ToolPanel>();

        toolPanel.Init();
        toolPanel.OnClickTool = HandleClickTool;

        StatePanel statePanel = canvasBack.Find("StatePanel").GetComponent <StatePanel>();

        statePanel.Init();

        InputPanel inputPanel = canvasBack.Find("InputPanel").GetComponent <InputPanel>();

        inputPanel.Init();

        ElementPanel elementPanel = canvasFront.Find("ElementPanel").GetComponent <ElementPanel>();

        elementPanel.Init();

        ActivePanel activePanel = canvasFront.Find("ActivePanel").GetComponent <ActivePanel>();

        activePanel.Init();

        CameraPanel cameraPanel = canvasFront.Find("CameraPanel").GetComponent <CameraPanel>();

        cameraPanel.OnCenterButtonClick  = HandleClickCenterButton;
        cameraPanel.OnZoomInButtonClick  = HandleClickZoomInButton;
        cameraPanel.OnZoomOutButtonClick = HandleClickZoomOutButton;
        cameraPanel.OnUpButtonClick      = HandleClickUpButton;
        cameraPanel.OnDownButtonClick    = HandleClickDownButton;
        cameraPanel.Init();
        cameraPanel.SetCenterButtonActive(false);

        geoUI.navPanel     = navPanel;
        geoUI.toolPanel    = toolPanel;
        geoUI.statePanel   = statePanel;
        geoUI.inputPanel   = inputPanel;
        geoUI.elementPanel = elementPanel;
        geoUI.activePanel  = activePanel;
        geoUI.cameraPanel  = cameraPanel;
    }
 public void showTool()
 {
     if (toolPaletteSet == null)
     {
         toolPaletteSet = new PaletteSet("工具栏", new System.Guid("D61D0875-A507-4b73-8B5F-9266BE399595"));
         tooPanel       = new ToolPanel();
         toolPaletteSet.AddVisual("ToolPanel", tooPanel);
     }
     toolPaletteSet.Visible = true;
     toolPaletteSet.SetSize(new System.Drawing.Size(185, 570));
 }
        public ConfigureEditorCommand()
        {
            if (ToolPanels.Current["EditorToolbarContainer"] == null)
            {
                _panel = new ToolPanel();
                _panel.ContainerName = "EditorToolbarContainer";
                _panel.Name          = "EditorToolbar";
                _panel.CanSerialize  = false;

                ToolPanels.Current.Add(_panel);
            }
        }
 private void OnCommandEnd(object sender, CommandEventArgs e)
 {
     if (e.GlobalCommandName.CompareTo("REVCLOUD") == 0)
     {
         Document doc = Application.DocumentManager.MdiActiveDocument;
         Database db  = doc.Database;
         PromptSelectionResult lastRes = doc.Editor.SelectLast();
         if (lastRes.Value != null && lastRes.Value.Count == 1)
         {
             //先给云线改颜色
             using (Transaction tr = db.TransactionManager.StartTransaction())
             {
                 //绑定数据
                 Autodesk.AutoCAD.Colors.Color selectedColor = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 0, 0);
                 int index = ToolPanel.currentConnectedType;
                 if (index == 1)
                 {
                     selectedColor = Autodesk.AutoCAD.Colors.Color.FromRgb(233, 150, 122);
                 }
                 else if (index == 2)
                 {
                     selectedColor = Autodesk.AutoCAD.Colors.Color.FromRgb(30, 144, 255);
                 }
                 else if (index == 3)
                 {
                     selectedColor = Autodesk.AutoCAD.Colors.Color.FromRgb(102, 249, 207);
                 }
                 doc.Editor.WriteMessage(index.ToString());
                 if (index != 0)
                 {
                     Entity ent = (Entity)tr.GetObject(lastRes.Value[0].ObjectId, OpenMode.ForRead);
                     ent.UpgradeOpen();
                     ent.Color = selectedColor;
                     //是否继续循环
                 }
                 tr.Commit();
                 //Utility.makeImageBottom();
             }
             District district = new District(currentSolution);
             district.BaseObjectId = lastRes.Value[0].ObjectId;
             Error err = district.CheckAndSave(ToolPanel.currentConnectedType);
             if (err.Err != Error.ErrorCode.NoErr)
             {
                 System.Windows.MessageBox.Show(err.Message);
                 district.RemoveSelf();
             }
             currentSolution.Districts.Add(district.BaseObjectId, district);
             //MessageBox.Show("in");
             ToolPanel.DrawCloudLine();
         }
     }
 }
示例#7
0
        private void PopulateToolbar()
        {
            if (ToolPanels.Current == null || ToolPanels.Current.Count <= 0 || this._popupToolbarContentControl == null)
            {
                return;
            }

            ToolPanel popupToolPanel = ToolPanels.Current.FirstOrDefault(p => p.ContainerName == this._popupToolbarContentControl.Name);

            if (popupToolPanel != null)
            {
                this._popupToolbarContentControl.Content = popupToolPanel;
            }
        }
示例#8
0
 /// <summary>
 /// Sets the toolbar.
 /// </summary>
 public void SetToolBar()
 {
     try
     {
         var _toolbar = new ToolPanel();
         GridBoxPanel?.Controls.Add(ToolBar);
         _toolbar.Dock = DockStyle.Fill;
         _toolbar.Dock = DockStyle.Bottom;
     }
     catch (Exception ex)
     {
         Fail(ex);
     }
 }
        private void Wizard_Completed(object sender, EventArgs e)
        {
            // Get tool properties UI
            EditToolbarItemControl toolPropsUI = null;

            if (sender is EditToolbarItemControl)
            {
                toolPropsUI = sender as EditToolbarItemControl;
            }
            else
            {
                Wizard wizard = sender as Wizard;
                foreach (WizardPage page in wizard.Pages)
                {
                    toolPropsUI = page.Content as EditToolbarItemControl;
                    if (toolPropsUI != null)
                    {
                        break;
                    }
                }
            }

            // Update command properties with the configured values
            ToolPanel               = toolPropsUI.SelectedToolPanel;
            DisplayInfo             = DisplayInfo ?? new ButtonDisplayInfo();
            DisplayInfo.Label       = toolPropsUI.Label;
            DisplayInfo.Description = toolPropsUI.Description;
            DisplayInfo.Icon        = toolPropsUI.IconUrl;

            // Set completed flag so window closed handler knows that window was closed as a
            // result of configuration being completed
            completed = true;
            // Hide configuration UI and fire the completed event
            BuilderApplication.Instance.HideWindow(configurationUI);
            ISupportsWizardConfiguration wizardConfigInterface = Class as ISupportsWizardConfiguration;

            if (wizardConfigInterface != null)
            {
                wizardConfigInterface.OnCompleted();
            }
            if (Completed != null)
            {
                Completed(this, EventArgs.Empty);
            }
        }
示例#10
0
        internal EditValuesCommand GetEditValuesToolCommand()
        {
            if (_popupToolbarContentControl == null || _popupToolbarContentControl.Content == null)
            {
                return(null);
            }

            ToolPanel tools = _popupToolbarContentControl.Content as ToolPanel;

            if (tools != null)
            {
                foreach (var tool in tools.AllButtons)
                {
                    if (tool.Command is EditValuesCommand)
                    {
                        return(tool.Command as EditValuesCommand);
                    }
                }
            }
            return(null);
        }
示例#11
0
    private void Awake()
    {
        if (TransitionManager.Instance == null)
        {
            Debug.LogWarning("ToolManager: No TransitionManager was found, so the zoom tool will not properly size content - transition manager is needed to identify when new content has loaded.");
        }

        smallestZoom = TargetMinZoomSize;
        panel        = GetComponent <ToolPanel>();

        if (panel == null)
        {
            Debug.LogError("ToolManager couldn't find ToolPanel. Hiding and showing of Tools unavailable.");
        }

        toolSounds = GetComponentInChildren <ToolSounds>();

        if (panel == null)
        {
            Debug.LogError("ToolManager couldn't find ToolSounds.");
        }
    }
示例#12
0
        public void ShowTools()
        {
            DoubleAnimation a = null;

            if (this.ToolPanel.Source == null)
            {
                this.ToolPanel.Navigate(this.ToolPage);
            }

            if (!_toolShow)
            {
                a      = new DoubleAnimation(this.ToolFrameWidth, TimeSpan.FromSeconds(0.3));
                a.From = 0;
            }
            else
            {
                a      = new DoubleAnimation(0, TimeSpan.FromSeconds(0.3));
                a.From = ToolFrameWidth;
            }

            ToolPanel.BeginAnimation(Frame.WidthProperty, a);
            _toolShow = !_toolShow;
        }
示例#13
0
        public DrawForm(List <VertexDraw> vertexDraws, List <EdgeDraw> edgeDraws, List <List <CellBox> > matrix, StartForm startForm,
                        InputCountVertexForm inputCountVertexForm, MatrixGraph matrixGraph, AdjacencyList adjacencyList)

        {
            InitializeComponent();

            StartPosition = FormStartPosition.CenterScreen;

            Text = "GraphVizualizer / Draw";

            this.BackColor = Color.DarkGray;

            DoubleBuffered = true;

            this.vertexDraws = vertexDraws;

            this.edgeDraws = edgeDraws;

            collisionVertex = new CollisionVertex();

            newEdgeDefinition = new NewEdgeDefinition();

            drawingEdges = new DrawingEdges();

            MouseDown += new MouseEventHandler(MouseClickDrawForm);

            vertexBrush = new SolidBrush(Color.Black);

            vertexStringFormat = new StringFormat();

            vertexStringFormat.Alignment = StringAlignment.Center;

            vertexStringFormat.LineAlignment = StringAlignment.Center;

            vertexTextFont = new Font("Times New Roman", 12, FontStyle.Bold);

            pen = new Pen(Brushes.Black, 5);

            weightTable = new WeightTable(200, 200, Size.Width - 200, 0);

            matrixWeightPanel = new MatrixWeightPanel(weightTable, matrix);

            matrixWeightPanel.DrawingMatrix();

            Controls.Add(weightTable);

            converter = new Converter();

            this.adjacencyList = adjacencyList;

            adListPanel = new AdjacencyListPanel(200, 200, Size.Width - 200, 0, adjacencyList);

            Controls.Add(adListPanel);

            Controls.Add(adListPanel);

            shortestPathPanel = new ShortestPathPanel(200, 200, 150, 0, adjacencyList, edgeDraws, this);

            Controls.Add(shortestPathPanel);

            toolPanel = new ToolPanel(0, 100, weightTable, this.edgeDraws
                                      , adjacencyList, this, adListPanel, this.vertexDraws, matrix
                                      , adListPanel.AdListTable.Cells, shortestPathPanel);

            Controls.Add(toolPanel);

            pen.EndCap = LineCap.ArrowAnchor;

            arrow = new Arrow();

            brushes = new Brush[2];

            brushes[(int)BrushColor.Orange] = Brushes.Orange;

            brushes[(int)BrushColor.Black] = Brushes.Black;

            backToMenuOfDrawButton = new BackToMenuFromDrawButton(adjacencyList, vertexDraws, edgeDraws,
                                                                  this, adListPanel, weightTable, matrix, adListPanel.AdListTable.Cells);

            backToInputFromDrawButton = new BackToInputFromDrawButton(adjacencyList, vertexDraws, edgeDraws,
                                                                      this, adListPanel, weightTable, matrix, adListPanel.AdListTable.Cells, inputCountVertexForm, matrixGraph, startForm);

            Controls.Add(backToInputFromDrawButton);

            Controls.Add(backToMenuOfDrawButton);
        }
        public override void OnApplyTemplate()
        {
            MapContentControlContainer = GetTemplateChild(PART_MAP_CONTENT_CONTAINER_CONTROL) as ContentControl;
            if (MapContentControlContainer != null)
            {
                MapContentControl               = new MapContents();
                MapContentControl.Name          = PART_MAP_CONTENT_CONTROL;
                MapContentControl.Map           = View.Map;
                MapContentControl.Configuration = new MapContentsConfiguration {
                    ContextMenuToolPanelName = "EditModeLayerConfigurationContextMenu", Mode = Mode.TopLevelLayersOnly
                };

                if (MapContentControlContainer.Resources != null)
                {
                    MapContentControl.ScrollViewerStyle          = MapContentControlContainer.Resources["BuilderMapContentsScrollViewerStyle"] as Style;
                    MapContentControl.SelectionColorBrush        = MapContentControlContainer.Resources["BuilderSelectedLayerColorBrush"] as Brush;
                    MapContentControl.SelectionOutlineColorBrush = MapContentControlContainer.Resources["BuilderSelectedLayerOutlineColorBrush"] as Brush;
                    MapContentControl.ToggleButtonStyle          = MapContentControlContainer.Resources["MapContentsControlNodeToggleButton"] as Style;
                }

                // Push foreground and background to map contents
                Binding b = new Binding("Foreground")
                {
                    Source = this
                };
                MapContentControl.SetBinding(MapContents.ForegroundProperty, b);
                b = new Binding("Background")
                {
                    Source = this
                };
                MapContentControl.SetBinding(MapContents.BackgroundProperty, b);

                MapContentControlContainer.Content = MapContentControl;
            }

            layerConfigurationLayout = GetTemplateChild(PART_CONFIGURE_LAYER_CONTROL_LAYOUT) as Grid;
            LayerConfiguration       = GetTemplateChild("LayerConfigurationDialog") as LayerConfiguration;
            if (LayerConfiguration != null)
            {
                LayerConfiguration.View = View.Instance;
            }

            mapContentLayerConfigurationLayout = GetTemplateChild(PART_MAP_CONTENTS_LAYER_CONFIGURATION_LAYOUT) as Grid;
            if (mapContentLayerConfigurationLayout != null)
            {
                mapContentLayerConfigurationLayout.Loaded      -= mapContentLayerConfigurationLayout_Loaded;
                mapContentLayerConfigurationLayout.Loaded      += mapContentLayerConfigurationLayout_Loaded;
                mapContentLayerConfigurationLayout.SizeChanged -= mapContentLayerConfigurationLayout_SizeChanged;
                mapContentLayerConfigurationLayout.SizeChanged += mapContentLayerConfigurationLayout_SizeChanged;
            }

            mapContentsLayout               = GetTemplateChild(PART_MAP_CONTENT_CONTROL_LAYOUT) as Grid;
            btnConfigurationComplete        = GetTemplateChild(PART_CONFIGURE_COMPLETE_BUTTON) as Button;
            _layerConfigToolbar             = GetTemplateChild(PART_TOOLPANEL) as ToolPanel;
            _allLayersConfigToolbar         = GetTemplateChild(PART_ALLLAYERSTOOLPANEL) as ToolPanel;
            _mapContentsContenxtMenuToolbar = GetTemplateChild(PART_EDIT_MODE_LAYER_CONFIGURATION_CONTEXT_MENU) as ToolPanel;
            _layerConfigPanel               = GetTemplateChild(PART_LAYERCONFIGPANEL) as FrameworkElement;
            InitializeToolbars();

            // hide the layer configuration elements until we need them
            RemoveLayerConfigurationVisualElements();
        }
示例#15
0
        void AssociatedObject_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            MapContents cont = ControlTreeHelper.FindAncestorOfType <MapContents>(AssociatedObject);

            if (cont == null)
            {
                return;
            }

            MapContentsConfiguration conf = cont.DataContext as MapContentsConfiguration;

            if (conf == null)
            {
                return;
            }

            if (ToolPanels.Current != null && !string.IsNullOrWhiteSpace(conf.ContextMenuToolPanelName))
            {
                _toolPanel = ToolPanels.Current[conf.ContextMenuToolPanelName];
            }

            if (_toolPanel == null)
            {
                return;
            }

            _contextMenu = new ContextMenu();
            if (ContextMenuStyle != null)
            {
                _contextMenu.Style = ContextMenuStyle;
            }

            // Bind background and foreground properties to context menu
            Binding b = new Binding("ContextMenuBackground")
            {
                Source = this
            };

            _contextMenu.SetBinding(ContextMenu.BackgroundProperty, b);

            b = new Binding("ContextMenuForeground")
            {
                Source = this
            };
            _contextMenu.SetBinding(ContextMenu.ForegroundProperty, b);

            // set the control to the current culture settings (LTR/RTL)
            RTLHelper helper = System.Windows.Application.Current.Resources["RTLHelper"] as RTLHelper;

            Debug.Assert(helper != null);
            if (helper != null)
            {
                _contextMenu.FlowDirection = helper.FlowDirection;
            }

            foreach (FrameworkElement button in _toolPanel.ToolPanelItems)
            {
                System.Windows.Controls.Primitives.ButtonBase btnBase = button as System.Windows.Controls.Primitives.ButtonBase;
                if (btnBase != null)
                {
                    MenuItem          item = new MenuItem();
                    ButtonDisplayInfo info = btnBase.DataContext as ButtonDisplayInfo;
                    if (info != null)
                    {
                        item.Header = info.Label;
                        if (!string.IsNullOrEmpty(info.Icon))
                        {
                            Image   image   = new Image();
                            Binding binding = new Binding("Icon")
                            {
                                Converter = _urlResolver
                            };
                            image.SetBinding(Image.SourceProperty, binding);
                            image.DataContext = info;
                            item.Icon         = image;
                        }
                        item.Command = btnBase.Command;
                        _contextMenu.Items.Add(item);
                    }
                }
                else
                {
                    _contextMenu.Items.Add(new Separator());
                }
            }

            Point point = e.GetPosition(null);

            if (point != null)
            {
                _contextMenu.HorizontalOffset = point.X;
                _contextMenu.VerticalOffset   = point.Y;
            }

            LayerItemViewModel layerViewModel = AssociatedObject.DataContext as LayerItemViewModel;

            if (layerViewModel != null && layerViewModel.Layer != null)
            {
                if (!CoreExtensions.GetIsSelected(layerViewModel.Layer))
                {
                    SetSelectedLayer(layerViewModel.Layer);
                }
            }
            if (_contextMenu.Items.Count > 0)
            {
                _contextMenu.IsOpen = true;

                if (_contextMenu.FlowDirection == FlowDirection.RightToLeft)
                {
                    // Now that the popup is open, we can update the layout measurements so that
                    // the ActualWidth is available.
                    _contextMenu.UpdateLayout();
                    _contextMenu.HorizontalOffset -= _contextMenu.ActualWidth;
                }
            }
        }
示例#16
0
 public void Init(ToolPanel toolPanel)
 {
     this.toolPanel  = toolPanel;
     totalToolGroups = ConfigManager.ToolGroups;
 }
示例#17
0
 void Awake()
 {
     Current = this;
 }