private List <NodeItemInfo> _CreateSampleList(ItemCountType countType = ItemCountType.Standard) { List <NodeItemInfo> list = new List <NodeItemInfo>(); int rootCount = GetItemCount(countType, false); for (int r = 0; r < rootCount; r++) { bool isLazy = (Data.RandomText.Rand.Next(10) >= 5); bool addChilds = !isLazy && (Data.RandomText.Rand.Next(10) >= 3); bool isExpanded = (addChilds && (Data.RandomText.Rand.Next(10) >= 2)); string rootKey = "R." + (++_InternalNodeId).ToString(); string text = Data.RandomText.GetRandomSentence(2, 5) + (isLazy ? " ..." : ""); DW.FontStyle fontStyleDelta = DW.FontStyle.Bold; NodeItemInfo rootNode = new NodeItemInfo(rootKey, null, text, expanded: isExpanded, lazyLoadChilds: isLazy, fontStyleDelta: fontStyleDelta); _FillNode(rootNode); list.Add(rootNode); if (addChilds) { list.AddRange(_CreateSampleChilds(rootKey, countType)); } } return(list); }
private void _FillNode(NodeItemInfo node) { if (Data.RandomText.Rand.Next(20) >= 15) { node.ImageName0 = "object_locked_2_16"; } string imageNumb = Data.RandomText.Rand.Next(1, 24).ToString("00"); node.ImageName1 = $"Ball{imageNumb }_16"; node.ToolTipTitle = null; // Data.RandomText.GetRandomSentence(2, 5); node.ToolTipText = Data.RandomText.GetRandomSentence(10, 50); }
private void _TreeNodeEditedBgr(DxTreeViewNodeArgs args) { var nodeInfo = args.NodeItemInfo; string nodeKey = nodeInfo.NodeId; string parentKey = nodeInfo.ParentNodeId; string oldValue = nodeInfo.Text; string newValue = (args.EditedValue is string text ? text : ""); _AddLogLine($"Změna textu pro node '{nodeKey}': '{oldValue}' => '{newValue}'"); System.Threading.Thread.Sleep(720); // Něco jako uděláme... if (String.IsNullOrEmpty(newValue)) { // Delete node: if (nodeInfo.CanDelete) { _TreeList.RemoveNode(nodeKey); } } else if (oldValue == "") { // Insert node: _TreeList.RunInLock(new Action <NodeItemInfo>(node => { // V jednom vizuálním zámku: _TreeList.RemoveNode(node.NodeId); // Odeberu blank node, to kvůli pořadí: nový blank přidám nakonec // Přidám nový node pro konkrétní text = jakoby záznam: NodeItemInfo newNode = _CreateChildNode(node.ParentNodeId, false); newNode.Text = newValue; _TreeList.AddNode(newNode); // Přidám Blank node, ten bude opět na konci Childs: NodeItemInfo blankNode = _CreateChildNode(node.ParentNodeId, true); _TreeList.AddNode(blankNode); // Aktivuji editovaný node: _TreeList.SelectNode(newNode); } ), nodeInfo); } else { // Edited node: args.NodeItemInfo.Text = newValue + " [OK]"; args.NodeItemInfo.Refresh(); } }
private NodeItemInfo _CreateChildNode(string parentKey, bool isBlankNode) { string childKey = "C." + (++_InternalNodeId).ToString(); NodeItemInfo childNode = null; if (isBlankNode) { string text = ""; childNode = new NodeItemInfo(childKey, parentKey, text, canEdit: true, canDelete: false); // Node pro přidání nového prvku (Blank) nelze odstranit childNode.ToolTipText = "Zadejte referenci nového prvku"; childNode.ImageName1 = "list_add_3_16"; } else { string text = Data.RandomText.GetRandomSentence(2, 5); childNode = new NodeItemInfo(childKey, parentKey, text, canEdit: true, canDelete: true); _FillNode(childNode); } return(childNode); }