/// <summary> /// Create a new one. /// </summary> /// <param name="cache"></param> /// <param name="hvoAnalysis"></param> /// <param name="ss"></param> /// <param name="choices"></param> /// <param name="rawWordform"></param> /// <param name="fTreatAsSentenceInitial"></param> /// <param name="mediator"></param> /// <param name="parent"></param> public Sandbox(FdoCache cache, Mediator mediator, IVwStylesheet ss, InterlinLineChoices choices, int hvoAnnotation, InterlinDocChild interlinDoc) : base(cache, mediator, ss, choices) { m_interlinDoc = interlinDoc; m_hvoAnnotation = hvoAnnotation; // Finish initialization with twfic context. int hvoInstanceOf = Cache.GetObjProperty(m_hvoAnnotation, (int)CmBaseAnnotation.CmAnnotationTags.kflidInstanceOf); LoadForWordBundleAnalysis(hvoInstanceOf); }
internal InterlinClipboardHelper(IVwSelection vwsel, InterlinDocChild site, FdoCache cache) { // Get the string and split it into its individual lines. vwsel.GetSelectionString(out m_tss, "\t"); m_rgtssPieces = StringUtils.Split(m_tss, new string[] { Environment.NewLine }, StringSplitOptions.None); m_choices = site.LineChoices; m_fHaveMorphemeLevel = m_choices.HaveMorphemeLevel; if (m_fHaveMorphemeLevel) m_cMorphLines = m_idxChoiceLastMorpheme - m_idxChoiceFirstMorpheme + 1; m_idxChoiceFirstMorpheme = m_choices.FirstMorphemeIndex; m_idxChoiceLastMorpheme = m_choices.LastMorphemeIndex; m_idxChoiceFirstFreeform = m_choices.FirstFreeformIndex; m_cChoices = m_choices.Count; m_cInterlinearLines = m_choices.FirstFreeformIndex; // Get the labels for the lines in m_choices. m_rgsLabel = new string[m_cInterlinearLines]; for (int i = 0; i < m_rgsLabel.Length; ++i) m_rgsLabel[i] = m_choices.LabelFor(m_choices[i].Flid); bool fTaggingView = site is InterlinTaggingChild; if (site is InterlinTaggingChild) { m_fHaveTagging = true; m_idxChoiceTaggingLine = m_idxChoiceFirstFreeform; ++m_idxChoiceFirstFreeform; ++m_cChoices; } else { m_fHaveTagging = false; m_idxChoiceTaggingLine = -1; } m_cache = cache; }
internal UndoRedoApproveAnalysis(InterlinDocChild interlinDoc, int hvoOldAnnotation, int hvoNewAnnotation) { m_interlinDoc = interlinDoc; m_cache = interlinDoc.Cache; if (hvoOldAnnotation != 0) { m_oldTwficInfo = new StTxtPara.TwficInfo(m_cache, hvoOldAnnotation); m_oldTwficInfo.CaptureObjectInfo(); } if (hvoNewAnnotation != 0) this.NewAnnotation = hvoNewAnnotation; }
protected override void Dispose(bool disposing) { if (disposing == true) { // let's make sure the active clerk doesn't have any invalid items as a result from the // the Undo/Redo. RecordClerk activeClerk = m_idc.ActiveClerk; if (activeClerk != null) activeClerk.RemoveInvalidItems(); // let's make sure the clerk driving the master doesn't have any invalid items. InterlinMaster master = m_idc.GetMaster(); if (master != null && master.Clerk != activeClerk) master.Clerk.RemoveInvalidItems(); m_idc.AllowLayout = true; if (m_hvoOriginalAnnotation != 0) { if (m_idc.CurrentParaIsValid()) m_idc.ResyncSandboxToDatabase(); else m_idc.MessageBoxMasterRefresh(); } else { // redisply the new state of things // possibly with or without a freeform annotation. m_idc.UpdateDisplayAfterUndo(); } } base.Dispose(disposing); m_idc = null; }
internal UndoRedoSyncTextAndSandbox(InterlinDocChild idc) : base(idc.ActiveClerk) { SkipShowRecord = true; TriggerPendingReloadOnDispose = false; // suspend reloading clerk. m_idc = idc; m_hvoOriginalAnnotation = m_idc.HvoAnnotation; // we may not have a sandbox due to a freeform annotation selection. if (m_hvoOriginalAnnotation != 0) m_idc.AbandonChangesInFocusBox(); m_idc.AllowLayout = false; // may be overkill, but i don't think we always get PropChanges for // restored or deleted objects. WordformInventory.OnChangedWordformsOC(); }
protected override void Dispose(bool disposing) { if (disposing) { if (m_idc != null) { // See LT-10193 -- multiple crash reports with HvoNewAnnotation apparently being zero. // This should not be possible, but if an exception gets thrown while trying to merge // two adjacent words, it might well have that appearance. Checking here at least keeps // the hypothetical exception from being hidden by a new exception in this method. if (HvoNewAnnotation != 0) m_idc.AddUndoRedoAction(0, HvoNewAnnotation); m_idc.AllowLayout = true; if (HvoNewAnnotation != 0) { ICmBaseAnnotation newAnnotation = CmBaseAnnotation.CreateFromDBObject(m_idc.Cache, HvoNewAnnotation); // reconstruction should restore guesses m_idc.ReconstructAndRecreateSandbox(false, HvoNewAnnotation, newAnnotation.InstanceOfRAHvo); } } } base.Dispose(disposing); if (m_idc != null && disposing) { m_idc.Focus(); } m_hvoNewAnnotation = 0; m_idc = null; m_para = null; m_cache = null; }
public SegmentFormsUpdateHelper(InterlinDocChild idc) : base(idc.ActiveClerk) { // set these flags early so that any dependent ListUpdateHelpers // can inherit these settings. SkipShowRecord = true; TriggerPendingReloadOnDispose = false; m_idc = idc; m_cache = idc.Cache; // any changes in the sandbox should be ignored. we don't want to try to save it. m_idc.AbandonChangesInFocusBox(); m_idc.AddUndoRedoAction(m_idc.HvoAnnotation, 0); m_idc.AllowLayout = false; CaptureInitialStateInfo(m_idc.HvoAnnotation); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// ----------------------------------------------------------------------------------- protected override void Dispose( bool disposing ) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; base.Dispose( disposing ); if (disposing) { } m_interlinDoc = null; }
void MakeInterlinPane() { if (m_idcPane != null) return; m_idcPane = new InterlinDocChild(); m_idcPane.Name = "m_idcPane"; m_idcPane.ForEditing = true; m_idcPane.Dock = DockStyle.Fill; m_idcPane.BackColor = Color.FromKnownColor(KnownColor.Window); this.SetStyleSheetFor(m_idcPane); // This isn't adequate now we're saving the active pane, this routine gets called before // we have our style sheet. //m_idcPane.StyleSheet = m_styleSheet; m_idcPane.AnnnotationSelected += new AnnotationSelectedEventHandler( m_idcPane_AnnnotationSelected); m_idcPane.Visible = false; m_panelInterlin.Controls.Add(m_idcPane); // If these don't happen now they will happen later in SetupDataContext. if (Cache != null) m_idcPane.Cache = Cache; if (m_mediator != null) m_idcPane.Init(m_mediator, m_configurationParameters); }
private void ClearInterlinDocPaneVariables() { m_idcPane = null; m_taggingViewPane = null; m_printViewPane = null; }
private int SelectFirstThingNeedingAnnotation(InterlinDocChild pane) { int hvoAnn = 0; AdvanceWordArgs args = new AdvanceWordArgs(0, 0); pane.AdvanceWord(this, args, true); if (args.Annotation != 0) hvoAnn = args.Annotation; return hvoAnn; }
private int HandleBookmark(InterlinDocChild pane) { int hvoResult = 0; int cchPara = -2; // won't match any begin offset! if (m_bookmark.IndexOfParagraph == pane.RawStText.ParagraphsOS.Count - 1) { // bookmark in last paragraph, see if after last character. IStTxtPara para = pane.RawStText.ParagraphsOS[m_bookmark.IndexOfParagraph] as IStTxtPara; cchPara = para.Contents.Length; } if (m_bookmark.BeginCharOffset == m_bookmark.EndCharOffset && m_bookmark.BeginCharOffset == cchPara) { // Bookmark is an IP at the end of the text, don't try to match it. // If we're in Analyze or Gloss, default is to select first thing that needs annotation. // Otherwise, do nothing for now. if (m_tabCtrl.SelectedIndex == ktpsAnalyze || m_tabCtrl.SelectedIndex == ktpsGloss) hvoResult = SelectFirstThingNeedingAnnotation(pane); } else { // bookmark is not an IP at end of text, try to select the corresponding thing. hvoResult = RawTextPane.AnnotationHvo(Cache, pane.RawStText, m_bookmark, true); } return hvoResult; }
private void TrySelectAnnotation(ISilDataAccess sda, InterlinDocChild pane, int annHvo) { // Try our best not to select an annotation we know won't work. int annoType = sda.get_ObjectProp(annHvo, kflidAnnotationType); int annInstanceOfRAHvo = sda.get_ObjectProp(annHvo, kflidInstanceOf); if (annInstanceOfRAHvo == 0 || annoType != CmAnnotationDefn.Twfic(Cache).Hvo) { // if we didn't set annHvo by our marker or Clerk.CurrentObject, // then we must have already tried the first word. if (m_bookmark.IndexOfParagraph < 0 && Clerk.CurrentObject.Hvo == 0) return; // reset our marker and return to avoid trying to reuse an "orphan annotation" // resulting from an Undo(). (cf. LT-2663). m_bookmark.Reset(); return; // Can't select nothing, so return. } pane.SelectAnnotation(annHvo); }
private void SetPaneSizeAndRoot(InterlinDocChild pane) { this.ResumeLayout(); // This ensures that its root has been constructed and it's in a valid state // for things like setting an annotation and making the focus box and scrolling // to show it. Also that all layout that happens in the process happens at the // correct width (and height...this helps us position the focus box sensibly). if (pane.Width != m_tabCtrl.SelectedTab.Width) pane.Width = m_tabCtrl.SelectedTab.Width; if (pane.Height != m_tabCtrl.SelectedTab.Height) pane.Height = m_tabCtrl.SelectedTab.Height; // If the suspendLayout was not used then there were sometimes significant delays // when switching from other tabs to the PrintView tab. pane.SuspendLayout(); pane.SetRoot(m_hvoStText); pane.ResumeLayout(); pane.Visible = true; }
private void ValidateFocusBoxState(int indexWordExpected, InterlinDocChild idc, StTxtPara.TwficInfo twficBeforeEdit1_0, IStText stTextBeforeEdit) { IStText stTextAfterEdit = idc.RawStText; Assert.AreEqual(stTextBeforeEdit, stTextAfterEdit, "We expect to be in the same text."); int hvoAnnAfterEdit = idc.HvoAnnotation; ICmBaseAnnotation cbaAfterEdit = new CmBaseAnnotation(Cache, hvoAnnAfterEdit); Assert.IsFalse(twficBeforeEdit1_0.IsCapturedObjectInfoValid()); Assert.AreEqual(twficBeforeEdit1_0.BeginOffset, cbaAfterEdit.BeginOffset, "FocusBox should be at the same location."); Assert.AreNotEqual(twficBeforeEdit1_0.EndOffset, cbaAfterEdit.EndOffset, "FocusBox should now be on phrase annotation."); // FocusBox should be on phrase, not somewhere else. Assert.IsNotNull(idc.IsFocusBoxInstalled, "Focus Box should still be installed."); Assert.AreEqual(idc.ExistingFocusBox.InterlinWordControl.HvoAnnotation, hvoAnnAfterEdit, "FocusBox should be on current annotation."); // Make sure we haven't changed word in the wordform record list. int indexWordAfterEdit = m_wordList.CurrentIndex; int hvoWordAfterEdit = m_wordList.CurrentObject.Hvo; Assert.AreEqual(indexWordExpected, indexWordAfterEdit, "Word index mismatch"); }