Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        private void FixDeleteButtonPosition()
        {
            var position = DetailList.GetCellPosition(_deleteButton);

            if (position.Row != FirstRow)
            {
                DetailList.SetCellPosition(_deleteButton, new TableLayoutPanelCellPosition(2, FirstRow));
            }
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        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);
        }