Пример #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Deletes a footnote
        /// </summary>
        /// <param name="args"></param>
        /// <returns><c>true</c> if we handle this</returns>
        /// ------------------------------------------------------------------------------------
        protected bool OnDeleteFootnote(object args)
        {
            if (DataUpdateMonitor.IsUpdateInProgress() || !ValidFootnoteSelection)
            {
                return(true);                //discard this event
            }
            string undo;
            string redo;

            TeResourceHelper.MakeUndoRedoLabels("kstidUndoDelFootnote", out undo, out redo);
            using (UndoTaskHelper undoTaskHelper = new UndoTaskHelper(this, undo, redo))
                using (new DataUpdateMonitor(this, "DeleteFootnote"))
                {
                    // Put code to do work in separate method for testing
                    DeleteFootnoteAux();
                    undoTaskHelper.RollBack = false;
                }

            // If there are no more footnotes, then give focus back to the main draft view
            if (RootBox.Height <= 0 && DraftView != null)
            {
                DraftView.Focus();
            }

            return(true);
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Waits for other app.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void WaitForOtherApp()
        {
            Text = FwUtils.ksSuiteName;
            switch (m_whatToWaitFor)
            {
            case WaitFor.WindowToActivate:
                m_lblMessage.Text = string.Format(Properties.Resources.kstidThisApplicationIsBusy,
                                                  m_appToStart.ApplicationName, m_appToStart.Cache.ProjectId.Name);
                break;

            case WaitFor.OtherBusyApp:
                m_lblMessage.Text = string.Format(Properties.Resources.kstidOtherApplicationBusy,
                                                  m_appToStart.ApplicationName, m_appToStart.Cache.ProjectId.Name, m_appToWaitFor.ApplicationName);
                break;

            case WaitFor.ModalDialogsToClose:
                m_lblMessage.Text = string.Format(Properties.Resources.kstidOtherApplicationHasDialog,
                                                  m_appToStart.ApplicationName, m_appToStart.Cache.ProjectId.Name, m_appToWaitFor.ApplicationName);
                break;
            }

            Show();
            Activate();

            bool readyToRoll = false;

            do
            {
                Application.DoEvents();

                Thread.Sleep(333);

                if (m_fCancelPressed)
                {
                    break;
                }
                switch (m_whatToWaitFor)
                {
                case WaitFor.WindowToActivate:
                    readyToRoll = (m_appToStart.MainWindows.Count > 0);
                    break;

                case WaitFor.OtherBusyApp:
                    readyToRoll = !DataUpdateMonitor.IsUpdateInProgress();
                    break;

                case WaitFor.ModalDialogsToClose:
                    readyToRoll = !m_appToWaitFor.IsModalDialogOpen;
                    break;
                }
            }while (!readyToRoll);

            Close();

            if (readyToRoll)
            {
                FieldWorks.KickOffAppFromOtherProcess(m_args);
            }
        }
Пример #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Deletes a footnote
        /// </summary>
        /// <param name="args"></param>
        /// <returns><c>true</c> if we handle this</returns>
        /// ------------------------------------------------------------------------------------
        protected bool OnDeleteFootnote(object args)
        {
            if (DataUpdateMonitor.IsUpdateInProgress(DataAccess))
            {
                return(true);                //discard this event
            }
            if (!ValidFootnoteSelection)
            {
                return(true);
            }

            string undo;
            string redo;

            TeResourceHelper.MakeUndoRedoLabels("kstidUndoDelFootnote", out undo, out redo);
            using (new UndoTaskHelper(this, undo, redo, false))
                using (new DataUpdateMonitor(this, RootBox.DataAccess, this, "DeleteFootnote"))
                {
                    SelectionHelper helper  = SelectionHelper.Create(this);
                    int             fnLevel = helper.GetLevelForTag((int)ScrBook.ScrBookTags.kflidFootnotes);

                    if (helper.Selection.IsRange)
                    {
                        DeleteFootnoteRange(helper);
                    }
                    else
                    {
                        // There's no range selection, so delete only one footnote
                        ScrFootnote footnote = new ScrFootnote(m_fdoCache, helper.LevelInfo[fnLevel].hvo);
                        ScrFootnote.DeleteFootnoteAndMarker(footnote);
                    }

                    if (RootBox.Height <= 0)
                    {
                        DraftView.Focus();
                    }
                    else
                    {
                        int     iBook     = helper.LevelInfo[fnLevel + 1].ihvo;
                        ScrBook book      = m_bookFilter.GetBook(iBook);
                        int     iFootnote = helper.LevelInfo[fnLevel].ihvo;

                        // If the last footnote in the book was deleted find a footnote to move to
                        if (iFootnote >= book.FootnotesOS.Count)
                        {
                            FindNearestFootnote(ref iBook, ref iFootnote);
                        }

                        FootnoteEditingHelper.ScrollToFootnote(iBook, iFootnote, 0);
                    }
                }

            return(true);
        }