public void AddSelectedResultsTreeNodeToSelected() { TreeNode node = ResultsTree.SelectedNode; if (node == null) { return; } if (node.Parent == null) { return; //TMehyar - 2016-02-23: This is to prevent the users from selecting folders } string name = node.Text; Guid id; NodeGuidDictionary.TryGetValue(node, out id); var ts = new TaxonomyStruct { Name = name, ID = id }; if (ResultsTree.SelectedNode.Parent != null) { ts.Section = ResultsTree.SelectedNode.Parent.FullPath; } AddToSelected(ts); }
public void AddSelectedResultsItemToSelected() { if (Results.SelectedItems.Count > 0) { ListViewItem item = Results.SelectedItems[0]; var id = new Guid(item.SubItems[2].Text); var taxonomy = new TaxonomyStruct { Name = item.Text, ID = id }; AddToSelected(taxonomy); } }
public void RemoveSelectedItemFromSelected() { if (Selected.SelectedItems.Count > 0) { ListViewItem item = Selected.SelectedItems[0]; string name = item.Text; var id = new Guid(item.SubItems[1].Text); var taxonomy = new TaxonomyStruct { Name = name, ID = id }; RemoveFromSelected(taxonomy); } }
public bool AddToSelected(TaxonomyStruct taxonomy) { bool added = false; if (!IsSelected(taxonomy)) { SelectedList.Add(taxonomy); added = true; PopulateSelected(); } RefreshResultsImages(); RefreshResultsTreeImages(); return(added); }
public void RemoveFromSelected(TaxonomyStruct taxonomy) { foreach (TaxonomyStruct ts in SelectedList) { if (ts.ID.Equals(taxonomy.ID)) { SelectedList.Remove(ts); break; } } PopulateSelected(); RefreshResultsImages(); RefreshResultsTreeImages(); }
private void AddEventHandlers() { ViewTreeLink.LinkClicked += delegate { ViewTree(); }; ViewSearchLink.LinkClicked += delegate { ViewSearchResults(); }; Results.MouseDown += delegate(object sender, MouseEventArgs e) { ListViewItem item = Results.HitTest(e.X, e.Y).Item; if (item != null) { if (Results.HitTest(e.X, e.Y).Location == ListViewHitTestLocations.Image) { string name = item.Text; var id = new Guid(item.SubItems[2].Text); var taxonomy = new TaxonomyStruct { Name = name, ID = id }; AddToSelected(taxonomy); } if (Results.HitTest(e.X, e.Y).SubItem == item.SubItems[1]) //if mouse click on "view in tree" { TreeNode node; GuidNodeDictionary.TryGetValue(new Guid(item.SubItems[2].Text), out node); ViewTree(); ExpandTreeTo(node); } } }; Results.ItemSelectionChanged += delegate(object sender, ListViewItemSelectionChangedEventArgs e) { foreach (ListViewItem i in Results.Items) { if (i != e.Item) { i.BackColor = Color.Empty; i.Selected = false; } } //e.Item.Selected = true; //e.Item.BackColor = Color.Yellow; }; Results.MouseMove += delegate(object sender, MouseEventArgs e) { ListViewItem item = Results.HitTest(e.X, e.Y).Item; if (item != null) { if (Results.HitTest(e.X, e.Y).SubItem == item.SubItems[1] || Results.HitTest(e.X, e.Y).Location == ListViewHitTestLocations.Image) { Cursor.Current = Cursors.Hand; } } }; Selected.MouseDown += delegate(object sender, MouseEventArgs e) { ListViewItem item = Selected.HitTest(e.X, e.Y).Item; if (Selected.HitTest(e.X, e.Y).Location == ListViewHitTestLocations.Image) { string name = item.Text; var id = new Guid(item.SubItems[1].Text); var taxonomy = new TaxonomyStruct { Name = name, ID = id }; RemoveFromSelected(taxonomy); } }; Keywords.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { if (Results.SelectedItems.Count != 0) { int index = Results.SelectedIndices[0]; if (index > 0) { Results.Items[index].Selected = false; Results.Items[index].BackColor = Color.Empty; Results.Items[index - 1].Selected = true; Results.Items[index - 1].BackColor = Color.Yellow; } } } if (e.KeyCode == Keys.Down) { if (Results.SelectedItems.Count != 0) { int index = Results.SelectedIndices[0]; if (index < Results.Items.Count - 1) { Results.Items[index].Selected = false; Results.Items[index].BackColor = Color.Empty; Results.Items[index + 1].Selected = true; Results.Items[index + 1].BackColor = Color.Yellow; } } } if (e.KeyCode == Keys.Enter) { if (Results.SelectedItems.Count == 0) { PopulateResults(); ViewSearchResults(); } else { string name = Results.SelectedItems[0].Text; Guid guid = new Guid(Results.SelectedItems[0].SubItems[2].Text); TaxonomyStruct ts = new TaxonomyStruct { ID = guid, Name = name }; if (!AddToSelected(ts)) { RemoveFromSelected(ts); } Keywords.Text = ""; } } }; Keywords.TextChanged += delegate { if (Keywords.TextLength > 1) { PopulateResults(); ViewSearchResults(); if (Results.Items.Count > 0) { Results.Items[0].BackColor = Color.Yellow; Results.Items[0].Selected = true; } } }; ResultsTree.MouseDown += delegate(object sender, MouseEventArgs e) { if (ResultsTree.HitTest(e.X, e.Y).Location == TreeViewHitTestLocations.Image) { TreeNode node = ResultsTree.HitTest(e.X, e.Y).Node; string name = node.Text; Guid id; NodeGuidDictionary.TryGetValue(node, out id); var ts = new TaxonomyStruct { Name = name, ID = id }; AddToSelected(ts); } }; }
public bool IsSelected(TaxonomyStruct ts) { return(IsSelected(ts.ID)); }
/// <summary> /// To add a new general tag that does not exist in Sitecore, /// give the general tag an empty Guid /// </summary> /// <param name="tag"></param> /// <param name="color"></param> protected void AddSelectedTag(GeneralTag tag) { if (tag == null) { return; } if (GetSelected(tag) != null) { return; } string[] selectedTaxonomyParts = tag.Path.Split('/'); selectedTaxonomyParts = selectedTaxonomyParts.SkipWhile(x => !x.Equals("Taxonomy")).ToArray(); selectedTaxonomyParts = selectedTaxonomyParts.Skip(1).ToArray(); string taxonomyRoot = selectedTaxonomyParts.First(); switch (taxonomyRoot.ToLower()) { case "general tags": case "create as new tag": //general tags case uxSelectedTags.RowStyles.Add(new RowStyle(SizeType.Absolute, 20f)); uxSelectedTags.Controls.Add(CreateRemoveImage(tag)); uxSelectedTags.Controls.Add(CreateSelectedLabel(tag)); SelectedTags.Add(GetTaxonomy(tag)); UpdateMenuItem(true); break; case "market segments": TaxonomyStruct marketItem = new TaxonomyStruct(); marketItem.ID = tag.Guid; marketItem.Name = tag.Title; MyPageSelector.pageMarketSegmentsControl.TabController.AddToSelected(marketItem); break; case "industries": TaxonomyStruct industryItem = new TaxonomyStruct(); industryItem.ID = tag.Guid; industryItem.Name = tag.Title; MyPageSelector.pageIndustriesControl.TabController.AddToSelected(industryItem); break; case "subjects": TaxonomyStruct subjectItem = new TaxonomyStruct(); subjectItem.ID = tag.Guid; subjectItem.Name = tag.Title; MyPageSelector.pageSubjectsControl.TabController.AddToSelected(subjectItem); break; case "therapeutic categories": TaxonomyStruct tcItem = new TaxonomyStruct(); tcItem.ID = tag.Guid; tcItem.Name = tag.Title; MyPageSelector.pageTherapeuticCategoriesControl.TabController.AddToSelected(tcItem); break; default: break; } }
private void AddEventHandlers() { ViewTreeLink.LinkClicked += delegate { PopulateResultsTree(); ViewTree(); }; ViewSearchLink.LinkClicked += delegate { ViewSearchResults(); }; Results.MouseDown += delegate(object sender, MouseEventArgs e) { ListViewItem item = Results.HitTest(e.X, e.Y).Item; if (item != null) { if (Results.HitTest(e.X, e.Y).SubItem == item.SubItems[1]) //if mouse click on "view in tree" { TreeNode node; GuidNodeDictionary.TryGetValue(new Guid(item.SubItems[2].Text), out node); ViewTree(); ExpandTreeTo(node); } } }; Results.ItemSelectionChanged += delegate(object sender, ListViewItemSelectionChangedEventArgs e) { foreach (ListViewItem i in Results.Items) { if (i != e.Item) { i.BackColor = Color.Empty; i.Selected = false; } } e.Item.BackColor = Color.Yellow; }; Results.DoubleClick += delegate { AddSelectedResultsItemToSelected(); }; Results.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { AddSelectedResultsItemToSelected(); } }; Results.MouseMove += delegate(object sender, MouseEventArgs e) { ListViewItem item = Results.HitTest(e.X, e.Y).Item; Cursor.Current = item != null ? Cursors.Hand : Cursors.Default; }; Selected.DoubleClick += delegate { RemoveSelectedItemFromSelected(); }; Selected.KeyDown += delegate(object sender, KeyEventArgs e) { //var clickPos = Selected.PointToClient(Control.MousePosition); if (e.KeyCode == Keys.Enter && Selected.SelectedItems.Count > 0) { RemoveSelectedItemFromSelected(); } }; Selected.MouseMove += delegate(object sender, MouseEventArgs e) { ListViewItem item = Selected.HitTest(e.X, e.Y).Item; Cursor.Current = item != null ? Cursors.Hand : Cursors.Default; }; Keywords.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { if (Results.SelectedItems.Count != 0) { int index = Results.SelectedIndices[0]; if (index > 0) { Results.BeginUpdate(); Results.Items[index - 1].Selected = true; } } } if (e.KeyCode == Keys.Down) { if (Results.SelectedItems.Count != 0) { int index = Results.SelectedIndices[0]; if (index < Results.Items.Count - 1) { Results.BeginUpdate(); Results.Items[index + 1].Selected = true; } } } if (e.KeyCode == Keys.Enter) { if (Results.SelectedItems.Count == 0) { PopulateResults(); ViewSearchResults(); } else { string name = Results.SelectedItems[0].Text; var guid = new Guid(Results.SelectedItems[0].SubItems[2].Text); var ts = new TaxonomyStruct { ID = guid, Name = name }; if (!AddToSelected(ts)) { RemoveFromSelected(ts); } Keywords.Text = ""; } e.SuppressKeyPress = true; } Results.EndUpdate(); }; Keywords.TextChanged += delegate { if (Keywords.TextLength > 1) { PopulateResults(); ViewSearchResults(); if (Results.Items.Count > 0) { Results.Items[0].BackColor = Color.Yellow; Results.Items[0].Selected = true; } } }; ResultsTree.NodeMouseDoubleClick += delegate { AddSelectedResultsTreeNodeToSelected(); }; ResultsTree.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { AddSelectedResultsTreeNodeToSelected(); e.SuppressKeyPress = true; } }; ResultsTree.MouseMove += delegate(object sender, MouseEventArgs e) { if (ResultsTree.HitTest(e.X, e.Y).Location == TreeViewHitTestLocations.Label) { Cursor.Current = Cursors.Hand; } }; Down.Click += delegate { var currentIndex = Selected.SelectedItems[0].Index; var item = Selected.Items[currentIndex]; if (currentIndex < Selected.Items.Count - 1) { Selected.Items.RemoveAt(currentIndex); Selected.Items.Insert(currentIndex + 1, item); TaxonomyStruct currentItem = SelectedList.FirstOrDefault(i => i.ID.ToString() == Selected.SelectedItems[0].SubItems[1].Text); SelectedList.Remove(currentItem); SelectedList.Insert(currentIndex + 1, currentItem); } }; Up.Click += delegate { var currentIndex = Selected.SelectedItems[0].Index; var item = Selected.Items[currentIndex]; if (currentIndex > 0) { Selected.Items.RemoveAt(currentIndex); Selected.Items.Insert(currentIndex - 1, item); TaxonomyStruct currentItem = SelectedList.FirstOrDefault(i => i.ID.ToString() == Selected.SelectedItems[0].SubItems[1].Text); SelectedList.Remove(currentItem); SelectedList.Insert(currentIndex - 1, currentItem); } }; Up.MouseMove += delegate { Cursor.Current = Cursors.Hand; }; Down.MouseMove += delegate { Cursor.Current = Cursors.Hand; }; }