protected virtual void AddWidgetsAfterGhostTrigger(PalasoDataObject wsdo, Control refControl, bool doGoToNextField) { Debug.Assert(!(this is LexEntryLayouter)); _detailList.SuspendLayout(); var position = _detailList.GetCellPosition(refControl); Debug.Assert(position.Row >= 0); var newLayouter = CreateAndInsertNewLayouter(position.Row, wsdo); Debug.Assert(newLayouter != null); // Add the widgets for the real object. Retain the existing ghost widget, which // gets shifted down to follow the row(s) for the real object. int rowCount = newLayouter.AddWidgets(wsdo, position.Row); var newPosition = _detailList.GetCellPosition(refControl); Debug.Assert(position.Row + rowCount == newPosition.Row); FirstRow = LastRow = newPosition.Row; // adjust settings for ghost's layouter (ie, "this") AdjustLayoutRowsAfterGhostTrigger(rowCount); //DumpLayoutRowsForDebugging(); _detailList.ResumeLayout(); }
protected override void AddWidgetsAfterGhostTrigger(PalasoDataObject wsdo, Control refControl, bool doGoToNextField) { DetailList.SuspendLayout(); base.AddWidgetsAfterGhostTrigger(wsdo, refControl, doGoToNextField); // We need to update the label on the ghost slice, either adding a number to the end // or incrementing the number at the end. var position = DetailList.GetCellPosition(refControl); var label = DetailList.GetLabelControlFromRow(position.Row); Debug.Assert(label != null); Match match = Regex.Match(label.Text, @"(^.*) ([0-9]+)$"); int n; // Note that Regex Groups have 1-based indexing. if (match.Success && Int32.TryParse(match.Groups[2].Value, out n)) { label.Text = String.Format("{0} {1}", match.Groups[1].Value, n + 1); } else { label.Text = label.Text + @" 2"; } DetailList.ResumeLayout(); }
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); }