Beispiel #1
0
        /// <summary>
        /// React on tool enabled changed.
        /// </summary>
        /// <param name="sender">Tool.</param>
        /// <param name="e">Ignored.</param>
        private void _ToolEnabledChanged(object sender, EventArgs e)
        {
            IMapTool tool = (IMapTool)sender;

            int index = _tools.IndexOf(tool);

            if (index != -1)
            {
                if (tool == _currentTool && !tool.IsEnabled && _currentTool.IsActivated)
                {
                    _DeactivateTool();
                }

                ToggleButton toggleButton = _toolButtonsPanel.Children[index] as ToggleButton;
                if (toggleButton != null)
                {
                    toggleButton.IsEnabled = tool.IsEnabled;
                }
                else
                {
                    ToolComboButton toolComboButton = _toolButtonsPanel.Children[index] as ToolComboButton;
                    toolComboButton.Enable(tool.IsEnabled);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// On tool activated by tool combo button.
        /// </summary>
        /// <param name="sender">Tool combo button.</param>
        /// <param name="e">Ignored.</param>
        private void _OnToolActivated(object sender, EventArgs e)
        {
            ToolComboButton toolComboButton = sender as ToolComboButton;
            int             index           = _toolButtonsPanel.Children.IndexOf(toolComboButton);

            _OnToolClick(toolComboButton.SelectedTool);

            _tools[index].OnComplete     -= new EventHandler(_OnCompleteTool);
            _tools[index].EnabledChanged -= new EventHandler(_ToolEnabledChanged);

            _tools[index] = toolComboButton.SelectedTool;

            _tools[index].OnComplete     += new EventHandler(_OnCompleteTool);
            _tools[index].EnabledChanged += new EventHandler(_ToolEnabledChanged);
        }
Beispiel #3
0
        /// <summary>
        /// Add tools.
        /// </summary>
        /// <param name="tools">Tools for adding.</param>
        /// <param name="canActivateToolHandler">Callback for checking is tool can be activated.</param>
        private void _AddTools(IMapTool[] tools, CanActivateToolHandler canActivateToolHandler)
        {
            foreach (IMapTool tool in tools)
            {
                tool.Initialize(_mapctrl);
            }

            IMapTool toolOnPanel = tools[0];

            toolOnPanel.OnComplete     += new EventHandler(_OnCompleteTool);
            toolOnPanel.EnabledChanged += new EventHandler(_ToolEnabledChanged);
            _tools.Add(toolOnPanel);

            _canActivateToolHandlers.Add(canActivateToolHandler);

            ToolComboButton button = new ToolComboButton();

            button.ToolActivated += new EventHandler(_OnToolActivated);
            button.Init(tools);

            _toolButtonsPanel.Children.Add(button);
        }
Beispiel #4
0
        /// <summary>
        /// Deactivate current tool.
        /// </summary>
        private void _DeactivateTool()
        {
            _mapctrl.ClickedCoords = null;
            if (_currentTool != _editingTool)
            {
                int          oldIndex     = _tools.IndexOf(_currentTool);
                ToggleButton toggleButton = _toolButtonsPanel.Children[oldIndex] as ToggleButton;
                if (toggleButton != null)
                {
                    toggleButton.IsChecked = false;
                }
                else
                {
                    ToolComboButton toolComboButton = _toolButtonsPanel.Children[oldIndex] as ToolComboButton;
                    toolComboButton.Check(false);
                }

                _mapctrl.map.Cursor = _overridedCursor;
                _overridedCursor    = null;
            }

            if (_currentTool != null)
            {
                _currentTool.Deactivate();
            }
            if (_mapctrl.IsInEditedMode)
            {
                _currentTool = _editingTool;
                _editingTool.EditingObject = _mapctrl.EditedObject;
            }
            else
            {
                _currentTool = null;
            }
            Mouse.OverrideCursor = null;
        }
Beispiel #5
0
        /// <summary>
        /// Start edit.
        /// </summary>
        /// <param name="item">Editing item.</param>
        internal void StartEdit(object item)
        {
            _editedCollection.Add(item);

            // In case of editing barriers need to support correct view.
            if (item is Barrier)
            {
                _editedObjectLayer.LayerContext = App.Current.CurrentDate;
            }

            _editedObjectLayer.MapLayer.Graphics[0].Select();

            // Prepare toolbar.
            for (int index = 0; index < _toolButtonsPanel.Children.Count; index++)
            {
                ToggleButton toggleButton = _toolButtonsPanel.Children[index] as ToggleButton;

                if (toggleButton != null)
                {
                    // TODO: check if this needed
                    toggleButton.IsEnabled = _canActivateToolHandlers[index]();
                    toggleButton.IsChecked = false;
                }
                else
                {
                    ToolComboButton toolComboButton = _toolButtonsPanel.Children[index] as ToolComboButton;
                    toolComboButton.IsEnabled = _canActivateToolHandlers[index]();
                }
            }

            // Prepare for edit.
            _ActivateTool(_editingTool);
            _editingTool.EditingObject = item;
            FillEditMarkers(item);
            _editMarkersLayer.Visible = true;
        }