public override void Initialize()
		{
			MakeTextAndCcl();
			m_chart = Cache.LangProject.DiscourseDataOA.ChartsOC.Add(new DsConstChart()) as DsConstChart;
			m_ccl.Chart = m_chart;
			//SetupTexts();
		}
예제 #2
0
		public override void Exit()
		{
			m_chart = null;
			m_mockRibbon = null;
			m_logic = null;

			base.Exit();
		}
예제 #3
0
        public override void Exit()
        {
            m_origCell = null;
            m_sentElem = null;
            m_chart    = null;
            m_cclogic  = null;

            base.Exit();
        }
		public override void Exit()
		{
			m_origCell = null;
			m_sentElem = null;
			m_chart = null;
			m_cclogic = null;

			base.Exit();
		}
예제 #5
0
        internal CmIndirectAnnotation MakeRow(DsConstChart chart, string lineNo)
        {
            CmIndirectAnnotation row = MakeIndirectAnnotation();

            chart.RowsRS.Append(row);
            row.Comment.SetAnalysisDefaultWritingSystem(lineNo);
            row.AnnotationTypeRA = CmAnnotationDefn.ConstituentChartRow(Cache);
            return(row);
        }
예제 #6
0
        int m_wsLineNumber;         // ws to use for line numbers.

        public DiscourseExporter(FdoCache cache, XmlWriter writer, int hvoRoot, IVwViewConstructor vc,
                                 int wsLineNumber)
            : base(null, cache.MainCacheAccessor, hvoRoot)
        {
            m_cache        = cache;
            m_writer       = writer;
            m_vc           = vc;
            m_wsLineNumber = wsLineNumber;
            m_chart        = DsConstChart.CreateFromDBObject(cache, hvoRoot);
        }
예제 #7
0
		public override void Exit()
		{
			m_chart = null;
			m_template = null;
			m_allColumns = null;
			m_mockRibbon = null;
			m_logic = null;
			m_firstParaWfics = null;

			base.Exit();
		}
예제 #8
0
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_firstParaWfics = m_helper.MakeAnnotations(m_firstPara);
			m_logic = new TestCCLogic(Cache, m_chart, m_stText.Hvo);
			m_helper.Logic = m_logic;
			m_logic.Ribbon = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
			m_template = m_helper.MakeTemplate(out m_allColumns);
			// Note: do this AFTER creating the template, which may also create the DiscourseData object.
			m_chart = new DsConstChart();
			Cache.LangProject.DiscourseDataOA.ChartsOC.Add(m_chart);
			m_chart.TemplateRA = m_template;
			m_logic.Chart = m_chart;
			m_helper.MakeDefaultChartMarkers();
			m_helper.Chart = m_chart;
		}
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_cclogic = new TestCCLogic(Cache, m_chart, m_stText.Hvo);
			m_helper.Logic = m_cclogic;
			m_template = m_helper.MakeTemplate(out m_allColumns);
			// Note: do this AFTER creating the template, which may also create the DiscourseData object.
			m_chart = new DsConstChart();
			Cache.LangProject.DiscourseDataOA.ChartsOC.Add(m_chart);
			m_chart.TemplateRA = m_template;
			m_cclogic.Chart = m_chart;
			m_cclogic.Ribbon = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
			m_helper.Chart = m_chart;
			m_origCell = null; // Test must fill in the ClickedCell in the CChartSentenceElements object
			m_eligCols = m_allColumns.ToArray(); // CChartSentenceElements always starts with all columns
			m_eligRows = null; // Test must fill in EligibleRows in the CChartSentenceElements object
			m_sentElem = new CChartSentenceElements(m_origCell, m_eligRows, m_eligCols);
			m_dlgLogicPrepose = new AdvancedMTDialogLogic(Cache, true, m_sentElem);
			m_dlgLogicPostpose = new AdvancedMTDialogLogic(Cache, false, m_sentElem); // create one each direction; test both
		}
예제 #10
0
 protected override void CreateTestData()
 {
     base.CreateTestData();
     m_cclogic      = new TestCCLogic(Cache, m_chart, m_stText.Hvo);
     m_helper.Logic = m_cclogic;
     m_template     = m_helper.MakeTemplate(out m_allColumns);
     // Note: do this AFTER creating the template, which may also create the DiscourseData object.
     m_chart = new DsConstChart();
     Cache.LangProject.DiscourseDataOA.ChartsOC.Add(m_chart);
     m_chart.TemplateRA = m_template;
     m_cclogic.Chart    = m_chart;
     m_cclogic.Ribbon   = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
     m_helper.Chart     = m_chart;
     m_origCell         = null;                   // Test must fill in the ClickedCell in the CChartSentenceElements object
     m_eligCols         = m_allColumns.ToArray(); // CChartSentenceElements always starts with all columns
     m_eligRows         = null;                   // Test must fill in EligibleRows in the CChartSentenceElements object
     m_sentElem         = new CChartSentenceElements(m_origCell, m_eligRows, m_eligCols);
     m_dlgLogicPrepose  = new AdvancedMTDialogLogic(Cache, true, m_sentElem);
     m_dlgLogicPostpose = new AdvancedMTDialogLogic(Cache, false, m_sentElem);             // create one each direction; test both
 }
예제 #11
0
		protected void CreateTestData()
		{
			using (new UndoRedoTaskHelper(Cache, "Undo LogicTest - CreateTestData", "Redo LogicTest - CreateTestData"))
			{
				m_helper = new DiscourseTestHelper(Cache);
				m_firstPara = m_helper.FirstPara;
				m_stText = m_firstPara.Owner as StText;
				m_firstParaWfics = m_helper.MakeAnnotations(m_firstPara);
				m_logic = new TestCCLogic(Cache, m_chart, m_stText.Hvo);
				m_helper.Logic = m_logic;
				m_logic.Ribbon = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
				m_template = m_helper.MakeTemplate(out m_allColumns);
				// Note: do this AFTER creating the template, which may also create the DiscourseData object.
				m_chart = new DsConstChart();
				Cache.LangProject.DiscourseDataOA.ChartsOC.Add(m_chart);
				m_chart.TemplateRA = m_template;
				m_logic.Chart = m_chart;
				m_helper.Chart = m_chart;
			}
		}
예제 #12
0
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_firstParaWfics = m_helper.MakeAnnotations(m_firstPara);
			m_logic = new TestCCLogic(Cache, m_chart, m_stText.Hvo); // m_chart is still null!
			m_helper.Logic = m_logic;
			m_logic.Ribbon = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
			m_template = m_helper.MakeTemplate(out m_allColumns);
			// Note: do this AFTER creating the template, which may also create the DiscourseData object.
			m_chart = new DsConstChart();
			Cache.LangProject.DiscourseDataOA.ChartsOC.Add(m_chart);
			m_chart.TemplateRA = m_template;
			m_logic.Chart = m_chart;
			m_helper.MakeDefaultChartMarkers();
			m_helper.Chart = m_chart;

			m_constChart = new ConstituentChart(Cache, m_logic);
			m_constChart.Init(null, null);
			m_chartBody = m_constChart.Body;
			m_chartBody.Cache = Cache; // don't know why constructor doesn't do this, but it doesn't.
			m_chartBody.SetRoot(m_chart.Hvo, m_allColumns.ToArray());
		}
예제 #13
0
        protected override void CreateTestData()
        {
            base.CreateTestData();
            m_firstParaWfics = m_helper.MakeAnnotations(m_firstPara);
            m_logic          = new TestCCLogic(Cache, m_chart, m_stText.Hvo);    // m_chart is still null!
            m_helper.Logic   = m_logic;
            m_logic.Ribbon   = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
            m_template       = m_helper.MakeTemplate(out m_allColumns);
            // Note: do this AFTER creating the template, which may also create the DiscourseData object.
            m_chart = new DsConstChart();
            Cache.LangProject.DiscourseDataOA.ChartsOC.Add(m_chart);
            m_chart.TemplateRA = m_template;
            m_logic.Chart      = m_chart;
            m_helper.MakeDefaultChartMarkers();
            m_helper.Chart = m_chart;

            m_constChart = new ConstituentChart(Cache, m_logic);
            m_constChart.Init(null, null);
            m_chartBody       = m_constChart.Body;
            m_chartBody.Cache = Cache;             // don't know why constructor doesn't do this, but it doesn't.
            m_chartBody.SetRoot(m_chart.Hvo, m_allColumns.ToArray());
        }
예제 #14
0
        internal bool m_fRecordBasicEdits        = false;  // set true for logging most low-level operations.

        internal TestCCLogic(FdoCache cache, DsConstChart chart, int hvoStText)
            : base(cache, chart, hvoStText)
        {
        }
예제 #15
0
		internal CmIndirectAnnotation MakeRow(DsConstChart chart, string lineNo)
		{
			CmIndirectAnnotation row = MakeIndirectAnnotation();
			chart.RowsRS.Append(row);
			row.Comment.SetAnalysisDefaultWritingSystem(lineNo);
			row.AnnotationTypeRA = CmAnnotationDefn.ConstituentChartRow(Cache);
			return row;
		}
예제 #16
0
		//void m_buttonRow_Layout(object sender, LayoutEventArgs e)
		//{
		//    int numColWidth;
		//    using (Graphics g = m_buttonRow.CreateGraphics())
		//    {
		//        numColWidth = (int)(m_body.NumColWidth * g.DpiX / 72000);
		//    }
		//    int remainingWidth = m_buttonRow.Width - numColWidth;
		//    int remainingButtons = m_buttonRow.Controls.Count;
		//    if (remainingButtons == 0)
		//        return;
		//    // compute column width
		//    int colWidth = remainingWidth / m_allColumns.Length;
		//    int arrowIconWidth = 10;
		//    int widthBtnContextMenu = arrowIconWidth + 10;
		//    int widthBtnMoveHere = colWidth - widthBtnContextMenu;
		//    int ibutton = 0;
		//    int left = numColWidth;
		//    while (remainingButtons > 0)
		//    {
		//        Control c = m_buttonRow.Controls[ibutton];
		//        int widthBtn = 0;
		//        // MoveHere buttons are even, Context Menu's are odd.
		//        if (remainingButtons % 2 == 0)
		//            widthBtn = widthBtnMoveHere;
		//        else
		//            widthBtn = widthBtnContextMenu;
		//        c.Width = widthBtn;
		//        c.Left = left;
		//        left += widthBtn;
		//        remainingWidth -= widthBtn;
		//        ibutton++;
		//        remainingButtons--;
		//    }
		//}

		/// <summary>
		/// Set the root object. This is called by reflection when the InterlinMaster determines that
		/// the root object has changed.
		/// </summary>
		/// <param name="hvoStText"></param>
		public void SetRoot(int hvoStText)
		{
			int oldTemplateHvo = 0;
			if (m_template != null)
				oldTemplateHvo = m_template.Hvo;
			// does it already have a chart? If not make one.
			m_chart = null; // in case of previous call.
			if (m_cache.LangProject.DiscourseDataOA == null)
			{
				m_template = m_cache.LangProject.GetDefaultChartTemplate();
			}
			string sColName; // Holds column name while setting buttons
			if (hvoStText != 0)
			{
				FdoOwningSequence<ICmPossibility> templates = m_cache.LangProject.DiscourseDataOA.ConstChartTemplOA.PossibilitiesOS;
				if (templates.Count == 0 || templates[0].SubPossibilitiesOS.Count == 0)
				{
					MessageBox.Show(this, DiscourseStrings.ksNoColumns, DiscourseStrings.ksWarning,
						MessageBoxButtons.OK, MessageBoxIcon.Warning);
				}
				if (templates.Count != 1)
				{
					MessageBox.Show(this, DiscourseStrings.ksOnlyOneTemplateAllowed, DiscourseStrings.ksWarning,
						MessageBoxButtons.OK, MessageBoxIcon.Warning);
				}
				// Text should already have been parsed. However, for the ribbon to work right,
				// we need all the annotations to be real.
				MakeAllAnnotationsReal(hvoStText);
				// We need to make or set the chart before calling NextUnusedInput.
				FindAndCleanUpMyChart(hvoStText); // Sets m_chart if it finds one for hvoStText
				if (m_chart == null)
				{
					m_chart = new DsConstChart();
					m_cache.LangProject.DiscourseDataOA.ChartsOC.Add(m_chart);
					m_chart.BasedOnRAHvo = hvoStText;
					// set a template.
					m_chart.TemplateRA = m_cache.LangProject.GetDefaultChartTemplate();
				}
				m_logic.Chart = m_chart;
				int[] unchartedAnnotations = DiscourseDbOps.NextUnusedInput(m_cache, hvoStText, 20, m_chart.Hvo);
				m_cache.VwCacheDaAccessor.CacheVecProp(hvoStText, m_ribbon.AnnotationListId, unchartedAnnotations,
					unchartedAnnotations.Length);
				// Don't need PropChanged here, ribbon will reconsruct. That is safer, since clearing
				// cache may have changed old object count.
				if (m_logic.StTextHvo != 0 && hvoStText != m_logic.StTextHvo)
				{
					EnableAllContextButtons();
					EnableAllMoveHereButtons();
					m_logic.ResetRibbonLimits();
					m_logic.CurrHighlightCells = null; // Should reset highlighting (w/PropChanged)
				}
			}
			m_ribbon.SetRoot(hvoStText);
			if (hvoStText != 0)
			{
				if (m_chart.TemplateRA == null) // LT-8700: if original template is deleted we might need this
					m_chart.TemplateRA = m_cache.LangProject.GetDefaultChartTemplate();
				m_template = m_chart.TemplateRA;
				m_logic.StTextHvo = hvoStText;
				m_allColumns = m_logic.AllColumns(m_chart.TemplateRA).ToArray();
			}
			else
			{
				// no text, so no chart
				m_logic.Chart = null;
				m_logic.StTextHvo = 0;
				m_allColumns = new int[0];
			}
			if (m_template != null && m_template.Hvo != oldTemplateHvo)
			{
				m_fInColWidthChanged = true;
				try
				{
					m_logic.MakeMainHeaderCols(m_headerMainCols);
					if (m_allColumns == null)
						return;
					int ccolsWanted = m_allColumns.Length + ConstituentChartLogic.NumberOfExtraColumns;
					m_columnWidths = new int[ccolsWanted];
					m_columnPositions = new int[ccolsWanted + 1]; // one extra for right of last column
					if (!RestoreColumnWidths())
					{
						SetDefaultColumnWidths();
					}
				}
				finally
				{
					m_fInColWidthChanged = false;
				}
			}
			if (m_chart != null)
			{
				m_body.SetRoot(m_chart.Hvo, m_allColumns);

				// Try to get the bookmark from InterlinMaster, if there are rows in the chart.
				if (m_chart.RowsRS.Count > 0)
				{
					m_bookmark = GetAncestorBookmark(this);
					m_logic.RaiseRibbonChgEvent(); // This will override bookmark if there is a ChOrph to be inserted first.
					if (!m_logic.IsChOrphActive)
					{
						if (m_bookmark != null && m_bookmark.IndexOfParagraph >= 0)
						{
							m_body.SelectAndScrollToBookmark(m_bookmark);
						}
						else if (!m_logic.IsChartComplete)
							ScrollToEndOfChart(); // Hopefully the 'otherwise' will automatically display chart at top.
					}
				} // else = no rows in chart; no selection necessary
			} else
				m_body.SetRoot(0, null);

			// If necessary adjust number of buttons
			if (m_MoveHereButtons.Count != m_allColumns.Length)
			{
				m_buttonRow.SuspendLayout();
				while (m_MoveHereButtons.Count > m_allColumns.Length)
				{
					// Remove MoveHere button
					Button lastButton = m_MoveHereButtons[m_MoveHereButtons.Count - 1];
					lastButton.Click -= new EventHandler(btnMoveHere_Click);
					m_buttonRow.Controls.Remove(lastButton);
					m_MoveHereButtons.Remove(lastButton);

					// Remove Context Menu button
					Button lastBtnContextMenu = m_ContextMenuButtons[m_ContextMenuButtons.Count - 1];
					lastBtnContextMenu.Click -= new EventHandler(btnContextMenu_Click);
					m_buttonRow.Controls.Remove(lastBtnContextMenu);
					m_ContextMenuButtons.Remove(lastBtnContextMenu);
				}
				int btnSpace; // useable pixel length on button

				while (m_MoveHereButtons.Count < m_allColumns.Length)
				{
					// Install MoveHere button
					Button newButton = new Button();
					newButton.Click += new EventHandler(btnMoveHere_Click);
					sColName = m_logic.GetColumnLabel(m_MoveHereButtons.Count);
					m_buttonRow.Controls.Add(newButton);
					// Enhance GordonM: This should deal in pixel length, not character length.
					// And column width needs to be known!
					newButton.Image = SIL.FieldWorks.Resources.ResourceHelper.MoveUpArrowIcon;
					newButton.ImageAlign = ContentAlignment.MiddleRight;

					// useable space is button width less (icon width * 2) because of centering
					btnSpace = newButton.Width - (newButton.Image.Size.Width * 2);
					newButton.TextAlign = ContentAlignment.MiddleCenter;
					newButton.Text = GetBtnName(sColName, btnSpace);

					// Set up the ToolTip text for the Button.
					m_toolTip.SetToolTip(newButton, String.Format(DiscourseStrings.ksMoveHereToolTip, sColName));

					m_MoveHereButtons.Add(newButton);

					// Install context menu button
					Button newBtnContextMenu = new Button();
					newBtnContextMenu.Click += new EventHandler(btnContextMenu_Click);
					newBtnContextMenu.Image = SIL.FieldWorks.Resources.ResourceHelper.ButtonMenuArrowIcon;
					m_buttonRow.Controls.Add(newBtnContextMenu);
					m_ContextMenuButtons.Add(newBtnContextMenu);
				}
				// To handle Refresh problem where buttons aren't set to match ChOrph state,
				// raise Ribbon changed event again here
				m_fContextMenuButtonsEnabled = true; // the newly added buttons will be enabled
				m_logic.RaiseRibbonChgEvent();
				m_buttonRow.ResumeLayout();
			}
			SetHeaderColWidths();
		}
예제 #17
0
		private void FindAndCleanUpMyChart(int hvoStText)
		{
			// Enhance JohnT: could use SQL here and follow backref.
			foreach (DsConstChart chart in m_cache.LangProject.DiscourseDataOA.ChartsOC)
			{
				if (chart.BasedOnRAHvo == hvoStText)
				{
					m_chart = chart;
					CleanupInvalidWfics();
					// Enhance GordonM: Eventually we may have allow > 1 chart per text
					// Then we'll need to take out this break.
					break;
				}
			}
		}
예제 #18
0
		internal bool m_fRecordBasicEdits = false; // set true for logging most low-level operations.

		internal TestCCLogic(FdoCache cache, DsConstChart chart, int hvoStText)
			: base(cache, chart, hvoStText)
		{
		}
예제 #19
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds an empty chart on the specified text.
		/// </summary>
		/// <param name="name">Chart name.</param>
		/// <param name="iText">Chart is BasedOn this text.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public IDsConstChart AddChartToLangProj(string name, IStText iText)
		{
			CheckDisposed();
			Debug.Assert(IsModuleLoaded("Ling"), "Need to load meta data for module Ling first");

			// Add a chart object
			DsConstChart chart = new DsConstChart(Cache, m_cacheBase.NewHvo(DsConstChart.kClassId));

			// Add the DiscourseData object to LangProj
			if (m_lp.DiscourseDataOA == null)
				m_lp.DiscourseDataOA = new DsDiscourseData();

			// Add the chart to the DiscourseData object
			m_cacheBase.AppendToFdoVector(m_lp.DiscourseDataOAHvo,
				(int)DsDiscourseData.DsDiscourseDataTags.kflidCharts, chart.Hvo);

			// Setup the new chart
			m_cacheBase.SetBasicProps(chart.Hvo, m_lp.DiscourseDataOAHvo, (int)DsConstChart.kClassId,
				(int)DsDiscourseData.DsDiscourseDataTags.kflidCharts, 1);
			chart.Name.AnalysisDefaultWritingSystem = name;
			chart.BasedOnRA = iText;

			return chart; // This chart has no template or rows, so far!!
		}