Exemplo n.º 1
0
        /// <summary>
        /// We want to be able to insert a sound/movie file for a pronunciation, even when the
        /// pronunciation doesn't yet exist.  See LT-6685.
        /// </summary>
        /// <param name="commandObject"></param>
        /// <param name="display"></param>
        /// <returns></returns>
        public override bool OnDisplayInsertMediaFile(object commandObject,
                                                      ref UIItemDisplayProperties display)
        {
            Slice slice = m_dataEntryForm.CurrentSlice;

            if (slice == null && m_dataEntryForm.Slices.Count > 0)
            {
                slice = m_dataEntryForm.FieldAt(0);
            }
            if (slice == null ||
                (m_dataEntryForm.Mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk).ListSize == 0)
            {
                // don't display the datatree menu/toolbar items when we don't have a data tree slice.
                display.Visible = false;
                display.Enabled = false;
                return(true);
            }
            display.Enabled = false;
            base.OnDisplayInsertMediaFile(commandObject, ref display);
            if (display.Enabled)
            {
                return(true);
            }
            if (!(slice.Object is ILexEntry) && !(slice.ContainingDataTree.Root is ILexEntry))
            {
                return(false);
            }
            FDO.ILexEntry entry = slice.Object as ILexEntry;
            if (entry == null)
            {
                entry = slice.ContainingDataTree.Root as ILexEntry;
            }
            display.Visible = entry != null;
            display.Enabled = entry != null;
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// decide whether to display this tree insert Menu Item
        /// </summary>
        /// <param name="commandObject"></param>
        /// <param name="display"></param>
        /// <returns></returns>
        public override bool OnDisplayDataTreeInsert(object commandObject, ref UIItemDisplayProperties display)
        {
            Slice slice = m_dataEntryForm.CurrentSlice;

            if (slice == null && m_dataEntryForm.Slices.Count > 0)
            {
                slice = m_dataEntryForm.FieldAt(0);
            }
            if (slice == null || slice.IsDisposed ||
                (m_dataEntryForm.Mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk).ListSize == 0)
            {
                // don't display the datatree menu/toolbar items when we don't have a data tree slice.
                // (If the slice is disposed, we're in a weird state, possibly trying to update the toolbar during OnIdle though we haven't
                // in fact finished reconstructing the tree. Leave things disabled, and hope they will get enabled
                // on the next call when things have stabilized.)
                display.Visible = false;
                display.Enabled = false;
                return(true);
            }

            base.OnDisplayDataTreeInsert(commandObject, ref display);

            if (!(slice.Object is ILexEntry) && !(slice.ContainingDataTree.Root is ILexEntry))
            {
                return(false);
            }
            FDO.ILexEntry entry = slice.Object as ILexEntry;
            if (entry == null)
            {
                entry = slice.ContainingDataTree.Root as ILexEntry;
            }
            if (entry == null || !entry.IsValidObject)
            {
                // At one point this could happen during delete object. Not sure it will be possible when I
                // finish debugging that, but the defensive programming doesn't hurt.
                display.Enabled = false;
                display.Visible = false;
                return(true);
            }
            XCore.Command command = (XCore.Command)commandObject;

            if (command.Id.EndsWith("AffixProcess"))
            {
                var  mmt    = entry.PrimaryMorphType;
                bool enable = mmt != null && mmt.IsAffixType;
                display.Enabled = enable;
                display.Visible = enable;
                return(true);
            }

            //if there aren't any alternate forms, go ahead and let the user choose either kind
            if (entry.AlternateFormsOS.Count == 0)
            {
                return(true);
            }

            if (command.Id.EndsWith("AffixAllomorph"))
            {
                if (!(entry.AlternateFormsOS[0] is IMoAffixAllomorph))
                {
                    display.Visible = false;
                }
                return(true);
            }

            if (command.Id.EndsWith("StemAllomorph"))
            {
                if (!(entry.AlternateFormsOS[0] is IMoStemAllomorph))
                {
                    display.Visible = false;
                }
                return(true);
            }

            return(true);           //we handled this, no need to ask anyone else.
        }