void GetCubes_InvokeCommandCompleted(DataLoaderEventArgs e, CustomTreeNode parentNode) { OlapDataLoader.DataLoaded -= new EventHandler <DataLoaderEventArgs>(OlapDataLoader_DataLoaded); List <CubeDefInfo> cubes = XmlSerializationUtility.XmlStr2Obj <List <CubeDefInfo> >(e.Result.Content); InitCubesList(cubes); }
private void PopulateCatalogue(CustomTreeNode treeNode, Document document, string sid) { if (m_IfcClassificationReferenceCollection == null) { m_IfcClassificationReferenceCollection = document.IfcXmlDocument.Items.OfType <IfcClassificationReference>().ToList(); } var classificationReferences = m_IfcClassificationReferenceCollection.Where(item => item.ReferencedSource != null && item.ReferencedSource.Item.Ref == sid).Select(item => item); foreach (var classificationReference in classificationReferences) { string nodeText = String.Format("{0} - {1}", classificationReference.Identification, classificationReference.Name); CustomTreeNode classificationReferenceNode = new CustomTreeNode(nodeText, classificationReference); // TODO: set node images, colors, ... treeNode.Nodes.Add(classificationReferenceNode); PopulateCatalogue(classificationReferenceNode, document, classificationReference.Id); } // gibt es ein propertySetTemplate zu RelatingClassification IEnumerable <IfcPropertySetTemplate> newPropertySetTemplates = GetIfcPropertySetTemplateCollectionRelatingClassificationId(document, sid); var baseObjects = new BaseObjects <IfcPropertySetTemplate>(null); baseObjects.AddRange(newPropertySetTemplates); treeNode.CcUISubObject = baseObjects; PopulatePropertyTemplates(treeNode, newPropertySetTemplates); }
private void treeView2_AfterSelect(object sender, TreeViewEventArgs e) { CustomTreeNode node = (CustomTreeNode)e.Node; if (node != null) { ClearFile1Selection(); ClearFile2Selection(); SelectMatches(); List <DiplomProject1.Match> matches = new List <Match>(); Controller.Instance.GetMatchesForFile2Node(node.Object, ref matches); richTextBox_FileView2.Select(node.Object.Position, node.Object.CommonLength); richTextBox_FileView2.SelectionBackColor = Color.Blue; richTextBox_FileView2.SelectionColor = Color.White; richTextBox_FileView2.ScrollToCaret(); foreach (Match m in matches) { richTextBox_FileView1.Select(m.pos, m.length); richTextBox_FileView1.SelectionBackColor = Color.Blue; richTextBox_FileView1.SelectionColor = Color.White; } if (matches.Count > 0) { richTextBox_FileView1.ScrollToCaret(); } } }
private void ApplianceTreeView_ItemCheckChanged(object sender, EventArgs e) { CustomTreeNode node = sender as CustomTreeNode; var poolNode = node.ParentNode as PoolNode; if (poolNode == null) { return; } XenRef <VDI> vdiRef = poolNode.VdiRef; // add pool if needed if (node.State == CheckState.Checked && !selectedPoolMetadata.ContainsKey(vdiRef)) { selectedPoolMetadata.Add(vdiRef, new PoolMetadata(allPoolMetadata[vdiRef].Pool, allPoolMetadata[vdiRef].Vdi)); } if (!selectedPoolMetadata.ContainsKey(vdiRef)) { return; } DoOnNodeStateChanged(node, vdiRef); // remove pool if no appliance or vm selected if (selectedPoolMetadata[vdiRef].VmAppliances.Count == 0 && selectedPoolMetadata[vdiRef].Vms.Count == 0) { selectedPoolMetadata.Remove(vdiRef); } OnPageUpdated(); }
public void Update(CustomTreeNode rootNode) { maxId = rootNode.MaxChildId; width = settings.CanvasPaddingX * 2 + CustomTreeHelper.DetermineSize(rootNode, this, this.actualDrawer, settings.NodeSize); height = settings.CanvasPaddingY * 2 + (rootNode.MaxChildId - 1) * settings.SegmentHeight + settings.NodeSize * rootNode.MaxChildId; actualDrawer.OnUpdate(width, height); }
/// <summary> Styles the given node using the current Label Provider. </summary> /// <param name="treeNode">Node to style</param> private void StyleNode(CustomTreeNode treeNode) { object element = treeNode.Tag; // Apply standard properties treeNode.Text = LabelProvider.GetText(element); treeNode.IsEnabled = LabelProvider.IsEnabled(element); treeNode.ToolTipText = LabelProvider.GetToolTipText(element) ?? string.Empty; // Apply image ImageDescriptor imageDescriptor = LabelProvider.GetImage(element); if (imageDescriptor != null) { string imageId = imageDescriptor.Id; treeNode.ImageKey = imageId; treeNode.SelectedImageKey = imageId; if (!ImageList.Images.ContainsKey(imageId)) { Stream imageStream = imageDescriptor.ImageStream; if (imageStream != null) { ImageList.Images.Add(imageId, new Bitmap(imageStream)); } } } }
public void AddChildTest() { CustomTreeNode node = new CustomTreeNode(); Assert.AreEqual(0, node.Children.Count()); node.AddChild(new CustomTreeNode()); Assert.AreEqual(1, node.Children.Count()); }
public MainWindow() { InitializeComponent(); wpfDrawerSettings = WPFTreeNodeDrawerSettings.CreateDefault(); rootNode = GetNodes(); drawer = new WPFTreeNodeDrawer(TreeGrid, wpfDrawerSettings); Button_Click(null, new RoutedEventArgs()); }
public void SelectedNodeTest() { customTree.SelectedNode = null; Assert.AreEqual(null, customTree.SelectedNode); var node = new CustomTreeNode(); customTree.SelectedNode = node; Assert.AreEqual(node, customTree.SelectedNode); }
private void setTreeView(TreeView tv, bool isSource) { try { var views = allViews.Where(tb => tb.IsSourceDB == isSource).OrderBy(tb => tb.DBView.Name); CustomTreeNode startNode = new CustomTreeNode(); startNode.IsParent = true; startNode.CanMenu = false; startNode.Text = "所有视图"; tv.Nodes.Add(startNode); var tempNode = new CustomTreeNode(); var color = Color.Black; var tip = ""; foreach (var view in views) { switch (view.Differences) { case DifferencesType.unique: color = Color.Green; break; case DifferencesType.differences: color = Color.Orange; break; case DifferencesType.common: color = Color.Black; break; case DifferencesType.lack: color = Color.Gray; break; default: color = Color.Black; break; } tempNode = new CustomTreeNode(); tempNode.IsParent = true; tempNode.CanMenu = true; tempNode.Text = view.DBView.Name; tempNode.View = view.DBView; tempNode.Differences = view.Differences; tempNode.IsSourceDB = view.IsSourceDB; tempNode.ForeColor = color; startNode.Nodes.Add(tempNode); } startNode.Expand(); } catch (Exception ex) { txtSql.Text = string.Format("--消息:{0}", ex.Message); throw ex; } }
public void UpdateTest() { var node = new CustomTreeNode(); customTree.SelectedNode = node; customTree.Update(node); Assert.DoesNotThrow(delegate { var id = node.Id; }); // because update must call init for root node! Assert.AreEqual(null, customTree.SelectedNode); // update should clear selection }
/// <summary> /// Check if given node position matches coords (specified by (X, Y) /// This is highly unoptimized. This can be done much better / faster /// </summary> /// <param name="node">CustomTreeNode object</param> /// <param name="x">x position </param> /// <param name="y">y position</param> /// <returns>returns true if matched</returns> public bool IsHit(CustomTreeNode node, double x, double y) { double nx, ny; GetXY(node, out nx, out ny); double nodeSizeHalf = settings.NodeSize / 2.0f; return(nx - nodeSizeHalf <= x && x <= nx - nodeSizeHalf + settings.SegmentWidth && ny <= y && y <= ny + settings.NodeSize); }
public int Max() { CustomTreeNode current = this._Root; while (current.Right != null) { current = current.Right; } return(current.iData); }
public virtual double GetSizeOf(CustomTreeNode node, double nodeSize, bool isSelected) { if (node.Info is ICustomTreeSimpleNodeInfo) { var formattedText = GetFormattedText(node.Info, isSelected); return(formattedText.Width + nodeSize + settings.TextPositionCorrection.X); } return(0.0); }
public void GetXY(CustomTreeNode node, out double x, out double y) { if (node == null) { throw new ArgumentNullException(); } x = settings.CanvasPaddingX + settings.SegmentWidth * node.LeftPadding + settings.NodeSize / 2.0f; y = settings.CanvasPaddingY + (settings.NodeSize + settings.SegmentHeight) * (maxId - node.Id); }
/// <summary> /// Check if given node position matches coords (specified by (X, Y) /// This is highly unoptimized. This can be done much better / faster /// </summary> /// <param name="node">CustomTreeNode object</param> /// <param name="x">x position </param> /// <param name="y">y position</param> /// <returns>returns true if matched</returns> public bool IsHit(CustomTreeNode node, double x, double y) { double nx, ny; GetXY(node, out nx, out ny); double startY = ny - settings.SegmentHeight / 2.0f; double endY = startY + settings.SegmentHeight + settings.NodeSize; return(startY <= y && y <= endY); }
public int Min() { CustomTreeNode current = this._Root; while (current.Left != null) { current = current.Left; } return(current.iData); }
public void RefreshTest() { Assert.DoesNotThrow(() => customTree.Update(null)); // update will null root shuld not throw var node = new CustomTreeNode(); customTree.SelectedNode = node; customTree.Refresh(); Assert.Throws <InvalidOperationException>(delegate { var id = node.Id; }); // because refresh must not call init for root node! Assert.AreEqual(node, customTree.SelectedNode); // refresh should not clear selection }
protected override int SameLevelSortOrder(CustomTreeNode other) { DiskListSrItem otherItem = other as DiskListSrItem; if (otherItem == null) //shouldnt ever happen!!! return -1; int rank = this.SrRank() - otherItem.SrRank(); if (rank == 0) return base.SameLevelSortOrder(other); else return rank; }
private void DoOnNodeStateChanged(CustomTreeNode node, XenRef <VDI> vdiRef) { var applianceNode = node as ApplianceNode; if (applianceNode != null) { switch (applianceNode.State) { case CheckState.Checked: if (!selectedPoolMetadata[vdiRef].VmAppliances.ContainsKey(applianceNode.ApplianceRef)) { selectedPoolMetadata[vdiRef].VmAppliances.Add(applianceNode.ApplianceRef, applianceNode.Appliance); } break; case CheckState.Unchecked: if (selectedPoolMetadata[vdiRef].VmAppliances.ContainsKey(applianceNode.ApplianceRef)) { selectedPoolMetadata[vdiRef].VmAppliances.Remove(applianceNode.ApplianceRef); } break; } foreach (var childNode in applianceNode.ChildNodes) { childNode.State = applianceNode.State; DoOnNodeStateChanged(childNode, vdiRef); } return; } var vmNode = node as VmNode; if (vmNode != null) { switch (vmNode.State) { case CheckState.Checked: if (!selectedPoolMetadata[vdiRef].Vms.ContainsKey(vmNode.VmRef)) { selectedPoolMetadata[vdiRef].Vms.Add(vmNode.VmRef, vmNode.Vm); } break; case CheckState.Unchecked: if (selectedPoolMetadata[vdiRef].Vms.ContainsKey(vmNode.VmRef)) { selectedPoolMetadata[vdiRef].Vms.Remove(vmNode.VmRef); } break; } } }
void ShowErrorInTree(CustomTreeNode parentNode) { if (parentNode != null) { parentNode.IsError = true; } else { Tree.IsError = true; } }
private void PopulatePropertyTemplates(CustomTreeNode treeNode, IEnumerable <IfcPropertySetTemplate> propertySetTemplates) { if (propertySetTemplates == null) { return; } foreach (var propertySetTemplate in propertySetTemplates) { if (propertySetTemplate.HasPropertyTemplates == null) { continue; } foreach (var propertyTemplate in propertySetTemplate.HasPropertyTemplates.Items) { IfcSimplePropertyTemplate simplePropertyTemplate = propertyTemplate as IfcSimplePropertyTemplate; if (simplePropertyTemplate == null) { continue; } string nodeText = String.Format("{0}", simplePropertyTemplate.Name); if (!String.IsNullOrEmpty(simplePropertyTemplate.PrimaryMeasureType)) { nodeText = String.Concat(nodeText, String.Format(" [{0}]", simplePropertyTemplate.PrimaryMeasureType)); } CustomTreeNode simplePropertyTemplateNode = new CustomTreeNode(nodeText, simplePropertyTemplate); treeNode.Nodes.Add(simplePropertyTemplateNode); if (simplePropertyTemplate.TemplateType == IfcSimplePropertyTemplateTypeEnum.PSinglevalue) { // TODO: set node images, colors, ... } else if (simplePropertyTemplate.TemplateType == IfcSimplePropertyTemplateTypeEnum.PEnumeratedvalue) { foreach (var enumItem in simplePropertyTemplate.Enumerators.EnumerationValues.Items) { if (enumItem is IfcLabelwrapper) { IfcLabelwrapper labelWrapper = enumItem as IfcLabelwrapper; string enumNodeText = String.Format("{0}", labelWrapper.Value); CustomTreeNode enumNode = new CustomTreeNode(enumNodeText, (IfcLabelwrapper)enumItem); // TODO: set node images, colors, ... simplePropertyTemplateNode.Nodes.Add(enumNode); } } // TODO: set node images, colors, ... } } } }
public void RestoreMark(CustomTreeNode treeNode) { if (_currentFileSettings == null) { return; } if (CurrentFileSettings.Marks.ContainsKey(treeNode.Text)) { SelectNode(CurrentFileSettings.Marks[treeNode.Text], treeNode); } }
public void RestoreMark(CustomTreeNode treeNode) { if (_currentDictionary == null) { return; } if (CurrentDictionary.ContainsKey(treeNode.Text)) { SelectNode(CurrentDictionary[treeNode.Text], treeNode); } }
public void PropertiesShouldFailBeforeInitTest() { CustomTreeNode node = new CustomTreeNode(); Assert.Throws <InvalidOperationException>(delegate { var id = node.Id; }); Assert.Throws <InvalidOperationException>(delegate { var parentId = node.ParentId; }); Assert.Throws <InvalidOperationException>(delegate { var height = node.Height; }); Assert.Throws <InvalidOperationException>(delegate { var width = node.Width; }); Assert.Throws <InvalidOperationException>(delegate { var topPadding = node.TopPadding; }); Assert.Throws <InvalidOperationException>(delegate { var leftPadding = node.LeftPadding; }); Assert.Throws <InvalidOperationException>(delegate { var maxChildId = node.MaxChildId; }); }
public bool?IsNoteExpanded(CustomTreeNode node) { var storage = ActiveStorage; var nodeKey = GetNodeKey(node); if (storage.ContainsKey(nodeKey)) { return(storage[nodeKey]); } return(null); }
private void BuildList() { Program.AssertOnEventThread(); labelWarningLine3.Visible = !_vm.UsingUpstreamQemu(); treeUsbList.ClearAllNodes(); treeUsbList.BeginUpdate(); try { List <UsbItem> usbNodeList = new List <UsbItem>(); foreach (Host host in possibleHosts) { // Add a host node to tree list. HostItem hostNode = new HostItem(host); List <PUSB> pusbs = host.Connection.ResolveAll(host.PUSBs); foreach (PUSB pusb in pusbs) { // Add a USB in the host to tree list. // Determin if the USB is valid to attach. USB_group usbGroup = pusb.Connection.Resolve(pusb.USB_group); bool attached = (usbGroup != null) && (usbGroup.VUSBs != null) && (usbGroup.VUSBs.Count > 0); if (pusb.passthrough_enabled && !attached) { UsbItem usbNode = new UsbItem(pusb); usbNodeList.Add(usbNode); } } // Show host node only when it contains available USB devices. if (usbNodeList.Count > 0) { treeUsbList.AddNode(hostNode); foreach (UsbItem item in usbNodeList) { treeUsbList.AddChildNode(hostNode, item); } } usbNodeList.Clear(); } if (treeUsbList.Nodes.Count == 0) { CustomTreeNode noDeviceNode = new CustomTreeNode(false); noDeviceNode.Text = Messages.DIALOG_ATTACH_USB_NO_DEVICES_AVAILABLE; treeUsbList.AddNode(noDeviceNode); } } finally { treeUsbList.EndUpdate(); } }
void Loader_DataLoaded(object sender, DataLoaderEventArgs e) { CustomTreeNode parentNode = e.UserState as CustomTreeNode; if (parentNode != null) { parentNode.IsWaiting = false; } else { Tree.IsWaiting = false; } if (e.Error != null) { ShowErrorInTree(parentNode); LogManager.LogError(this, e.Error.ToString()); return; } if (e.Result.ContentType == InvokeContentType.Error) { ShowErrorInTree(parentNode); LogManager.LogError(this, e.Result.Content); return; } List <CubeDefInfo> cubes = XmlSerializationUtility.XmlStr2Obj <List <CubeDefInfo> >(e.Result.Content); if (cubes != null) { foreach (CubeDefInfo info in cubes) { if (ShowAllCubes || info.Type == CubeInfoType.Cube) { CubeTreeNode node = new CubeTreeNode(info); // Кубы будут конечными узлами. Двойной клик на них будет равнозначен выбору node.Expanded += new RoutedEventHandler(node_Expanded); node.Collapsed += new RoutedEventHandler(node_Collapsed); if (parentNode == null) { Tree.Items.Add(node); } else { parentNode.Items.Add(node); } } } } }
/// <summary> Styles all nodes of the given collection using the current Label Provider. </summary> /// <param name="nodes">Collection of nodes to style</param> private void StyleTree(TreeNodeCollection nodes) { for (IEnumerator enmtor = nodes.GetEnumerator(); enmtor.MoveNext();) { CustomTreeNode treeNode = enmtor.Current as CustomTreeNode; if (treeNode == null) { continue; } StyleNode(treeNode); StyleTree(treeNode.Nodes); } }
public void FixtureSetUp() { CustomTreeNode node71 = new CustomTreeNode(new SomeCustomClass("71")); CustomTreeNode node61 = new CustomTreeNode(new SomeCustomClass("61"), new List <CustomTreeNode>() { node71 }); CustomTreeNode node51 = new CustomTreeNode(new SomeCustomClass("51")); CustomTreeNode node52 = new CustomTreeNode(new SomeCustomClass("52")); CustomTreeNode node53 = new CustomTreeNode(new SomeCustomClass("53"), new List <CustomTreeNode>() { node61 }); CustomTreeNode node14 = new CustomTreeNode(new SomeCustomClass("14"), new List <CustomTreeNode>() { node51, node52 }); CustomTreeNode node24 = new CustomTreeNode(new SomeCustomClass("24"), new List <CustomTreeNode>() { node53 }); CustomTreeNode node13 = new CustomTreeNode(new SomeCustomClass("13")); CustomTreeNode node23 = new CustomTreeNode(new SomeCustomClass("23")); CustomTreeNode node33 = new CustomTreeNode(new SomeCustomClass("33")); node43 = new CustomTreeNode(new SomeCustomClass("Vratice se NODE"), new List <CustomTreeNode>() { node14, node24 }); CustomTreeNode node12 = new CustomTreeNode(new SomeCustomClass("12"), new List <CustomTreeNode>() { node13, node23 }); CustomTreeNode node22 = new CustomTreeNode(new SomeCustomClass("22"), new List <CustomTreeNode>() { node33, node43 }); node32 = new CustomTreeNode(new SomeCustomClass("Coban je nas boban")); complexRoot = new CustomTreeNode(new SomeCustomClass("11"), new List <CustomTreeNode>() { node12, node22, node32 }); complexRoot.Init(); // must initialize everything @see PropertiesShouldFailBeforeInitTest }
protected override int SameLevelSortOrder(CustomTreeNode other) { if (Enabled && !other.Enabled) return -1; else if (!Enabled && other.Enabled) return 1; else if (Enabled && other.Enabled && other is HostItem) return TheHost.CompareTo(((HostItem)other).TheHost); else return base.SameLevelSortOrder(other); }
/// <summary> /// Returneaza un sir de CustomTreeNode cu lectiile din fisier /// </summary> /// <returns></returns> public CustomTreeNode<Lectie>[] GetCuprinsLectiiTreeNodes() { if (LectiiHolder == null) return new CustomTreeNode<Lectie>[0]; var lista = new List<CustomTreeNode<Lectie>>(); foreach (Lectie lectie in LectiiHolder.Lectii) { CustomTreeNode<Lectie> node; if (lectie.HasChildren) node = new CustomTreeNode<Lectie>(lectie.Titlu, GetLectieSubNodes(lectie.Lectii), lectie, false); else node = new CustomTreeNode<Lectie>(lectie.Titlu, lectie, true); lista.Add(node); } return lista.ToArray(); }
/// <summary> /// Returneaza lista de sub-lectii a unei liste de lectii /// </summary> /// <param name="lectie">Lista de lectii</param> /// <returns></returns> private CustomTreeNode<Lectie>[] GetLectieSubNodes(List<Lectie> lectie) { if (lectie == null) return null; var listNodes = new List<CustomTreeNode<Lectie>>(); foreach (Lectie subLectie in lectie) { CustomTreeNode<Lectie> node; if (subLectie.HasChildren) node = new CustomTreeNode<Lectie>(subLectie.Titlu, GetLectieSubNodes(subLectie.Lectii), subLectie, false); else node = new CustomTreeNode<Lectie>(subLectie.Titlu, subLectie, true); listNodes.Add(node); } return listNodes.ToArray(); }
private void btnTesteLectie_Click(object sender, EventArgs e) { CustomTreeNode<Test>[] list = (from CustomTreeNode<Test> test in listaTeste.Nodes where test.Text.Equals("Teste asociate lectiei") select test).ToArray(); if (list.Length > 0) listaTeste.Nodes.Remove(list[0]); if (Res.Instance.SelectedLectie.IdsTeste == null) return; var treeNode = new CustomTreeNode<Test>("Teste asociate lectiei", Res.Instance.GetTesteTreeNodes(Res.Instance.SelectedLectie.IdsTeste), null, true); treeNode.Expand(); treeNode.BackColor = Color.YellowGreen; listaTeste.Nodes.Add(treeNode); SelectTab(tabPageTeste.Name); }
private bool SelectNextEnabledNode(CustomTreeNode currentNode, bool searchForward) { CustomTreeNode nextEnabledNode = GetNextEnabledNode(currentNode, searchForward); if (nextEnabledNode != null) { SelectedItem = nextEnabledNode; return true; } return false; }
public void Resort() { try { lastSelected = SelectedItem as CustomTreeNode; } catch (IndexOutOfRangeException) { // Accessing ListBox.SelectedItem sometimes throws an IndexOutOfRangeException (See CA-24396) log.Warn("IndexOutOfRangeException in ListBox.SelectedItem"); lastSelected = null; } Nodes.Sort(); Items.Clear(); foreach (CustomTreeNode node in Nodes) { if (node.Level != -1 && node.ParentNode.Expanded) Items.Add(node); } SelectedItem = lastSelected; // I've yet to come across the above assignement working. If we fail to restore the selection, select something so the user can see focus feedback // (the color of the selected item is the only indication as to whether it is focused or not) // Iterating through and using CustomTreeNode.equals is useless here as it compares based on index, which I think is why the above call almost never works if (SelectedItem == null && lastSelected != null && Items.Count > 0) { SelectedItem = Items[0]; } }
public void RemoveNode(CustomTreeNode node) { Nodes.Remove(node); if (!_inUpdate) { RecalculateWidth(); Resort(); Refresh(); } }
public void AddNode(CustomTreeNode node) { if (Nodes.Count == 0) Nodes.Add(SecretNode); SecretNode.AddChild(node); Nodes.Add(node); if (!_inUpdate) { RecalculateWidth(); Resort(); Refresh(); } }
public void AddChildNode(CustomTreeNode parent, CustomTreeNode child) { parent.AddChild(child); Nodes.Add(child); if (!_inUpdate) { RecalculateWidth(); Resort(); Refresh(); } }
// Fixed for CA-57131. // Though it would be better to use the usual search mechanism for building // the tree, so that the order is absolutely guaranteed to be the same. protected override int SameLevelSortOrder(CustomTreeNode other) { if (other.Tag is IXenConnection && this.Tag is IXenConnection) { return (this.Tag as IXenConnection).CompareTo(other.Tag as IXenConnection); } else if (other.Tag is IXenConnection) { return -1; } else if (this.Tag is IXenConnection) { return 1; } else if (this.Tag is Host && other.Tag is Host) { return (this.Tag as Host).CompareTo(other.Tag as Host); } else { return base.SameLevelSortOrder(other); } }
protected override int SameLevelSortOrder(CustomTreeNode other) { if (Enabled && !other.Enabled) return -1; else if (!Enabled && other.Enabled) return 1; else return base.SameLevelSortOrder(other); }
/// <summary> /// Finds next/previous enabled node in Items collection. /// </summary> /// <param name="currentNode">Node where the search for next/previous enabled node will start.</param> /// <param name="searchForward">Determines direction of search (search for next or previous node).</param> /// <returns></returns> protected CustomTreeNode GetNextEnabledNode(CustomTreeNode currentNode, bool searchForward) { if (currentNode == null) return null; CustomTreeNode nextNode = GetNextNode(currentNode, searchForward); if (nextNode == null) return null; if (nextNode.Enabled) return nextNode; return GetNextEnabledNode(nextNode, searchForward); }
/// <summary> /// Tries to select the node if it is a host item. If it is a host item, but is disabled, selects its parent instead. /// </summary> /// <param name="item"></param> /// <param name="host"></param> /// <returns>True if successful</returns> private bool TryToSelectHost(CustomTreeNode item, Host host) { if (item is HostItem) { HostItem hostitem = item as HostItem; if (hostitem.TheHost.opaque_ref == host.opaque_ref) { if (hostitem.Enabled) { SelectedItem = hostitem; return true; } else if (hostitem.ParentNode is PoolItem) { SelectConnection(host.Connection); return true; } } } return false; }
/// <summary> /// Finds next/previous node in Items collection. /// </summary> /// <param name="currentNode">Node where the search for next/previous node will start.</param> /// <param name="searchForward">Determines direction of search (search for next or previous node).</param> /// <returns></returns> protected CustomTreeNode GetNextNode(CustomTreeNode currentNode, bool searchForward) { if (currentNode == null) return null; int index = Items.IndexOf(currentNode); if (searchForward) { index++; if (index >= Items.Count) index = -1; } else index--; if (index < 0) return null; return (CustomTreeNode)Items[index]; }
/// <summary> /// Umple lista cu cuvinte cheie dupa sirul cautat /// </summary> /// <param name="searchText">Sirul cautat</param> /// <param name="init">Adevarat daca metoda este folosita pentru initializare</param> private void FillCuvinteCheie(string searchText, bool init) { if (searchText == " " || searchText == null) searchText = ""; // lista de cuvinte cheie var cuvinteList = new List<CustomTreeNode<CuvantCheie>>(); // lista temporara de cuvinte cheie var currentCuvinte = new List<string>(); listaCuvinteCheie.Nodes.Clear(); foreach (Tip tip in Res.Instance.ListaTipuri) { cuvinteList.Clear(); currentCuvinte.Clear(); if (tip == null) continue; var probleme = from Problema problema in Res.Instance.ListaProbleme where problema.Tip.Equals(tip.Nume) select problema; foreach (Problema problema in probleme) { CuvantCheie cuvanteCheie = Res.Instance.GetCuvantCheieById(problema.Id); if (!cuvanteCheie.Cuvinte.Contains(searchText)) continue; string[] cuvinteCheieTmp = cuvanteCheie.Cuvinte.Split(','); foreach (string cuvantCheie in cuvinteCheieTmp) { if (!cuvantCheie.Contains(searchText)) continue; string cuvant = cuvantCheie.Trim(); if (!currentCuvinte.Contains(cuvant)) // nu exista introdus acest cuvant cheie { currentCuvinte.Add(cuvant); var treeNode = new CustomTreeNode<CuvantCheie>(string.Format("{0} ({1})", cuvant, 1), cuvanteCheie, false); if (treeNode.ListaProbleme == null) treeNode.ListaProbleme = new List<Problema>(); treeNode.ListaProbleme.Add(problema); cuvinteList.Add(treeNode); } else { int index = currentCuvinte.IndexOf(cuvant); var node = cuvinteList[index]; if (node.ListaProbleme == null) node.ListaProbleme = new List<Problema>(); node.ListaProbleme.Add(problema); node.Text = string.Format("{0} ({1})", cuvant, node.ListaProbleme.Count); } } } if (cuvinteList.Count > 0) listaCuvinteCheie.Nodes.Add(new CustomTreeNode<CuvantCheie>(tip.Nume, cuvinteList.ToArray(), null, true)); else Logging.Instance.Write("Problema fara cuvinte cheie"); } listaCuvinteCheie.Sort(); splitContainerCuvinteCheie.Panel2Collapsed = searchText.Length > 0; if (!init) // ne asiguram ca este selectat tab-ul potrivit { SelectTab(tabPageProbleme.Name); tabControlSubProbleme.SelectTab(tabPageCuvinteCheie); } }
protected override void OnSelectedIndexChanged(EventArgs e) { if (SelectedItem is CustomTreeNode) { CustomTreeNode item = SelectedItem as CustomTreeNode; if (!item.Enabled) { SelectedItem = lastSelected; } if (!AllowPoolSelect && item is PoolItem) { SelectedItem = lastSelected; } } lastSelected = SelectedItem as CustomTreeNode; base.OnSelectedIndexChanged(e); if(SelectedItemChanged != null) SelectedItemChanged(null,new SelectedItemEventArgs((SelectedItem is PoolItem || SelectedItem is HostItem) && (SelectedItem as CustomTreeNode).Enabled)); }