public void MergeWithNext(GlossingControl control) { for (int i = 0; i < flowLayoutPanel.Controls.Count; i++) { GlossingControl aGC = (GlossingControl)flowLayoutPanel.Controls[i]; if (aGC == control) { // add the contents of this one to the next one GlossingControl theNextGC = (GlossingControl)flowLayoutPanel.Controls[i + 1]; theNextGC.SourceWord = String.Format("{0} {1}", control.SourceWord, theNextGC.SourceWord); theNextGC.TargetWord = String.Format("{0} {1}", control.TargetWord, theNextGC.TargetWord); flowLayoutPanel.Controls.Remove(aGC); theNextGC.Focus(); break; } } }
public GlossingForm(ProjectSettings proj, string strSentence, GlossType eGlossType) { InitializeComponent(); m_aEC = InitLookupAdapter(proj, eGlossType); ProjectSettings.LanguageInfo liSource; ProjectSettings.LanguageInfo liTarget; switch (eGlossType) { case GlossType.eVernacularToNational: liSource = proj.Vernacular; liTarget = proj.NationalBT; break; case GlossType.eVernacularToEnglish: // the glossing KB for the Vern to Natl project liSource = proj.Vernacular; liTarget = proj.InternationalBT; break; case GlossType.eNationalToEnglish: liSource = proj.NationalBT; liTarget = proj.InternationalBT; break; default: System.Diagnostics.Debug.Assert(false); throw new ApplicationException("Wrong glossing type specified. Send to [email protected] for help"); } // get the EncConverter to break apart the given sentence into bundles m_aEC.SplitAndConvert(strSentence, out SourceWords, out StringsInBetween, out TargetWords); if (SourceWords.Count == 0) { throw new ApplicationException("No sentence to gloss!"); } if (liSource.IsRTL) { flowLayoutPanel.FlowDirection = FlowDirection.RightToLeft; } System.Diagnostics.Debug.Assert(SourceWords.Count == TargetWords.Count); for (int i = 0; i < SourceWords.Count; i++) { GlossingControl gc = new GlossingControl(this, liSource, SourceWords[i], liTarget, TargetWords[i], StringsInBetween[i + 1]); // Bill Martin says that glossing KBs can't have Map greater than 1. if (eGlossType == GlossType.eVernacularToEnglish) { gc.DisableButton(); } flowLayoutPanel.Controls.Add(gc); } // disable the button on the last one ((GlossingControl)flowLayoutPanel.Controls[flowLayoutPanel.Controls.Count - 1]).DisableButton(); }