Пример #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);
                        }
                    }
                }
            }
        }
        private void InitializeToolbars()
        {
            List <ButtonBase> toolbarCommands = null;

            if (_layerConfigToolbar != null)
            {
                toolbarCommands = CreateButtonsForLayerConfigurationToolbar();
                if (toolbarCommands != null)
                {
                    foreach (ButtonBase btnBase in toolbarCommands)
                    {
                        _layerConfigToolbar.AddToolButton(btnBase.DataContext as ButtonDisplayInfo, btnBase.Command, _layerConfigToolbar.ToolPanelItems);
                    }
                }
            }

            if (_allLayersConfigToolbar != null)
            {
                toolbarCommands = CreateButtonsForAllLayersConfigurationToolbar();
                if (toolbarCommands != null)
                {
                    foreach (ButtonBase btnBase in toolbarCommands)
                    {
                        _allLayersConfigToolbar.AddToolButton(btnBase.DataContext as ButtonDisplayInfo, btnBase.Command, _allLayersConfigToolbar.ToolPanelItems);
                    }
                }
            }

            if (_mapContentsContenxtMenuToolbar != null)
            {
                toolbarCommands = CreateButtonsForContextMenu();
                if (toolbarCommands != null)
                {
                    foreach (ButtonBase btnBase in toolbarCommands)
                    {
                        _mapContentsContenxtMenuToolbar.AddToolButton(btnBase.DataContext as ButtonDisplayInfo, btnBase.Command, _mapContentsContenxtMenuToolbar.ToolPanelItems);
                    }
                    AddToolPanels();
                }
            }
        }