protected void AddComboBoxChildren(ComboTreeNode parentNode, string childMats) { if (childMats == null || childMats.Length == 0) return; foreach (var mat in childMats.Split(';')) { var newNode = parentNode.Nodes.Add(mat); newNode.Tag = new List<string>() { mat }; AddComboBoxChildren(newNode, GUILayer.RawMaterial.Get(mat).BuildInheritanceList()); } }
/// <summary> /// Commits the search by selecting the equivalent node in the drop-down or /// adding the result as a new node. /// </summary> /// <param name="e"></param> protected virtual void OnCommitSearch(CommitSearchEventArgs e) { if (CommitSearch != null) { CommitSearch(this, e); } if (!e.Handled) { ComboTreeNode match = null; // try to find an equivalent match in the normal list if (e.Result != null) { if (OwnsNode(e.Result)) { match = e.Result; } else if ((match = AllNormalNodes.FirstOrDefault(x => DefaultEquivalencePredicate(e.Result, x))) == null) { // search result not in original collection; add match = e.Result.Clone(); Nodes.Add(match); } } SelectedNode = match; } }
public static ComboTreeNode ToComboTreeNode(this TaxonomyLeaf taxonomyLeaf) { var key = $"{TaxonomyLevel.Leaf.TaxonomyLevelID}-{taxonomyLeaf.TaxonomyLeafID}"; var comboTreeNode = new ComboTreeNode(taxonomyLeaf.GetDisplayName(), key); return(comboTreeNode); }
/// <summary> /// Scrolls between adjacent nodes, or scrolls the drop-down portion of /// the control in response to the mouse wheel. /// </summary> /// <param name="e"></param> protected override void OnMouseWheel(MouseEventArgs e) { HandledMouseEventArgs he = (HandledMouseEventArgs)e; he.Handled = true; base.OnMouseWheel(e); if (DroppedDown) { _dropDown.ScrollDropDown(-(e.Delta / 120) * SystemInformation.MouseWheelScrollLines); } else if (e.Delta > 0) { ComboTreeNode prev = GetPrevSelectableNode(); if (prev != null) { SetSelectedNode(prev); } } else if (e.Delta < 0) { ComboTreeNode next = GetNextSelectableNode(); if (next != null) { SetSelectedNode(next); } } }
/// <summary> /// Places the control in normal mode, optionally committing the search result. /// </summary> /// <param name="commit"></param> private void LeaveSearchMode(bool commit) { _inSearchMode = false; BeginUpdate(); ComboTreeNode searchSelectedNode = SelectedNode; // clear and replace with normal nodes Nodes.Clear(); Nodes.AddRange(_normalNodes); if (commit) { OnCommitSearch(new CommitSearchEventArgs(searchSelectedNode)); } else { SelectedNode = _normalSelectedNode; } EndUpdate(); DropDownControl.ProcessKeys = true; Cursor = Cursors.Default; }
/// <summary> /// Expands parent nodes until the specified node is visible. /// </summary> /// <param name="node"></param> private void ExpandTo(ComboTreeNode node) { while ((node = node.Parent) != null) { node.Expanded = true; } }
void nodes_AfterCheck(object sender, ComboTreeNodeEventArgs e) { if (_cascadeCheckState) { _recurseDepth++; if (_recurseDepth == 1) { IEnumerator <ComboTreeNode> enumerator = ComboTreeNodeCollection.GetNodesRecursive(e.Node.Nodes, false); while (enumerator.MoveNext()) { if (_threeState) { enumerator.Current.CheckState = e.Node.CheckState; } else { enumerator.Current.Checked = e.Node.Checked; } } ComboTreeNode parent = e.Node.Parent; while (parent != null) { parent.CheckState = parent.GetAggregateCheckState(); parent = parent.Parent; } } _recurseDepth--; } Invalidate(); OnAfterCheck(e); }
/// <summary> /// Handles keyboard shortcuts. /// </summary> /// <param name="e"></param> protected override void OnKeyDown(KeyEventArgs e) { e.Handled = e.SuppressKeyPress = true; if (e.Alt && (e.KeyCode == Keys.Down)) { DroppedDown = true; } else if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Left)) { ComboTreeNode prev = GetPrevSelectableNode(); if (prev != null) { SetSelectedNode(prev); } } else if ((e.KeyCode == Keys.Down) || (e.KeyCode == Keys.Right)) { ComboTreeNode next = GetNextSelectableNode(); if (next != null) { SetSelectedNode(next); } } else { e.Handled = e.SuppressKeyPress = false; } base.OnKeyDown(e); }
/// <summary> /// Sets the value of the SelectedNode property and raises the SelectedNodeChanged event. /// </summary> /// <param name="node"></param> private void SetSelectedNode(ComboTreeNode node) { if ((_selectedNode != node) && !_showCheckBoxes && ((node == null) || node.Selectable)) { _selectedNode = node; Invalidate(); OnSelectedNodeChanged(EventArgs.Empty); } }
/// <summary> /// Returns the full path to the specified <see cref="ComboTreeNode"/>. /// </summary> /// <param name="node"></param> /// <returns></returns> public string GetFullPath(ComboTreeNode node) { if (node == null) { throw new ArgumentNullException("node"); } return(node.GetFullPath(_pathSeparator, _useNodeNamesForPath)); }
/// <summary> /// Sets the value of the SelectedNode property and raises the SelectedNodeChanged event. /// </summary> /// <param name="node"></param> private void SetSelectedNode(ComboTreeNode node) { if (selectedNode != node) { selectedNode = node; Invalidate(); OnSelectedNodeChanged(EventArgs.Empty); } }
/// <summary> /// Updates the check state of the parent nodes /// </summary> /// <param name="node"></param> private void SetCheckState(ComboTreeNode node) { node.CheckState = node.GetAggregateCheckState(); if (node.Parent != null) { SetCheckState(node.Parent); } }
/// <summary> /// Initialises a new instance of the <see cref="ComboTreeNodePaintEventArgs"/> class using the specified values. /// </summary> /// <param name="graphics"></param> /// <param name="node"></param> /// <param name="bounds"></param> /// <param name="textBounds"></param> /// <param name="font"></param> /// <param name="isHighlighted"></param> public ComboTreeNodePaintEventArgs(Graphics graphics, ComboTreeNode node, Rectangle bounds, Rectangle textBounds, Font font, bool isHighlighted) { Graphics = graphics; Node = node; Bounds = bounds; TextBounds = textBounds; Font = font; IsHighlighed = isHighlighted; DrawDefault = true; }
public static ComboTreeNode ToComboTreeNode(this TaxonomyTrunk taxonomyTrunk) { var key = $"{TaxonomyLevel.Trunk.TaxonomyLevelID}-{taxonomyTrunk.TaxonomyTrunkID}"; var comboTreeNode = new ComboTreeNode(taxonomyTrunk.GetDisplayName(), key) { SubNodes = taxonomyTrunk.TaxonomyBranches.SortByOrderThenName().Select(x => x.ToComboTreeNode()).ToList() }; return(comboTreeNode); }
private void AddNode(ComboTreeNodeCollection nodes, KindOfGoods kind) { var node = new ComboTreeNode(kind.Name) { Tag = kind, Expanded = true }; nodes.Add(node); kind.SubKinds.ForEach(k => this.AddNode(node.Nodes, k)); }
private void ddlCategoryId_SelectedNodeChanged(object sender, EventArgs e) { if (ddlCategoryId.Path.Split('\\').Length == 2 || ddlCategoryId.Path.Split('\\').Length == 1 && ddlCategoryId.Text != "--Seleccionar--") { ddlCategoryId.SelectedNode = valueCategoryId; } valueCategoryId = ddlCategoryId.SelectedNode; var nroOrden = ddlCategoryId.SelectedNode.Tag.ToString(); unUIIndex.Text = nroOrden; }
protected void AddComboBoxChildren( ComboTreeNode parentNode, List<string> childMats) { if (childMats == null) return; foreach (var mat in childMats) { var newNode = parentNode.Nodes.Add(mat); newNode.Tag = new List<string>() { mat }; AddComboBoxChildren(newNode, GUILayer.RawMaterial.BuildInheritanceList(mat)); } }
/// <summary> /// Determines whether the specified node should be displayed. /// </summary> /// <param name="node"></param> /// <returns></returns> internal bool IsNodeVisible(ComboTreeNode node) { bool displayed = true; ComboTreeNode parent = node; while ((parent = parent.Parent) != null) { if (ShowGlyphs && !parent.Expanded) { displayed = false; break; } } return(displayed); }
protected void AddComboBoxChildren( ComboTreeNode parentNode, List <GUILayer.RawMaterial> childMats) { if (childMats == null) { return; } foreach (var mat in childMats) { var newNode = parentNode.Nodes.Add(mat.Filename + ":" + mat.SettingName); newNode.Tag = mat; AddComboBoxChildren(newNode, mat.BuildInheritanceList()); } }
/// <summary> /// Determines whether the specified node belongs to this ComboTreeBox, and /// hence is a valid selection. For the purposes of this method, a null /// value is always a valid selection. /// </summary> /// <param name="node"></param> /// <returns></returns> public bool OwnsNode(ComboTreeNode node) { if (node == null) { return(true); } ComboTreeNode parent = node; while (parent.Parent != null) { parent = parent.Parent; } return(_nodes.Contains(parent)); }
public static ComboTreeNode ToComboTreeNode(this ComicListItem x) { ComboTreeNode node = new ComboTreeNode(x.Name); node.Tag = x.Id; ComicListItemFolder folderList = x as ComicListItemFolder; if (folderList != null) { node.Nodes.AddRange(folderList.Items.Select(c => c.ToComboTreeNode())); } return(node); }
public void LoadCategoryTreeView() { CategoryTreeBox.Nodes.Clear(); List<Categories> cates = manager.GetAllCategories(); foreach (Categories p in cates) { if (p.Level == 1) { ComboTreeNode t1 = new ComboTreeNode(p.Name); t1.Tag = p; CategoryTreeBox.Nodes.Add(t1); if (selectedCategory != null && selectedCategory.Id == p.Id) { CategoryTreeBox.SelectedNode = t1; } foreach (Categories c in cates) { if (c.ParentId == p.Id && c.Level == p.Level + 1) { ComboTreeNode t2 = new ComboTreeNode(c.Name); t2.Tag = c; t1.Nodes.Add(t2); if (selectedCategory != null && selectedCategory.Id == c.Id) { CategoryTreeBox.SelectedNode = t2; } foreach (Categories f in cates) { if (f.ParentId == c.Id && f.Level == c.Level + 1) { ComboTreeNode t3 = new ComboTreeNode(f.Name); t3.Tag = f; t2.Nodes.Add(t3); if (selectedCategory != null && selectedCategory.Id == f.Id) { CategoryTreeBox.SelectedNode = t3; } } } } } } } CategoryTreeBox.ExpandAll(); }
private void frmMedicalExamEdicion_Load(object sender, EventArgs e) { #region Mayusculas - Normal var _EsMayuscula = int.Parse(Common.Utils.GetApplicationConfigValue("EsMayuscula")); if (_EsMayuscula == 1) { SearchControlAndSetEvents(this); } #endregion OperationResult objOperationResult = new OperationResult(); //Llenado de combos Utils.LoadComboTreeBoxList(ddlCategoryId, BLL.Utils.GetSystemParameterForComboTreeBox(ref objOperationResult, 116, null), DropDownListAction.Select); Utils.LoadDropDownList(ddlDiagnosableId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 111, null), DropDownListAction.Select); Utils.LoadDropDownList(ddlComponentTypeId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 126, null), DropDownListAction.Select); Utils.LoadDropDownList(ddlUIIsVisibleId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 111, null), DropDownListAction.Select); Utils.LoadDropDownList(ddlIsApprovedId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 111, null), DropDownListAction.Select); if (Mode == "New") { // Additional logic here. } else if (Mode == "Edit") { // Get the Entity Data objmedicalexamDto = new componentDto(); objmedicalexamDto = _objMedicalExamBL.GetMedicalExam(ref objOperationResult, MedicalExamId); txtInsertName.Text = objmedicalexamDto.v_Name; _NameComponentOld = objmedicalexamDto.v_Name; ComboTreeNode nodoABuscar = ddlCategoryId.AllNodes.First(x => x.Tag.ToString() == objmedicalexamDto.i_CategoryId.ToString()); ddlCategoryId.SelectedNode = nodoABuscar; unBasePrice.Text = objmedicalexamDto.r_BasePrice.ToString(); ddlDiagnosableId.SelectedValue = objmedicalexamDto.i_DiagnosableId.ToString(); ddlComponentTypeId.SelectedValue = objmedicalexamDto.i_ComponentTypeId.ToString(); ddlUIIsVisibleId.SelectedValue = objmedicalexamDto.i_UIIsVisibleId.ToString(); unUIIndex.Value = objmedicalexamDto.i_UIIndex; ddlIsApprovedId.SelectedValue = objmedicalexamDto.i_IsApprovedId.ToString(); unValidInDays.Value = objmedicalexamDto.i_ValidInDays.ToString(); } }
protected void AddComboBoxChildren(ComboTreeNode parentNode, string childMats) { if (childMats == null || childMats.Length == 0) { return; } foreach (var mat in childMats.Split(';')) { var newNode = parentNode.Nodes.Add(mat); newNode.Tag = new List <string>() { mat }; AddComboBoxChildren(newNode, GUILayer.RawMaterial.Get(mat).BuildInheritanceList()); } }
/// <summary> /// Updates the Checked property of all child nodes /// </summary> /// <param name="node"></param> private void CheckNodes(ComboTreeNode node) { foreach (ComboTreeNode child in node.Nodes) { if (_threeState) { child.CheckState = node.CheckState; } else { child.Checked = node.Checked; } CheckNodes(child); } }
/// <summary> /// Highlights and scrolls to the specified node. /// </summary> /// <param name="node"></param> private void ScrollTo(ComboTreeNode node) { for (int i = 0; i < _visibleItems.Count; i++) { if (_visibleItems[i].Node == node) { _highlightedItemIndex = i; if ((_highlightedItemIndex < _scrollOffset) || (_highlightedItemIndex >= (_scrollOffset + _numItemsDisplayed))) { _scrollOffset = Math.Min(Math.Max(0, _highlightedItemIndex - _numItemsDisplayed + 1), _visibleItems.Count - _numItemsDisplayed); UpdateScrolling(); } break; } } }
private void LoadData() { OperationResult objOperationResult = new OperationResult(); ////Llenado de combos Utils.LoadComboTreeBoxList(ddlCategoryId, BLL.Utils.GetDataHierarchyForComboTreeBox(ref objOperationResult, 103, null), DropDownListAction.Select); Utils.LoadDropDownList(ddlMeasurementUnitId, "Value1", "Id", BLL.Utils.GetDataHierarchyForCombo(ref objOperationResult, 105, null), DropDownListAction.Select); dtpExpirationDate.CustomFormat = "dd/MM/yyyy"; if (_Mode == "New") { // Additional logic here. } else if (_Mode == "Edit") { // Get the Entity Data _productDto = _objBL.GetProduct(ref objOperationResult, _ProductId); ComboTreeNode nodoABuscar = ddlCategoryId.AllNodes.First(x => x.Tag.ToString() == _productDto.i_CategoryId.ToString()); ddlCategoryId.SelectedNode = nodoABuscar; txtName.Text = _productDto.v_Name; txtGenericName.Text = _productDto.v_GenericName; txtBarCode.Text = _productDto.v_BarCode; txtBarCode.Text = _productDto.v_ProductCode; txtBrand.Text = _productDto.v_Brand; txtModel.Text = _productDto.v_Model; txtSerialNumber.Text = _productDto.v_SerialNumber; if (_productDto.d_ExpirationDate == null) { dtpExpirationDate.Checked = false; } else { dtpExpirationDate.Checked = true; dtpExpirationDate.Value = (DateTime)_productDto.d_ExpirationDate; } ddlMeasurementUnitId.SelectedValue = _productDto.i_MeasurementUnitId.ToString(); txtReferentialCostPrice.Text = _productDto.r_ReferentialCostPrice.ToString(); txtReferentialSalesPrice.Text = _productDto.r_ReferentialSalesPrice.ToString(); txtPresentation.Text = _productDto.v_Presentation; txtAdiccionalInformation.Text = _productDto.v_AdditionalInformation; } }
/// <summary> /// Returns the image associated with the specified node. /// </summary> /// <param name="node"></param> /// <param name="images"></param> /// <param name="imageIndex"></param> /// <param name="imageKey"></param> /// <param name="expandedImageIndex"></param> /// <param name="expandedImageKey"></param> /// <returns></returns> internal static Image GetNodeImage(ComboTreeNode node, ImageList images, int imageIndex, string imageKey, int expandedImageIndex, string expandedImageKey) { if ((images != null) && (node != null)) { if (node.Expanded && (node.Nodes.Count > 0)) { if (images.Images.ContainsKey(node.ExpandedImageKey)) { return(images.Images[node.ExpandedImageKey]); // node's key } else if (node.ExpandedImageIndex >= 0) { return(images.Images[node.ExpandedImageIndex]); // node's index } else if (images.Images.ContainsKey(expandedImageKey)) { return(images.Images[expandedImageKey]); // default key } else if ((expandedImageIndex >= 0) && (expandedImageIndex < images.Images.Count)) { return(images.Images[expandedImageIndex]); // default index } } else { if (images.Images.ContainsKey(node.ImageKey)) { return(images.Images[node.ImageKey]); // node's key } else if (node.ImageIndex >= 0) { return(images.Images[node.ImageIndex]); // node's index } else if (images.Images.ContainsKey(imageKey)) { return(images.Images[imageKey]); // default key } else if ((imageIndex >= 0) && (imageIndex < images.Images.Count)) { return(images.Images[imageIndex]); // default index } } } return(null); }
/// <summary> /// Returns the image referenced by the specified node in the ImageList component associated with this control. /// </summary> /// <param name="node"></param> /// <returns></returns> internal Image GetNodeImage(ComboTreeNode node) { if ((images != null) && (node != null)) { if (node.Expanded) { if (images.Images.ContainsKey(node.ExpandedImageKey)) { return(images.Images[node.ExpandedImageKey]); // node's key } else if (node.ExpandedImageIndex >= 0) { return(images.Images[node.ExpandedImageIndex]); // node's index } else if (images.Images.ContainsKey(expandedImageKey)) { return(images.Images[expandedImageKey]); // default key } else if (expandedImageIndex >= 0) { return(images.Images[expandedImageIndex]); // default index } } else { if (images.Images.ContainsKey(node.ImageKey)) { return(images.Images[node.ImageKey]); // node's key } else if (node.ImageIndex >= 0) { return(images.Images[node.ImageIndex]); // node's index } else if (images.Images.ContainsKey(imageKey)) { return(images.Images[imageKey]); // default key } else if (imageIndex >= 0) { return(images.Images[imageIndex]); // default index } } } return(null); }
public static void LoadComboTreeBoxList_(ComboTreeBox prmDropDownList, List <KeyValueDTOForTree> prmDataSource = null, DropDownListAction?prmDropDownListAction = null) { prmDropDownList.Nodes.Clear(); KeyValueDTOForTree firstItem = null; if (prmDropDownListAction != null) { switch (prmDropDownListAction) { case DropDownListAction.All: firstItem = new KeyValueDTOForTree() { Id = Constants.AllValue, Value1 = Constants.All }; break; case DropDownListAction.Select: firstItem = new KeyValueDTOForTree() { Id = Constants.SelectValue, Value1 = Constants.Select }; break; } } if (prmDataSource != null) { prmDropDownList.Nodes.AddRange(ProcessDataForComboTreeBox(prmDataSource, prmDataSource[0].ParentId)); } if (firstItem != null) { ComboTreeNode firstNode = new ComboTreeNode(firstItem.Value1); firstNode.Tag = firstItem.Id; prmDropDownList.Nodes.Insert(0, firstNode); prmDropDownList.SelectedNode = firstNode; } prmDropDownList.ExpandAll(); }
/// <summary> /// Paints the cell. /// </summary> /// <param name="graphics"></param> /// <param name="clipBounds"></param> /// <param name="cellBounds"></param> /// <param name="rowIndex"></param> /// <param name="cellState"></param> /// <param name="value"></param> /// <param name="formattedValue"></param> /// <param name="errorText"></param> /// <param name="cellStyle"></param> /// <param name="advancedBorderStyle"></param> /// <param name="paintParts"></param> protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); BeforePaintContent(graphics, cellBounds, cellState, cellStyle, paintParts); if (paintParts.HasFlag(DataGridViewPaintParts.ContentForeground)) { ComboTreeBoxColumn column = (ComboTreeBoxColumn)OwningColumn; ComboTreeNode node = Nodes.ParsePath(Convert.ToString(formattedValue), column.PathSeparator, column.UseNodeNamesForPath); string displayValue; if (column.ShowPath) { displayValue = Convert.ToString(formattedValue); } else { displayValue = (node != null) ? node.Text : String.Empty; } Image img = ComboTreeBox.GetNodeImage(node, column.Images, column.ImageIndex, column.ImageKey, column.ExpandedImageIndex, column.ExpandedImageKey); Rectangle contentBounds = cellBounds; contentBounds.Width -= 17; TextFormatFlags flags = ComboTreeBox.TEXT_FORMAT_FLAGS | TextFormatFlags.PreserveGraphicsClipping; Rectangle imgBounds = (img == null) ? new Rectangle(Point.Add(contentBounds.Location, new Size(1, 0)), Size.Empty) : new Rectangle(contentBounds.Left + 4, contentBounds.Top + (contentBounds.Height / 2 - img.Height / 2), img.Width, img.Height); Rectangle txtBounds = new Rectangle(imgBounds.Right, contentBounds.Top, contentBounds.Right - imgBounds.Right - 3, contentBounds.Height); if (img != null) { graphics.DrawImage(img, imgBounds); } TextRenderer.DrawText(graphics, displayValue, cellStyle.Font, txtBounds, cellStyle.ForeColor, flags); } AfterPaintContent(graphics, clipBounds, cellBounds, rowIndex, cellStyle, advancedBorderStyle, paintParts); }
/// <summary> /// Returns a value indicating whether the <paramref name="test"/> node is equivalent to the <paramref name="result"/> node. /// </summary> /// <param name="result"></param> /// <param name="test"></param> /// <returns></returns> /// <remarks> /// The base implementation of this method performs a case-insensitive /// comparison firstly on the <see cref="ComboTreeNode.Name"/> property /// and then on the <see cref="ComboTreeNode.Text"/> property. /// </remarks> public virtual bool DefaultEquivalencePredicate(ComboTreeNode result, ComboTreeNode test) { if (!String.IsNullOrEmpty(result.Name)) { if (String.Equals(result.Name, test.Name, StringComparison.OrdinalIgnoreCase)) { return(true); } } if (!String.IsNullOrEmpty(result.Text)) { if (String.Equals(result.Text, test.Text, StringComparison.OrdinalIgnoreCase)) { return(true); } } return(false); }
/// <summary> /// Displays the dropdown beneath its owning ComboTreeBox control. /// </summary> public void Open() { // the selected node(s) must have a clear path (i.e. all parents expanded) if (_sourceControl.ShowCheckBoxes) { foreach (ComboTreeNode node in _sourceControl.CheckedNodes) { ExpandTo(node); } } else if (_sourceControl.SelectedNode != null) { ExpandTo(_sourceControl.SelectedNode); } UpdateVisibleItems(); // highlight and scroll to the selected node ComboTreeNode scrollToNode = null; if (_sourceControl.ShowCheckBoxes) { foreach (ComboTreeNode node in _sourceControl.CheckedNodes) { scrollToNode = node; break; } } else { scrollToNode = _sourceControl.SelectedNode; } if (scrollToNode != null) { ScrollTo(scrollToNode); } // show below the source control Show(_sourceControl, new Point(0, _sourceControl.ClientRectangle.Height)); }
/// <summary> /// Determines whether the specified node belongs to this ComboTreeBox, and /// hence is a valid selection. For the purposes of this method, a null /// value is always a valid selection. /// </summary> /// <param name="node"></param> /// <returns></returns> private bool OwnsNode(ComboTreeNode node) { if (node == null) return true; ComboTreeNode parent = node; while (parent.Parent != null) parent = parent.Parent; return nodes.Contains(parent); }
/// <summary> /// Determines whether the specified node should be displayed. /// </summary> /// <param name="node"></param> /// <returns></returns> internal bool IsNodeVisible(ComboTreeNode node) { bool displayed = true; ComboTreeNode parent = node; while ((parent = parent.Parent) != null) { if (!parent.Expanded) { displayed = false; break; } } return displayed; }
/// <summary> /// Returns the image referenced by the specified node in the ImageList component associated with this control. /// </summary> /// <param name="node"></param> /// <returns></returns> internal Image GetNodeImage(ComboTreeNode node) { if ((images != null) && (node != null)) { if (node.Expanded) { if (images.Images.ContainsKey(node.ExpandedImageKey)) return images.Images[node.ExpandedImageKey]; // node's key else if (node.ExpandedImageIndex >= 0) return images.Images[node.ExpandedImageIndex]; // node's index else if (images.Images.ContainsKey(expandedImageKey)) return images.Images[expandedImageKey]; // default key else if (expandedImageIndex >= 0) return images.Images[expandedImageIndex]; // default index } else { if (images.Images.ContainsKey(node.ImageKey)) return images.Images[node.ImageKey]; // node's key else if (node.ImageIndex >= 0) return images.Images[node.ImageIndex]; // node's index else if (images.Images.ContainsKey(imageKey)) return images.Images[imageKey]; // default key else if (imageIndex >= 0) return images.Images[imageIndex]; // default index } } return null; }
/// <summary> /// Returns the full path to the specified <see cref="ComboTreeNode"/>. /// </summary> /// <param name="node"></param> /// <returns></returns> public string GetFullPath(ComboTreeNode node) { if (node == null) throw new ArgumentNullException("node"); return node.GetFullPath(_pathSeparator, _useNodeNamesForPath); }
/// <summary> /// Returns the image associated with the specified node. /// </summary> /// <param name="node"></param> /// <param name="images"></param> /// <param name="imageIndex"></param> /// <param name="imageKey"></param> /// <param name="expandedImageIndex"></param> /// <param name="expandedImageKey"></param> /// <returns></returns> internal static Image GetNodeImage(ComboTreeNode node, ImageList images, int imageIndex, string imageKey, int expandedImageIndex, string expandedImageKey) { if ((images != null) && (node != null)) { if (node.Expanded) { if (images.Images.ContainsKey(node.ExpandedImageKey)) return images.Images[node.ExpandedImageKey]; // node's key else if (node.ExpandedImageIndex >= 0) return images.Images[node.ExpandedImageIndex]; // node's index else if (images.Images.ContainsKey(expandedImageKey)) return images.Images[expandedImageKey]; // default key else if ((expandedImageIndex >= 0) && (expandedImageIndex < images.Images.Count)) return images.Images[expandedImageIndex]; // default index } else { if (images.Images.ContainsKey(node.ImageKey)) return images.Images[node.ImageKey]; // node's key else if (node.ImageIndex >= 0) return images.Images[node.ImageIndex]; // node's index else if (images.Images.ContainsKey(imageKey)) return images.Images[imageKey]; // default key else if ((imageIndex >= 0) && (imageIndex < images.Images.Count)) return images.Images[imageIndex]; // default index } } return null; }
/// <summary> /// Returns the image referenced by the specified node in the ImageList component associated with this control. /// </summary> /// <param name="node"></param> /// <returns></returns> internal Image GetNodeImage(ComboTreeNode node) { return GetNodeImage(node, _images, _imageIndex, _imageKey, _expandedImageIndex, _expandedImageKey); }
/// <summary> /// Sets the value of the SelectedNode property and raises the SelectedNodeChanged event. /// </summary> /// <param name="node"></param> private void SetSelectedNode(ComboTreeNode node) { if ((_selectedNode != node) && !_showCheckBoxes) { _selectedNode = node; Invalidate(); OnSelectedNodeChanged(EventArgs.Empty); } }