Ejemplo n.º 1
0
        public void GhostField_Trigger_RegressionTest()
        {
            AddInitialEntries();
            ClickAddWord();

            DetailList detailList   = GetDetailList();
            int        initialCount = detailList.RowCount;

            FillInTheGhostMeaning();

            //ghost really did fire
            Assert.IsTrue(detailList.RowCount > initialCount);

            //now do another one
            initialCount = detailList.RowCount;
            MultiTextControl editControl2 = (MultiTextControl)GetEditControl("Meaning 2", true);

            Assert.IsTrue(editControl2.Name.Contains("ghost"));
            editControl2.TextBoxes[0].Focus();
            Application.DoEvents();
            TextBoxTester t2 = new TextBoxTester(editControl2.TextBoxes[0].Name, _window);

            t2.Properties.Text = "bar";
            Application.DoEvents();
            TextBoxTester lxt = new TextBoxTester(GetLexicalFormControlName(), _window);

            lxt.Properties.Focus();
            Application.DoEvents();
            Assert.IsTrue(detailList.RowCount > initialCount);
        }
Ejemplo n.º 2
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.º 3
0
        protected Control MakeBoundControl(MultiText multiTextToBindTo, Field field)
        {
            MultiTextControl m;

            if (_previouslyGhostedControlToReuse == null)
            {
                m = new MultiTextControl(field.WritingSystemIds,
                                         multiTextToBindTo,
                                         field.FieldName,
                                         field.Visibility !=
                                         CommonEnumerations.VisibilitySetting.ReadOnly,
                                         //show annotation
                                         BasilProject.Project.WritingSystems,
                                         field.Visibility,
                                         field.IsSpellCheckingEnabled,
                                         field.IsMultiParagraph,
                                         _serviceProvider);
                if (_columnWidths != null && _columnWidths.Length == 3)
                {
                    m.Width = _columnWidths[1];
                }
            }
            else
            {
                m = _previouslyGhostedControlToReuse;
                _previouslyGhostedControlToReuse = null;
            }
            BindMultiTextControlToField(m, multiTextToBindTo);
            return(m);
        }
Ejemplo n.º 4
0
 public void WordShownInVernacularWithMinorMeaningLabel()
 {
     using (DetailList dl = MakeDetailList(false, true, MakeViewTemplate()))
     {
         MultiTextControl box = (MultiTextControl)dl.GetEditControlFromRow(0);
         Assert.AreEqual("WordInVernacular", box.TextBoxes[0].Text);
     }
 }
Ejemplo n.º 5
0
 private void BindMultiTextControlToField(MultiTextControl control,
                                          INotifyPropertyChanged multiTextToBindTo)
 {
     foreach (Control c in control.TextBoxes)
     {
         TextBinding binding = new TextBinding(multiTextToBindTo, ((IControlThatKnowsWritingSystem)c).WritingSystem.Id, c);
         binding.ChangeOfWhichItemIsInFocus += _detailList.OnBinding_ChangeOfWhichItemIsInFocus;
     }
 }
Ejemplo n.º 6
0
 private void _binding_LayoutNeededAfterMadeReal(object sender,
                                                 IList <Child> list,
                                                 int index,
                                                 MultiTextControl
                                                 previouslyGhostedControlToReuse,
                                                 bool doGoToNextField,
                                                 EventArgs args)
 {
     _didNotify = true;
 }
Ejemplo n.º 7
0
        private void OnSelectedIndexChanged(object sender, EventArgs e)
        {
            if (_listBox.SelectedIndex > -1 &&
                ((Option.OptionDisplayProxy)_listBox.SelectedItem).UnderlyingOption !=
                _currentOption)
            {
                SaveEditsToCurrentItem();
                var proxy = (Option.OptionDisplayProxy)_listBox.SelectedItem;
                splitContainer1.Panel2.Controls.Remove(_nameMultiTextControl);

                _currentOption = proxy.UnderlyingOption;
                var m = new MultiTextControl(
                    _currentField.WritingSystemIds,
                    _currentOption.Name,
                    _currentField.FieldName,
                    false,
                    BasilProject.Project.WritingSystems,
                    CommonEnumerations.VisibilitySetting.Visible,
                    _currentField.IsSpellCheckingEnabled, false,
                    WeSayWordsProject.Project.ServiceLocator
                    );
                m.SizeChanged += OnNameControlSizeChanged;
                m.Bounds       = _nameMultiTextControl.Bounds;
                m.Top          = _nameLabel.Top;
                m.BorderStyle  = BorderStyle.FixedSingle;
                m.Anchor       = _nameMultiTextControl.Anchor;
                m.TextChanged += OnNameChanged;

                _nameMultiTextControl = m;
                splitContainer1.Panel2.Controls.Add(m);

                /* user can't change this anymore. It was confusing to people an probably not needed
                 * _keyText.TextChanged -= OnKeyTextChanged;
                 * _keyText.Text = proxy.UnderlyingOption.Key;
                 * _keyText.TextChanged += OnKeyTextChanged;
                 */

                var justTextBoxes = from z in m.TextBoxes where z is IWeSayTextBox select z;
                foreach (IWeSayTextBox box in justTextBoxes)
                {
                    var binding = new TextBinding(
                        _currentOption.Name,
                        box.WritingSystem.Id,
                        (Control)box
                        );
                    //hooking on to this is more reliable, sequence-wise, than directly wiring to m.TextChanged
                    //JH (2011): Maybe so, but this doesn't fire until they tab away, and that's too late.
                    binding.DataTarget.PropertyChanged += DataTarget_PropertyChanged;
                }
                AdjustLocations();
                UpdateDisplay();
            }
        }
Ejemplo n.º 8
0
        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
            }
        }
Ejemplo n.º 9
0
        private static MultiTextControl GetEditControl(DetailList detailList, string labelText)
        {
            MultiTextControl editControl = null;

            for (int i = 0; i < detailList.RowCount; i++)
            {
                Label label = detailList.GetLabelControlFromRow(i);
                if (label != null && label.Text == labelText)
                {
                    editControl = (MultiTextControl)detailList.GetEditControlFromRow(i);
                    break;
                }
            }
            return(editControl);
        }
Ejemplo n.º 10
0
        private void CustomTextFieldPreservedCore(string fieldLabel)
        {
            MultiTextControl note = GetEditControl(fieldLabel);
            Control          box  = note.TextBoxes[0];

            box.Focus();
            box.Text = "a note";

            Application.DoEvents();
            LexEntry entry = GetCurrentEntry();

            CycleTheCurrentEntryOutAndBackIn(entry);
            Application.DoEvents();
            note = GetEditControl(fieldLabel);
            Assert.AreEqual("a note", note.TextBoxes[0].Text);
        }
Ejemplo n.º 11
0
        private void FillInTheGhostMeaning()
        {
            MultiTextControl editControl = (MultiTextControl)GetEditControl("Meaning", true);

            Assert.IsTrue(GetEditControl("Meaning").Name.Contains("ghost"));
            editControl.TextBoxes[0].Focus();
            TextBoxTester t = new TextBoxTester(editControl.TextBoxes[0].Name, _window);

            //didn''t work  t.FireEvent("KeyPress", new KeyPressEventArgs('a'));
            t.Properties.Text = "foo";
            //move focus away
            Application.DoEvents();
            TextBoxTester lxt = new TextBoxTester(GetLexicalFormControlName(), _window);

            lxt.Properties.Focus();
            Application.DoEvents();
        }
Ejemplo n.º 12
0
 public void EditField_Change_DisplayedInFormattedView()
 {
     using (
         EntryViewControl entryViewControl = CreateFilteredForm(apple,
                                                                Field.FieldNames.
                                                                EntryLexicalForm.
                                                                ToString(),
                                                                "LexEntry",
                                                                WritingSystemsIdsForTests.VernacularIdForTest)
         )
     {
         DetailList       entryDetailControl = entryViewControl.ControlEntryDetail;
         MultiTextControl editControl        =
             (MultiTextControl)entryDetailControl.GetEditControlFromRow(0);
         editControl.TextBoxes[0].Text = "test";
         Assert.IsTrue(entryViewControl.RtfContentsOfPreviewForTests.Contains("test"));
     }
 }
Ejemplo n.º 13
0
        private void PutCursorInMeaningFieldOfSecondEntry()
        {
            //skip to second word (first has extra stuff in the sense)
            ListViewTester t = new ListViewTester("_recordsListBox", _window);

            t.Properties.Focus();
            ((WeSayListView)t.Properties).SelectedIndex = 1;
            Assert.AreEqual("Secondary", LexemeFormOfSelectedEntry);
            Assert.AreEqual(1,
                            GetCurrentEntry().Senses.Count,
                            "this test assumes an entry with 1 sense");
            Assert.AreEqual(0,
                            GetCurrentEntry().Senses[0].ExampleSentences.Count,
                            "this test assumes a sense w/ no example");
            MultiTextControl editControl = GetEditControl("Definition");             // edit control is associated with minor label of Meaning 1

            editControl.TextBoxes[0].Focus();
        }
Ejemplo n.º 14
0
 private void EnsureField_Change_UpdatesSenseMeaning(LexEntry entry)
 {
     using (EntryViewControl entryViewControl = CreateFilteredForm(
                entry,
                _primaryMeaningFieldName,
                "LexSense",
                WritingSystemsIdsForTests.AnalysisIdForTest
                ))
     {
         DetailList entryDetailControl = entryViewControl.ControlEntryDetail;
         Label      labelControl       = entryDetailControl.GetLabelControlFromRow(0);
         Assert.AreEqual("Meaning 1", labelControl.Text);
         MultiTextControl editControl =
             (MultiTextControl)entryDetailControl.GetEditControlFromRow(0);
         editControl.TextBoxes[0].Focus();
         editControl.TextBoxes[0].Text = "test";
         entryDetailControl.GetEditControlFromRow(2).Focus();
         Assert.IsTrue(editControl.TextBoxes[0].Text.Contains(GetMeaning(entry)));
     }
 }
Ejemplo n.º 15
0
        public void EditField_RemoveContents_RemovesSense()
        {
            LexEntry meaningOnly = CreateTestEntry("word", "meaning", "");

            using (EntryViewControl entryViewControl = CreateForm(meaningOnly, true))
            {
                MultiTextControl editControl = GetEditControl(entryViewControl.ControlEntryDetail,
                                                              "Meaning 1");
                editControl.TextBoxes[0].Focus();
                editControl.TextBoxes[0].Text = "";
                entryViewControl.ControlEntryDetail.GetEditControlFromRow(0).Focus();
                Application.DoEvents();
                Thread.Sleep(1000);
                Application.DoEvents();

                Assert.IsTrue(
                    GetEditControl(entryViewControl.ControlEntryDetail, "Meaning").Name.Contains
                        ("ghost"),
                    "Only ghost should remain");
            }
        }
Ejemplo n.º 16
0
        public GatherBySemanticDomainsControl(GatherBySemanticDomainTask presentationModel)
        {
            _presentationModel = presentationModel;
            InitializeComponent();
            this._listViewWords.UserClick += new System.EventHandler(this.OnListViewWords_Click);

#if __MonoCS__
            // The label "(Enter Key)" does not display properly on Linux/Mono.  Part of the string is cut off.
            // This simple setting fixes that problem.  (Don't ask me why!)
            tableLayoutPanel8.AutoSize = false;
#endif
            InitializeDisplaySettings();
            _listViewWords.FormWritingSystem    = _presentationModel.FormWritingSystem;
            _listViewWords.MeaningWritingSystem = _presentationModel.ShowMeaningField ? _presentationModel.MeaningWritingSystem: null;
            _listViewWords.ItemDrawer           = DrawOneAnswerForList;
            _listViewWords.BackColor            = Color.White;
            _listViewWords.DisplayMeaning       = _presentationModel.ShowMeaningField;

            _domainListComboBox.Font          = _presentationModel.GetFontOfSemanticDomainField();
            _domainListComboBox.WritingSystem = _presentationModel.GetSemanticDomainWritingSystem();
            _question.Font = _presentationModel.GetFontOfSemanticDomainField();
            ((IWeSayTextBox)_question).WritingSystem = _presentationModel.GetSemanticDomainWritingSystem();
            ((IWeSayTextBox)_question).Multiline     = true;
            _question.Width = Width - _question.Location.X - 10;
            //we'd like to have monospace, but I don't know for sure which languages these fonts will work
            //this is going to override the normal font choice they've made
            var majorRomanWritingSystems = new List <string>(new[] { "en", "id", "fr" });
            if (majorRomanWritingSystems.Contains(presentationModel.SemanticDomainWritingSystemId))
            {
#if __MonoCS__
                _domainListComboBox.Font = new Font("monospace", _domainListComboBox.Font.Size, FontStyle.Bold);
#else
                _domainListComboBox.Font = new Font("Lucida Console", _domainListComboBox.Font.Size, FontStyle.Bold);
#endif
            }

            if (WeSayWordsProject.GeckoOption)
            {
                _domainListComboBox.Height = _domainListComboBox.Font.Height + 30;
            }

            RefreshCurrentWords();
            LoadDomainListCombo();
            RefreshCurrentDomainAndQuestion();
            bool showDescription = false;
            if (!showDescription)
            {
                _listViewWords.Anchor     |= AnchorStyles.Top;
                _question.Anchor          |= AnchorStyles.Top;
                _question.Anchor          &= ~AnchorStyles.Bottom;
                _reminder.Anchor           = _question.Anchor;
                _questionIndicator.Anchor |= AnchorStyles.Top;
                _questionIndicator.Anchor &= ~AnchorStyles.Bottom;

                int height = _question.Top - _description.Top;
                _question.Top          -= height;
                _question.Height       -= 5;
                _reminder.Top           = _question.Bottom + 5;
                _questionIndicator.Top -= height;
                _listViewWords.Top     -= height;
                _listViewWords.Height  += height;

                _description.Visible = false;
            }

            //they have a border in the design view because otherwise they're hard to find
            _vernacularBox.CellBorderStyle = TableLayoutPanelCellBorderStyle.None;
            _vernacularBox.BackColor       = Color.White;
            _meaningBox.CellBorderStyle    = TableLayoutPanelCellBorderStyle.None;
            _meaningBox.BackColor          = Color.White;

            _vernacularBox.WritingSystemsForThisField = new[]
            {
                _presentationModel.FormWritingSystem
            };

            if (_vernacularBox.WritingSystemsForThisField.Count == 0 || _vernacularBox.TextBoxes.Count == 0)
            {
                Palaso.Reporting.ErrorReport.ReportFatalMessageWithStackTrace(String.Format("This task cannot be used with the audio/voice input system '{0}'. Please use the config tool to specify a non-audio input system for this task.", _presentationModel.FormWritingSystem.Abbreviation));
            }

            //bit of a hack here... we make our own meaning box as a less intrusive way to add spell checking to
            //this box, which wasn't really designed to work well with auto-generated designer code.
            //so all this is to be able to turn IsSpellCheckingEnabled before the box is built.

            var meaning = new MultiTextControl(_presentationModel.ViewTemplate.WritingSystems, WeSayWordsProject.Project.ServiceLocator)
            {
                IsSpellCheckingEnabled     = true,
                ShowAnnotationWidget       = false,
                WritingSystemsForThisField = new[] { _presentationModel.DefinitionWritingSystem },
                Visible      = _presentationModel.ShowMeaningField,
                Anchor       = _meaningBox.Anchor,
                BackColor    = _meaningBox.BackColor,
                AutoSize     = _meaningBox.AutoSize,
                AutoSizeMode = _meaningBox.AutoSizeMode,
                Location     = _meaningBox.Location,
                Size         = _meaningBox.Size,
                TabIndex     = _meaningBox.TabIndex
            };
            meaning.KeyDown += _boxVernacularWord_KeyDown;
            tableLayoutPanel6.Controls.Remove(_meaningBox);
            tableLayoutPanel6.Controls.Add(meaning, 1, 1);
            _meaningBox           = meaning;
            _meaningLabel.Visible = _presentationModel.ShowMeaningField;


            //  _listViewWords.ItemHeight = (int)Math.Ceiling(_presentationModel.FormWritingSystem.Font.GetHeight());

            //    _animatedText.Font = _presentationModel.FormWritingSystem.Font;

            _reminder.Text = _presentationModel.Reminder;
            _reminder.Font = (Font)Palaso.i18n.StringCatalog.LabelFont.Clone();

            _flyingLabel.Font = _vernacularBox.TextBoxes[0].Font;

            _flyingLabel.Finished += _animator_Finished;
        }
Ejemplo n.º 17
0
        private void _binding_LayoutNeededAfterMadeReal(object sender,
														IList<Child> list,
														int index,
														MultiTextControl
																previouslyGhostedControlToReuse,
														bool doGoToNextField,
														EventArgs args)
        {
            _didNotify = true;
        }