コード例 #1
0
        public SelectionRectDragController(SelectionRectDragControllerSetupArgs args)
        {
            _nodes                  = args.Nodes;
            _connections            = args.Connections;
            _panel                  = args.BaseControl;
            SelectionChangedCommand = args.SelectionChangedCommand;


            var startPosition = args.Args.GetPosition(args.BaseControl);

            _startPoint.X = startPosition.X;
            _startPoint.Y = startPosition.Y;

            //! オプション引数としてStyleが渡されている場合はStyleを適用する
            if (args.BaseControl.Style != null)
            {
                Debug.Assert(args.RectangleStyle.TargetType == typeof(Rectangle));
                Rectangle.Style = args.RectangleStyle;
            }
            else // デフォルトスタイルを利用する
            {
                if (_defaultStyle is null)
                {
                    _defaultStyle = make_default_style();
                }
                Rectangle.Style = _defaultStyle;
            }

            Canvas.SetLeft(Rectangle, _startPoint.X);
            Canvas.SetTop(Rectangle, _startPoint.Y);
            Rectangle.Width  = 1;
            Rectangle.Height = 1;
            _panel.Children.Add(Rectangle);
        }
コード例 #2
0
        public IDragController Build()
        {
            var setupArgs = new SelectionRectDragControllerSetupArgs(
                _dragControllerBuilder.InputElement,
                _dragControllerBuilder.MouseEventArgs,
                _dragControllerBuilder.Nodes,
                _dragControllerBuilder.ConnectionShapes)
            {
                SelectionChangedCommand = _dragControllerBuilder.SelectionChangedCommand,
                RectangleStyle          = SelectionRectangleStyle
            };

            return(new SelectionRectDragController(setupArgs));
        }