コード例 #1
1
ファイル: DLabel.cs プロジェクト: mrkcass/SuffixTreeExplorer
 public DTextLabel(DObject parentPar, DrawingLabel label)
     : base(parentPar, label)
 {
 }
コード例 #2
0
 public DLabel(DObject parentPar, DrawingLabel label, FrameworkElement content)
     : base(parentPar)
 {
     DrawingLabel = label;
     if (parentPar != null)
     {
         label.Owner = parentPar.DrawingObject;
         if (label.GeometryLabel != null)
         {
             label.GeometryLabel.GeometryParent = parentPar.DrawingObject.GeometryObject;
         }
         if (parentPar.DrawingObject.GeometryObject is IGeometryLabeledObject)
         {
             ((IGeometryLabeledObject)parentPar.DrawingObject.GeometryObject).Label = label.GeometryLabel;
         }
     }
     if (ParentObject is IHavingDLabel)
     {
         ((IHavingDLabel)ParentObject).Label = this;
     }
     Content = content;
     if ((label.Owner is Node) && ((label.Owner as DrawingNode).GeometryObject as GeometryNode).BoundaryCurve != null)
     {
         Label.GeometryLabel.Center = ((Label.Owner as DrawingNode).GeometryObject as GeometryNode).Center;
         MakeVisual();
     }
     else if ((label.Owner is Edge) && ((label.Owner as DrawingEdge).GeometryObject as GeometryEdge).Curve != null)
     {
         Label.GeometryLabel.Center = ((Label.Owner as DrawingEdge).GeometryObject as GeometryEdge).BoundingBox.Center;
         MakeVisual();
     }
 }
コード例 #3
0
        internal static void AddStyleForPen(DObject dObj, Brush myPen, MsaglStyle style)
        {
            if (style == MsaglStyle.Dashed)
            {
                throw new NotImplementedException();

                /*
                 * myPen.DashStyle = DashStyle.Dash;
                 *
                 * if (dObj.DashPatternArray == null)
                 * {
                 *  float f = dObj.DashSize();
                 *  dObj.DashPatternArray = new[] { f, f };
                 * }
                 * myPen.DashPattern = dObj.DashPatternArray;
                 *
                 * myPen.DashOffset = dObj.DashPatternArray[0];
                 */
            }
            else if (style == MsaglStyle.Dotted)
            {
                throw new NotImplementedException();

                /*
                 * myPen.DashStyle = DashStyle.Dash;
                 * if (dObj.DashPatternArray == null)
                 * {
                 *  float f = dObj.DashSize();
                 *  dObj.DashPatternArray = new[] { 1, f };
                 * }
                 * myPen.DashPattern = dObj.DashPatternArray;
                 */
            }
        }
コード例 #4
0
ファイル: DLabel.cs プロジェクト: mrkcass/SuffixTreeExplorer
 public DLabel(DObject parentPar, DrawingLabel label, FrameworkElement content)
     : base(parentPar)
 {
     DrawingLabel = label;
     if (parentPar != null)
     {
         label.Owner = parentPar.DrawingObject;
         if (label.GeometryLabel != null)
             label.GeometryLabel.GeometryParent = parentPar.DrawingObject.GeometryObject;
         if (parentPar.DrawingObject.GeometryObject is IGeometryLabeledObject)
             ((IGeometryLabeledObject)parentPar.DrawingObject.GeometryObject).Label = label.GeometryLabel;
     }
     if (ParentObject is IHavingDLabel)
         ((IHavingDLabel)ParentObject).Label = this;
     Content = content;
     if ((label.Owner is Node) && ((label.Owner as DrawingNode).GeometryObject as GeometryNode).BoundaryCurve != null)
     {
         Label.GeometryLabel.Center = ((Label.Owner as DrawingNode).GeometryObject as GeometryNode).Center;
         MakeVisual();
     }
     else if ((label.Owner is Edge) && ((label.Owner as DrawingEdge).GeometryObject as GeometryEdge).Curve != null)
     {
         Label.GeometryLabel.Center = ((Label.Owner as DrawingEdge).GeometryObject as GeometryEdge).BoundingBox.Center;
         MakeVisual();
     }
 }
コード例 #5
0
        public virtual FrameworkElement GetNewGUIInstance(DObject obj)
        {
            DTextLabel editingLabel = obj is IHavingDLabel ? (obj as IHavingDLabel).Label as DTextLabel : obj as DTextLabel;

            if (editingLabel == null)
            {
                return(null);
            }
            var tb = new TextBox()
            {
                MinWidth = 50.0, Text = editingLabel.Text, SelectionStart = 0, SelectionLength = editingLabel.Text.Length, AcceptsReturn = true
            };

            tb.KeyDown += (sender, args) =>
            {
                if (System.Windows.Input.Keyboard.Modifiers == System.Windows.Input.ModifierKeys.None)
                {
                    if (args.Key == System.Windows.Input.Key.Enter)
                    {
                        Owner.LabelEditor.Close(true);
                    }
                    else if (args.Key == System.Windows.Input.Key.Escape)
                    {
                        Owner.LabelEditor.Close(false);
                    }
                }
            };
            return(tb);
        }
コード例 #6
0
 public bool IsAncestorOf(DObject obj)
 {
     if (obj == null)
     {
         return(false);
     }
     return(obj.ParentObject == this || IsAncestorOf(obj.ParentObject));
 }
コード例 #7
0
 public DNestedGraphLabel(DObject parentPar, FrameworkElement content)
     : base(parentPar, content)
 {
     Graphs = new List <DGraph>();
     if (content is DGraph)
     {
         Graphs.Add(content as DGraph);
         (content as DGraph).ParentObject = this;
     }
 }
コード例 #8
0
ファイル: DLabel.cs プロジェクト: mrkcass/SuffixTreeExplorer
 public DNestedGraphLabel(DObject parentPar, FrameworkElement content)
     : base(parentPar, content)
 {
     Graphs = new List<DGraph>();
     if (content is DGraph)
     {
         Graphs.Add(content as DGraph);
         (content as DGraph).ParentObject = this;
     }
 }
コード例 #9
0
        internal Geometry(DObject dObject)
        {
            this.dObject = dObject;

            DNode dNode = dObject as DNode;
            if (dNode != null)
                bBox = dNode.DrawingNode.BoundingBox;
            else
            {
                DLabel dLabel = dObject as DLabel;
                if (dLabel != null)
                    bBox = dLabel.Label.BoundingBox;
            }
        }
コード例 #10
0
ファイル: DNode.cs プロジェクト: mrkcass/SuffixTreeExplorer
        internal DNode(DObject graph, DrawingNode drawingNode)
            : base(graph)
        {
            this.DrawingNode = drawingNode;
            _OutEdges = new List<DEdge>();
            _InEdges = new List<DEdge>();
            _SelfEdges = new List<DEdge>();
            PortsToDraw = new Set<Port>();

            if (drawingNode.Label != null && drawingNode.Label.GeometryLabel != null)
                Label = new DTextLabel(this, drawingNode.Label);

            if (!(this is DCluster))
                Canvas.SetZIndex(this, 10000);
        }
コード例 #11
0
 public virtual FrameworkElement GetNewGUIInstance(DObject obj)
 {
     DTextLabel editingLabel = obj is IHavingDLabel ? (obj as IHavingDLabel).Label as DTextLabel : obj as DTextLabel;
     if (editingLabel == null)
         return null;
     var tb = new TextBox() { MinWidth = 50.0, Text = editingLabel.Text, SelectionStart = 0, SelectionLength = editingLabel.Text.Length, AcceptsReturn = true };
     tb.KeyDown += (sender, args) =>
     {
         if (System.Windows.Input.Keyboard.Modifiers == System.Windows.Input.ModifierKeys.None)
         {
             if (args.Key == System.Windows.Input.Key.Enter)
                 Owner.LabelEditor.Close(true);
             else if (args.Key == System.Windows.Input.Key.Escape)
                 Owner.LabelEditor.Close(false);
         }
     };
     return tb;
 }
コード例 #12
0
        internal Geometry(DObject dObject)
        {
            this.dObject = dObject;

            DNode dNode = dObject as DNode;

            if (dNode != null)
            {
                bBox = dNode.DrawingNode.BoundingBox;
            }
            else
            {
                DLabel dLabel = dObject as DLabel;
                if (dLabel != null)
                {
                    bBox = dLabel.Label.BoundingBox;
                }
            }
        }
コード例 #13
0
        internal DNode(DObject graph, DrawingNode drawingNode)
            : base(graph)
        {
            this.DrawingNode = drawingNode;
            _OutEdges        = new List <DEdge>();
            _InEdges         = new List <DEdge>();
            _SelfEdges       = new List <DEdge>();
            PortsToDraw      = new Set <Port>();

            if (drawingNode.Label != null && drawingNode.Label.GeometryLabel != null)
            {
                Label = new DTextLabel(this, drawingNode.Label);
            }

            if (!(this is DCluster))
            {
                Canvas.SetZIndex(this, 10000);
            }
        }
コード例 #14
0
        internal Line(DObject tag, MsaglPoint start, MsaglPoint end, double lw)
            : base(tag)
        {
            lineWidth = lw;
            MsaglPoint dir = end - start;

            if (lineWidth < 0)
            {
                lineWidth = 1;
            }

            double len = dir.Length;

            if (len > ApproximateComparer.IntersectionEpsilon)
            {
                dir /= (len / (lineWidth / 2));
                dir  = dir.Rotate(Math.PI / 2);
            }
            else
            {
                dir.X = 0;
                dir.Y = 0;
            }

            this.bBox = new Rectangle(start + dir);
            this.bBox.Add(start - dir);
            this.bBox.Add(end + dir);
            this.bBox.Add(end - dir);
            this.start = start;
            this.end   = end;

            if (this.bBox.LeftTop.X == this.bBox.RightBottom.X)
            {
                bBox.LeftTop     = bBox.LeftTop + new MsaglPoint(-0.05f, 0);
                bBox.RightBottom = bBox.RightBottom + new MsaglPoint(0.05f, 0);
            }
            if (this.bBox.LeftTop.Y == this.bBox.RightBottom.Y)
            {
                bBox.LeftTop     = bBox.LeftTop + new MsaglPoint(0, -0.05f);
                bBox.RightBottom = bBox.RightBottom + new MsaglPoint(0, 0.05f);
            }
        }
コード例 #15
0
        /// <summary>
        /// first and count denine the segment  needed to be split into two groups
        /// </summary>
        /// <param name="first"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        BBNode ProcessGroup(int first, int count)
        {
            if (count > 1)
            {
                int            seed0;
                MsaglRectangle b0;
                int            seed1;
                FindSeeds(first, count, out seed0, out b0, out seed1);
                MsaglRectangle b1;
                int            count0;
                int            count1;
                SplitOnGroups(first, count, seed0, ref b0, seed1, out b1, out count0, out count1);
                BBNode node = new BBNode();
                node.bBox         = new MsaglRectangle(b0, b1);
                node.left         = ProcessGroup(first, count0);
                node.left.parent  = node;
                node.right        = ProcessGroup(first + count0, count1);
                node.right.parent = node;
                return(node);
            }

            if (count == 1)
            {
                Geometry geom = geometries[first] as Geometry;
                if (geom != null)
                {
                    BBNode node = new BBNode();
                    node.geometry = geom;
                    return(node);
                }

                DObject dObject = geometries[first] as DObject;

                if (dObject != null)
                {
                    return(dObject.BBNode);
                }
            }

            return(null);
        }
コード例 #16
0
 void DObject_MouseMove(object sender, MouseEventArgs e)
 {
     if (e != m_CurrentEvent)
     {
         m_CurrentEvent  = e;
         m_LastObjectSet = null;
     }
     if (m_LastObjectSet == null)
     {
         DObject obj = this;
         if (obj is DLabel && !(obj.ParentObject is DEdge))
         {
             obj = obj.ParentObject;
         }
         if (obj is DGraph)
         {
             obj = null;
         }
         m_LastObjectSet = ParentGraph.ObjectUnderMouseCursor = obj;
     }
 }
コード例 #17
0
ファイル: Line.cs プロジェクト: mrkcass/SuffixTreeExplorer
        internal Line(DObject tag, MsaglPoint start, MsaglPoint end, double lw)
            : base(tag)
        {
            lineWidth = lw;
            MsaglPoint dir = end - start;
            if (lineWidth < 0)
                lineWidth = 1;

            double len = dir.Length;
            if (len > ApproximateComparer.IntersectionEpsilon)
            {
                dir /= (len / (lineWidth / 2));
                dir = dir.Rotate(Math.PI / 2);
            }
            else
            {
                dir.X = 0;
                dir.Y = 0;
            }

            this.bBox = new Rectangle(start + dir);
            this.bBox.Add(start - dir);
            this.bBox.Add(end + dir);
            this.bBox.Add(end - dir);
            this.start = start;
            this.end = end;

            if (this.bBox.LeftTop.X == this.bBox.RightBottom.X)
            {
                bBox.LeftTop = bBox.LeftTop + new MsaglPoint(-0.05f, 0);
                bBox.RightBottom = bBox.RightBottom + new MsaglPoint(0.05f, 0);
            }
            if (this.bBox.LeftTop.Y == this.bBox.RightBottom.Y)
            {
                bBox.LeftTop = bBox.LeftTop + new MsaglPoint(0, -0.05f);
                bBox.RightBottom = bBox.RightBottom + new MsaglPoint(0, 0.05f);
            }
        }
コード例 #18
0
 private void DefaultBeginContentEdit(DObject obj)
 {
     if (m_EditingLabel)
         return;
     FrameworkElement fe = ContentEditorProvider.GetNewGUIInstance(obj);
     if (fe != null)
     {
         DecorateObjectForDragging(obj);
         m_LabelEditor = new LabelEditor() { EditControl = fe, EditTarget = obj, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top };
         m_LabelEditor.Closed += (sender, args) =>
             {
                 RemoveObjDraggingDecorations(obj);
                 if (m_LabelEditor.OK)
                     ContentEditorProvider.UpdateLabel(fe, obj);
                 m_EditingLabel = false;
                 LayoutRoot.Children.Remove(m_LabelEditor);
                 m_LabelEditor = null;
             };
         m_EditingLabel = true;
         LayoutRoot.Children.Add(m_LabelEditor);
         SynchronizationContext.Current.Post(o => ContentEditorProvider.FocusGUI(fe, obj), null);
     }
 }
コード例 #19
0
ファイル: DLabel.cs プロジェクト: mrkcass/SuffixTreeExplorer
 public DLabel(DObject parentPar, FrameworkElement content)
     : this(parentPar, new DrawingLabel(), content)
 {
 }
コード例 #20
0
        static BBNode BuildBBHierarchyUnderDObject(DObject dObject)
        {
            var dNode = dObject as DNode;
            if (dNode != null)
                return BuildBBHierarchyUnderDNode(dNode);
            var dedge = dObject as DEdge;
            if (dedge != null)
            {
                return BuildBBHierarchyUnderDEdge(dedge);
            }
            var dLabel = dObject as DLabel;
            if (dLabel != null)
                return BuildBBHierarchyUnderDLabel(dLabel);

            var dGraph = dObject as DGraph;
            if (dGraph != null)
            {
                dGraph.BBNode.bBox = dGraph.DrawingGraph.BoundingBox;
                return dGraph.BBNode;
            }

            throw new InvalidOperationException();
        }
コード例 #21
0
ファイル: DObject.cs プロジェクト: mrkcass/SuffixTreeExplorer
 protected DObject(DObject parent)
     : this()
 {
     ParentObject = parent;
     Canvas.SetZIndex(this, parent == null ? 0 : Canvas.GetZIndex(parent) + 1);
 }
コード例 #22
0
 public DLabel(DObject parentPar, FrameworkElement content)
     : this(parentPar, new DrawingLabel(), content)
 {
 }
コード例 #23
0
 public DTextLabel(DObject parentPar)
     : this(parentPar, new DrawingLabel())
 {
 }
コード例 #24
0
 static void RebuildBBHierarchyUnderObject(DObject dObj)
 {
     BBNode oldNode = dObj.BBNode;
     BBNode newNode = BuildBBHierarchyUnderDObject(dObj);
     if (newNode != null)
     {
         //now copy all fields, except the parent
         oldNode.left = newNode.left;
         oldNode.right = newNode.right;
         oldNode.geometry = newNode.geometry;
         oldNode.bBox = newNode.bBox;
     }
     else
         oldNode.bBox = Microsoft.Msagl.Core.Geometry.Rectangle.CreateAnEmptyBox();
 }
コード例 #25
0
 static void InvalidateBBNodesAbove(DObject dObj)
 {
     for (BBNode node = dObj.BBNode; node != null; node = node.parent)
         node.bBox.Width = -1; //this will make the box empty
 }
コード例 #26
0
 public virtual void FocusGUI(FrameworkElement guiElement, DObject obj)
 {
     (guiElement as TextBox).Focus();
 }
コード例 #27
0
 protected DObject(DObject parent)
     : this()
 {
     ParentObject = parent;
     Canvas.SetZIndex(this, parent == null ? 0 : Canvas.GetZIndex(parent) + 1);
 }
コード例 #28
0
 protected DObject(DObject parent)
 {
     ParentObject = parent;
 }
コード例 #29
0
 internal DCluster(DObject parent, DrawingCluster drawingCluster)
     : base(parent, drawingCluster)
 {
     Node.Attr.FillColor = Drawing.Color.White;
 }
コード例 #30
0
ファイル: DLabel.cs プロジェクト: mrkcass/SuffixTreeExplorer
 public DTextLabel(DObject parentPar)
     : this(parentPar, new DrawingLabel())
 {
 }
コード例 #31
0
ファイル: DObject.cs プロジェクト: mrkcass/SuffixTreeExplorer
 protected DObject(DObject parent)
 {
     ParentObject = parent;
 }
コード例 #32
0
ファイル: DObject.cs プロジェクト: mrkcass/SuffixTreeExplorer
 public bool IsAncestorOf(DObject obj)
 {
     if (obj == null)
         return false;
     return obj.ParentObject == this || IsAncestorOf(obj.ParentObject);
 }
コード例 #33
0
 private void DefaultBeginContentEdit(DObject obj)
 {
     if (m_EditingLabel)
         return;
     DTextLabel clicked = obj is IHavingDLabel ? (obj as IHavingDLabel).Label as DTextLabel : obj as DTextLabel;
     DObject labelOwner = obj is DTextLabel ? (obj as DTextLabel).ParentObject : obj;
     if (clicked != null /*&& clicked != m_EditingLabel*/)
     {
         //EndContentEdit();
         DTextLabel editingLabel = clicked;
         FrameworkElement fe = null;
         bool isMine = false;
         if (GetNewEditControlDelegate != null)
             fe = GetNewEditControlDelegate(labelOwner);
         else
         {
             isMine = true;
             fe = new TextBox() { MinWidth = 50.0, Text = editingLabel.Text, SelectionStart = 0, SelectionLength = editingLabel.Text.Length, AcceptsReturn = true };
         }
         if (fe != null)
         {
             DecorateObjectForDragging(obj);
             m_LabelEditor = new LabelEditor() { EditControl = fe, EditTarget = obj, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top };
             if (isMine)
             {
                 fe.KeyDown += (sender, args) =>
                     {
                         if (System.Windows.Input.Keyboard.Modifiers == System.Windows.Input.ModifierKeys.None)
                         {
                             if (args.Key == System.Windows.Input.Key.Enter)
                                 m_LabelEditor.Close(true);
                             else if (args.Key == System.Windows.Input.Key.Escape)
                                 m_LabelEditor.Close(false);
                         }
                     };
             }
             m_LabelEditor.Closed += (sender, args) =>
                 {
                     RemoveObjDraggingDecorations(obj);
                     if (m_LabelEditor.OK)
                     {
                         if (GetTextFromEditControlDelegate != null)
                             editingLabel.Text = GetTextFromEditControlDelegate(labelOwner, fe);
                         else
                             editingLabel.Text = (fe as TextBox).Text;
                         BuildBBHierarchy();
                     }
                     m_EditingLabel = false;
                     LayoutRoot.Children.Remove(m_LabelEditor);
                     m_LabelEditor = null;
                 };
             m_EditingLabel = true;
             LayoutRoot.Children.Add(m_LabelEditor);
             if (isMine)
                 (fe as TextBox).Focus();
         }
     }
 }
コード例 #34
0
 internal Geometry(DObject dObject, MsaglRectangle box)
 {
     this.dObject = dObject;
     this.bBox    = box;
 }
コード例 #35
0
 internal Geometry(DObject dObject, MsaglRectangle box)
 {
     this.dObject = dObject;
     this.bBox = box;
 }
コード例 #36
0
ファイル: DLabel.cs プロジェクト: mrkcass/SuffixTreeExplorer
 public DLabel(DObject parentPar, DrawingLabel label)
     : this(parentPar, label, null)
 {
 }
コード例 #37
0
 public DLabel(DObject parentPar, DrawingLabel label)
     : this(parentPar, label, null)
 {
 }
コード例 #38
0
 private IEnumerable<DObject> RelatedObjs(DObject dObj)
 {
     yield return dObj;
     var dNode = dObj as DNode;
     if (dNode != null)
     {
         foreach (DEdge e in dNode.OutEdges)
             yield return e;
         foreach (DEdge e in dNode.InEdges)
             yield return e;
         foreach (DEdge e in dNode.SelfEdges)
             yield return e;
     }
     else
     {
         var dEdge = dObj as DEdge;
         if (dEdge != null)
         {
             yield return dEdge.Source;
             yield return dEdge.Target;
             if (dEdge.Label != null)
                 yield return dEdge.Label;
         }
     }
 }
コード例 #39
0
 public DTextLabel(DObject parentPar, DrawingLabel label)
     : base(parentPar, label)
 {
 }
コード例 #40
0
 public virtual void FocusGUI(FrameworkElement guiElement, DObject obj)
 {
     (guiElement as TextBox).Focus();
 }
コード例 #41
0
 public DTextLabel(DObject parentPar, string text)
     : this(parentPar)
 {
     Text = text;
 }
コード例 #42
0
        public virtual void UpdateLabel(FrameworkElement guiElement, DObject obj)
        {
            DTextLabel editingLabel = obj is IHavingDLabel ? (obj as IHavingDLabel).Label as DTextLabel : obj as DTextLabel;

            editingLabel.Text = (guiElement as TextBox).Text;
        }
コード例 #43
0
ファイル: Draw.cs プロジェクト: mrkcass/SuffixTreeExplorer
        internal static void AddStyleForPen(DObject dObj, Brush myPen, MsaglStyle style)
        {
            if (style == MsaglStyle.Dashed)
            {
                throw new NotImplementedException();
                /*
                myPen.DashStyle = DashStyle.Dash;

                if (dObj.DashPatternArray == null)
                {
                    float f = dObj.DashSize();
                    dObj.DashPatternArray = new[] { f, f };
                }
                myPen.DashPattern = dObj.DashPatternArray;

                myPen.DashOffset = dObj.DashPatternArray[0];
                */
            }
            else if (style == MsaglStyle.Dotted)
            {
                throw new NotImplementedException();
                /*
                myPen.DashStyle = DashStyle.Dash;
                if (dObj.DashPatternArray == null)
                {
                    float f = dObj.DashSize();
                    dObj.DashPatternArray = new[] { 1, f };
                }
                myPen.DashPattern = dObj.DashPatternArray;
                */
            }
        }
コード例 #44
0
ファイル: DLabel.cs プロジェクト: mrkcass/SuffixTreeExplorer
 public DTextLabel(DObject parentPar, string text)
     : this(parentPar)
 {
     Text = text;
 }
コード例 #45
0
 public virtual void UpdateLabel(FrameworkElement guiElement, DObject obj)
 {
     DTextLabel editingLabel = obj is IHavingDLabel ? (obj as IHavingDLabel).Label as DTextLabel : obj as DTextLabel;
     editingLabel.Text = (guiElement as TextBox).Text;
 }
コード例 #46
0
 internal DCluster(DObject parent, DrawingCluster drawingCluster)
     : base(parent, drawingCluster)
 {
     Node.Attr.FillColor = Drawing.Color.White;
 }