/// <summary> 将该节点滚动致可视范围 /// /// </summary> public void ScrollToView() { if (NodeContent == null) { return; } MindMap_Panel MindMap_PanelTemp = MindMap_Panel; Rectangle PanelRec = new Rectangle(MindMap_PanelTemp.PointToScreen(new Point(0, 0)), MindMap_PanelTemp.Size); Rectangle NodeRec = new Rectangle(NodeContent.PointToScreen(new Point(0, 0)), NodeContent.Size); if (PanelRec.Contains(NodeRec)) { return; } Point ResultPoint = new Point(); #region 获取X轴偏移量 if (PanelRec.Left > NodeRec.Left) { ResultPoint.X = NodeRec.Left - PanelRec.Left; } if (PanelRec.Left + PanelRec.Width < NodeRec.Left + NodeRec.Width) { ResultPoint.X = (NodeRec.Left + NodeRec.Width) - (PanelRec.Left + PanelRec.Width) + 20; } #endregion 获取X轴偏移量 #region 获取Y轴偏移量 if (PanelRec.Top > NodeRec.Top) { ResultPoint.Y = NodeRec.Top - PanelRec.Top; } if (PanelRec.Top + PanelRec.Height < NodeRec.Top + NodeRec.Height) { ResultPoint.Y = (NodeRec.Top + NodeRec.Height) - (PanelRec.Top + PanelRec.Height) + 20; } #endregion 获取Y轴偏移量 MindMap_PanelTemp.ScrollMindMap(ResultPoint); }
/// <summary> 将该滚动之居中位置 /// /// </summary> public void ScrollToCenter() { if (NodeContent == null) { return; } MindMap_Panel MindMap_PanelTemp = MindMap_Panel; Rectangle PanelRec = new Rectangle(MindMap_PanelTemp.PointToScreen(new Point(0, 0)), MindMap_PanelTemp.Size); Rectangle NodeRec = new Rectangle(NodeContent.PointToScreen(new Point(0, 0)), NodeContent.Size); Point ResultPoint = new Point(); ResultPoint.X = PanelRec.Width - NodeContent.Width; ResultPoint.Y = PanelRec.Height - NodeContent.Height; ResultPoint.X = ResultPoint.X / 2; ResultPoint.Y = ResultPoint.Y / 2; ResultPoint.X = ResultPoint.X + PanelRec.X; ResultPoint.Y = ResultPoint.Y + PanelRec.Y; ResultPoint.X = NodeRec.Left - ResultPoint.X; ResultPoint.Y = NodeRec.Top - ResultPoint.Y; MindMap_PanelTemp.ScrollMindMap(ResultPoint); }