コード例 #1
0
 private void CheckLine()
 {
     if (_editor.SelectedItems != null && _editor.SelectedItems.Count == 1 && _editor.SelectedItems[0] is Helios.Controls.LineDecoration)
     {
         if (!_isline)
         {
             _children.Remove(_bottomLeft);
             _children.Remove(_bottomRight);
             _topRight.Cursor = Cursors.Cross;
             _topLeft.Cursor  = Cursors.Cross;
         }
         Helios.Controls.LineDecoration line = _editor.SelectedItems[0] as Helios.Controls.LineDecoration;
         _tempLine = new Helios.Controls.LineDecoration();
         _tempLine.Clone(line);
         _isline = true;
     }
     else
     {
         if (_isline)
         {
             _children.Add(_bottomLeft);
             _children.Add(_bottomRight);
             _topRight.Cursor = Cursors.SizeNESW;
             _topLeft.Cursor  = Cursors.SizeNWSE;
         }
         _tempLine = null;
         _isline   = false;
     }
 }
コード例 #2
0
        private void HandleDragDelta(object sender, DragDeltaEventArgs args)
        {
            _editor.SnapManager.ForceProportions = Keyboard.Modifiers.HasFlag(ModifierKeys.Shift);
            _editor.SnapManager.IgnoreTargets    = Keyboard.Modifiers.HasFlag(ModifierKeys.Control);
            _editor.SnapManager.DragVector       = new Vector(args.HorizontalChange, args.VerticalChange);

            if (_isline)
            {
                Helios.Controls.LineDecoration line = _editor.SelectedItems[0] as Helios.Controls.LineDecoration;

                if (_editor.SnapManager.Action == SnapAction.LineStart)
                {
                    _tempLine.Start = GetLineDragPoint(_tempLine.End, _editor.SnapManager.NewLocation);
                }
                else if (_editor.SnapManager.Action == SnapAction.LineEnd)
                {
                    _tempLine.End = GetLineDragPoint(_tempLine.Start, _editor.SnapManager.NewLocation);
                }
            }

            InvalidateVisual();
        }
コード例 #3
0
        void TopRight_DragStarted(object sender, DragStartedEventArgs e)
        {
            _editor.LoadSnapTargets(true);

            if (_isline)
            {
                Helios.Controls.LineDecoration line = _editor.SelectedItems[0] as Helios.Controls.LineDecoration;
                _editor.SnapManager.Size     = new Size(1, 1);
                _editor.SnapManager.Location = line.End;
                _editor.SnapManager.Action   = SnapAction.LineEnd;
                _tempLine.Clone(line);
                line.IsHidden = true;
            }
            else
            {
                _editor.SnapManager.Action   = SnapAction.ResizeNE;
                _editor.SnapManager.Size     = _editor.SelectedItems.Rectangle.Size;
                _editor.SnapManager.Location = _editor.SelectedItems.Rectangle.TopLeft;
            }

            _editor.SnapManager.DragVector = new Vector(0, 0);
            _editor.Focus();
        }
コード例 #4
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Rect selectionRect = _editor.SelectedItems.Rectangle;

            selectionRect.Scale(_editor.ZoomFactor, _editor.ZoomFactor);

            if (_isline)
            {
                Helios.Controls.LineDecoration line = _editor.SelectedItems[0] as Helios.Controls.LineDecoration;
                _topLeft.Arrange(new Rect((line.Start.X - ResizeRadius) * _editor.ZoomFactor, (line.Start.Y - ResizeRadius) * _editor.ZoomFactor, ResizeDiameter, ResizeDiameter));
                _topRight.Arrange(new Rect((line.End.X - ResizeRadius) * _editor.ZoomFactor, (line.End.Y - ResizeRadius) * _editor.ZoomFactor, ResizeDiameter, ResizeDiameter));
            }
            else
            {
                _topLeft.Arrange(new Rect(selectionRect.Left - ResizeRadius, selectionRect.Top - ResizeRadius, ResizeDiameter, ResizeDiameter));
                _topRight.Arrange(new Rect(selectionRect.Right - ResizeRadius, selectionRect.Top - ResizeRadius, ResizeDiameter, ResizeDiameter));
                _bottomLeft.Arrange(new Rect(selectionRect.Left - ResizeRadius, selectionRect.Bottom - ResizeRadius, ResizeDiameter, ResizeDiameter));
                _bottomRight.Arrange(new Rect(selectionRect.Right - ResizeRadius, selectionRect.Bottom - ResizeRadius, ResizeDiameter, ResizeDiameter));
            }

            // Return the final size.
            return(finalSize);
        }
コード例 #5
0
        void HandleDragCompleted(object sender, DragCompletedEventArgs e)
        {
            ConfigManager.UndoManager.StartBatch();

            if (_editor.SnapManager.Action == SnapAction.LineStart || _editor.SnapManager.Action == SnapAction.LineEnd)
            {
                Helios.Controls.LineDecoration line = _editor.SelectedItems[0] as Helios.Controls.LineDecoration;
                line.Start    = _tempLine.Start;
                line.End      = _tempLine.End;
                line.IsHidden = false;
            }
            else
            {
                double scaleX = Math.Max(_editor.SnapManager.NewSize.Width / _editor.SelectedItems.Rectangle.Size.Width, 0d);
                double scaleY = Math.Max(_editor.SnapManager.NewSize.Height / _editor.SelectedItems.Rectangle.Size.Height, 0d);
                ScaleVisuals(_editor.SelectedItems, _editor.SelectedItems.Rectangle, _editor.SnapManager.LocationOffset, scaleX, scaleY, _editor.SnapManager.ForceProportions);
            }

            ConfigManager.UndoManager.CloseBatch();

            _editor.SnapManager.Action = SnapAction.None;

            InvalidateVisual();
        }
コード例 #6
0
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            if (_editor.SelectedItems.Count > 0)
            {
                Pen   rectPen     = _drawFocus ? SelectionRectPen : SelectionRectPenNoFocus;
                Brush circleBrush = _drawFocus ? SelectionResizeBrush : SelectionResizeBrushNoFocus;

                if (_isline)
                {
                    Point start;
                    Point end;

                    drawingContext.PushTransform(new ScaleTransform(_editor.ZoomFactor, _editor.ZoomFactor));
                    if (_editor.SnapManager.Action == SnapAction.LineStart || _editor.SnapManager.Action == SnapAction.LineEnd)
                    {
                        drawingContext.PushTransform(new TranslateTransform(_tempLine.Left, _tempLine.Top));
                        _tempLine.Renderer.Render(drawingContext);
                        drawingContext.Pop();

                        start = _tempLine.Start;
                        end   = _tempLine.End;
                    }
                    else
                    {
                        Helios.Controls.LineDecoration line = _editor.SelectedItems[0] as Helios.Controls.LineDecoration;

                        start = line.Start;
                        end   = line.End;
                        if (_editor.SnapManager.Action == SnapAction.Move)
                        {
                            start += _editor.SnapManager.LocationOffset;
                            end   += _editor.SnapManager.LocationOffset;
                            _tempLine.Clone(line);

                            drawingContext.PushTransform(new TranslateTransform(_tempLine.Left + _editor.SnapManager.LocationOffset.X, _tempLine.Top + _editor.SnapManager.LocationOffset.Y));
                            _tempLine.Renderer.Render(drawingContext);
                            drawingContext.Pop();
                        }
                    }
                    drawingContext.Pop();

                    start.X *= _editor.ZoomFactor;
                    start.Y *= _editor.ZoomFactor;
                    end.X   *= _editor.ZoomFactor;
                    end.Y   *= _editor.ZoomFactor;

                    drawingContext.DrawEllipse(circleBrush, rectPen, start, ResizeRadius, ResizeRadius);
                    drawingContext.DrawEllipse(circleBrush, rectPen, end, ResizeRadius, ResizeRadius);
                }
                else
                {
                    foreach (HeliosVisual visual in _editor.SelectedItems)
                    {
                        Rect visualRect = visual.DisplayRectangle;
                        visualRect.Scale(_editor.ZoomFactor, _editor.ZoomFactor);
                        drawingContext.DrawRectangle(null, SelectionBorderPen, visualRect);
                    }

                    Rect selectionRect = (_editor.SnapManager.Action != SnapAction.None && _editor.SnapManager.Action != SnapAction.Drop && _editor.SnapManager.IsValidDrag) ? _editor.SnapManager.NewRectangle : _editor.SelectedItems.Rectangle;
                    selectionRect.Scale(_editor.ZoomFactor, _editor.ZoomFactor);

                    drawingContext.DrawRectangle(null, rectPen, selectionRect);

                    drawingContext.DrawEllipse(circleBrush, rectPen, selectionRect.TopLeft, ResizeRadius, ResizeRadius);
                    drawingContext.DrawEllipse(circleBrush, rectPen, selectionRect.TopRight, ResizeRadius, ResizeRadius);
                    drawingContext.DrawEllipse(circleBrush, rectPen, selectionRect.BottomLeft, ResizeRadius, ResizeRadius);
                    drawingContext.DrawEllipse(circleBrush, rectPen, selectionRect.BottomRight, ResizeRadius, ResizeRadius);
                }
            }
        }