Beispiel #1
0
        public ExpressionTextBox(ISharedViewState sharedViewState, IFunctionsDetails functionsDetails)
        {
            _sharedViewState  = sharedViewState;
            _functionsDetails = functionsDetails;
            KeyPress         += ExpressionTextBox_KeyPress;
            _autocompleteMenu = new AutocompleteMenu.AutocompleteMenu(_sharedViewState, _functionsDetails);
            _autocompleteMenu.SetAutocompleteMenu(this, _autocompleteMenu);

            GotFocus         += ExpressionTextBox_GotFocus;
            MouseDoubleClick += Control_MouseDoubleClick;
            SetFont(Settings.Default.ExpressionFont);
            SizeChanged +=
                (o, e) =>
            {
                _autocompleteMenu.MaximumSize = new Size(Size.Width, _autocompleteMenu.MaximumSize.Height);
            };

            Settings.Default.PropertyChanged += (o, e) =>
            {
                switch (e.PropertyName)
                {
                case nameof(Settings.Default.FunctionsOrder):
                    RefreshAutoComplete();
                    break;

                case nameof(Settings.Default.ExpressionFont):
                    SetFont(Settings.Default.ExpressionFont);
                    break;
                }
            };

            if (!DesignMode)
            {
                RefreshAutoComplete();
                _sharedViewState.PropertyChanged += (o, e) =>
                {
                    if (e.PropertyName == nameof(SharedViewState.IsExponent))
                    {
                        _showCaret();
                    }
                };
            }
        }