/// <summary>
        /// ctor
        /// </summary>
        /// <param name="chosenItems">The set of chosen items we are displaying/editting</param>
        /// <param name="sourceChoices"> The set of objects that the user can choose from. The AutoCompleteAdaptor is used
        /// to convert these into display strings.</param>
        /// <param name="writingSystems">a list of writing systems ordered by preference</param>
        /// <param name="visibility"></param>
        /// <param name="adaptor">does all the conversion between keys, wrappers, actual objects, etc.</param>
        /// <param name="serviceProvider">passed to the AutoCompleteWithCreation so it can get the appropriate type of AutoComplete control</param>
        public ReferenceCollectionEditor(IBindingList chosenItems,
                                         IEnumerable <KV> sourceChoices,
                                         IList <IWritingSystemDefinition> writingSystems,
                                         CommonEnumerations.VisibilitySetting visibility,
                                         IChoiceSystemAdaptor <KV, ValueT, KEY_CONTAINER> adaptor,
                                         IServiceProvider serviceProvider)
        {
            if (chosenItems == null)
            {
                throw new ArgumentException("chosenItems");
            }
            if (adaptor == null)
            {
                throw new ArgumentException("adaptor");
            }
            if (writingSystems == null)
            {
                throw new ArgumentException("writingSystems");
            }
            if (sourceChoices == null)
            {
                throw new ArgumentException("sourceChoices");
            }
            InitializeComponent();

            _chosenItems             = chosenItems;
            _sourceChoices           = sourceChoices;
            _writingSystems          = writingSystems;
            _visibility              = visibility;
            _choiceSystemAdaptor     = adaptor;
            chosenItems.ListChanged += chosenItems_ListChanged;
            BackColorChanged        += OnBackColorChanged;
            _serviceProvider         = serviceProvider;
        }
示例#2
0
        public MultiTextControl(IList <string> writingSystemIds,
                                MultiText multiTextToCopyFormsFrom, string nameForTesting,
                                bool showAnnotationWidget, IWritingSystemRepository allWritingSystems,
                                CommonEnumerations.VisibilitySetting visibility, bool isSpellCheckingEnabled,
                                bool isMultiParagraph, IServiceProvider serviceProvider) : this(allWritingSystems, serviceProvider)
        {
            Name = nameForTesting + "-mtc";
            _writingSystemsForThisField = new List <IWritingSystemDefinition>();
//            foreach (KeyValuePair<string, WritingSystem> pair in allWritingSystems)
//            {
//                if (writingSystemIds.Contains(pair.Key))
//                {
//                    _writingSystemsForThisField.Add(pair.Value);
//                }
//            }
            foreach (var id in writingSystemIds)
            {
                if (allWritingSystems.Contains(id))                 //why wouldn't it?
                {
                    _writingSystemsForThisField.Add(allWritingSystems.Get(id));
                }
            }
            _showAnnotationWidget  = showAnnotationWidget;
            _visibility            = visibility;
            IsSpellCheckingEnabled = isSpellCheckingEnabled;
            _isMultiParagraph      = isMultiParagraph;
            BuildBoxes(multiTextToCopyFormsFrom);
        }
示例#3
0
        public MultiTextControl(IList<string> writingSystemIds,
								MultiText multiTextToCopyFormsFrom,
								string nameForTesting,
								bool showAnnotationWidget,
								WritingSystemCollection allWritingSystems,
								CommonEnumerations.VisibilitySetting visibility,
								bool isSpellCheckingEnabled)
            : this(allWritingSystems)
        {
            Name = nameForTesting + "-mtc";
            _writingSystemsForThisField = new List<WritingSystem>();
            foreach (KeyValuePair<string, WritingSystem> pair in allWritingSystems)
            {
                if (writingSystemIds.Contains(pair.Key))
                {
                    _writingSystemsForThisField.Add(pair.Value);
                }
            }
            _showAnnotationWidget = showAnnotationWidget;
            _visibility = visibility;
            _isSpellCheckingEnabled = isSpellCheckingEnabled;
            BuildBoxes(multiTextToCopyFormsFrom);
        }
        public AutoCompleteWithCreationBox(CommonEnumerations.VisibilitySetting visibility, IServiceProvider serviceProvider)
        {
            _visibility = visibility;
            InitializeComponent();

            if (DesignMode)
            {
                return;
            }

            //
            // _textBox
            //
            this.SuspendLayout();
            if (serviceProvider != null)
            {
                this._textBox = serviceProvider.GetService(typeof(IWeSayAutoCompleteTextBox)) as IWeSayAutoCompleteTextBox;
            }
            else
            {
                // For test cases
                this._textBox = new WeSayAutoCompleteTextBox();
            }

            //this._textBox = new WeSay.UI.AutoCompleteTextBox.WeSayAutoCompleteTextBox();
            this._textBox.BackColor               = System.Drawing.Color.White;
            this._textBox.BorderStyle             = System.Windows.Forms.BorderStyle.None;
            this._textBox.Location                = new System.Drawing.Point(1, 1);
            this._textBox.Multiline               = false;
            this._textBox.MultiParagraph          = false;
            this._textBox.Name                    = "_textBox";
            this._textBox.PopupBorderStyle        = System.Windows.Forms.BorderStyle.FixedSingle;
            this._textBox.PopupOffset             = new System.Drawing.Point(0, 0);
            this._textBox.PopupSelectionBackColor = System.Drawing.SystemColors.Highlight;
            this._textBox.PopupSelectionForeColor = System.Drawing.SystemColors.HighlightText;
            this._textBox.SelectedItem            = null;
            this._textBox.Size                    = new System.Drawing.Size(110, 20);
            this._textBox.TabIndex                = 0;
            this._textBox.TextChanged            += new System.EventHandler(this.box_TextChanged);
            this._textBox.KeyDown                += TextBox_OnKeyDown;
            this.Controls.Add((Control)this._textBox);
            this.ResumeLayout(false);
            this.PerformLayout();

            //todo: what other cases make sense
            if (visibility == CommonEnumerations.VisibilitySetting.ReadOnly)
            {
                _textBox.ReadOnly = true;
                //  _textBox.Enabled = false;
                _textBox.TabStop = false;

                TabStop = false;
            }

            _textBox.SelectedItemChanged += OnSelectedItemChanged;
            GotFocus += OnFocusChanged;
            _textBox.UserGotFocus  += OnFocusChanged;
            LostFocus              += OnFocusChanged;
            _textBox.UserLostFocus += OnFocusChanged;
            AddNewButton.LostFocus += OnFocusChanged;
            BackColorChanged       += OnBackColorChanged;
            UpdateDisplay();
            GetValueFromKeyValue = CastKeyValueToValue;
            GetKeyValueFromValue = CastValueToKeyValue;

            _textBox.SizeChanged += _textBox_SizeChanged;
        }