Esempio n. 1
0
        /// <summary>
        /// Called when the underlying ListView raises the NodeLabelEdited event</summary>
        /// <param name="e">Event args from the underlying ListView's NodeLabelEdited event</param>
        protected virtual void OnNodeLabelEdited(LabelEditEventArgs e)
        {
            IListView      listView      = m_listViewAdapter.ListView;
            ListViewItem   item          = m_listView.Items[e.Item];
            INamingContext namingContext = listView.As <INamingContext>();

            if (namingContext != null &&
                namingContext.CanSetName(item.Tag))
            {
                ITransactionContext transactionContext = listView.As <ITransactionContext>();
                transactionContext.DoTransaction(
                    delegate
                {
                    namingContext.SetName(item.Tag, e.Label);
                }, "Edit Label".Localize());
            }
        }
Esempio n. 2
0
        private void selectionAdapter_SelectedItemHit(object sender, DiagramHitEventArgs e)
        {
            m_itemHitRecord = e.HitRecord;
            // hit on diagram label part?
            DiagramLabel hitLabel = e.HitRecord.Part.As <DiagramLabel>();

            if (hitLabel != null)
            {
                INamingContext namingContext = AdaptedControl.ContextAs <INamingContext>();
                if (namingContext != null)
                {
                    // if label editing is enabled, mouse is over label, and item can be named, open it for edit
                    if (namingContext.CanSetName(e.HitRecord.Item))
                    {
                        m_hitLabel = hitLabel;
                        m_labelEditTimer.Interval = SystemInformation.DoubleClickTime;
                        m_labelEditTimer.Enabled  = true;
                    }
                }
            }
        }