Exemplo n.º 1
0
 public void InitTest()
 {
     m_dummyItemProps                     = new TMItemProperties();
     m_mainWnd                            = new InvisibleTeMainWnd();
     m_dummyItemProps.ParentForm          = m_mainWnd;
     m_mainWnd.m_fSimulateNoEditingHelper = false;
 }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnMainViewOpened(object args)
        {
            try
            {
                if (args is PaMainWnd)
                {
                    m_adapter = PaApp.TMAdapter;

                    m_adapter.AddCommandItem("CmdBackupProject", "BackupProject",
                                             Properties.Resources.kstidBackupMenuText, null, null, null, null,
                                             null, Keys.None, null, Properties.Resources.kimidBackup);

                    m_adapter.AddCommandItem("CmdRestoreProject", "RestoreProject",
                                             Properties.Resources.kstidRestoreMenuText, null, null, null, null,
                                             null, Keys.None, null, null);

                    TMItemProperties itemProps = new TMItemProperties();
                    itemProps.CommandId = "CmdBackupProject";
                    itemProps.Name      = "mnuBackupProject";
                    itemProps.Text      = null;
                    m_adapter.AddMenuItem(itemProps, "mnuFile", "mnuPlayback");

                    itemProps           = new TMItemProperties();
                    itemProps.CommandId = "CmdRestoreProject";
                    itemProps.Name      = "mnuRestoreProject";
                    itemProps.Text      = null;
                    m_adapter.AddMenuItem(itemProps, "mnuFile", "mnuPlayback");

                    AddOnHelper.AddSeparatorBeforeMenuItem("mnuPlayback");
                }
            }
            catch { }

            return(false);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool OnUpdatePasteSavedPattern(object args)
        {
            if (!App.IsFormActive(FindForm()) || m_btnPaste == null)
            {
                return(false);
            }

            bool enable = (SelectedNode != null && m_patternClipboard != null);

            if (m_btnPaste.Enabled != enable)
            {
                m_btnPaste.Enabled = enable;
            }

            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps != null && itemProps.Enabled != enable)
            {
                itemProps.Visible = true;
                itemProps.Enabled = enable;
                itemProps.Update  = true;
            }

            return(true);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool OnUpdateCopySavedPattern(object args)
        {
            if (!App.IsFormActive(FindForm()) || m_btnCopy == null)
            {
                return(false);
            }

            bool enable = (CurrentQuery != null);

            if (m_btnCopy.Enabled != enable)
            {
                m_btnCopy.Enabled = enable;
            }

            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps != null && itemProps.Enabled != enable)
            {
                itemProps.Visible = true;
                itemProps.Enabled = enable;
                itemProps.Update  = true;
            }

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_mainWnd != null)
                {
                    m_mainWnd.Dispose();
                }
                if (m_dummyItemProps != null)
                {
                    m_dummyItemProps.ParentForm = null;
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_mainWnd        = null;
            m_dummyItemProps = null;             // TMItemProperties should implement IDisposable.

            base.Dispose(disposing);
        }
Exemplo n.º 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Disables the toolbar item
        /// </summary>
        /// <param name="args"></param>
        /// ------------------------------------------------------------------------------------
        private void DisableTMItem(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps != null)
            {
                itemProps.Enabled = false;
                itemProps.Update  = true;
            }
        }
Exemplo n.º 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Enable Edit/Select All only if we have at least one note.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        protected bool OnUpdateEditSelectAll(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps != null && itemProps.ParentForm == Parent)
            {
                itemProps.Enabled = (DisplayedNotesCount > 0);
                itemProps.Update  = true;
                return(true);
            }
            return(false);
        }
Exemplo n.º 8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handle the click on the book in the book list.
        /// </summary>
        /// <param name="args"></param>
        /// <returns><c>true</c> if we handle this</returns>
        /// ------------------------------------------------------------------------------------
        protected bool OnInsertBook(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps != null && itemProps.Tag.GetType() == typeof(int))
            {
                m_bookChosen = (int)itemProps.Tag;
                m_Option     = Option.Book;
                Close();
            }

            return(true);
        }
Exemplo n.º 9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Only allow deleting of a footnote if we aren't in a BT footnote view and we have
        /// a valid selection.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        protected bool OnUpdateDeleteFootnote(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps == null || !Focused)
            {
                return(false);
            }

            itemProps.Enabled = !IsBackTranslation && ValidFootnoteSelection;
            itemProps.Update  = true;
            return(true);
        }
Exemplo n.º 10
0
        public override void FixtureSetup()
        {
            CheckDisposed();
            base.FixtureSetup();

            m_dummyItemProps = new TMItemProperties();

            Debug.Assert(m_mainWnd == null, "m_mainWnd is not null.");
            //if (m_mainWnd != null)
            //	m_mainWnd.Dispose();
            m_mainWnd = new InvisibleTeMainWnd();
            m_dummyItemProps.ParentForm = m_mainWnd;
        }
Exemplo n.º 11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnUpdateCAESort(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps != null)
            {
                itemProps.Update  = true;
                itemProps.Visible = true;
                itemProps.Enabled = (m_view.ResultViewManger != null &&
                                     m_view.ResultViewManger.CurrentViewsGrid != null);
            }

            return(true);
        }
Exemplo n.º 12
0
        /// ------------------------------------------------------------------------------------
        protected bool OnUpdateVerifyPattern(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps == null || !OwningView.ActiveView)
            {
                return(false);
            }

            itemProps.Visible = true;
            itemProps.Enabled = !IsPatternEmpty;
            itemProps.Update  = true;
            return(true);
        }
Exemplo n.º 13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Called when to enable or disable the enable receive sync message button.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public bool OnUpdateEnableReceiveSyncMessage(object args)
        {
            CheckDisposed();

            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps != null && m_draftView.EditingHelper != null)
            {
                itemProps.Enabled = true;
                itemProps.Checked = EditingHelper.ReceiveSyncMessages;
                itemProps.Update  = true;
                return(true);
            }

            return(false);
        }
Exemplo n.º 14
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnMainViewOpened(object args)
        {
            try
            {
                if (args is PaMainWnd)
                {
                    m_mainWnd = args as PaMainWnd;
                    m_adapter = PaApp.TMAdapter;

                    m_adapter.AddCommandItem("CmdSendFeedback", "SendFeedback",
                                             Properties.Resources.kstidFeedbackMenuText, null, null, null, null,
                                             null, Keys.None, null, Properties.Resources.kimidSendFeedback);

                    m_feedbackItemProps            = new TMItemProperties();
                    m_feedbackItemProps.BeginGroup = true;
                    m_feedbackItemProps.CommandId  = "CmdSendFeedback";
                    m_feedbackItemProps.Name       = "mnuSendFeedback";
                    m_feedbackItemProps.Text       = null;
                    m_adapter.AddMenuItem(m_feedbackItemProps, "mnuHelp", "mnuHelpAbout");

                    // Get the number of times PA has been launched.
                    int launchCount = PaApp.SettingsHandler.GetIntSettingsValue(
                        "feedbackaddon", "launchcount", 0);

                    // Increase the launch count by one and save it.
                    PaApp.SettingsHandler.SaveSettingsValue(
                        "feedbackaddon", "launchcount", ++launchCount);

                    // If we've reached the tenth time PA has been run, then show
                    // the user the dialog requesting feedback.
                    if (launchCount == 10)
                    {
                        using (RequestDlg dlg = new RequestDlg())
                        {
                            if (dlg.ShowDialog(m_mainWnd) == DialogResult.Yes)
                            {
                                OnSendFeedback(null);
                            }
                        }
                    }
                }
            }
            catch { }

            return(false);
        }
Exemplo n.º 15
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnUpdateResetAutoFilledChart(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps == null)
            {
                return(false);
            }

            if (itemProps.Enabled != m_chartHasBeenAutoFilled)
            {
                itemProps.Enabled = m_chartHasBeenAutoFilled;
                itemProps.Visible = true;
                itemProps.Update  = true;
            }

            return(true);
        }
Exemplo n.º 16
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handle the logic for all methods OnUpdateEditFind(Next/Previous)
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private bool HandleFindItemUpdate(TMItemProperties itemProps, bool enableAllow)
        {
            if (!_activeView || itemProps == null)
            {
                return(false);
            }

            bool enable = false;

            if (itemProps.Enabled != enable)
            {
                itemProps.Enabled = enable;
                itemProps.Visible = true;
                itemProps.Update  = true;
            }

            return(true);
        }
Exemplo n.º 17
0
        /// ------------------------------------------------------------------------------------
        protected bool OnUpdateSavePattern(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (!OwningView.ActiveView || itemProps == null)
            {
                return(false);
            }

            if (itemProps.Enabled != IsPatternFull)
            {
                itemProps.Visible = true;
                itemProps.Enabled = IsPatternFull;
                itemProps.Update  = true;
            }

            return(true);
        }
Exemplo n.º 18
0
        /// ------------------------------------------------------------------------------------
        protected bool OnUpdateBeginSearch(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (!OwningView.ActiveView || itemProps == null ||
                itemProps.Name.StartsWith("cmnu", StringComparison.Ordinal))
            {
                return(false);
            }

            if (itemProps.Enabled != IsPatternFull)
            {
                itemProps.Visible = true;
                itemProps.Enabled = IsPatternFull;
                itemProps.Update  = true;
            }

            return(true);
        }
Exemplo n.º 19
0
        ///// ------------------------------------------------------------------------------------
        ///// <summary>
        /////
        ///// </summary>
        ///// ------------------------------------------------------------------------------------
        //protected bool OnUpdateShowCIEResults(object args)
        //{
        //    TMItemProperties itemProps = args as TMItemProperties;
        //    if (!m_activeView || itemProps == null)
        //        return false;

        //    if (itemProps.Enabled || itemProps.Checked)
        //    {
        //        itemProps.Visible = true;
        //        itemProps.Enabled = false;
        //        itemProps.Checked = false;
        //        itemProps.Update = true;
        //    }

        //    return true;
        //}
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handle the logic for all methods OnUpdateEditFind(Next/Previous)
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private bool HandleFindItemUpdate(TMItemProperties itemProps, bool enableAllow)
        {
            if (!m_activeView || itemProps == null)
            {
                return(false);
            }

            bool enable = (enableAllow && WordListGrid != null &&
                           WordListGrid.Cache != null && WordListGrid.RowCount > 0);

            if (itemProps.Enabled != enable)
            {
                itemProps.Enabled = enable;
                itemProps.Visible = true;
                itemProps.Update  = true;
            }

            return(true);
        }
Exemplo n.º 20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SetupAutoFillMarkerMenus()
        {
            try
            {
                string menuText = string.Format("{0} Auto. Fill Consonant Marker", kAutoFillConMarker);
                m_view.TMAdapter.AddCommandItem("CmdInsertAutoFillConMarker", "InsertAutoFillConMarker",
                                                menuText, null, null, null, null, null, Keys.None, null, null);

                TMItemProperties itemProps = new TMItemProperties();
                itemProps.BeginGroup = true;
                itemProps.CommandId  = "CmdInsertAutoFillConMarker";
                itemProps.Name       = "mnuInsertAutoFillConMarker";
                itemProps.Text       = null;
                m_view.TMAdapter.AddMenuItem(itemProps, "tbbInsertIntoChart", null);

                itemProps            = new TMItemProperties();
                itemProps.BeginGroup = true;
                itemProps.CommandId  = "CmdInsertAutoFillConMarker";
                itemProps.Name       = "cmnuInsertAutoFillConMarker";
                itemProps.Text       = null;
                m_view.TMAdapter.AddMenuItem(itemProps, "cmnuInsertIntoChart", null);

                menuText = string.Format("{0} Auto. Fill Vowel Marker", kAutoFillVowMarker);
                m_view.TMAdapter.AddCommandItem("CmdInsertAutoFillVowMarker", "InsertAutoFillVowMarker",
                                                menuText, null, null, null, null, null, Keys.None, null, null);

                itemProps            = new TMItemProperties();
                itemProps.BeginGroup = false;
                itemProps.CommandId  = "CmdInsertAutoFillVowMarker";
                itemProps.Name       = "mnuInsertAutoFillVowMarker";
                itemProps.Text       = null;
                m_view.TMAdapter.AddMenuItem(itemProps, "tbbInsertIntoChart", null);

                itemProps            = new TMItemProperties();
                itemProps.BeginGroup = false;
                itemProps.CommandId  = "CmdInsertAutoFillVowMarker";
                itemProps.Name       = "cmnuInsertAutoFillVowMarker";
                itemProps.Text       = null;
                m_view.TMAdapter.AddMenuItem(itemProps, "cmnuInsertIntoChart", null);
            }
            catch { }
        }
Exemplo n.º 21
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnUpdateBackupProject(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps == null)
            {
                return(false);
            }

            bool enable = (PaApp.Project != null);

            if (itemProps.Enabled != enable)
            {
                itemProps.Update  = true;
                itemProps.Visible = true;
                itemProps.Enabled = enable;
            }

            return(true);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SetupFilterMenu()
        {
            try
            {
                if (m_adapter == null)
                {
                    return;
                }

                m_adapter.AddCommandItem("CmdFilters", "DisplayFilterDlg",
                                         Properties.Resources.kstidFiltersMenuText, null, null, null, null,
                                         null, Keys.None, null, Properties.Resources.kimidDefineFilters);

                TMItemProperties itemProps = new TMItemProperties();
                itemProps.CommandId = "CmdFilters";
                itemProps.Name      = "mnuFilters";
                itemProps.Text      = null;
                m_adapter.AddMenuItem(itemProps, "mnuFile", "mnuUndefinedCharacters");
            }
            catch { }
        }
Exemplo n.º 23
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnMainViewOpened(object args)
        {
            try
            {
                if (args is PaMainWnd)
                {
                    PaApp.TMAdapter.AddCommandItem("CmdAddOnInfo", "AddOnInformation",
                                                   Properties.Resources.kstidMenuText, null, null, null, null,
                                                   null, Keys.None, null, null);

                    TMItemProperties itemProps = new TMItemProperties();
                    itemProps.CommandId = "CmdAddOnInfo";
                    itemProps.Name      = "mnuAddOnInfo";
                    itemProps.Text      = null;
                    PaApp.TMAdapter.AddMenuItem(itemProps, "mnuTools", "mnuOptions");
                }
            }
            catch { }

            return(false);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Don't allow this menu item to be chosen when there's only one tab.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnUpdateMoveToNewStackedTabGroup(object args)
        {
            // If we're not the tab group that owns the tab that was
            // clicked on, then we don't want to handle the message.
            if (!Tabs.Contains(ContextMenuTab))
            {
                return(false);
            }

            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps == null)
            {
                return(false);
            }

            itemProps.Visible = true;
            itemProps.Enabled = (Tabs.Count > 1);
            itemProps.Update  = true;
            return(true);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool OnRemovePattern(object args)
        {
            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps == null || !itemProps.Name.EndsWith("-FromSavedList", StringComparison.Ordinal) ||
                !App.IsFormActive(FindForm()))
            {
                return(false);
            }

            if (CurrentQuery == null)
            {
                DeleteCategory(SelectedNode);
            }
            else
            {
                DeletePattern(SelectedNode, false);
            }

            UpdateButtons();
            return(true);
        }
Exemplo n.º 26
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private bool HandleAutoFillMenuItemUpdate(TMItemProperties itemProps1)
        {
            if (itemProps1 != null)
            {
                itemProps1.Visible = true;
                itemProps1.Update  = true;

                if (itemProps1.Name.StartsWith("mnuInsertAutoFill"))
                {
                    itemProps1.Enabled = true;
                }
                else
                {
                    TMItemProperties itemProps2 =
                        m_view.TMAdapter.GetItemProperties("cmnuInsertORGroup");

                    itemProps1.Enabled = (itemProps2 != null && itemProps2.Enabled);
                }
            }

            return(true);
        }