Пример #1
0
        private void SetSelected(_Control control)
        {
            _selectedControls.Add(control);

            if (null == _adornerLayer)
            {
                _adornerLayer = AdornerLayer.GetAdornerLayer(control);
            }
            int rootHasCode = control.GetHashCode();

            if (!_adorners.ContainsKey(rootHasCode))
            {
                if (control is _Line)
                {
                    _adorners.Add(rootHasCode, new LineAdorner(control as _Line));
                }
                else
                {
                    _adorners.Add(rootHasCode, new ElementAdorner(control));
                }
            }
            ElementAdorner rootAdorner = _adorners[rootHasCode];

            _adornerLayer.Add(rootAdorner);

            LoadAdorner(rootAdorner);
        }
Пример #2
0
        private void HandlerMouseButtonLeftDown(MouseButtonEventArgs e, _Control rootElement)
        {
            if (null != rootElement)
            {
                if (null == _adornerLayer)
                {
                    _adornerLayer = AdornerLayer.GetAdornerLayer(rootElement);
                }
                int rootHasCode = rootElement.GetHashCode();
                if (!_adorners.ContainsKey(rootHasCode))
                {
                    if (rootElement is _Line)
                    {
                        _adorners.Add(rootHasCode, new LineAdorner(rootElement as _Line));
                    }
                    else
                    {
                        _adorners.Add(rootHasCode, new ElementAdorner(rootElement));
                    }
                }
                ElementAdorner rootAdorner = _adorners[rootHasCode];
                if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                {
                    if (_selectedControls.Contains(rootElement))
                    {
                        _adornerLayer.Remove(rootAdorner);

                        UnLoadAdorner(rootAdorner);
                        _selectedControls.Remove(rootElement);
                    }
                    else
                    {
                        _adornerLayer.Add(rootAdorner);

                        LoadAdorner(rootAdorner);

                        _selectedControls.Add(rootElement);
                        rootAdorner.RaisePreviewMouseLeftButtonDown(e);
                    }
                }
                else
                {
                    CleanSelection();
                    _adornerLayer.Add(rootAdorner);

                    LoadAdorner(rootAdorner);
                    _selectedControls.Add(rootElement);
                    rootAdorner.RaisePreviewMouseLeftButtonDown(e);
                }
            }
            else
            {
                CleanSelection();
            }

            if (null != SelectionChangedAction)
            {
                SelectionChangedAction(_selectedControls);
            }
        }