/// <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.Controls.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 LexEntry) && !(slice.ContainingDataTree.Root is LexEntry)) { return(false); } FDO.Ling.LexEntry entry = slice.Object as LexEntry; if (entry == null) { entry = slice.ContainingDataTree.Root as LexEntry; } display.Visible = entry != null; display.Enabled = entry != null; return(true); }
/// <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.Controls.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); } base.OnDisplayDataTreeInsert(commandObject, ref display); if (!(slice.Object is LexEntry) && !(slice.ContainingDataTree.Root is LexEntry)) { return(false); } FDO.Ling.LexEntry entry = slice.Object as LexEntry; if (entry == null) { entry = slice.ContainingDataTree.Root as LexEntry; } XCore.Command command = (XCore.Command)commandObject; if (command.Id.EndsWith("AffixProcess")) { bool enable = MoMorphType.IsAffixType(entry.MorphType); 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.FirstItem is MoAffixAllomorph)) { display.Visible = false; } return(true); } if (command.Id.EndsWith("StemAllomorph")) { if (!(entry.AlternateFormsOS.FirstItem is MoStemAllomorph)) { display.Visible = false; } return(true); } return(true); //we handled this, no need to ask anyone else. }