This class contains methods that can be used for displaying the Semantic Domains in a TreeView and ListView. These views are used in FLEX for allowing the user to select Semantic Domains.
Example #1
0
 private void OnDisplayUsageCheckedChanged(object sender, EventArgs e)
 {
     using (new WaitCursor(this))
     {
         domainTree.BeginUpdate();
         domainList.BeginUpdate();
         var stack = new Stack <LabelNode>(domainTree.Nodes.Cast <LabelNode>());
         while (stack.Count > 0)
         {
             LabelNode node = stack.Pop();
             node.DisplayUsage = displayUsageCheckBox.Checked;
             foreach (TreeNode childNode in node.Nodes)
             {
                 var labelNode = childNode as LabelNode;
                 if (labelNode != null)
                 {
                     stack.Push(labelNode);
                 }
             }
         }
         foreach (ListViewItem item in domainList.Items)
         {
             item.Text = SemanticDomainSelectionUtility.CreateLabelListItem(item.Tag as ICmObject,
                                                                            item.Checked,
                                                                            displayUsageCheckBox.Checked).Text;
         }
         domainTree.EndUpdate();
         domainList.EndUpdate();
     }
 }
Example #2
0
        private void SearchSemanticDomains()
        {
            IEnumerable <ObjectLabel> labels = new List <ObjectLabel>();

            // The FindDomainsThatMatch method returns IEnumerable<ICmSemanticDomain>
            // based on the search string we give it.
            var searchString = TrimmedSearchBoxText;

            if (!string.IsNullOrEmpty(searchString))
            {
                btnCancelSearch.SearchIsActive = true;
                domainList.ItemChecked        -= OnDomainListChecked;
                var semDomainsToShow = m_semdomRepo.FindDomainsThatMatch(searchString);
                SemanticDomainSelectionUtility.UpdateDomainListLabels(
                    ObjectLabel.CreateObjectLabels(Cache, semDomainsToShow, string.Empty, DisplayWs),
                    m_stylesheet, domainList, displayUsageCheckBox.Checked);
                domainTree.Visible      = false;
                domainList.Visible      = true;
                domainList.ItemChecked += OnDomainListChecked;
            }
            else
            {
                domainTree.Visible             = true;
                domainList.Visible             = false;
                btnCancelSearch.SearchIsActive = false;
            }
            SearchInProgress = false;
        }
Example #3
0
 private void OnDomainTreeCheck(object sender, TreeViewEventArgs e)
 {
     if (e.Action != TreeViewAction.Unknown)
     {
         var domain = (e.Node.Tag as ObjectLabel).Object;
         SemanticDomainSelectionUtility.AdjustSelectedDomainList(domain, e.Node.Checked, selectedDomainsList);
     }
 }
Example #4
0
 private void UpdateDomainTreeAndListLabels(IEnumerable <ObjectLabel> labels)
 {
     domainTree.BeginUpdate();
     SemanticDomainSelectionUtility.UpdateDomainTreeLabels(labels, displayUsageCheckBox.Checked, domainTree, m_stylesheet, m_selectedItems);
     foreach (var selectedItem in m_selectedItems)
     {
         selectedDomainsList.Items.Add(SemanticDomainSelectionUtility.CreateLabelListItem(selectedItem, true, false));
     }
     domainTree.EndUpdate();
 }
Example #5
0
        private void OnSuggestClicked(object sender, EventArgs e)
        {
            IEnumerable <ICmSemanticDomain> partialMatches;
            var semDomainsToShow = m_semdomRepo.FindDomainsThatMatchWordsIn(Sense, out partialMatches);

            foreach (var domain in semDomainsToShow)
            {
                SemanticDomainSelectionUtility.AdjustSelectedDomainList(domain, true, selectedDomainsList);
            }
            // Add all the partial matches to the list also, but do not check them by default
            foreach (var domainMatch in partialMatches)
            {
                SemanticDomainSelectionUtility.AdjustSelectedDomainList(domainMatch, false, selectedDomainsList);
            }
        }
Example #6
0
        private void SearchSemanticDomains()
        {
            IEnumerable <ObjectLabel> labels = new List <ObjectLabel>();

            // The FindDomainsThatMatch method returns IEnumerable<ICmSemanticDomain>
            // based on the search string we give it.
            var searchString = TrimmedSearchBoxText;

            if (!string.IsNullOrEmpty(searchString))
            {
                if (m_searchIconSet)
                {
                    // When disabled, we use a Background image rather than a regular image so that it
                    // does not gray out. When showing the search icon, the button is never enabled,
                    // so it is a shame to have it grey-out our pretty magnifying glass. The X however
                    // can work as a normal button image (which avoids needing to make it larger
                    // than the button etc. in order to avoid repeating it as wallpaper, which is how
                    // BackgroundImage works.)
                    btnCancelSearch.Image           = FieldWorks.Resources.Images.X;
                    btnCancelSearch.BackgroundImage = null;
                    m_searchIconSet         = false;
                    btnCancelSearch.Enabled = true;
                }
                domainList.ItemChecked -= OnDomainListChecked;
                var semDomainsToShow = m_semdomRepo.FindDomainsThatMatch(searchString);
                SemanticDomainSelectionUtility.UpdateDomainListLabels(ObjectLabel.CreateObjectLabels(Cache, semDomainsToShow, string.Empty, DisplayWs), domainList, displayUsageCheckBox.Checked);
                domainTree.Visible      = false;
                domainList.Visible      = true;
                domainList.ItemChecked += OnDomainListChecked;
            }
            else
            {
                domainTree.Visible = true;
                domainList.Visible = false;
                if (!m_searchIconSet)
                {
                    btnCancelSearch.BackgroundImage = FieldWorks.Resources.Images.Search;
                    btnCancelSearch.Image           = null;
                    m_searchIconSet         = true;
                    btnCancelSearch.Enabled = false;
                }
            }
        }
Example #7
0
        private void OnDomainListChecked(object sender, ItemCheckedEventArgs e)
        {
            var domain = m_semdomRepo.GetObject((int)e.Item.Tag);

            SemanticDomainSelectionUtility.AdjustSelectedDomainList(domain, e.Item.Checked, selectedDomainsList);
        }
Example #8
0
 private void OnSelectedDomainItemChecked(object sender, ItemCheckedEventArgs e)
 {
     SemanticDomainSelectionUtility.AdjustTreeAndListView(e.Item.Tag, e.Item.Checked, domainTree, domainList);
 }