Example #1
0
        private void ShaderTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (IntellisenseInvokedCommand == null)
            {
                return;
            }
            var startPoiter = this.CaretPosition;
            var endPoiter   = startPoiter.GetPositionAtOffset(1);

            var    i            = (int)e.Key;
            var    t            = IntellisenseTypes.Dot;
            string variableName = null;

            if (Keyboard.Modifiers != ModifierKeys.None)
            {
                return;
            }

            if (e.Key == Key.OemPeriod)
            {
                t = IntellisenseTypes.Dot;
                var docstart = startPoiter.DocumentStart;
                var offset   = startPoiter.DocumentStart.GetOffsetToPosition(startPoiter);
                variableName = docstart.GetPositionAtOffset(offset - 1).GetVariableName();
            }
            else if (44 <= i && 69 >= i)
            {
                t            = IntellisenseTypes.AutoComplete;
                variableName = startPoiter.GetVariableName();
                endPoiter    = startPoiter;
            }

            if (string.IsNullOrWhiteSpace(variableName))
            {
                return;
            }

            var pr = IntellisensePopup.Build(this, endPoiter, new TextPoiterChanged {
                EndPointer = startPoiter, StartPointer = endPoiter
            });

            pr.Type          = t;
            pr.VariableName  = variableName;
            pr.ShaderTextBox = this;

            IntellisenseInvokedCommand.RiseCommand(pr);
            e.Handled = true;
        }
Example #2
0
        private void ShaderTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (IntellisenseInvokedCommand == null)
            {
                return;
            }
            var startPoiter = this.CaretPosition;
            var name        = startPoiter.GetVariableName();
            var endPoiter   = startPoiter.GetPositionAtOffset(1);
            var pr          = IntellisensePopup.Build(this, endPoiter, new TextPoiterChanged {
                EndPointer = startPoiter, StartPointer = endPoiter
            });

            pr.VariableName = name;

            if (e.Key == Key.OemPeriod)
            {
                pr.Type = IntellisenseTypes.Dot;
                IntellisenseInvokedCommand.RiseCommand(pr);
                e.Handled = true;
            }
        }