コード例 #1
0
        /// <summary>
        /// The node is upon to be resized.
        /// </summary>
        public void InitializeReshape(IInputModeContext context)
        {
            var graphControl = context.CanvasControl as GraphControl;

            layoutHelper = new LayoutHelper(graphControl, node);
            layoutHelper.InitializeLayout();
            handler.InitializeReshape(context);
        }
コード例 #2
0
        /// <summary>
        /// Initializes the drag.
        /// </summary>
        public void InitializeDrag(IInputModeContext context)
        {
            var imc = context.Lookup <IModelItemCollector>();

            if (imc != null)
            {
                imc.Add(node);
            }
            rotationCenter = node.Layout.GetCenter();
            initialAngle   = GetAngle();

            var graph = context.Lookup <IGraph>();

            if (graph != null)
            {
                compoundEdit = graph.BeginEdit("Change Rotation Angle", "Change Rotation Angle");
            }

            portHandles.Clear();
            var portContext = new DelegatingContext(context);

            foreach (var port in node.Ports)
            {
                var portHandle = new DummyPortLocationModelParameterHandle(port);
                portHandle.InitializeDrag(portContext);
                portHandles.Add(portHandle);
            }
            if (reshapeHandler != null)
            {
                reshapeHandler.InitializeReshape(context);
            }
            // Collect other visible nodes and their angles
            if (SnapToSameAngleDelta > 0)
            {
                var canvas       = context.CanvasControl;
                var rotatedNodes =
                    canvas.GetCanvasObjects()
                    .Select(co => co.UserObject)
                    // only collect nodes
                    .OfType <INode>()
                    // ... that are in the viewport
                    .Where(n => canvas.Viewport.Intersects(n.Layout.ToRectD()))
                    // ... and can be rotated
                    .Where(n => n.Style is RotatableNodeStyleDecorator)
                    // ... and are not *this* node
                    .Where(n => n != node);
                // Group nodes by identical angles
                nodeAngles =
                    rotatedNodes.GroupBy(n => ((RotatableNodeStyleDecorator)n.Style).Angle)
                    .Select(nodes => Tuple.Create(nodes.Key, nodes.ToList().AsEnumerable())).ToList();
            }
        }
コード例 #3
0
            public void InitializeReshape(IInputModeContext context)
            {
                simulationRectangle = new MutableRectangle(originalHandler.Bounds);
                var node = new SimpleNode {
                    Layout = simulationRectangle,
                    Style  =
                        new ShapeNodeStyle {
                        Shape = ShapeNodeShape.RoundRectangle,
                        Brush = Brushes.Transparent,
                        Pen   = new Pen(Brushes.Gray, 2)
                    }
                };

                shadowObject = context.CanvasControl.RootGroup.AddChild(node, GraphModelManager.DefaultNodeDescriptor).ToFront();

                originalHandler.InitializeReshape(context);
                originalBounds = originalHandler.Bounds.ToRectD();
            }
コード例 #4
0
        /// <summary>
        /// Stores the initial layout of the node in case the user cancels the resizing.
        /// </summary>
        /// <param name="inputModeContext"></param>
        public void InitializeDrag(IInputModeContext inputModeContext)
        {
            if (reshapeHandler != null)
            {
                // if there is a reshape handler: initialize to
                // ensure proper handling of a parent group node
                reshapeHandler.InitializeReshape(inputModeContext);
            }
            initialLayout.Reshape(GetNodeBasedOrientedRectangle());
            dummyLocation = initialLayout.GetAnchorLocation();
            dummySize     = initialLayout.GetSize();
            initialRect   = node.Layout.ToRectD();

            portHandles.Clear();
            var portContext = new DelegatingContext(inputModeContext);

            foreach (var port in node.Ports)
            {
                var portHandle = new DummyPortLocationModelParameterHandle(port);
                portHandle.InitializeDrag(portContext);
                portHandles.Add(portHandle);
            }
        }