Exemplo n.º 1
0
        public void UsesNextAlternativeWhenMissing()
        {
            MultiTextBase multiTextBase = new MultiTextBase();

            multiTextBase["wsWithNullElement"]  = null;
            multiTextBase["wsWithEmptyElement"] = "";
            multiTextBase["wsWithContent"]      = "hello";
            Assert.AreEqual(String.Empty, multiTextBase.GetExactAlternative("missingWs"));
            Assert.AreEqual(String.Empty, multiTextBase.GetExactAlternative("wsWithEmptyElement"));
            Assert.AreEqual("hello", multiTextBase.GetBestAlternative("missingWs"));
            Assert.AreEqual("hello", multiTextBase.GetBestAlternative("wsWithEmptyElement"));
            Assert.AreEqual("hello*", multiTextBase.GetBestAlternative("wsWithEmptyElement", "*"));
            Assert.AreEqual("hello", multiTextBase.GetBestAlternative("wsWithNullElement"));
            Assert.AreEqual("hello*", multiTextBase.GetBestAlternative("wsWithNullElement", "*"));
            Assert.AreEqual("hello", multiTextBase.GetExactAlternative("wsWithContent"));
            Assert.AreEqual("hello", multiTextBase.GetBestAlternative("wsWithContent"));
            Assert.AreEqual("hello", multiTextBase.GetBestAlternative("wsWithContent", "*"));
        }
Exemplo n.º 2
0
        public void SetAnnotation()
        {
            MultiTextBase multiTextBase = new MultiTextBase();

            multiTextBase.SetAnnotationOfAlternativeIsStarred("zz", true);
            Assert.AreEqual(String.Empty, multiTextBase.GetExactAlternative("zz"));
            Assert.IsTrue(multiTextBase.GetAnnotationOfAlternativeIsStarred("zz"));
            multiTextBase.SetAnnotationOfAlternativeIsStarred("zz", false);
            Assert.IsFalse(multiTextBase.GetAnnotationOfAlternativeIsStarred("zz"));
        }
Exemplo n.º 3
0
        private Control AddTextBox(IWritingSystemDefinition writingSystem, MultiTextBase multiText)
        {
            Control control;

            if (writingSystem.IsVoice)
            {
                if (_serviceProvider == null)
                {
                    //no, better to just omit it.  throw new ConfigurationException("WeSay cannot handle yet audio in this task.");
                    return(null);
                }
                var ap = _serviceProvider.GetService(typeof(AudioPathProvider)) as AudioPathProvider;
                control = new WeSayAudioFieldBox(writingSystem, ap, _serviceProvider.GetService(typeof(Palaso.Reporting.ILogger)) as ILogger);
                control.SuspendLayout();
                ((WeSayAudioFieldBox)control).PlayOnly = (_visibility == CommonEnumerations.VisibilitySetting.ReadOnly);
            }
            else
            {
                IWeSayTextBox box = null;
                if (_serviceProvider != null)
                {
                    box = _serviceProvider.GetService(typeof(IWeSayTextBox)) as IWeSayTextBox;
                }
                else
                {
                    // Shouldn't get to this but just in case.
                    box = new WeSayTextBox();
                }
                box.Init(writingSystem, Name);

                control = (Control)box;
                control.SuspendLayout();
                box.ReadOnly               = (_visibility == CommonEnumerations.VisibilitySetting.ReadOnly);
                box.Multiline              = true;
                box.WordWrap               = true;
                box.MultiParagraph         = _isMultiParagraph;
                box.IsSpellCheckingEnabled = IsSpellCheckingEnabled;
                //box.Enabled = !box.ReadOnly;
                if (!box.ReadOnly && box is WeSayTextBox)
                {
                    Palaso.UI.WindowsForms.Keyboarding.KeyboardController.Register((Control)box);
                }
            }

            _inputBoxes.Add(control);

            string text = multiText.GetExactAlternative(writingSystem.Id);

            if (_isMultiParagraph)            //review... stuff was coming in with just \n, and the text box then didn't show the paragarph marks
            {
                text = text.Replace("\r\n", "\n");
                text = text.Replace("\n", "\r\n");
            }
            control.Name = Name.Replace("-mtc", "") + "_" + writingSystem.Id;
            //for automated tests to find this particular guy
            control.Text = text;

            if (control is IWeSayTextBox)
            {
                var spans = multiText.GetExactAlternativeSpans(writingSystem.Id);
                (control as IWeSayTextBox).Spans = spans;
            }

            control.TextChanged += OnTextOfSomeBoxChanged;
            control.KeyDown     += OnKeyDownInSomeBox;
            control.MouseWheel  += subControl_MouseWheel;

            control.ResumeLayout(false);
            return(control);
        }