private void arborViewer1_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { Point pt = e.GetCurrentPoint(arborViewer1).Position; ArborNode resNode = arborViewer1.System.GetNearestNode((int)pt.X, (int)pt.Y); if (resNode == null) { if (fTipShow) { //fTip.Hide(arborViewer1); ToolTipService.SetToolTip(arborViewer1, null); fTipShow = false; } } else { if (!fTipShow) { fTip.Content = resNode.Sign; ToolTipService.SetToolTip(arborViewer1, fTip); //fTip.Show(resNode.Sign, arborViewer1, e.X + 24, e.Y); fTipShow = true; } } }
public ArborViewer() { base.BorderStyle = BorderStyle.Fixed3D; base.TabStop = true; base.BackColor = Color.White; base.DoubleBuffered = true; base.SetStyle(ControlStyles.AllPaintingInWmPaint, true); base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // repulsion - отталкивание, stiffness - тугоподвижность, friction - сила трения fSys = new ArborSystemEx(10000, 500 /*1000*/, 0.1, this); fSys.setScreenSize(Width, Height); fSys.AutoStop = false; fEnergyDebug = false; fDrawFont = new Font("Calibri", 9); fStrFormat = new StringFormat(); fStrFormat.Alignment = StringAlignment.Center; fStrFormat.LineAlignment = StringAlignment.Center; fBlackBrush = new SolidBrush(Color.Black); fWhiteBrush = new SolidBrush(Color.White); fDragged = null; fNodesDragging = false; }
public ArborViewer() { InitializeComponent(); // repulsion - отталкивание, stiffness - тугоподвижность, friction - сила трения fSystem = new ArborSystemEx(10000.0f, 500.0f /*1000.0f*/, 0.1f, this); fSystem.SetViewSize((int)Width, (int)Height); fSystem.AutoStop = true; fSystem.Graph = new Graph(); fDragged = null; fEnergyDebug = false; fNodesDragging = false; //fDrawFont = new Font("Calibri", 9); //fLinePen = new Pen(Color.Gray, 1); //fLinePen.StartCap = LineCap.NoAnchor; //fLinePen.EndCap = LineCap.ArrowAnchor; fStrFormat = new CanvasTextFormat(); fStrFormat.HorizontalAlignment = CanvasHorizontalAlignment.Center; fStrFormat.VerticalAlignment = CanvasVerticalAlignment.Center; fStrFormat.FontSize = 9; fStrFormat.WordWrapping = CanvasWordWrapping.NoWrap; fBlackBrush = new SolidColorBrush(Colors.Black); fWhiteBrush = new SolidColorBrush(Colors.White); }
public ArborEdge(ArborNode src, ArborNode tgt, double len, double stiffness) { this.Source = src; this.Target = tgt; this.Length = len; this.Stiffness = stiffness; }
private void ArborViewer1_MouseMove(object sender, MouseEventArgs e) { ArborNode resNode = arborViewer1.getNodeByCoord(e.X, e.Y); if (resNode == null) { if (fTipShow) { fTip.Hide(arborViewer1); fTipShow = false; } } else { if (!fTipShow) { string xref = resNode.Sign; GDMFamilyRecord famRec = fBase.Context.Tree.XRefIndex_Find(xref) as GDMFamilyRecord; string txt = GKUtils.GetFamilyString(famRec) + " [" + xref + "] " /* + resNode.Mass.ToString()*/; fTip.Show(txt, arborViewer1, e.X + 24, e.Y); fTipShow = true; } } }
private void ArborViewer1_MouseMove(object sender, MouseEventArgs e) { Point mpt = new Point(e.Location); ArborNode resNode = fArborViewer.getNodeByCoord(mpt.X, mpt.Y); if (resNode == null) { if (fTipShow) { //fTip.Hide(arborViewer1); fArborViewer.ToolTip = string.Empty; fTipShow = false; } } else { if (!fTipShow) { string xref = resNode.Sign; GEDCOMFamilyRecord famRec = fBase.Context.Tree.XRefIndex_Find(xref) as GEDCOMFamilyRecord; string txt = GKUtils.GetFamilyString(famRec) + " [" + xref + "] " /* + resNode.Mass.ToString()*/; //fTip.Show(txt, arborViewer1, mpt.X + 24, mpt.Y); fArborViewer.ToolTip = txt; fTipShow = true; } } }
public ArborEdge(ArborNode src, ArborNode tgt, double len, double stiffness, bool directed) { this.Source = src; this.Target = tgt; this.Length = len; this.Stiffness = stiffness; this.Directed = directed; }
public void T2_Tests() { IExtensionCollection <GraphObject, IExtension <GraphObject> > exts = _context.Extensions; ArborNode node = new ArborNode(""); exts.Add(node); Assert.IsTrue(exts.Contains(node)); Assert.AreEqual(1, exts.Count); IExtension <GraphObject> xt = exts.Find <ArborNode>(); Assert.IsNotNull(xt); Assert.IsTrue(xt is ArborNode); Assert.AreEqual(node, xt); // Assert.IsTrue(exts.Remove(node)); Assert.IsFalse(exts.Contains(node)); Assert.AreEqual(0, exts.Count); // exts.Add(node); ArborNode node1 = new ArborNode(""); exts.Add(node1); Assert.IsTrue(exts.Contains(node)); Assert.IsTrue(exts.Contains(node1)); Assert.AreEqual(2, exts.Count); Collection <ArborNode> cols = exts.FindAll <ArborNode>(); Assert.AreEqual(2, cols.Count); Assert.IsTrue(exts.Remove(node)); Assert.IsFalse(exts.Contains(node)); Assert.IsTrue(exts.Contains(node1)); Assert.AreEqual(1, exts.Count); // exts.Add(node); // adding second node, but internal array was length=2 // exts.Clear(); Assert.AreEqual(0, exts.Count); // Assert.IsFalse(exts.Remove(null)); Assert.Throws(typeof(ArgumentNullException), () => { exts.Add(null); }); Assert.Throws(typeof(ArgumentNullException), () => { new ExtensionCollection <GraphObject, IExtension <GraphObject> >(null); }); }
public Rect GetNodeRect(CanvasDrawingSession gfx, ArborNode node) { CanvasTextLayout textLayout = new CanvasTextLayout(gfx, node.Sign, fStrFormat, 0.0f, 0.0f); double w = textLayout.DrawBounds.Width + 10; double h = textLayout.DrawBounds.Height + 4; ArborPoint pt = fSystem.GetViewCoords(node.Pt); return(new Rect(pt.X - w / 2, pt.Y - h / 2, w, h)); }
protected override void OnPointerReleased(PointerRoutedEventArgs e) { base.OnPointerReleased(e); if (fNodesDragging && fDragged != null) { fDragged.Fixed = false; fDragged = null; } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (fNodesDragging && fDragged != null) { fDragged.Fixed = false; //fDragged.Mass = 1000; fDragged = null; } }
public RectangleF getNodeRect(Graphics gfx, ArborNode node) { SizeF tsz = gfx.MeasureString(node.Sign, fDrawFont); float w = tsz.Width + 10; float h = tsz.Height + 4; ArborPoint pt = fSys.toScreen(node.Pt); pt.X = Math.Floor(pt.X); pt.Y = Math.Floor(pt.Y); return(new RectangleF((float)pt.X - w / 2, (float)pt.Y - h / 2, w, h)); }
protected override void OnPointerPressed(PointerRoutedEventArgs e) { base.OnPointerPressed(e); //if (!Focused) base.Focus(); if (fNodesDragging) { Point pt = e.GetCurrentPoint(this).Position; fDragged = fSystem.GetNearestNode((int)pt.X, (int)pt.Y); if (fDragged != null) { fDragged.Fixed = true; } } }
public void CreateArborGraph(IBaseWindow baseWin, int minGens, bool loneSuppress) { fBase = baseWin; try { fSys = new ArborSystem(1000, 1000, 0.1, null); //(10000, 1000, 0.1, this); fSys.setScreenSize(50, 50); fSys.OnStop += OnArborStop; using (ExtList <PatriarchObj> patList = PatriarchsMan.GetPatriarchsLinks( baseWin.Context, minGens, false, loneSuppress)) { int num = patList.Count; for (int i = 0; i < num; i++) { PatriarchObj pObj = patList[i]; if (!loneSuppress || pObj.HasLinks) { ArborNode node = fSys.addNode(pObj.IRec.XRef); node.Data = pObj; } } for (int i = 0; i < num; i++) { PatriarchObj pat1 = patList[i]; foreach (PatriarchObj pat2 in pat1.Links) { fSys.addEdge(pat1.IRec.XRef, pat2.IRec.XRef); } } } z = -50; fSys.start(); } catch (Exception ex) { Logger.LogWrite("TreeVizControl.CreateArborGraph(): " + ex.Message); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (!Focused) { base.Focus(); } if (fNodesDragging) { fDragged = fSys.nearest(e.Location.X, e.Location.Y); if (fDragged != null) { fDragged.Fixed = true; } } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (!Focused) { Focus(); } Point mpt = e.Location; if (fNodesDragging) { fDragged = fSys.GetNearestNode(mpt.X, mpt.Y); if (fDragged != null) { fDragged.Fixed = true; } } }
private void ArborViewer1MouseMove(object sender, MouseEventArgs e) { ArborNode resNode = arborViewer1.System.GetNearestNode(e.X, e.Y); if (resNode == null) { if (fTipShow) { fTip.Hide(arborViewer1); fTipShow = false; } } else { if (!fTipShow) { fTip.Show(resNode.Sign, arborViewer1, e.X + 24, e.Y); fTipShow = true; } } }
protected override void OnMouseDown(MouseEventArgs e) { if (!HasFocus) { base.Focus(); } Point mpt = new Point(e.Location); if (fNodesDragging) { fDragged = fSys.GetNearestNode(mpt.X, mpt.Y); if (fDragged != null) { fDragged.Fixed = true; } } e.Handled = true; base.OnMouseDown(e); }
public ArborEdge(ArborNode src, ArborNode tgt, double len, double stiffness) : this(src, tgt, len, stiffness, false) { }
protected override ArborEdge CreateEdge(ArborNode src, ArborNode tgt, double len, double stiffness, bool directed = false) { return(new ArborEdge(src, tgt, len, stiffness, directed)); }
public ArborEdge(ArborNode src, ArborNode tgt, double len, double stiffness, bool directed) : this(src, tgt, len, stiffness) { this.Directed = directed; }
protected override ArborEdge CreateEdge(ArborNode source, ArborNode target, double length, double stiffness, bool directed = false) { return(new ArborEdge(source, target, length, stiffness, directed)); }