/// ------------------------------------------------------------------------------------ /// <summary> /// Handle Mouse up /// </summary> /// ------------------------------------------------------------------------------------ protected override void OnMouseUp(MouseEventArgs e) { if (e.Button != MouseButtons.Right) { base.OnMouseUp(e); return; } NotesMainWnd notesMainWnd = TheMainWnd as NotesMainWnd; if (notesMainWnd == null || notesMainWnd.TMAdapter == null) { return; } Rectangle rcSrcRoot; Rectangle rcDstRoot; GetCoordRects(out rcSrcRoot, out rcDstRoot); Point pt = new Point(e.X, e.Y); IVwSelection sel = m_rootb.MakeSelAt(pt.X, pt.Y, rcSrcRoot, rcDstRoot, false); int noteHvo = 0; if (sel != null) { SelectionHelper selHelper = SelectionHelper.Create(sel, this); SelLevInfo annInfo = selHelper.GetLevelInfoForTag(m_currentNotesTag); noteHvo = annInfo.hvo; } pt = PointToScreen(new Point(e.X, e.Y)); notesMainWnd.TMAdapter.PopupMenu("cmnuNotesDataEntryView", pt.X, pt.Y); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Makes sure a closing notes window gets removed from the table of notes windows. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private static void HandleNotesWindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { if (sender is NotesMainWnd) { NotesMainWnd gonner = sender as NotesMainWnd; s_notesWindoes.Remove(gonner.Cache); gonner.Closing -= new System.ComponentModel.CancelEventHandler(HandleNotesWindowClosing); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds a notes window for a specified cache to the list of notes windows stored for /// this application. /// </summary> /// <param name="cache"></param> /// <param name="wnd"></param> /// ------------------------------------------------------------------------------------ public static void AddNotesWndForCache(FdoCache cache, NotesMainWnd wnd) { if (s_notesWindoes.ContainsKey(cache)) { NotesMainWnd oldValue = s_notesWindoes[cache]; oldValue.Close(); } s_notesWindoes[cache] = wnd; wnd.Closing += new System.ComponentModel.CancelEventHandler(HandleNotesWindowClosing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Removes the specified IFwMainWnd from the list of windows. /// </summary> /// <param name="fwMainWindow">The IFwMainWnd to remove</param> /// ------------------------------------------------------------------------------------ public override void RemoveWindow(IFwMainWnd fwMainWindow) { base.RemoveWindow(fwMainWindow); Debug.Assert(!IsDisposed, "Shuting down the app should have happened asynchronously after we get called"); if (MainWindows.Count == 1 && MainWindows[0] is NotesMainWnd) { NotesWindow = null; // Notes window is the only window left } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Apply the filter the user clicked in the side bar or in the menu. /// </summary> /// <param name="sender">The side-bar button the user clicked</param> /// ------------------------------------------------------------------------------------ public virtual void OnChangeFilter(object sender) { CheckDisposed(); ICmFilter userFilter = null; if (sender is SBTabItemProperties) // from sidebar { userFilter = (ICmFilter)((SBTabItemProperties)sender).Tag; } else if (sender is TMItemProperties) // from menu { userFilter = (ICmFilter)((TMItemProperties)sender).Tag; } if (userFilter != null && !GetFilterValuesFromUser(userFilter)) { return; } NotesViewFilter annotationFilter = new NotesViewFilter(Cache, userFilter); IFilter prevFilter = ((FilteredDomainDataByFlidDecorator)m_rootb.DataAccess).Filter; try { annotationFilter.InitCriteria(); ((FilteredDomainDataByFlidDecorator)m_rootb.DataAccess).Filter = annotationFilter; } catch { // User must have cancelled the filter, or something horrible happened. // Just revert back to the previous state. NotesMainWnd notesMainWnd = TheMainWnd as NotesMainWnd; Debug.Assert(notesMainWnd != null); notesMainWnd.SelectFilterButton(prevFilter); return; } // Set up the view constructor with the filtered sequence handler corresponding to the // notes filter chosen by the user. RefreshDisplay(); if (FilterChanged != null) { FilterChanged(this, userFilter); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle Mouse up /// </summary> /// ------------------------------------------------------------------------------------ protected override void OnMouseUp(MouseEventArgs e) { if (e.Button != MouseButtons.Right) { base.OnMouseUp(e); return; } NotesMainWnd notesMainWnd = TheMainWnd as NotesMainWnd; if (notesMainWnd == null || notesMainWnd.TMAdapter == null) { return; } Point pt = PointToScreen(new Point(e.X, e.Y)); notesMainWnd.TMAdapter.PopupMenu("cmnuNotesDataEntryView", pt.X, pt.Y); }
/// ------------------------------------------------------------------------------------ /// <summary> /// We override this method to make a selection in all of the views that are in a /// snynced group. This fixes problems where the user changes the selection in one of /// the slaves, but the master is not updated. Thus the view is not scrolled as the /// groups scroll position only scrolls the master's selection into view. (TE-3380) /// </summary> /// <param name="prootb"></param> /// <param name="vwselNew"></param> /// ------------------------------------------------------------------------------------ protected override void HandleSelectionChange(IVwRootBox prootb, IVwSelection vwselNew) { CheckDisposed(); base.HandleSelectionChange(prootb, vwselNew); if (m_ignoreSelChanged || EditingHelper.CurrentSelection == null) { return; } SelLevInfo noteInfo = EditingHelper.CurrentSelection.GetLevelInfoForTag(kCurrentNotesTag); if (m_prevNote != null && noteInfo.hvo == m_prevNote.Hvo) { return; } // Set text of caption to indicate which annotation is selected IScrScriptureNote ann = Cache.ServiceLocator.GetInstance <IScrScriptureNoteRepository>().GetObject(noteInfo.hvo); // Remove highlighting on previously selected annotation, and add highlighting to selected annotation. UpdateNoteHighlight(ann); m_notesMainWnd.InformationBarText = BaseInfoBarCaption + " - " + GetRefAsString(ann) + " " + GetQuotedText(ann.QuoteOA, 30); m_prevNote = ann; if (!m_fSendSyncScrollMsg) { return; } NotesMainWnd notesMainWnd = TheMainWnd as NotesMainWnd; if (notesMainWnd != null && notesMainWnd.SyncHandler != null) { Trace.WriteLine("Calling SyncToAnnotation from NotesDataEntryView: " + ann.CitedText); notesMainWnd.SyncHandler.SyncToAnnotation(this, ann, m_scr); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Makes sure a closing notes window gets removed from the table of notes windows. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void HandleNotesWindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { Debug.Assert(sender != null || sender == m_notesWindow); m_notesWindow.Closing -= HandleNotesWindowClosing; m_notesWindow = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// We override this method to make a selection in all of the views that are in a /// snynced group. This fixes problems where the user changes the selection in one of /// the slaves, but the master is not updated. Thus the view is not scrolled as the /// groups scroll position only scrolls the master's selection into view. (TE-3380) /// </summary> /// <param name="prootb"></param> /// <param name="vwselNew"></param> /// ------------------------------------------------------------------------------------ public override void SelectionChanged(IVwRootBox prootb, IVwSelection vwselNew) { CheckDisposed(); if (s_fInSelectionChanged) { return; } base.SelectionChanged(prootb, vwselNew); if (m_ignoreSelChanged || EditingHelper.CurrentSelection == null) { return; } SelLevInfo noteInfo = EditingHelper.CurrentSelection.GetLevelInfoForTag(m_currentNotesTag); if (noteInfo.hvo == m_prevNoteHvo) { return; } ScrScriptureNote ann = new ScrScriptureNote(m_fdoCache, noteInfo.hvo); s_fInSelectionChanged = true; try { // Remove highlighting on previously selected annotation, and add highlighting to selected annotation. SelectionHelper sel = EditingHelper.CurrentSelection; m_vc.SelectedNoteHvo = noteInfo.hvo; if (m_prevNoteHvo != 0) { // Make sure we use the index in the virtual property and not // the index in the list of notes. int ownerHvo = m_fdoCache.GetOwnerOfObject(m_prevNoteHvo); int ihvo = m_fdoCache.GetObjIndex(ownerHvo, m_currentNotesTag, m_prevNoteHvo); if (ihvo >= 0) // Could be -1 if not in the filter anymore (TE-8891) { m_fdoCache.PropChanged(null, PropChangeType.kpctNotifyAll, ownerHvo, m_currentNotesTag, ihvo, 1, 1); } } m_fdoCache.PropChanged(null, PropChangeType.kpctNotifyAll, ann.OwnerHVO, m_currentNotesTag, noteInfo.ihvo, 1, 1); sel.SetSelection(false); // restore selection taken from PropChange } finally { s_fInSelectionChanged = false; } // Set text of caption to indicate which annotation is selected m_notesMainWnd.InformationBarText = BaseInfoBarCaption + " - " + GetRefAsString(ann) + " " + GetQuotedText(ann.QuoteOA, 30); SetNoteUpdateTime(m_prevNoteHvo); m_prevNoteHvo = noteInfo.hvo; if (!m_fSendSyncScrollMsg) { return; } NotesMainWnd notesMainWnd = TheMainWnd as NotesMainWnd; if (notesMainWnd != null && notesMainWnd.SyncHandler != null) { Trace.WriteLine("Calling SyncToAnnotation from NotesDataEntryView: " + ann.CitedText); notesMainWnd.SyncHandler.SyncToAnnotation(this, ann, m_scr); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Apply the filter the user clicked in the side bar or in the menu. /// </summary> /// <param name="sender">The side-bar button the user clicked</param> /// ------------------------------------------------------------------------------------ public virtual void OnChangeFilter(object sender) { CheckDisposed(); CmFilter userFilter = null; if (sender is SBTabItemProperties) // from sidebar { userFilter = (sender != null) ? (CmFilter)((SBTabItemProperties)sender).Tag : null; } else if (sender is TMItemProperties) // from menu { userFilter = (sender != null) ? (CmFilter)((TMItemProperties)sender).Tag : null; } if (userFilter != null && !GetFilterValuesFromUser(userFilter)) { return; } NotesViewFilter annotationFilter = new NotesViewFilter(Cache, userFilter); FilteredSequenceHandler handler; try { handler = FilteredSequenceHandler.GetFilterInstance(m_fdoCache, ScrBookAnnotations.kClassId, annotationFilter, Handle.ToInt32()); if (handler != null) { handler.Reinitialize(false); } else { if (userFilter != null) { userFilter.UserView = m_UserView; } handler = new FilteredSequenceHandler(m_fdoCache, ScrBookAnnotations.kClassId, Handle.ToInt32(), annotationFilter, null, m_UserView); } } catch { // User must have cancelled the filter, or something horrible happened. // Just revert back to the previous state. NotesMainWnd notesMainWnd = TheMainWnd as NotesMainWnd; Debug.Assert(notesMainWnd != null); notesMainWnd.SelectFilterButton(m_vc.NotesSequenceHandler != null ? m_vc.NotesSequenceHandler.Filter as CmFilter: null); return; } Debug.Assert(handler != null); m_currentNotesTag = handler.Tag; // Set up the view constructor with the filtered sequence handler corresponding to the // notes filter chosen by the user. m_vc.NotesSequenceHandler = handler; RefreshDisplay(); if (FilterChanged != null) { FilterChanged(this, userFilter); } }