Example #1
0
        private void OnEmptyObjectsRemoved(object sender, EventArgs e)
        {
            VerifyNotDisposed();
            //find out where our current focus is and attempt to return to that place
            int?row = null;

            if (_detailListControl.ContainsFocus)
            {
                Control focussedControl = _detailListControl.FocussedImmediateChild;
                if (focussedControl != null)
                {
                    row = _detailListControl.GetRow(focussedControl);
                }
            }
            Logger.WriteMinorEvent("OnEmptyObjectsRemoved: b4 RefreshEntryDetial");
            RefreshEntryDetail();
            Logger.WriteMinorEvent("OnEmptyObjectsRemoved: b4  Application.DoEvents()");
            Application.DoEvents();
            //TODO: We need to remove this.  It's a dangerous thing in a historically buggy spot
            Logger.WriteMinorEvent("OnEmptyObjectsRemoved: b4 MoveInsertionPoint");
            if (row != null)
            {
                row = Math.Min((int)row, _detailListControl.RowCount - 1);
                Debug.Assert(row > -1, "You've reproduced bug ws-511!");
                // bug WS-511, which we haven't yet been able to reproduce
                row = Math.Max((int)row, 0);                  //would get around bug WS-511
                _detailListControl.MoveInsertionPoint((int)row);
            }
            Logger.WriteMinorEvent("OnEmptyObjectsRemoved end");
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        public void RowOrder()
        {
            Control rowOne = AddRow();
            Control rowTwo = AddRow();

            Assert.AreEqual(0, _control.GetRow(rowOne));
            Assert.AreEqual(1, _control.GetRow(rowTwo));

            //insert one in between
            Control rowOneHalf = AddRow(1);

            Assert.AreEqual(0, _control.GetRow(rowOne));
            Assert.AreEqual(1, _control.GetRow(rowOneHalf));
            Assert.AreEqual(2, _control.GetRow(rowTwo));

            //stick one at the end
            Control rowLast = AddRow(-1);

            Assert.AreEqual(0, _control.GetRow(rowOne));
            Assert.AreEqual(1, _control.GetRow(rowOneHalf));
            Assert.AreEqual(2, _control.GetRow(rowTwo));
            Assert.AreEqual(3, _control.GetRow(rowLast));

            //insert one before all of the others
            Control rowFirst = AddRow(0);

            Assert.AreEqual(0, _control.GetRow(rowFirst));
            Assert.AreEqual(1, _control.GetRow(rowOne));
            Assert.AreEqual(2, _control.GetRow(rowOneHalf));
            Assert.AreEqual(3, _control.GetRow(rowTwo));
            Assert.AreEqual(4, _control.GetRow(rowLast));
        }
Example #5
0
        private int AddOneCustomField(PalasoDataObject target,
                                      Field customField,
                                      int insertAtRow,
                                      int rowCount)
        {
            IReportEmptiness data = target.GetProperty <IReportEmptiness>(customField.FieldName);

            if (!customField.GetDoShow(data, ShowNormallyHiddenFields))
            {
                return(rowCount);
            }
            Control box;

            switch (customField.DataTypeName)
            {
            case "Picture":
                box = MakePictureWidget(target, customField, _detailList);
                if (box == null)
                {
                    return(rowCount);                            // other code does the user notification
                }
                break;

            case "Flag":
                box = MakeCheckBoxWidget(target, customField);
                break;

            case "Option":
                box = MakeOptionWidget(target, customField);
                break;

            case "OptionCollection":
                box = MakeOptionCollectionWidget(target, customField);
                break;

            case "MultiText":
                box =
                    MakeBoundControl(
                        target.GetOrCreateProperty <MultiText>(customField.FieldName),
                        customField);
                break;

            default:
                LexRelationType lexRelType = GetRelationType(customField.DataTypeName);
                if (lexRelType != null)
                {
                    box = MakeRelationWidget(target, lexRelType, customField);
                }
                else
                {
                    throw new ApplicationException(
                              string.Format("WeSay doesn't understand how to layout a {0}",
                                            customField.DataTypeName));
                }
                break;
            }

            string label = StringCatalog.Get(customField.DisplayName);

            //for checkboxes, the label is part of the control
            if (customField.DataTypeName == "Flag")
            {
                label = string.Empty;
            }

            Control c = DetailList.AddWidgetRow(StringCatalog.Get(label),
                                                false,
                                                box,
                                                insertAtRow,
                                                false);

            DetailList.GetRow(c);
            ++rowCount;
            return(rowCount);
        }