Esempio n. 1
0
        private void Delete(string commandName)
        {
            OnDeleting(EventArgs.Empty);

            IInstancingContext instancingContext = m_contextRegistry.GetActiveContext <IInstancingContext>();

            if (instancingContext != null &&
                instancingContext.CanDelete())
            {
                ITransactionContext transactionContext = instancingContext.As <ITransactionContext>();
                transactionContext.DoTransaction(
                    delegate
                {
                    instancingContext.Delete();

                    ISelectionContext selectionContext = instancingContext.As <ISelectionContext>();
                    if (selectionContext != null)
                    {
                        selectionContext.Clear();
                    }
                }, commandName);
            }

            OnDeleted(EventArgs.Empty);
        }
        /// <summary>
        /// Deselects all objects in the given context</summary>
        /// <param name="selectionContext">Context holding selection</param>
        /// <returns>True iff all objects were deselected</returns>
        public bool DeselectAll(ISelectionContext selectionContext)
        {
            if (selectionContext != null)
            {
                selectionContext.Clear();
                return true;
            }

            return false;
        }
Esempio n. 3
0
        /// <summary>
        /// Deselects all objects in the given context</summary>
        /// <param name="selectionContext">Context holding selection</param>
        /// <returns>True iff all objects were deselected</returns>
        public bool DeselectAll(ISelectionContext selectionContext)
        {
            if (selectionContext != null)
            {
                selectionContext.Clear();
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
        private void SelectAllInstances(DomNodeType nodeType)
        {
            ISelectionContext sc = GetSelectionContext();

            if (sc != null)
            {
                List <object> nodes = new List <object>();
                foreach (DomNode node in Util.FindAll(nodeType, true))
                {
                    nodes.Add(Util.AdaptDomPath(node));
                }
                if (nodes.Count > 0)
                {
                    sc.SetRange(nodes);
                }
                else
                {
                    sc.Clear();
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Delete selected objects</summary>
        private bool Delete()
        {
            var instancingContext = m_layerLister.TreeView.As <IInstancingContext>();

            if (instancingContext.CanDelete())
            {
                var transactionContext = m_layerLister.TreeView.As <ITransactionContext>();
                transactionContext.DoTransaction(
                    delegate
                {
                    instancingContext.Delete();
                    ISelectionContext selectionContext = m_layerLister.TreeView.As <ISelectionContext>();
                    if (selectionContext != null)
                    {
                        selectionContext.Clear();
                    }
                },
                    m_deleteLayer.Text);
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
        private void SelectAllInstances()
        {
            DomNodeType domNodeType = SelectedNodeType;

            if (domNodeType == null)
            {
                return;
            }

            ISelectionContext selectionContext = SelectionContext;

            if (selectionContext == null)
            {
                return;
            }

            DomNode rootNode = GetRootNode(selectionContext);

            if (rootNode == null)
            {
                return;
            }


            selectionContext.Clear();
            List <Path <object> > newSelection = new List <Path <object> >();

            foreach (DomNode domNode in GetNodesOfType(rootNode, domNodeType))
            {
                newSelection.Add(Util.AdaptDomPath(domNode));
            }
            if (newSelection.Count > 0)
            {
                selectionContext.SetRange(newSelection);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Performs custom actions on MouseDown events</summary>
        /// <param name="e">Mouse event args</param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            // If there is an ISelectionContext implemented for the type of our search results,
            // and the mouse click was on one of the search result list items,
            // then have that ISelectionContext select the instance associated with the clicked search result.
            // Additionally, if the type of our search results implements an ISubSelectionContext, have
            // that ISubSelectionContext select the instance associated with the subitem of the clicked search results
            //
            // (For instance, when each search result ListItem is a DomNode, and contains a SubItem for every DomNode
            // property that matched, this would allow both setting ISelectionContext to the DomNode associated with
            // the clicked ListItem, and setting ISubSelectionContext to the property associated with the clicked SubItem
            // in the row)
            if (m_queryResultContext != null)
            {
                // Is the query result type associated with m_queryResultContext have a way of specifying a selection was made?
                ISelectionContext selectionContext = m_queryResultContext.As <ISelectionContext>();
                if (selectionContext != null)
                {
                    // We can specify a selection was made.  Now check if a selection was actually made.
                    ListViewHitTestInfo hitTestInfo = HitTest(e.Location);
                    if (hitTestInfo != null && hitTestInfo.Item != null)
                    {
                        // A selection was made in the search results.  Specify this selection through ISelectionContext.
                        object tag = hitTestInfo.Item.Tag;
                        selectionContext.Set(tag);

                        // Does the query result type also have a way to specify a sub-selection?
                        ISubSelectionContext subSelectionContext = m_queryResultContext.As <ISubSelectionContext>();
                        if (subSelectionContext != null)
                        {
                            object selectedTag = null;
                            if (hitTestInfo.SubItem != null && hitTestInfo.SubItem.Tag != null)
                            {
                                selectedTag = hitTestInfo.SubItem.Tag; // Specific sub-item clicked, use it
                            }
                            else
                            {
                                // No sub-item clicked, select first sub-item if the selected item has any
                                foreach (var obj in hitTestInfo.Item.SubItems)
                                {
                                    var subItem = obj as ListViewItem.ListViewSubItem;
                                    if (subItem != null && subItem.Tag != null)
                                    {
                                        selectedTag = subItem.Tag;
                                        break;
                                    }
                                }
                            }

                            if (selectedTag != null)
                            {
                                subSelectionContext.Set(selectedTag);
                            }
                            else
                            {
                                subSelectionContext.Clear();
                            }
                        }
                    }
                    else // no selection
                    {
                        selectionContext.Clear();
                    }
                }
            }
        }