/// <summary> /// Returns true if successfully refreshes all node positions. If canvas is not big enough, the operation is aborted and 'false' is returned. /// </summary> /// <param name="parent"></param> /// <param name="sideToRefresh"></param> /// <returns></returns> private bool RefreshChildNodePositionsRecursive(MapNode parent, NodePosition sideToRefresh) { NodeView nView = this.GetNodeView(parent); if (!parent.HasChildren || parent.Folded) { if (!NodeWithinCanvas(parent, 50)) { return(false); } return(true); } else { for (int i = 0; i < 2; i++) { IEnumerable <MapNode> childNodes; NodePosition rpos; if (i == 0) { rpos = NodePosition.Left; childNodes = parent.ChildLeftNodes; } else { rpos = NodePosition.Right; childNodes = parent.ChildRightNodes; } float left = nView.Left + nView.Width + HOR_MARGIN; float top = nView.Top - (int)((this.GetNodeHeight(parent, rpos) - nView.Height) / 2) - ((parent.Pos == NodePosition.Root) ? (int)(nView.Height / 2) : 0); int topOffset; foreach (MapNode rnode in childNodes) { NodeView tView = this.GetNodeView(rnode); topOffset = (int)((this.GetNodeHeight(rnode, rpos) - tView.Height) / 2); if (i == 0) { left = nView.Left - tView.Width - HOR_MARGIN; } tView.RefreshPosition(left, top + topOffset); top += (topOffset * 2) + tView.Height + VER_MARGIN; if (!rnode.Folded) { // recursive call bool continueProcess = RefreshChildNodePositionsRecursive(rnode, NodePosition.Undefined); if (!continueProcess) { return(false); } } } } } return(true); }
private void ResetNodeTextSize(NodeView nView) { MapNode node = nView.Node; nView.RefreshText(); if (node == node.Tree.RootNode) node.NodeView.RefreshPosition(node.NodeView.Left, node.NodeView.Top); mapView.RefreshNodePositions(node.Parent != null ? node.Parent : node, NodePosition.Undefined); mapView.Canvas.Invalidate(); }
public void BeginNodeEdit(NodeView nView, TextCursorPosition org) { if (!enabled) return; MapNode node = nView.Node; if (!node.HasChildren && nView.RecText.Width < TEXTBOX_DEFAULT_WIDTH) { IncreaseNodeTextSize(nView, TEXTBOX_DEFAULT_WIDTH); } else if(nView.RecText.Width < TEXTBOX_MIN_WIDTH) { IncreaseNodeTextSize(nView, TEXTBOX_MIN_WIDTH); } else { IncreaseNodeTextSize(nView, (int)(nView.RecText.Width + TEXTBOX_PADDING)); } mapView.AdjustLocationToShowNodeView(nView); this.editBox.Location = new Point( (int)nView.RecText.X, (int)nView.RecText.Y - 3 ); this.editBox.MinimumSize = new Size((int)nView.RecText.Width, (int)nView.RecText.Height); this.editBox.Size = this.editBox.MinimumSize; this.editBox.Text = node.Text; this.editBox.Tag = node; this.editBox.Visible = true; this.editBox.BringToFront(); if (org == TextCursorPosition.End || org == TextCursorPosition.Undefined) { this.editBox.SelectionStart = node.Text.Length; } else if (org == TextCursorPosition.Start) { this.editBox.SelectionStart = 0; } this.editBox.SelectionLength = 0; this.editBox.Focus(); this.IsTextEditing = true; }
private void IncreaseNodeTextSize(NodeView nView, int width) { MapNode node = nView.Node; nView.RefreshText(new SizeF(width, nView.RecText.Height)); if (node == node.Tree.RootNode) node.NodeView.RefreshPosition(node.NodeView.Left, node.NodeView.Top); mapView.RefreshNodePositions(node.Parent != null ? node.Parent : node, NodePosition.Undefined); mapView.Canvas.Invalidate(); }