Ejemplo n.º 1
0
 /// <summary>
 /// Pass it on...
 /// </summary>
 public override void OnAboutToEdit()
 {
     if (m_decoratedEditingHelper != null)
     {
         m_decoratedEditingHelper.OnAboutToEdit();
     }
     else
     {
         base.OnAboutToEdit();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Create one.
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="sda"></param>
        /// <param name="site"></param>
        /// <param name="updateDescription"></param>
        /// <param name="fTurnOnMonitor">if true, start monitoring. if false, suspend/disable monitoring.</param>
        /// <param name="fSuppressRecordingPriorSelection">True for operations (currently only ReplaceAll)
        /// where we do not want to record the prior selection. This prevents calling editinghelper.OnAboutToEdit,
        /// which therefore doesn't save info about the current selection. The current actual effect
        /// is to suppress the work of the AnnotationAdjuster for the selected paragraphs.</param>
        public DataUpdateMonitor(Control owner, ISilDataAccess sda, IVwRootSite site,
                                 string updateDescription, bool fTurnOnMonitor, bool fSuppressRecordingPriorSelection)
        {
            // DataUpdateMonitor may be nested, so make sure we're not already monitoring the site.
            m_fTurnOnMonitor = fTurnOnMonitor && (site == null || !s_sitesMonitoring.Contains(site));
            if (!m_fTurnOnMonitor)
            {
                return;
            }
            // register this site as being monitored.
            if (site != null)
            {
                s_sitesMonitoring.Add(site);
            }
            Debug.Assert(sda != null);
            if (s_UpdateSemaphores.ContainsKey(sda))
            {
                UpdateSemaphore semaphore = s_UpdateSemaphores[sda];
                if (semaphore.fDataUpdateInProgress)
                {
                    throw new Exception("Concurrent access on Database detected");
                }
                // Set ((static semaphore) members) for this data update
                semaphore.fDataUpdateInProgress = true;
                semaphore.sDescr = updateDescription;
            }
            else
            {
                s_UpdateSemaphores[sda] = new UpdateSemaphore(true, updateDescription);
            }
            m_Owner    = owner;
            m_sda      = sda;
            m_rootSite = site;
            if (m_rootSite != null)
            {
                m_editingHelper = ((IRootSite)m_rootSite).EditingHelper;
            }
            // store original selection info.
            // Note, some of its internals are computed from the actual selection
            // which can get changed during the life of DataUpdateMonitor.
            // But its properties and Hvo(fEndPoint) should remain the same.
            if (m_editingHelper != null && !fSuppressRecordingPriorSelection)
            {
                m_tsi = new TextSelInfo(m_editingHelper.EditedRootBox);
                m_editingHelper.OnAboutToEdit();
            }

            // Set wait cursor
            if (owner != null)
            {
                m_oldCursor  = owner.Cursor;
                owner.Cursor = Cursors.WaitCursor;
            }
        }