예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
0
파일: Layouter.cs 프로젝트: sillsdev/wesay
        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
            }
        }
예제 #4
0
        public void MoveInsertionPoint()
        {
            ActuallyShowOnScreen();
            _control.AddWidgetRow("blah", false, MakeWiredUpTextBox());
            _control.AddWidgetRow("blah", false, MakeWiredUpTextBox());
            _control.AddWidgetRow("blah", false, MakeWiredUpTextBox());

            _control.MoveInsertionPoint(0);

            Assert.AreSame(_control.GetEditControlFromRow(0), _focussedControl);
            _control.MoveInsertionPoint(1);
            Assert.AreSame(_control.GetEditControlFromRow(1), _focussedControl);
            _control.MoveInsertionPoint(2);
            Assert.AreSame(_control.GetEditControlFromRow(2), _focussedControl);
            _window.Close();
        }
예제 #5
0
파일: Layouter.cs 프로젝트: sillsdev/wesay
        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);
        }
예제 #6
0
        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);
        }