private void AddExampleSentenceGhost(LexSense sense, int insertAtRow) { DetailList.SuspendLayout(); var exampleLayouter = new LexExampleSentenceLayouter(DetailList, insertAtRow, ActiveViewTemplate, _serviceProvider, null) { ParentLayouter = this }; exampleLayouter.AddGhost(null, sense.ExampleSentences, insertAtRow); ChildLayouts.Add(exampleLayouter); DetailList.ResumeLayout(false); }
/// <summary> /// Create a new LexExampleSentenceLayouter for a new LexExampleSentence created from a ghost, /// and insert it at the right place in the Layouter tree. /// </summary> protected override Layouter CreateAndInsertNewLayouter(int row, PalasoDataObject wsdo) { var newLayouter = new LexExampleSentenceLayouter(DetailList, row, ActiveViewTemplate, _serviceProvider, wsdo as LexExampleSentence) { ShowNormallyHiddenFields = ShowNormallyHiddenFields, Deletable = false, ParentLayouter = ParentLayouter }; var idx = ParentLayouter.ChildLayouts.IndexOf(this); if (idx >= 0) { ParentLayouter.ChildLayouts.Insert(idx, newLayouter); } else { ParentLayouter.ChildLayouts.Add(newLayouter); } return(newLayouter); }
internal override int AddWidgets(PalasoDataObject wsdo, int insertAtRow) { LexSense sense = (LexSense)wsdo; FirstRow = insertAtRow; int rowCount = 0; DetailList.SuspendLayout(); try { #if GlossMeaning Field field = ActiveViewTemplate.GetField(Field.FieldNames.SenseGloss.ToString()); if (field != null && field.GetDoShow(sense.Gloss, this.ShowNormallyHiddenFields)) { Control meaningControl = MakeBoundControl(sense.Gloss, field); #else Field field = ActiveViewTemplate.GetField(LexSense.WellKnownProperties.Definition); if (field != null && field.GetDoShow(sense.Definition, ShowNormallyHiddenFields)) { Control meaningControl = MakeBoundControl(sense.Definition, field); #endif //NB: http://jira.palaso.org/issues/browse/WS-33937 describes how this makes it hard to change this in English (but not other languages) string label = StringCatalog.Get("~Meaning"); LexEntry entry = sense.Parent as LexEntry; if (entry != null) // && entry.Senses.Count > 1) { label += " " + (entry.Senses.IndexOf(sense) + 1); } DetailList.AddWidgetRow(label, true, meaningControl, insertAtRow, false); rowCount++; } rowCount += AddCustomFields(sense, insertAtRow + rowCount); foreach (var lexExampleSentence in sense.ExampleSentences) { var exampleLayouter = new LexExampleSentenceLayouter(DetailList, rowCount, ActiveViewTemplate, _serviceProvider, lexExampleSentence) { ShowNormallyHiddenFields = ShowNormallyHiddenFields, Deletable = false, ParentLayouter = this }; rowCount += AddChildrenWidgets(exampleLayouter, lexExampleSentence, insertAtRow + rowCount); ChildLayouts.Add(exampleLayouter); } //add a ghost for another example if we don't have one or we're in the "show all" mode //removed because of its effect on the Add Examples task, where //we'd like to be able to add more than one //if (ShowNormallyHiddenFields || sense.ExampleSentences.Count == 0) { AddExampleSentenceGhost(sense, insertAtRow + rowCount); rowCount++; } LastRow = insertAtRow + rowCount - 1; // want index of last row owned, not a limit FixDeleteButtonPosition(); } catch (ConfigurationException e) { ErrorReport.NotifyUserOfProblem(e.Message); } DetailList.ResumeLayout(false); return(rowCount); }
internal override int AddWidgets(WeSayDataObject wsdo, int insertAtRow) { LexSense sense = (LexSense) wsdo; int rowCount = 0; DetailList.SuspendLayout(); try { #if GlossMeaning Field field = ActiveViewTemplate.GetField(Field.FieldNames.SenseGloss.ToString()); if (field != null && field.GetDoShow(sense.Gloss, this.ShowNormallyHiddenFields)) { Control meaningControl = MakeBoundControl(sense.Gloss, field); #else Field field = ActiveViewTemplate.GetField(LexSense.WellKnownProperties.Definition); if (field != null && field.GetDoShow(sense.Definition, ShowNormallyHiddenFields)) { Control meaningControl = MakeBoundControl(sense.Definition, field); #endif string label = StringCatalog.Get("~Meaning"); LexEntry entry = sense.Parent as LexEntry; if (entry != null) // && entry.Senses.Count > 1) { label += " " + (entry.Senses.IndexOf(sense) + 1); } Control meaningRowControl = DetailList.AddWidgetRow(label, true, meaningControl, insertAtRow, false); ++rowCount; insertAtRow = DetailList.GetRow(meaningRowControl); } //#if GlossMeaning //#else // Field glossfield = ActiveViewTemplate.GetField(Field.FieldNames.SenseGloss.ToString()); // if (glossfield != null && glossfield.GetDoShow(sense.Gloss, this.ShowNormallyHiddenFields)) // { // Control control = MakeBoundControl(sense.Gloss, glossfield); // DetailList.AddWidgetRow( // StringCatalog.Get("~Gloss", // "This is the field that normally has just a single word translation, not a full definition. Mostly used with interlinear text displays."), // false, // control, insertAtRow + rowCount, false); // ++rowCount; // insertAtRow = DetailList.GetRow(control); // } //#endif rowCount += AddCustomFields(sense, insertAtRow + rowCount); LexExampleSentenceLayouter exampleLayouter = new LexExampleSentenceLayouter(DetailList, ActiveViewTemplate); exampleLayouter.ShowNormallyHiddenFields = ShowNormallyHiddenFields; rowCount = AddChildrenWidgets(exampleLayouter, sense.ExampleSentences, insertAtRow, rowCount); //add a ghost for another example if we don't have one or we're in the "show all" mode //removed because of its effect on the Add Examples task, where //we'd like to be able to add more than one //if (ShowNormallyHiddenFields || sense.ExampleSentences.Count == 0) { rowCount += exampleLayouter.AddGhost(sense.ExampleSentences, insertAtRow + rowCount); } } catch (ConfigurationException e) { ErrorReport.ReportNonFatalMessage(e.Message); } DetailList.ResumeLayout(); return rowCount; }