예제 #1
0
        HitTestResultBehavior NodeOrRailHitTestSelOnlyOneNodeCallback(HitTestResult result)
        {
            var frameworkElement = result.VisualHit as FrameworkElement;

            if (!(frameworkElement is Path))
            {
                return(HitTestResultBehavior.Continue);
            }
            object tag = frameworkElement.Tag;

            if (tag != null)
            {
                GraphmapsNode graphmapsNode = tag as GraphmapsNode;
                if (graphmapsNode != null)
                {
                    _nodeUnderMouse = graphmapsNode;
                    return(HitTestResultBehavior.Stop);
                }
                else
                {
                    var rail = frameworkElement.Tag as Rail;
                    if (rail != null)
                    {
                        _railUnderMouse = rail;
                    }
                }
            }

            return(HitTestResultBehavior.Continue);
        }
 public object GetNodeOrRailUnderMouse(RectangleGeometry rect) {
     _nodeUnderMouse = null;
     _railUnderMouse = null;
     VisualTreeHelper.HitTest(_graphCanvas, null,
         NodeOrRailHitTestSelOnlyOneNodeCallback,
         new GeometryHitTestParameters(rect));
     return (object)_nodeUnderMouse ?? _railUnderMouse;
 }
예제 #3
0
 public object GetNodeOrRailUnderMouse(RectangleGeometry rect)
 {
     _nodeUnderMouse = null;
     _railUnderMouse = null;
     VisualTreeHelper.HitTest(_graphCanvas, null,
                              NodeOrRailHitTestSelOnlyOneNodeCallback,
                              new GeometryHitTestParameters(rect));
     return((object)_nodeUnderMouse ?? _railUnderMouse);
 }
        HitTestResultBehavior NodeOrRailHitTestSelOnlyOneNodeCallback(HitTestResult result) {
            var frameworkElement = result.VisualHit as FrameworkElement;

            if (!(frameworkElement is Path))
                return HitTestResultBehavior.Continue;
            object tag = frameworkElement.Tag;
            if (tag != null) {
                GraphmapsNode graphmapsNode = tag as GraphmapsNode;
                if (graphmapsNode != null) {
                    _nodeUnderMouse = graphmapsNode;
                    return HitTestResultBehavior.Stop;
                }
                else {
                    var rail = frameworkElement.Tag as Rail;
                    if (rail != null)
                        _railUnderMouse = rail;
                }
            }

            return HitTestResultBehavior.Continue;
        }
 void SetNodeAppearence(GraphmapsNode node) {
     node.Node.Attr.LineWidth = GetBorderPathThickness();
 }
 bool IsSelected(GraphmapsNode vnode) {
     //if (lgSettings == null) return false;
     var nodeInfo = _lgLayoutSettings.GeometryNodesToLgNodeInfos[vnode.Node.GeometryNode];
     if (nodeInfo == null) return false;
     return nodeInfo.Selected;
 }
        void SelectEdgesIncidentTo(GraphmapsNode vnode) {
            var lgSettings = Graph.LayoutAlgorithmSettings as LgLayoutSettings;
            if (lgSettings == null) return;

            var nodeInfo = lgSettings.GeometryNodesToLgNodeInfos[vnode.Node.GeometryNode];
            lgSettings.Interactor.SelectAllEdgesIncidentTo(nodeInfo);
            ViewChangeEvent(null, null);
        }
 void HandleClickForNode(GraphmapsNode vnode) {
     if (clickCounter.DownCount == clickCounter.UpCount && clickCounter.UpCount == 1) {                
         //SelectRailsOfIncidentEdgesOnActiveLayer(vnode, !isSelected(vnode));
         SelectEdgesIncidentTo(vnode);
         SelectUnselectNode(vnode.LgNodeInfo, !IsSelected(vnode));
         //ToggleNodeSlidingZoom(vnode);
         //ToggleNodeEdgesSlidingZoom(vnode);
     }
     vnode.Invalidate();
 }
        GraphmapsNode CreateVNode(Node node) {
            lock (this) {
                Debug.Assert(!_drawingObjectsToIViewerObjects.ContainsKey(node));
                FrameworkElement feOfLabel = CreateAndRegisterFrameworkElementOfDrawingNode(node);

                var vn = new GraphmapsNode(node, GetCorrespondingLgNode(node), feOfLabel,
                    e => (GraphmapsEdge)_drawingObjectsToIViewerObjects[e], () => GetBorderPathThickness() * node.Attr.LineWidth, _lgLayoutSettings);

                foreach (var fe in vn.FrameworkElements) {
                    GraphCanvasChildrenAdd(fe);
                    Panel.SetZIndex(fe, 500);
                }
                if (feOfLabel != null) {
                    Panel.SetZIndex(feOfLabel, 600);
                    var viewbox = feOfLabel as Viewbox;
                    if (viewbox != null)
                        if (!string.IsNullOrEmpty(node.LabelText))
                            viewbox.IsHitTestVisible = true;
                }

                _drawingObjectsToIViewerObjects[node] = vn;
                node.Attr.LineWidth = GetBorderPathThickness();
                return vn;
            }
        }
        void AdjustNodeVisualsForHighZoomLevel(int iLevel, GraphmapsNode vnode, Node node) {
            var levelScale = GetLevelScale(iLevel);
            var nodeDotWidth = _lgLayoutSettings.NodeDotWidthInInches*DpiX/levelScale;
            var nodeMinWidth = _lgLayoutSettings.NodeDotWidthInInchesMinInImage*DpiX/levelScale;
            if (vnode.LgNodeInfo.ZoomLevel > Math.Pow(2, iLevel))
                nodeDotWidth = Math.Max(nodeMinWidth,
                    nodeDotWidth*(2*Math.Pow(2, iLevel)/vnode.LgNodeInfo.ZoomLevel));
            else {
                HideVNode(node);
                return;
            }

            vnode.Node.Attr.LineWidth = 0; //GetBorderPathThickness(tileScale);

            vnode.InvalidateNodeDot(nodeDotWidth*0.8); // make them just a bit smaller
            vnode.HideNodeLabel();
            vnode.SetLowTransparency();
        }
        private void ArrangeNodeLabel(GraphmapsNode vNode, double zf)
        {
            double nodeLabelHeight = _lgLayoutSettings.NodeLabelHeightInInches*DpiY/CurrentScale;
            double nodeLabelWidth = nodeLabelHeight*vNode.LgNodeInfo.LabelWidthToHeightRatio;

            if (vNode.LgNodeInfo.LabelVisibleFromScale >= 0 &&
                vNode.LgNodeInfo.LabelVisibleFromScale <= zf) {
                var offset = Point.Scale(nodeLabelWidth + NodeDotWidth*1.01, nodeLabelHeight + NodeDotWidth*1.01,
                    vNode.LgNodeInfo.LabelOffset);
                vNode.InvalidateNodeLabel(nodeLabelHeight, nodeLabelWidth, offset);
            }
            else
                vNode.HideNodeLabel();
        }
 static void SetupTileNode(GraphmapsNode vNode) {
     vNode.Node.Attr.LineWidth = 0;
     vNode.SetLowTransparency();
 }