Exemplo n.º 1
0
        public GhostBinding(PalasoDataObject parent,
                            IList <T> targetList,
                            string propertyName,
                            IWritingSystemDefinition writingSystem,
                            IWeSayTextBox textBoxTarget)
        {
            _parent     = parent;
            _listTarget = targetList;
            //           _listTarget.ListChanged +=new ListChangedEventHandler(_listTarget_ListChanged);
            _propertyName  = propertyName;
            _writingSystem = writingSystem;

            _textBoxTarget          = (Control)textBoxTarget;
            _textBoxTarget.KeyDown += _textBoxTarget_KeyDown;
            // Lost Focus doesn't seem to fire for the GeckoBox so added leaving
            _textBoxTarget.LostFocus       += _textBoxTarget_LostFocus;
            _textBoxTarget.Leave           += _textBoxTarget_LostFocus;
            _textBoxTarget.Enter           += OnTextBoxEntered;
            _textBoxTarget.HandleDestroyed += _textBoxTarget_HandleDestroyed;
            _textBoxTarget.Disposed        += _textBoxTarget_Disposed;
            if (_textBoxTarget is IWeSayTextBox)
            {
                ((IWeSayTextBox)_textBoxTarget).UserLostFocus += _textBoxTarget_LostFocus;
                ((IWeSayTextBox)_textBoxTarget).UserGotFocus  += OnTextBoxEntered;
            }
        }
Exemplo n.º 2
0
        public void Setup()
        {
            BasilProjectTestHelper.InitializeForTests();
            _writingSystemId = WritingSystemsIdsForTests.AnalysisIdForTest;

            IWritingSystemDefinition writingSystem = WritingSystemDefinition.Parse(_writingSystemId);

            _papaNameWidget       = new WeSayTextBox(writingSystem, null);
            _papaNameWidget.Text  = "John";
            _ghostFirstNameWidget = new WeSayTextBox(writingSystem, null);
            _binding = new GhostBinding <Child>(null,
                                                _papa.Children,
                                                "First",
                                                writingSystem,
                                                _ghostFirstNameWidget);
            _didNotify = false;
            //Window w = new Window("test");
            //VBox box = new VBox();
            //w.Add(box);
            //box.PackStart(_papaNameWidget);
            //box.PackStart(_ghostFirstNameWidget);
            //box.ShowAll();
            //w.ShowAll();
            _papaNameWidget.Show();
            //            while (Gtk.Application.EventsPending())
            //            { Gtk.Application.RunIteration(); }

            //Application.Run();
            _papaNameWidget.Focus();
            _ghostFirstNameWidget.Focus();
        }
Exemplo n.º 3
0
        private static void FocusWithInsertionPointAtEnd(Control c)
        {
            c.Focus();
            IWeSayTextBox tb = c as IWeSayTextBox;

            if (tb != null)
            {
                tb.Select(1000, 0);                 //go to end}
            }
        }
Exemplo n.º 4
0
        protected GhostBinding <T> MakeGhostBinding <T>(PalasoDataObject parent, IList <T> list,
                                                        string ghostPropertyName,
                                                        IWritingSystemDefinition writingSystem,
                                                        IWeSayTextBox entry)
            where T : PalasoDataObject, new()
        {
            GhostBinding <T> binding = new GhostBinding <T>(parent,
                                                            list,
                                                            ghostPropertyName,
                                                            writingSystem,
                                                            entry);

            binding.LayoutNeededAfterMadeReal += OnGhostBindingLayoutNeeded;
            binding.CurrentItemChanged        += _detailList.OnBinding_ChangeOfWhichItemIsInFocus;
            return(binding);
        }
Exemplo n.º 5
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);
        }