protected void matchingEntries_SelectionChanged(object sender, SIL.FieldWorks.Common.Utils.FwObjectSelectionEventArgs e) { if (m_skipCheck) { return; } m_selEntryID = e.Hvo; HandleMatchingSelectionChanged(e); }
/// <summary> /// Handle interaction between to and from POS for a derivational affix MSA. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// If the new value is zero, then set the other one's value to zero, as well. /// If the other one's value is zero, then set it to the new value. /// In all cases, set this one's value to the new value. /// </remarks> protected void OnReferenceChanged(object sender, SIL.FieldWorks.Common.Utils.FwObjectSelectionEventArgs e) { Debug.Assert(sender is AtomicReferenceLauncher); AtomicReferenceLauncher source = (AtomicReferenceLauncher)sender; Debug.Assert(Control == source); Debug.Assert(Object is MoDerivAffMsa); AtomicReferenceLauncher otherControl = null; int idxSender = Parent.Controls.IndexOf(this); int otherFlid; bool myIsFromPOS = true; if (m_flid == (int)MoDerivAffMsa.MoDerivAffMsaTags.kflidFromPartOfSpeech) { otherFlid = (int)MoDerivAffMsa.MoDerivAffMsaTags.kflidToPartOfSpeech; } else { otherFlid = (int)MoDerivAffMsa.MoDerivAffMsaTags.kflidFromPartOfSpeech; myIsFromPOS = false; } int otherHvo = 0; Slice otherSlice = null; int idxOther; if (idxSender > 0) { idxOther = idxSender - 1; while (otherSlice == null || (otherSlice.Indent == Indent && idxOther > 0 && otherSlice.Object == Object)) { otherSlice = (Slice)Parent.Controls[idxOther--]; if (otherSlice is AtomicReferenceSlice && (otherSlice as AtomicReferenceSlice).Flid == otherFlid) { break; } } if (otherSlice != null && otherSlice is AtomicReferenceSlice) { otherHvo = GetOtherHvo(otherSlice as AtomicReferenceSlice, otherFlid, myIsFromPOS, out otherControl); } else { otherSlice = null; } } if (otherControl == null && idxSender < Parent.Controls.Count) { idxOther = idxSender + 1; while (otherSlice == null || (otherSlice.Indent == Indent && idxOther > 0 && otherSlice.Object == Object)) { otherSlice = (Slice)Parent.Controls[idxOther++]; if (otherSlice is AtomicReferenceSlice && (otherSlice as AtomicReferenceSlice).Flid == otherFlid) { break; } } if (otherSlice != null && otherSlice is AtomicReferenceSlice) { otherHvo = GetOtherHvo(otherSlice as AtomicReferenceSlice, otherFlid, myIsFromPOS, out otherControl); } else { otherSlice = null; } } MoDerivAffMsa msa = Object as MoDerivAffMsa; if (e.Hvo == 0 && otherHvo != 0) { if (otherControl == null) { otherControl.AddItem(0); // Clear the other one, as well. } else { if (m_flid == (int)MoDerivAffMsa.MoDerivAffMsaTags.kflidFromPartOfSpeech) { msa.ToPartOfSpeechRAHvo = 0; } else { msa.FromPartOfSpeechRAHvo = 0; } } } else if (otherHvo == 0 && e.Hvo > 0) { if (otherControl == null) { // The other one is not available (filtered out?), // so set it directly using the msa. if (m_flid == (int)MoDerivAffMsa.MoDerivAffMsaTags.kflidFromPartOfSpeech) { msa.ToPartOfSpeechRAHvo = e.Hvo; } else { msa.FromPartOfSpeechRAHvo = e.Hvo; } } else { otherControl.AddItem(e.Hvo); // Set the other guy to this value. } } }
/// <summary> /// invoked when our XmlDocView selection changes. /// </summary> /// <param name="sender">unused</param> /// <param name="e">the event arguments</param> public void OnSelectionChanged(object sender, FwObjectSelectionEventArgs e) { CheckDisposed(); // paranoid sanity check. Debug.Assert(e.Hvo != 0); if (e.Hvo == 0) return; Clerk.ViewChangedSelectedRecord(e); // Change it if it's actually changed. SetInfoBarText(); }
/// <summary> /// Handle interaction between POS and Slot ptoeprties for a inflectional affix MSA. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// If the new value is zero, then set the Slot prop to zero. /// If the new value is not zero, then make sure the Slot prop is valid. /// If the current slot is not legal for the new POS value, then set it to zero. /// Otherwise leave the slot value alone. /// </remarks> protected void OnReferenceChanged(object sender, SIL.FieldWorks.Common.Utils.FwObjectSelectionEventArgs e) { Debug.Assert(sender is AtomicReferenceLauncher); AtomicReferenceLauncher source = (AtomicReferenceLauncher)sender; Debug.Assert(Control == source); Debug.Assert(Object is MoInflAffMsa); int idxSender = Parent.Controls.IndexOf(this); int otherFlid = (int)MoInflAffMsa.MoInflAffMsaTags.kflidSlots; Slice otherSlice = null; int idxOther; // Try to get the Slots slice. // Check for slices before this one. if (idxSender > 0) { idxOther = idxSender - 1; while (idxOther >= 0 && (otherSlice == null || (otherSlice.Indent == Indent && idxOther > 0 && otherSlice.Object == Object))) { otherSlice = (Slice)Parent.Controls[idxOther--]; if (otherSlice is ReferenceVectorSlice && (otherSlice as ReferenceVectorSlice).Flid == otherFlid) { break; } otherSlice = null; } } // Check for following slices, if we didn't get one earlier. if (otherSlice == null && idxSender < Parent.Controls.Count) { idxOther = idxSender + 1; while (idxOther < Parent.Controls.Count && (otherSlice == null || (otherSlice.Indent == Indent && idxOther > 0 && otherSlice.Object == Object))) { otherSlice = (Slice)Parent.Controls[idxOther++]; if (otherSlice is ReferenceVectorSlice && (otherSlice as ReferenceVectorSlice).Flid == otherFlid) { break; } otherSlice = null; } } VectorReferenceLauncher otherControl = null; if (otherSlice != null) { Debug.Assert((otherSlice as ReferenceVectorSlice).Flid == otherFlid); Debug.Assert(otherSlice.Object == Object); otherControl = otherSlice.Control as VectorReferenceLauncher; Debug.Assert(otherControl != null); } MoInflAffMsa msa = Object as MoInflAffMsa; int slotHvo = 0; if (msa.SlotsRC.Count > 0) { int[] hvos = msa.SlotsRC.HvoArray; slotHvo = hvos[0]; } if (e.Hvo == 0 || slotHvo > 0) { IPartOfSpeech pos = msa.PartOfSpeechRA; List <int> slotIDs = new List <int>(); if (pos != null) { slotIDs = pos.AllAffixSlotIDs; } bool clearSlot = ((e.Hvo == 0) || (!slotIDs.Contains(slotHvo))); if (clearSlot) { if (otherControl == null) { msa.ClearAllSlots(); // The slot slice is not showing, so directly set the object's Slot property. } else { otherControl.AddItem(0); // Reset it using the other slice, so it gets refreshed. } } } }
/// <summary> /// This comes from a double click on a row in the browse view. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void m_bvMatches_SelectionMade(object sender, FwObjectSelectionEventArgs e) { m_selEntryID = e.Hvo; RaiseSelectionChanged(); Form frm = FindForm(); if (frm is BaseGoDlg && (frm as BaseGoDlg).IsOkEnabled) frm.DialogResult = DialogResult.OK; else if (frm is InsertEntryDlg) frm.DialogResult = DialogResult.Yes; }
/// <summary> /// This comes from a single click on a row in the browse view. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void m_bvMatches_SelectionChanged(object sender, FwObjectSelectionEventArgs e) { m_selEntryID = e.Hvo; (Clerk as MatchingItemsRecordClerk).SetListIndex(e.Index); // keep the list index in sync. RaiseSelectionChanged(); }
/// <summary> /// Called by a view (e.g. browseView) when, internally, it changes the currently selected record. /// </summary> public void ViewChangedSelectedRecord(FwObjectSelectionEventArgs e) { CheckDisposed(); // Don't do anything if we haven't changed our selection. int hvoCurrent = 0; if (CurrentObject != null) hvoCurrent = CurrentObject.Hvo; if (e.Index >= 0 && CurrentIndex == e.Index && hvoCurrent == e.Hvo || e.Index < 0 && hvoCurrent == e.Hvo) { return; } // In some cases (e.g. sorting LexEntries by Gloss), results in a list that // contains multiple rows referring to the same object. In that case // we want to try to JumpToRecord of the same index, since jumping to the hvo // jumps to the first instance of that object (LT-4691). if (e.Index >= 0) { ICmObject co = m_list.RootObjectAt(e.Index); // if for some reason the index doesn't match the hvo, we'll jump to the Hvo. Debug.Assert(e.Hvo == co.Hvo, "the index (" + e.Index + ") for selected object (" + e.Hvo + ") does not match the object (" + co.Hvo + " in our list at that index.)"); if (co.Hvo != e.Hvo) JumpToRecord(e.Hvo); else JumpToIndex(e.Index); } else if (e.Hvo > 0) { JumpToRecord(e.Hvo); } }
/// <summary> /// invoked when our BrowseView selection changes /// </summary> /// <param name="sender">unused</param> /// <param name="e">the event arguments</param> virtual public void OnSelectionChanged(object sender, FwObjectSelectionEventArgs e) { CheckDisposed(); if (!m_suppressRecordNavigation || ! m_suppressShowRecord) { Clerk.ViewChangedSelectedRecord(e); SetInfoBarText(); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Process mouse double click /// </summary> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ protected override void OnDoubleClick(EventArgs e) { if (!ReadOnlySelect) { base.OnDoubleClick(e); } else { FwObjectSelectionEventArgs e1 = new FwObjectSelectionEventArgs(SelectedObject, SelectedIndex); m_bv.OnDoubleClick(e1); } }