partial void WordGroupRASideEffects(IConstChartWordGroup oldObjValue, IConstChartWordGroup newObjValue) { if (newObjValue == null) { DeleteMyself(); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Compares WordGroups in two segments to see if they are similar enough to be considered /// the same. Mostly designed for testing. Tests wordforms tagged for same baseline text /// and checks to see that they both reference the same CmPossibility column. /// </summary> /// ------------------------------------------------------------------------------------ public bool IsAnalogousTo(IConstChartWordGroup otherWordGrp) { if (otherWordGrp == null) { return(false); } if (this.ColumnRA != otherWordGrp.ColumnRA) { return(false); } var myWordforms = this.GetOccurrences(); var otherWordforms = otherWordGrp.GetOccurrences(); if (myWordforms == null || otherWordforms == null || myWordforms.Count == 0 || otherWordforms.Count == 0) { throw new ArgumentException("Found an invalid ConstChartWordGroup."); } if (myWordforms.Count != otherWordforms.Count) { return(false); } // Below LINQ returns false if it finds any tagged wordforms in the two lists // that have different baseline text (at the same index) return(!myWordforms.Where((t, i) => t.BaselineText.Text != otherWordforms[i].BaselineText.Text).Any()); }
/// <summary> /// Makes a ChartMovedTextMarker object and appends it to the row /// </summary> /// <param name="row"></param> /// <param name="icol"></param> /// <param name="target"></param> /// <param name="fPreposed"></param> /// <returns></returns> internal IConstChartMovedTextMarker MakeMovedTextMarker(IConstChartRow row, int icol, IConstChartWordGroup target, bool fPreposed) { Assert.Less(icol, m_allColumns.Count, "Invalid column index"); Assert.IsNotNull(target, "Can't make a MovedTextMarker with no target WordGroup"); var ccmtm = m_mtmFact.Create(row, row.CellsOS.Count, m_allColumns[icol], fPreposed, target); return(ccmtm); }
private void VerifyMoveOccurrenceToSameRowLaterColBeforeMtm(AnalysisOccurrence[] allParaOccurrences, IConstChartWordGroup wGrp01, int cExpectCSelect) { // Should have: added allParaOccurrences[1] to a new WordGroup in column 3 of row 0 // (before moved text marker in col 4). VerifyRow(0, "1a", 3); VerifyWordGroup(0, 0, m_allColumns[1], new List <AnalysisOccurrence> { allParaOccurrences[0] }); VerifyWordGroup(0, 1, m_allColumns[3], new List <AnalysisOccurrence> { allParaOccurrences[1] }); VerifyMovedText(0, 2, m_allColumns[4], wGrp01, true); Assert.AreEqual(cExpectCSelect, m_mockRibbon.CSelectFirstCalls); AssertUsedAnalyses(allParaOccurrences, 2); Assert.AreEqual(1, m_chart.RowsOS.Count, "should not add a row"); }
internal void Init() { Debug.Assert(SentElem != null && SentElem.AffectedWordGroups.Count > 0, "No WordGroup Hvo set."); // Collect eligible rows var crows = CollectRowsToCombo(); // Next collect all columns and create ColumnMenuItem List for ComboBox if (crows == 1) { CollectColumnsToCombo(GetColumnChoices(SentElem.GetOriginRow)); } else { CollectAllColumnsToCombo(); } // TODO GordonM: Eventually we want to check and see if AffectedWordGroups has more than one // and put them all in the Ribbon! // Review: Perhaps we need to build a temporary/dummy WordGroup with all the occurrences of // the AffectedWordGroups in it for dialog Ribbon display purposes. m_wordGroup = SentElem.AffectedWordGroups[0]; SetRibbon(); }
/// <summary> /// Verify that there is a row with the specified index that has a cell part /// (subclass ConstChartMovedTextMarker) with the specified index which belongs to the /// specified column and points to the specified WordGroup object in the right direction. /// </summary> /// <param name="irow"></param> /// <param name="icellPart"></param> /// <param name="column"></param> /// <param name="wordGroup"></param> /// <param name="fPrepose"></param> internal void VerifyMovedTextMarker(int irow, int icellPart, ICmPossibility column, IConstChartWordGroup wordGroup, bool fPrepose) { Assert.IsNotNull(wordGroup, "CCMTMarker must refer to a wordgroup"); var cellPart = VerifyCellPartBasic(irow, icellPart, column) as IConstChartMovedTextMarker; Assert.IsNotNull(cellPart, "Cell part should be a ConstChartMovedTextMarker!"); Assert.IsNotNull(cellPart.WordGroupRA, "MovedText Marker does not refer to a word group"); Assert.AreEqual(wordGroup.Hvo, cellPart.WordGroupRA.Hvo); Assert.AreEqual(fPrepose, cellPart.Preposed, "MTMarker is not pointing the right direction!"); }
/// <summary> /// Creates a MovedTextMarker that lives in a row/column combo. This assumes we append this cell to /// the row. It doesn't check that you haven't done something silly like tell it to add /// to a column previous to where you've already added things in this row. /// </summary> /// <param name="row">The row to add the cell to</param> /// <param name="column">The column to add the cell to</param> /// <param name="wordGrp">The WordGroup to point to</param> /// <param name="fPreposed"></param> private IConstChartMovedTextMarker CreateMTMarker(IConstChartRow row, ICmPossibility column, IConstChartWordGroup wordGrp, bool fPreposed) { return m_mtMrkrFact.Create(row, row.CellsOS.Count, column, fPreposed, wordGrp); }
/// <summary> /// Creates a MovedTextMarker that lives in a row/column combo. This assumes we append this cell to /// the row. It doesn't check that you haven't done something silly like tell it to add /// to a column previous to where you've already added things in this row. /// </summary> /// <param name="row">The row to add the cell to</param> /// <param name="column">The column to add the cell to</param> /// <param name="wordGrp">The WordGroup to point to</param> /// <param name="fPreposed"></param> private IConstChartMovedTextMarker CreateMTMarker(IConstChartRow row, ICmPossibility column, IConstChartWordGroup wordGrp, bool fPreposed) { return(m_mtMrkrFact.Create(row, row.CellsOS.Count, column, fPreposed, wordGrp)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Compares WordGroups in two segments to see if they are similar enough to be considered /// the same. Mostly designed for testing. Tests wordforms tagged for same baseline text /// and checks to see that they both reference the same CmPossibility column. /// </summary> /// ------------------------------------------------------------------------------------ public bool IsAnalogousTo(IConstChartWordGroup otherWordGrp) { if (otherWordGrp == null) return false; if (this.ColumnRA != otherWordGrp.ColumnRA) return false; var myWordforms = this.GetOccurrences(); var otherWordforms = otherWordGrp.GetOccurrences(); if (myWordforms == null || otherWordforms == null || myWordforms.Count == 0 || otherWordforms.Count == 0) throw new ArgumentException("Found an invalid ConstChartWordGroup."); if (myWordforms.Count != otherWordforms.Count) return false; // Below LINQ returns false if it finds any tagged wordforms in the two lists // that have different baseline text (at the same index) return !myWordforms.Where((t, i) => t.BaselineText.Text != otherWordforms[i].BaselineText.Text).Any(); }
partial void WordGroupRASideEffects(IConstChartWordGroup oldObjValue, IConstChartWordGroup newObjValue) { if (newObjValue == null) DeleteMyself(); }
private IConstChartMovedTextMarker MakeMovedTextMarker(IConstChartRow row, int icol, IConstChartWordGroup target, bool fPreposed) { return m_helper.MakeMovedTextMarker(row, icol, target, fPreposed); }
/// <summary> /// Test must preload Clicked Cell, and Eligible Rows and then call this. /// </summary> /// <param name="group"></param> void SetupParameterObject(IConstChartWordGroup group) { SetupParamObjBase(); Assert.IsNotNull(group, "Invalid CCWordGroup."); m_sentElem.AffectedWordGroups.Add(group); }
private IConstChartMovedTextMarker MakeMovedTextMarker(IConstChartRow row, int icol, IConstChartWordGroup target, bool fPreposed) { return(m_helper.MakeMovedTextMarker(row, icol, target, fPreposed)); }
/// <summary> /// Verify that there is a row with the specified index that has a cell part /// (subclass ConstChartMovedTextMarker) with the specified index which belongs to the /// specified column and points to the specified WordGroup object in the right direction. /// </summary> /// <param name="irow"></param> /// <param name="icellPart"></param> /// <param name="column"></param> /// <param name="wordGrp"></param> /// <param name="fPrepose"></param> void VerifyMovedText(int irow, int icellPart, ICmPossibility column, IConstChartWordGroup wordGrp, bool fPrepose) { m_helper.VerifyMovedTextMarker(irow, icellPart, column, wordGrp, fPrepose); }
/// <summary> /// Creates a new Chart Moved Text Marker (shows where some text was moved from). /// </summary> /// <param name="row"></param> /// <param name="insertAt"></param> /// <param name="column"></param> /// <param name="fPreposed">True if the CCWG was 'moved' earlier than its 'normal' position</param> /// <param name="wordGroup">The CCWG that was 'moved'</param> /// <returns></returns> public IConstChartMovedTextMarker Create(IConstChartRow row, int insertAt, ICmPossibility column, bool fPreposed, IConstChartWordGroup wordGroup) { if (column == null || row == null) throw new ArgumentNullException(); var ccells = row.CellsOS.Count; if (insertAt < 0 || insertAt > ccells) // insertAt == Count will append throw new ArgumentOutOfRangeException("insertAt"); var newby = Create(); row.CellsOS.Insert(insertAt, newby); newby.ColumnRA = column; newby.Preposed = fPreposed; newby.WordGroupRA = wordGroup; return newby; }
/// <summary> /// Test must preload Clicked Cell, and Eligible Rows and then call this. /// </summary> /// <param name="affectedGroupsArray"></param> void SetupParameterObject(IConstChartWordGroup[] affectedGroupsArray) { SetupParamObjBase(); Assert.IsNotNull(affectedGroupsArray, "Empty parameter array."); Assert.Greater(affectedGroupsArray.Length, 0, "No CCWordGroups to add."); foreach (var group in affectedGroupsArray) { m_sentElem.AffectedWordGroups.Add(group); } }
private void VerifyMoveOccurrenceToSameRowLaterColBeforeMtm(AnalysisOccurrence[] allParaOccurrences, IConstChartWordGroup wGrp01, int cExpectCSelect) { // Should have: added allParaOccurrences[1] to a new WordGroup in column 3 of row 0 // (before moved text marker in col 4). VerifyRow(0, "1a", 3); VerifyWordGroup(0, 0, m_allColumns[1], new List<AnalysisOccurrence> { allParaOccurrences[0] }); VerifyWordGroup(0, 1, m_allColumns[3], new List<AnalysisOccurrence> { allParaOccurrences[1] }); VerifyMovedText(0, 2, m_allColumns[4], wGrp01, true); Assert.AreEqual(cExpectCSelect, m_mockRibbon.CSelectFirstCalls); AssertUsedAnalyses(allParaOccurrences, 2); Assert.AreEqual(1, m_chart.RowsOS.Count, "should not add a row"); }
/// <summary> /// Verify that FindFirstWordGroup() finds the given 'testCellPart' as the first /// CellPart in 'list'. /// </summary> /// <param name="testWordGrp"></param> /// <param name="list"></param> /// <param name="message"></param> private void VerifyFirstWordGroup(IConstChartWordGroup testWordGrp, List<IConstituentChartCellPart> list, string message) { var wordGrp = m_logic.CallFindWordGroup(list); Assert.IsNotNull(wordGrp, message); Assert.AreEqual(testWordGrp.Hvo, wordGrp.Hvo, message); }
internal void Init() { Debug.Assert(SentElem != null && SentElem.AffectedWordGroups.Count > 0, "No WordGroup Hvo set."); // Collect eligible rows var crows = CollectRowsToCombo(); // Next collect all columns and create ColumnMenuItem List for ComboBox if (crows == 1) CollectColumnsToCombo(GetColumnChoices(SentElem.GetOriginRow)); else CollectAllColumnsToCombo(); // TODO GordonM: Eventually we want to check and see if AffectedWordGroups has more than one // and put them all in the Ribbon! // Review: Perhaps we need to build a temporary/dummy WordGroup with all the occurrences of // the AffectedWordGroups in it for dialog Ribbon display purposes. m_wordGroup = SentElem.AffectedWordGroups[0]; SetRibbon(); }