protected virtual void OnGhostBindingLayoutNeeded <T>(GhostBinding <T> sender, IList <T> list, int index, MultiTextControl previouslyGhostedControlToReuse, bool doGoToNextField, EventArgs args) where T : PalasoDataObject, new() { DetailList.SuspendLayout(); var position = _detailList.GetCellPosition(sender.ReferenceControl); var rowIndex = position.Row; _previouslyGhostedControlToReuse = previouslyGhostedControlToReuse; PdoToLayout = list[index]; AddWidgetsAfterGhostTrigger(PdoToLayout, sender.ReferenceControl, doGoToNextField); if (GhostRequestedLayout != null) { GhostRequestedLayout(this, new EventArgs()); } DetailList.ResumeLayout(); if (doGoToNextField) { _detailList.MoveInsertionPoint(rowIndex + 1); } else { _detailList.MoveInsertionPoint(rowIndex); } // For Linux/Mono, merely resuming layout and refreshing doesn't work. ForceLayoutAndRefresh(); }
internal int AddWidgets(LexEntry entry, int insertAtRow) { DetailList.SuspendLayout(); Debug.Assert(DetailList.RowCount == 0); Debug.Assert(DetailList.ColumnCount == 3); Debug.Assert(DetailList.RowStyles.Count == 0); FirstRow = 0; int rowCount = 0; Field field = ActiveViewTemplate.GetField(Field.FieldNames.EntryLexicalForm.ToString()); if (field != null && field.GetDoShow(entry.LexicalForm, ShowNormallyHiddenFields)) { Control formControl = MakeBoundControl(entry.LexicalForm, field); DetailList.AddWidgetRow(StringCatalog.Get(field.DisplayName), true, formControl, insertAtRow, false); insertAtRow = DetailList.GetRow(formControl); ++rowCount; } rowCount += AddCustomFields(entry, insertAtRow + rowCount); var rowCountBeforeSenses = rowCount; LastRow = insertAtRow + rowCount; foreach (var lexSense in entry.Senses) { var layouter = new LexSenseLayouter( DetailList, rowCount, ActiveViewTemplate, RecordListManager, _serviceProvider, lexSense ) { ShowNormallyHiddenFields = ShowNormallyHiddenFields, Deletable = _sensesAreDeletable, ShowMinorMeaningLabel = ShowMinorMeaningLabel, ParentLayouter = this }; layouter.DeleteClicked += OnSenseDeleteClicked; rowCount += AddChildrenWidgets(layouter, lexSense, rowCount); ChildLayouts.Add(layouter); } //see: WS-1120 Add option to limit "add meanings" task to the ones that have a semantic domain //also: WS-639 ([email protected]) In Add meanings, don't show extra meaning slots just because a sense was created for the semantic domain var ghostingRule = ActiveViewTemplate.GetGhostingRuleForField(LexEntry.WellKnownProperties.Sense); if (rowCountBeforeSenses == rowCount || ghostingRule.ShowGhost) { AddSenseGhost(entry, rowCount); rowCount++; } DetailList.ResumeLayout(false); return(rowCount); }
internal void OnSenseDeleteClicked(object sender, EventArgs e) { var sendingLayouter = (Layouter)sender; var sense = (LexSense)sendingLayouter.PdoToLayout; IConfirmDelete confirmation = _confirmDeleteFactory(); var deletionStringToLocalize = StringCatalog.Get("This will permanently remove the meaning"); var meaningText = (GlossMeaningField ? sense.Gloss.GetBestAlternative(ActiveViewTemplate.GetDefaultWritingSystemForField(LexSense.WellKnownProperties.Gloss).Id) : sense.Definition.GetBestAlternative(ActiveViewTemplate.GetDefaultWritingSystemForField(LexSense.WellKnownProperties.Definition).Id) ); confirmation.Message = String.Format("{0} {1}.", deletionStringToLocalize, meaningText); if (!confirmation.DeleteConfirmed) { return; } DetailList.SuspendLayout(); Entry.Senses.Remove(sense); DetailList.Clear(); //for now just relayout the whole thing as the meaning numbers will change etc. AddWidgets(); DetailList.ResumeLayout(); // For Linux/Mono, merely resuming layout doesn't work -- the display doesn't redraw properly. ForceLayoutAndRefresh(); }
internal override int AddWidgets(PalasoDataObject wsdo, int insertAtRow) { LexExampleSentence example = (LexExampleSentence)wsdo; FirstRow = insertAtRow; DetailList.SuspendLayout(); int rowCount = 0; try { Field field = ActiveViewTemplate.GetField(Field.FieldNames.ExampleSentence.ToString()); if (field != null && field.GetDoShow(example.Sentence, ShowNormallyHiddenFields)) { Control control = MakeBoundControl(example.Sentence, field); DetailList.AddWidgetRow( StringCatalog.Get("~Example", "This is the field containing an example sentence of a sense of a word."), false, control, insertAtRow, false); ++rowCount; insertAtRow = DetailList.GetRow(control); } field = ActiveViewTemplate.GetField(Field.FieldNames.ExampleTranslation.ToString()); if (field != null && field.GetDoShow(example.Translation, ShowNormallyHiddenFields)) { Control entry = MakeBoundControl(example.Translation, field); DetailList.AddWidgetRow( StringCatalog.Get("~Translation", "This is the field for putting in a translation of an example sentence."), false, entry, insertAtRow + rowCount, false); ++rowCount; } rowCount += AddCustomFields(example, insertAtRow + rowCount); } catch (ConfigurationException e) { ErrorReport.NotifyUserOfProblem(e.Message); } DetailList.ResumeLayout(false); LastRow = insertAtRow + rowCount - 1; // want index of last row owned, not a limit value return(rowCount); }
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); }
protected int MakeGhostWidget <T>(PalasoDataObject parent, IList <T> list, string fieldName, string label, string propertyName, bool isHeading, int row) where T : PalasoDataObject, new() { Field field = ActiveViewTemplate.GetField(fieldName); if (field != null && field.Enabled && field.Visibility == CommonEnumerations.VisibilitySetting.Visible) { DetailList.SuspendLayout(); MultiTextControl m = new MultiTextControl(field.WritingSystemIds, new MultiText(), fieldName + "_ghost", false, BasilProject.Project.WritingSystems, field.Visibility, field.IsSpellCheckingEnabled, false, _serviceProvider); if (_columnWidths != null && _columnWidths.Length == 3) { m.Width = _columnWidths[1]; } Control refWidget = DetailList.AddWidgetRow(label, isHeading, m, row, true); foreach (IControlThatKnowsWritingSystem box in m.TextBoxes) { var tb = box as IWeSayTextBox; if (tb != null) { GhostBinding <T> g = MakeGhostBinding(parent, list, propertyName, box.WritingSystem, tb); g.ReferenceControl = refWidget; } } DetailList.ResumeLayout(false); return(1); } else { return(0); //didn't add a row } }
private void InitializeDetailList() { _scrollableContainer.SuspendLayout(); _detailListControl = new DetailList(); _detailListControl.SuspendLayout(); _detailListControl.BackColor = BackColor; _detailListControl.Name = "LexEntryDetailList"; _detailListControl.TabIndex = 1; _detailListControl.Size = new Size(_scrollableContainer.ClientRectangle.Width - 20, _detailListControl.Height); _detailListControl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; _detailListControl.SizeChanged += OnScrollableContainerOrDetailListSizeChanged; _detailListControl.AutoSize = true; _detailListControl.ChangeOfWhichItemIsInFocus += OnChangeOfWhichItemIsInFocus; _detailListControl.KeyDown += _detailListControl_KeyDown; _detailListControl.MouseWheel += OnDetailListMouseWheel; _detailListControl.GeckoOption = WeSayWordsProject.GeckoOption; _scrollableContainer.AutoScroll = true; _scrollableContainer.Controls.Add(_detailListControl); _detailListControl.ResumeLayout(false); _scrollableContainer.ResumeLayout(false); }
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); }