internal int m_chvoDel; // On Do, Redo; #inserted on Undo. /// <summary> /// Make an instance and add it to the undo stack. Also, if it's the 'redo' action added after the /// actual changes (fForRedo is true), issue the propchanged at once to complete the original action. /// </summary> public static ExtraPropChangedAction AddAndInvokeIfRedo(IActionHandler actionHandler, ISilDataAccess sda, int hvo, int tag, int ihvo, int chvoIns, int chvoDel, bool fForRedo) { ExtraPropChangedAction action = new ExtraPropChangedAction(sda, hvo, tag, ihvo, chvoIns, chvoDel, fForRedo); actionHandler.AddAction(action); if (fForRedo) action.Redo(); return action; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add a book to the imported saved version. If necessary, create the imported saved version, /// and set up an UndoAction so it will be deleted if we Undo. Set or update the description /// of the saved version as necessary. /// </summary> /// <param name="nCanonicalBookNumber"></param> /// <param name="description"></param> /// <param name="hvoTitle"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ private IScrBook AddBookToImportedSavedVersion(int nCanonicalBookNumber, string description, out int hvoTitle) { IActionHandler actionHandler = SetCurrentBookInternal(nCanonicalBookNumber); Debug.Assert(nCanonicalBookNumber > 0); if (m_importedSavedVersion == null) { m_importedSavedVersion = new ScrDraft(); m_scr.ArchivedDraftsOC.Add(m_importedSavedVersion); m_importedSavedVersion.Type = ScrDraftType.ImportedVersion; actionHandler.AddAction(new UndoImportObjectAction(m_importedSavedVersion)); } m_importedSavedVersion.Description = description; int iBook = 0; foreach (IScrBook existingBook in m_importedSavedVersion.BooksOS) { if (existingBook.CanonicalNum == nCanonicalBookNumber) { // For some reason, typically reading multiple independent SF files, we've been // asked to create a book we already have. Just return it. hvoTitle = existingBook.TitleOAHvo; return(existingBook); } if (existingBook.CanonicalNum > nCanonicalBookNumber) { break; } iBook++; } IScrBook newScrBook = new ScrBook(); m_importedSavedVersion.BooksOS.InsertAt(newScrBook, iBook); newScrBook.CanonicalNum = nCanonicalBookNumber; newScrBook.BookIdRAHvo = m_scr.Cache.ScriptureReferenceSystem.BooksOS.HvoArray[nCanonicalBookNumber - 1]; newScrBook.TitleOA = new StText(); hvoTitle = newScrBook.TitleOAHvo; actionHandler.AddAction(new UndoImportObjectAction(newScrBook)); return(newScrBook); }
internal int m_chvoDel; // On Do, Redo; #inserted on Undo. /// <summary> /// Make an instance and add it to the undo stack. Also, if it's the 'redo' action added after the /// actual changes (fForRedo is true), issue the propchanged at once to complete the original action. /// </summary> public static ExtraPropChangedAction AddAndInvokeIfRedo(IActionHandler actionHandler, ISilDataAccess sda, int hvo, int tag, int ihvo, int chvoIns, int chvoDel, bool fForRedo) { ExtraPropChangedAction action = new ExtraPropChangedAction(sda, hvo, tag, ihvo, chvoIns, chvoDel, fForRedo); actionHandler.AddAction(action); if (fForRedo) { action.Redo(); } return(action); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:UndoImportInfo"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="bookFilter">The book filter.</param> /// ------------------------------------------------------------------------------------ public UndoImportManager(FdoCache cache, FilteredScrBooks bookFilter) { m_cache = cache; m_bookFilter = bookFilter; m_scr = m_cache.LangProject.TranslatedScriptureOA; Debug.Assert(m_cache.ActionHandlerAccessor != null); Debug.Assert(m_cache.ActionHandlerAccessor.CurrentDepth == 0); m_hMark = m_cache.ActionHandlerAccessor.Mark(); IActionHandler actionHandler = m_cache.ActionHandlerAccessor; m_suppressor = new SuppressSubTasks(m_cache); // don't need to undo setting properties. // Create new archive for saving backup versions of imported book m_savedVersion = new ScrDraft(); m_scr.ArchivedDraftsOC.Add(m_savedVersion); actionHandler.AddAction(new UndoImportObjectAction(m_savedVersion)); m_savedVersion.Description = TeResourceHelper.GetResourceString("kstidSavedVersionDescriptionOriginal"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Called when we are about to import a book but are not importing the main translation. /// </summary> /// <param name="nCanonicalBookNumber"></param> /// <param name="fMakeBackup">This should be true if we are importing a back /// translation.</param> /// <returns>The version of the book in the imported version if available; otherwise /// the current version of the book (in which case a backup will be made first if /// <c>fMakeBackup</c> is <c>true</c>.</returns> /// ------------------------------------------------------------------------------------ public IScrBook PrepareBookNotImportingVern(int nCanonicalBookNumber, bool fMakeBackup) { IActionHandler actionHandler = SetCurrentBookInternal(nCanonicalBookNumber); IScrBook cvBook = m_scr.FindBook(nCanonicalBookNumber); if (ImportedSavedVersion != null) { IScrBook isvBook = ImportedSavedVersion.FindBook(nCanonicalBookNumber); if (isvBook != null) { // We won't make a new undo action in this case. The import of a BT for an // imported book will be undone if the import of the book is undone. return(isvBook); } } if (cvBook != null && fMakeBackup && m_savedVersion.FindBook(nCanonicalBookNumber) == null) { actionHandler.AddAction(new UndoImportModifiedBookAction(this, cvBook)); } return(cvBook); }
public void CreatedUndoSelectionActions() { CheckDisposed(); ShowForm(); // we need a selection - set to start m_basicView.RootBox.MakeSimpleSel(true, true, false, true); IActionHandler acth = m_basicView.Cache.ActionHandlerAccessor; Assert.AreEqual(0, acth.UndoableActionCount, "Undoable actions at start"); using (UndoTaskHelper helper = new UndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { Assert.AreEqual(1, acth.UndoableActionCount, "Wrong number of undoable actions after beginning task"); acth.AddAction(new DummyUndoAction()); Assert.AreEqual(2, acth.UndoableActionCount, "Wrong number of undoable actions after adding a task"); } Assert.AreEqual(3, acth.UndoableActionCount, "Wrong number of undoable actions after ending task"); }
/// <summary> /// Member CacheObjProp /// </summary> /// <param name="obj">obj</param><param name="tag">tag</param><param name="val">val</param> /// <remarks> /// IVwCacheDa method /// </remarks> public void CacheObjProp(int obj, int tag, int val) { var before = new CacheInfo(ObjType.Object, obj, tag, m_cache.get_Prop(obj, tag)); var after = new CacheInfo(ObjType.Object, obj, tag, val); ActionHandler.AddAction(new CacheUndoAction(m_cache, before, after)); m_cache.CacheObjProp(obj, tag, val); }