示例#1
0
        private void WriteMTMarker(ITsString tss)
        {
            ITsString newTss;
            var       ws = GetWsFromTsString(tss);

            if (tss == ((ConstChartVc)m_vc).m_sMovedTextBefore)
            {
                newTss = m_cache.TsStrFactory.MakeString("Preposed", ws);
            }
            else
            {
                newTss = m_cache.TsStrFactory.MakeString("Postposed", ws);
            }
            var hvoTarget = m_sda.get_ObjectProp(m_hvoCurr,
                                                 ConstChartMovedTextMarkerTags.kflidWordGroup); // the CCWordGroup we refer to

            if (ConstituentChartLogic.HasPreviousMovedItemOnLine(m_chart, hvoTarget))
            {
                WriteStringVal("moveMkr", ws, newTss, "targetFirstOnLine", "false");
            }
            else
            {
                WriteStringVal("moveMkr", ws, newTss, null, null);
            }
        }
示例#2
0
        public void SetAffectedCcas_All()
        {
            // Setup test here; modify as needed
            int[] allParaWfics = m_helper.MakeAnnotationsUsedN(5);
            // Setup 3 rows each with at least one wfic
            CmIndirectAnnotation row0   = m_helper.MakeFirstRow();
            CmIndirectAnnotation cca0_0 = m_helper.MakeColumnAnnotation(0,
                                                                        new int[] { allParaWfics[0], allParaWfics[1] }, row0);
            CmIndirectAnnotation cca0_0b = m_helper.MakeColumnAnnotation(0,
                                                                         new int[] { allParaWfics[2] }, row0);

            ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, cca0_0b.Hvo,
                                             ConstituentChartLogic.MovedTextFeatureName, true);
            CmIndirectAnnotation cca0_0c = m_helper.MakeColumnAnnotation(0,
                                                                         new int[] { allParaWfics[3], allParaWfics[4] }, row0);

            int icolClicked = 0;             // Shouldn't matter
            List <ICmIndirectAnnotation> eligibleRows = new List <ICmIndirectAnnotation>();

            eligibleRows.Add(row0);

            SetClickedCell(row0, icolClicked);
            SetEligibleRows(eligibleRows);
            // Initially we set AffectedCcas to all the CCAs in the cell here.
            SetupParameterObject(new int[] { cca0_0.Hvo, cca0_0b.Hvo, cca0_0c.Hvo });

            int[] selWfics = new int[] { allParaWfics[1], allParaWfics[2], allParaWfics[3] };

            // SUT
            m_dlgLogicPrepose.SetAffectedCcas(selWfics);             // We don't care about Pre/Postpose for this method.

            // Verify changes in SentElem.AffectedCcas
            Assert.AreEqual(new int[] { cca0_0.Hvo, cca0_0b.Hvo, cca0_0c.Hvo }, m_dlgLogicPrepose.SentElem.AffectedCcas,
                            "Should affect all of the CCAs.");
        }
示例#3
0
		/// <summary>
		/// Make one. This variant is used in testing (to plug in a known logic class).
		/// </summary>
		internal ConstituentChart(FdoCache cache, ConstituentChartLogic logic)
		{
			m_cache = cache;
			m_serviceLocator = m_cache.ServiceLocator;
			m_logic = logic;

			BuildUIComponents();
		}
示例#4
0
		/// <summary>
		/// Make one.
		/// </summary>
		public ConstChartBody(ConstituentChartLogic logic, ConstituentChart chart)
			: base(null)
		{
			m_logic = logic;
			m_logic.RowModifiedEvent += new RowModifiedEventHandler(m_logic_RowModifiedEvent);
			m_chart = chart;
			//this.ReadOnlyView = true;
		}
示例#5
0
		/// <summary>
		/// Make one.
		/// </summary>
		public ConstChartBody(ConstituentChartLogic logic, ConstituentChart chart)
			: base(null)
		{
			m_logic = logic;
			m_logic.RowModifiedEvent += m_logic_RowModifiedEvent;
			m_chart = chart;
			IsRightToLeft = m_chart.ChartIsRtL;
			//this.ReadOnlyView = true;
		}
示例#6
0
		/// <summary>
		/// Make one. This variant is used in testing (to plug in a known logic class).
		/// </summary>
		internal ConstituentChart(FdoCache cache, ConstituentChartLogic logic)
		{
			m_cache = cache;
			m_logic = logic;
			this.SuspendLayout();
			m_ribbon = new InterlinRibbon(m_cache, 0);
			m_ribbon.Dock = DockStyle.Fill; // fills the 'bottom stuff'
			m_logic.Ribbon = m_ribbon as IInterlinRibbon;
			m_toolTip = new ToolTip(); // Holds tooltip help for 'Move Here' buttons.
			// Set up the delays for the ToolTip.
			m_toolTip.AutoPopDelay = 5000;
			m_toolTip.InitialDelay = 1000;
			m_toolTip.ReshowDelay = 500;
			// Force the ToolTip text to be displayed whether or not the form is active.
			m_toolTip.ShowAlways = true;

			m_bottomStuff = new Panel();
			m_bottomStuff.SuspendLayout();
			m_bottomStuff.Height = 100; // Enhance: figure based on contents or at least number of rows.
			m_bottomStuff.Dock = DockStyle.Bottom;

			m_buttonRow = new Panel();
			m_buttonRow.Height = new Button().Height; // grab the default height of a button; don't insert any yet.
			m_buttonRow.Dock = DockStyle.Top;
			m_buttonRow.Layout += new LayoutEventHandler(m_buttonRow_Layout);

			m_bottomStuff.Controls.AddRange(new Control[] { m_ribbon, m_buttonRow });
			m_fContextMenuButtonsEnabled = true;
			m_bottomStuff.ResumeLayout();

			m_body = new ConstChartBody(m_logic, this);
			m_body.Cache = m_cache;
			m_body.Dock = DockStyle.Fill;

			//m_headerGroups = new ChartHeaderView();
			m_headerMainCols = new ChartHeaderView(this);
			m_headerMainCols.Dock = DockStyle.Top;
			m_headerMainCols.Layout += new LayoutEventHandler(m_headerMainCols_Layout);
			m_headerMainCols.SizeChanged += new EventHandler(m_headerMainCols_SizeChanged);
			m_headerMainCols.View = System.Windows.Forms.View.Details;
			m_headerMainCols.Height = 22; // Seems to be right (cf BrowseViewer) but not ideal.
			m_headerMainCols.Scrollable = false;
			m_headerMainCols.AllowColumnReorder = false;
			m_headerMainCols.ColumnWidthChanged += new ColumnWidthChangedEventHandler(m_headerMainCols_ColumnWidthChanged);
			//m_headerGroups.Layout += new LayoutEventHandler(m_headerGroups_Layout);

			m_logic.Ribbon_Changed += new EventHandler(m_logic_Ribbon_Changed);

			m_topStuff = new Panel();
			m_topStuff.Dock = DockStyle.Fill;
			m_topStuff.Controls.AddRange(new Control[] { m_body, m_headerMainCols /*, m_headerGroups */});

			this.Controls.AddRange(new Control[] { m_topStuff, m_bottomStuff });

			this.ResumeLayout();
		}
示例#7
0
		public void CellContextPrePostposedOtherClause()
		{
			int[] allParaWfics = m_helper.MakeAnnotationsUsedN(4);
			// Setup 3 rows each with at least one wfic
			CmIndirectAnnotation row0 = m_helper.MakeRow1a();
			CmIndirectAnnotation row1 = m_helper.MakeSecondRow();
			CmIndirectAnnotation row2 = m_helper.MakeRow(m_chart, "1c");
			CmIndirectAnnotation cca0_0 = m_helper.MakeColumnAnnotation(0, new int[] { allParaWfics[0] }, row0);
			CmIndirectAnnotation cca0_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[1] }, row0);
			CmIndirectAnnotation cca1_2 = m_helper.MakeColumnAnnotation(2, new int[] { allParaWfics[2] }, row1);
			CmIndirectAnnotation cca1_3 = m_helper.MakeMovedTextAnnotation(3, cca0_1, row1, "Preposed");
			CmIndirectAnnotation cca2_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[3] }, row2);
			ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, cca0_1.Hvo,
				ConstituentChartLogic.MovedTextFeatureName, true);

			// Test a cell with wfics in a non-boundary row/column
			int ccols = m_logic.AllMyColumns.Length;
			ContextMenuStrip strip = m_logic.MakeCellContextMenu(MakeLocObj(row1, 2));
			// Postpose menu for row1 col 2 should have items for 2 columns plus 'Another clause...'.
			ToolStripMenuItem itemPost = AssertHasMenuWithText(strip.Items,
				ConstituentChartLogic.FTO_PostposeFromMenuItem, 3);
			// Prepose menu for row1 col 2 should have subitems for all subsequent columns plus 'Another clause...'.
			ToolStripMenuItem itemPre = AssertHasMenuWithText(strip.Items,
				ConstituentChartLogic.FTO_PreposeFromMenuItem, ccols - 3 + 1);
			// None of the items on this context menu should be in a checked state
			VerifyMenuItemTextAndChecked(itemPost.DropDownItems[0], m_logic.GetColumnLabel(0), false);
			VerifyMenuItemTextAndChecked(itemPost.DropDownItems[1], m_logic.GetColumnLabel(1), false);
			VerifyMenuItemTextAndChecked(itemPre.DropDownItems[0], m_logic.GetColumnLabel(3), false);
			// a couple more here to check for 'Another clause...' in both Pre and Postposed menus.
			AssertHasMenuWithText(itemPost.DropDownItems, ConstituentChartLogic.FTO_AnotherClause, 0);
			AssertHasMenuWithText(itemPre.DropDownItems, ConstituentChartLogic.FTO_AnotherClause, 0);

			// Test a boundary row's cell with wfics.
			strip = m_logic.MakeCellContextMenu(MakeLocObj(row0, 1));
			// Prepose menu for row0 col 1 should have subitems for all subsequent columns including col2
			// AND a checked item for 'Advanced...'.
			itemPre = AssertHasMenuWithText(strip.Items, ConstituentChartLogic.FTO_PreposeFromMenuItem, ccols - 2 + 1);
			VerifyMenuItemTextAndChecked(itemPre.DropDownItems[itemPre.DropDownItems.Count - 1],
				ConstituentChartLogic.FTO_AnotherClause, true);
			// Postpose menu in row0 col1 should only have 1 postposed (col0; plus 'Advanced...').
			itemPost = AssertHasMenuWithText(strip.Items, ConstituentChartLogic.FTO_PostposeFromMenuItem, 2);
			VerifyMenuItemTextAndChecked(itemPost.DropDownItems[0], m_logic.GetColumnLabel(0), false);
		}
示例#8
0
        /// <summary>
        /// Called whenever we start the display of an object, we currently use it to catch the start of
        /// a row, basedon the frag. Overriding OpenTableRow() might be more natural, but I was trying to
        /// minimize changes to other DLLs, and those routines are not currently virtual in the base class.
        /// </summary>
        /// <param name="hvo"></param>
        /// <param name="ihvo"></param>
        protected override void OpenTheObject(int hvo, int ihvo)
        {
            int frag = m_frags[m_frags.Count - 1];

            switch (frag)
            {
            case ConstChartVc.kfragChartRow:
                if (m_titleStage == TitleStage.ktsStartedSecondHeaderRow)
                {
                    // This is the best way I've found to detect the end of the second header row
                    // and terminate it.
                    m_titleStage = TitleStage.ktsFinishedHeaders;
                    m_writer.WriteEndElement();
                }
                m_writer.WriteStartElement("row");
                if (ConstituentChartLogic.GetFeature(m_cache.MainCacheAccessor, hvo, ConstituentChartLogic.EndParaFeatureName))
                {
                    m_writer.WriteAttributeString("endPara", "true");
                }
                else if (ConstituentChartLogic.GetFeature(m_cache.MainCacheAccessor, hvo, ConstituentChartLogic.EndSentFeatureName))
                {
                    m_writer.WriteAttributeString("endSent", "true");
                }
                ConstChartVc vc         = m_vc as ConstChartVc;
                string       clauseType = vc.GetRowStyleName(this, hvo);
                m_writer.WriteAttributeString("type", clauseType);
                string label = m_cache.GetMultiStringAlt(hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment,
                                                         m_wsLineNumber).Text;
                if (!String.IsNullOrEmpty(label))
                {
                    m_writer.WriteAttributeString("id", label);
                }
                break;

            default:
                break;
            }
            base.OpenTheObject(hvo, ihvo);
        }
示例#9
0
		public void SetAndGetFeature()
		{
			ISilDataAccess sda = Cache.MainCacheAccessor;
			CmIndirectAnnotation row0 = m_helper.MakeFirstRow();
			int hvoRow = row0.Hvo;

			Assert.IsFalse(ConstituentChartLogic.GetFeature(sda, hvoRow, "newPara"), "unmarked ann should have false feature");

			ConstituentChartLogic.SetFeature(sda, hvoRow, "newPara", true);
			Assert.IsTrue(ConstituentChartLogic.GetFeature(sda, hvoRow, "newPara"), "feature newPara set should be true");

			Assert.IsFalse(ConstituentChartLogic.GetFeature(sda, hvoRow, "speech"), "speech feature should still be false");

			ConstituentChartLogic.SetFeature(sda, hvoRow, "speech", true);
			Assert.IsTrue(ConstituentChartLogic.GetFeature(sda, hvoRow, "newPara"), "feature newPara set should still be true");
			Assert.IsTrue(ConstituentChartLogic.GetFeature(sda, hvoRow, "speech"), "speech feature should now be true");

			ConstituentChartLogic.SetFeature(sda, hvoRow, "newPara", false);
			Assert.IsFalse(ConstituentChartLogic.GetFeature(sda, hvoRow, "newPara"), "feature newPara set false should be false");
			Assert.IsTrue(ConstituentChartLogic.GetFeature(sda, hvoRow, "speech"), "speech feature should still be true");

		}
示例#10
0
        public void Export()
        {
            using (MemoryStream stream = new MemoryStream())
            {
                //Set up some cells.
                int[] allParaWfics = m_helper.MakeAnnotationsUsedN(5);

                // This block makes the first row, puts CCAs in cells 1 and 2, and list refs in cells 1 and 2
                CmIndirectAnnotation row0    = m_helper.MakeFirstRow();
                int[] movedItems             = new int[] { allParaWfics[1] };
                CmIndirectAnnotation cca0_1  = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[0] }, row0);
                ICmPossibility       marker  = m_helper.GetAMarker();
                ICmBaseAnnotation    cca0_1b = m_helper.MakeMarkerAnnotation(1, row0, marker);
                CmIndirectAnnotation cca0_2  = m_helper.MakeColumnAnnotation(2, movedItems, row0);
                ICmPossibility       marker2 = m_helper.GetAnotherMarker();
                ICmBaseAnnotation    cca0_2b = m_helper.MakeMarkerAnnotation(2, row0, marker2);
                ICmBaseAnnotation    cca0_2c = m_helper.MakeMarkerAnnotation(2, row0, marker);

                // Now another row, and cell 4 on the first has a ref to it. The new row has a CCA with two wfics in cell 1. The cell is
                // two columns wide, being merged with the previous cell.
                CmIndirectAnnotation  row1   = m_helper.MakeSecondRow();
                ICmIndirectAnnotation cca0_4 = m_helper.MakeDependentClauseMarker(row0, 4, new int[] { row1.Hvo }, "song", "2");
                CmIndirectAnnotation  cca1_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[2], allParaWfics[3] }, row1);
                ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, cca1_1.Hvo, ConstituentChartLogic.mergeBeforeTag, true);

                // Let's have some notes on row 0.
                StText notesText = new StText();
                row0.TextOA = notesText;
                StTxtPara notesPara = new StTxtPara();
                notesText.ParagraphsOS.Append(notesPara);
                notesPara.Contents.UnderlyingTsString = Cache.MakeAnalysisTss("This is a test note");

                // And some moved text in row 1
                CmIndirectAnnotation cca1_2 = m_helper.MakeColumnAnnotation(2, new int[] { allParaWfics[4] }, row1);
                ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, cca1_2.Hvo,
                                                 ConstituentChartLogic.MovedTextFeatureName, true);
                CmIndirectAnnotation cca2_3 = m_helper.MakeMovedTextAnnotation(3, cca1_2, row1, "Preposed");

                // We need four rows to properly test the variations on endPara/endSent
                CmIndirectAnnotation row2 = m_helper.MakeRow(m_chart, "2");
                ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, row2.Hvo, ConstituentChartLogic.EndSentFeatureName, true);
                CmIndirectAnnotation row3 = m_helper.MakeRow(m_chart, "3");
                ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, row3.Hvo, ConstituentChartLogic.EndParaFeatureName, true);
                ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, row3.Hvo, ConstituentChartLogic.EndSentFeatureName, true);
                CmIndirectAnnotation row4 = m_helper.MakeRow(m_chart, "4");


                XmlWriter    writer = new XmlTextWriter(stream, Encoding.UTF8);
                ConstChartVc vc     = new ConstChartVc(m_chartBody);
                vc.LineChoices = m_chartBody.LineChoices;
                DiscourseExporter exporter = new DiscourseExporter(m_inMemoryCache.Cache, writer, m_chart.Hvo,
                                                                   vc, m_inMemoryCache.Cache.DefaultAnalWs);
                writer.WriteStartDocument();
                writer.WriteStartElement("document");
                exporter.ExportDisplay();
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();                 // Close makes it unuseable
                stream.Position = 0;
                StreamReader reader = new StreamReader(stream, Encoding.UTF8);
                string       result = reader.ReadToEnd();
                XmlDocument  doc    = new XmlDocument();
                doc.LoadXml(result);
                XmlNode docNode = doc.DocumentElement;
                Assert.AreEqual("document", docNode.Name);
                XmlNode chartNode = VerifyNode("chart", docNode, 0, "chart", 7, 0);
                VerifyTitleRow(chartNode);
                VerifyTitle2Row(chartNode);
                VerifyFirstDataRow(chartNode);
                VerifySecondDataRow(chartNode);
                XmlNode thirdRow = VerifyNode("row", chartNode, 4, "row", 8, 3);
                AssertAttr(thirdRow, "endSent", "true");
                XmlNode fourthRow = VerifyNode("row", chartNode, 5, "row", 8, 3);
                AssertAttr(fourthRow, "endPara", "true");


                XmlNode langNode = VerifyNode("languages", docNode, 1, "languages", 2, 0);
                XmlNode enNode   = VerifyNode("english lang node", langNode, 0, "language", 0, 2);
                AssertAttr(enNode, "lang", "en");
                AssertAttr(enNode, "font", null);                 // don't verify exact font, may depend on installation.
            }
        }
示例#11
0
        public override void AddStringAltMember(int tag, int ws, IVwViewConstructor _vwvc)
        {
            if (tag == (int)WfiWordform.WfiWordformTags.kflidForm)
            {
                if (m_frags.Contains(ConstChartVc.kfragCcaMoved))
                {
                    WriteStringProp(tag, "word", ws, "moved", "true");
                }
                else
                {
                    WriteStringProp(tag, "word", ws);
                }
            }
            else if (tag == (int)WfiGloss.WfiGlossTags.kflidForm)
            {
                m_wsGloss = ws;
                string val = m_sda.get_MultiStringAlt(m_hvoCurr, tag, ws).Text;
                if (val == null)
                {
                    val = "";
                }
                m_glossesInCellCollector.Add(val);
            }
            else if (tag == (int)CmAnnotation.CmAnnotationTags.kflidComment)
            {
                switch (m_frags[m_frags.Count - 1])
                {
                case ConstChartVc.kfragCca:
                    if (m_cache.GetVectorSize(m_hvoCurr,
                                              (int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo) == 0)
                    {
                        WriteStringProp(tag, "lit", ws);                                 // missing marker.
                        break;
                    }
                    int hvoTarget = m_cache.GetVectorItem(m_hvoCurr,
                                                          (int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 0);       // the cca we refer to
                    if (ConstituentChartLogic.HasPreviousMovedItemOnLine(m_chart, hvoTarget))
                    {
                        WriteStringProp(tag, "moveMkr", ws, "targetFirstOnLine", "false");
                    }
                    else
                    {
                        WriteStringProp(tag, "moveMkr", ws);
                    }
                    break;

                case ConstChartVc.kfragComment:
                    WriteStringProp(tag, "clauseMkr", ws, "target", m_sda.get_MultiStringAlt(m_hvoCurr, tag, ws).Text);
                    break;

                case ConstChartVc.kfragChartRow:
                    WriteStringProp(tag, "rownum", ws);
                    break;
                }
            }
            else if (tag == (int)CmPossibility.CmPossibilityTags.kflidAbbreviation)
            {
                // That makes it a list reference
                WriteStringProp(tag, "listRef", ws);
            }
        }