private void FixDeleteButtonPosition() { var position = DetailList.GetCellPosition(_deleteButton); if (position.Row != FirstRow) { DetailList.SetCellPosition(_deleteButton, new TableLayoutPanelCellPosition(2, FirstRow)); } }
internal override int AddWidgets(PalasoDataObject wsdo, int insertAtRow) { LexSense sense = (LexSense)wsdo; FirstRow = insertAtRow; int rowCount = 0; DetailList.SuspendLayout(); try { Field field = null; Control meaningControl = null; string minorLabel; if (GlossMeaningField) { minorLabel = StringCatalog.Get("~Gloss"); field = ActiveViewTemplate.GetField(LexSense.WellKnownProperties.Gloss); if (field != null && field.GetDoShow(sense.Gloss, this.ShowNormallyHiddenFields)) { meaningControl = MakeBoundControl(sense.Gloss, field); } } else { minorLabel = StringCatalog.Get("~Definition"); field = ActiveViewTemplate.GetField(LexSense.WellKnownProperties.Definition); if (field != null && field.GetDoShow(sense.Definition, this.ShowNormallyHiddenFields)) { meaningControl = MakeBoundControl(sense.Definition, field); } } if (meaningControl != null) { //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); } if (ShowMinorMeaningLabel) { string[] labels = new string[] { label, minorLabel }; DetailList.AddWidgetRow(labels, true, meaningControl, insertAtRow, false); rowCount += 2; } else { 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 var position = DetailList.GetCellPosition(_deleteButton); if (position.Row != FirstRow + (ShowMinorMeaningLabel ? 1 : 0)) { DetailList.SetCellPosition(_deleteButton, new TableLayoutPanelCellPosition(2, FirstRow + (ShowMinorMeaningLabel ? 1 : 0))); } } catch (ConfigurationException e) { ErrorReport.NotifyUserOfProblem(e.Message); } DetailList.ResumeLayout(false); return(rowCount); }