Inheritance: ScintillaNET.TopLevelHelper
Example #1
0
        /// <summary>
        /// Show the call tip.
        /// </summary>
        /// <param name="tip"></param>
        /// <param name="handlers"></param>
        /// <param name="position"></param>
        /// <param name="hint"></param>
        private void TipShow(ref CallTip tip, ShowTipEventHandler handlers, int position, object hint)
        {
            // create calltip class
            if (tip == null)
            {
                tip        = new CallTip();
                tip.Enter += new EventHandler(tip_MouseEnter);
                tip.SetChartIntervals(10, 0);
                Theme.Apply(tip);
            }

            // get screen position
            var rect = GetWordBounds(position);

            rect.Location = PointToScreen(rect.Location);
            rect.Inflate(3, 3);

            // Fore some reason PointToScreen can return
            // different positions. In this case the call
            // tip needs to be repositioned.
            if (!tip.Visible || tip.Location != rect.Location)
            {
                // invoke event hadlers
                var e = new ShowTipEventHandlerArgs();
                e.TextPosition   = position;
                e.Definition     = hint;
                e.ScreenPosition = rect.Location;
                handlers?.Invoke(this, e);
                if (e.Cancle)
                {
                    return;
                }

                // show calltip
                if (hint is string)
                {
                    tip.Show(rect, (string)hint);
                }
                else if (hint is Array)
                {
                    const int w = 500;
                    var       X = (Array)((Array)hint).GetValue(0);
                    var       Y = (Array)((Array)hint).GetValue(1);
                    tip.Show(rect, X, Y, w, w * 0.6, ContentAlignment.TopLeft, 0.3, 0.3);
                }

                // make sure the calltip window
                // is in front of all others
                tip.BringToFront();
            }
        }
Example #2
0
        /// <summary>
        /// Cancel the call tip.
        /// </summary>
        /// <param name="tip"></param>
        /// <param name="handlers"></param>
        private void TipCancel(CallTip tip, CancleTipEventHandler handlers)
        {
            if (tip == null || !tip.Visible)
            {
                return;
            }

            var e = new CancleTipEventHandlerArgs();

            handlers?.Invoke(this, e);
            if (e.Cancle)
            {
                return;
            }

            tip.Hide();
            OnMouseLeave(null);
        }
Example #3
0
        public Scintilla()
        {
            this._state = new BitVector32(0);
            this._state[_acceptsReturnState] = true;
            this._state[_acceptsTabState] = true;

            _ns = (INativeScintilla)this;

            _caption = GetType().FullName;

            // Set up default encoding to UTF-8 which is the Scintilla's best supported.
            // .NET strings are UTF-16 but should be able to convert without any problems
            this.Encoding = Encoding.UTF8;

            // Ensure all style values have at least defaults
            _ns.StyleClearAll();

            _caret = new CaretInfo(this);
            _lines = new LineCollection(this);
            _selection = new Selection(this);
            _indicators = new IndicatorCollection(this);
            _snippets = new SnippetManager(this);
            _margins = new MarginCollection(this);
            _scrolling = new Scrolling(this);
            _whitespace = new Whitespace(this);
            _endOfLine = new EndOfLine(this);
            _clipboard = new Clipboard(this);
            _undoRedo = new UndoRedo(this);
            _dropMarkers = new DropMarkers(this);
            _hotspotStyle = new HotspotStyle(this);
            _callTip = new CallTip(this);
            _styles = new StyleCollection(this);
            _indentation = new Indentation(this);
            _markers = new MarkerCollection(this);
            _autoComplete = new AutoComplete(this);
            _documentHandler = new DocumentHandler(this);
            _lexing = new Lexing(this);
            _longLines = new LongLines(this);
            _commands = new Commands(this);
            _folding = new Folding(this);
            _configurationManager = new ConfigurationManager(this);
            _printing = new Printing(this);
            _findReplace = new FindReplace(this);
            _documentNavigation = new DocumentNavigation(this);
            _goto = new GoTo(this);

            _helpers.AddRange(new TopLevelHelper[]
            {
                _caret,
                _lines,
                _selection,
                _indicators,
                _snippets,
                _margins,
                _scrolling,
                _whitespace,
                _endOfLine,
                _clipboard,
                _undoRedo,
                _dropMarkers,
                _hotspotStyle,
                _styles,
                _indentation,
                _markers,
                _autoComplete,
                _documentHandler,
                _lexing,
                _longLines,
                _commands,
                _folding,
                _configurationManager,
                _printing,
                _findReplace,
                _documentNavigation,
                _goto
            });

            // Change from Scintilla's default black on white to
            // platform defaults for edit controls.
            base.BackColor = SystemColors.Window;
            base.ForeColor = SystemColors.WindowText;

            Styles[0].Font = Font;
            Styles[0].ForeColor = ForeColor;
            Styles[0].BackColor = BackColor;
            Styles.Default.BackColor = BackColor;
        }
Example #4
0
        public Scintilla()
        {
            // We don't want .NET to use GetWindowText because we manage ('cache') our own text
            SetStyle(ControlStyles.CacheText, true);

            // Necessary control styles (see TextBoxBase)
            SetStyle(ControlStyles.StandardClick
                   | ControlStyles.StandardDoubleClick
                   | ControlStyles.UseTextForAccessibility
                   | ControlStyles.UserPaint,
                   false);

            // It's critical that we initialize helpers that listen for notifications early and
            // in the correct order. They have to be the first to know when notifications occur.
            _lineStorage = new LineStorage(this);
            _stringAdapter = new StringAdapter(this, _lineStorage);

            _state = new BitVector32(0);
            _state[_acceptsReturnState] = true;
            _state[_acceptsTabState] = true;

            _ns = (INativeScintilla)this;

            _caption = GetType().FullName;

            // Most Windows Forms controls delay-load everything until a handle is created.
            // That's a major pain so we just explicity create a handle right away.
            CreateControl();

            // Set up default encoding to UTF-8 which is the Scintilla's best supported.
            // .NET strings are UTF-16 but should be able to convert without any problems
            this.Encoding = Encoding.UTF8;

            // Ensure all style values have at least defaults
            _ns.StyleClearAll();

            _caret = new CaretInfo(this);
            _lines = new LineCollection(this);
            _selection = new Selection(this);
            _snippets = new SnippetManager(this);
            _margins = new MarginCollection(this);
            _whitespace = new Whitespace(this);
            _endOfLine = new EndOfLine(this);
            _clipboard = new Clipboard(this);
            _undoRedo = new UndoRedo(this);
            _dropMarkers = new DropMarkers(this);
            _hotspotStyle = new HotspotStyle(this);
            _callTip = new CallTip(this);
            _styles = new StyleCollection(this);
            _indentation = new Indentation(this);
            _markers = new MarkerCollection(this);
            _autoComplete = new AutoComplete(this);
            _documentHandler = new DocumentHandler(this);
            _lexing = new Lexing(this);
            _longLines = new LongLines(this);
            _commands = new Commands(this);
            _folding = new Folding(this);
            _configurationManager = new ConfigurationManager(this);
            _printing = new Printing(this);
            _findReplace = CreateFindReplaceInstance();
            _documentNavigation = new DocumentNavigation(this);
            _goto = new GoTo(this);


            _helpers.AddRange(new TopLevelHelper[]
            {
                _caret,
                _lines,
                _selection,
                _snippets,
                _margins,
                _whitespace,
                _endOfLine,
                _clipboard,
                _undoRedo,
                _dropMarkers,
                _hotspotStyle,
                _styles,
                _indentation,
                _markers,
                _autoComplete,
                _documentHandler,
                _lexing,
                _longLines,
                _commands,
                _folding,
                _configurationManager,
                _printing,
                _findReplace,
                _documentNavigation,
                _goto
            });


            // Change from Scintilla's default black on white to
            // platform defaults for edit controls.
            base.BackColor = SystemColors.Window;
            base.ForeColor = SystemColors.WindowText;

            Styles[0].Font = Font;
            Styles[0].ForeColor = ForeColor;
            Styles[0].BackColor = BackColor;
            Styles.Default.BackColor = BackColor;

            // Change scrolling defaults
            DirectMessage(NativeMethods.SCI_SETSCROLLWIDTH, new IntPtr(1), IntPtr.Zero);
            DirectMessage(NativeMethods.SCI_SETSCROLLWIDTHTRACKING, new IntPtr(1), IntPtr.Zero);
        }
Example #5
0
        /// <summary>
        /// Cancel the call tip.
        /// </summary>
        /// <param name="tip"></param>
        /// <param name="handlers"></param>
        private void TipCancel(CallTip tip, CancleTipEventHandler handlers)
        {
            if (tip == null || !tip.Visible)
                return;

            var e = new CancleTipEventHandlerArgs();
            handlers?.Invoke(this, e);
            if (e.Cancle)
                return;

            tip.Hide();
        }
Example #6
0
        /// <summary>
        /// Show the call tip.
        /// </summary>
        /// <param name="tip"></param>
        /// <param name="handlers"></param>
        /// <param name="position"></param>
        /// <param name="hint"></param>
        private void TipShow(ref CallTip tip, ShowTipEventHandler handlers, int position, object hint)
        {
            // create calltip class
            if (tip == null)
            {
                tip = new CallTip();
                tip.Enter += new EventHandler(tip_MouseEnter);
                Theme.Apply(tip);
            }

            // get screen position
            var p = PointToScreen(new Point(
                PointXFromPosition(position),
                PointYFromPosition(position)));

            // Fore some reason PointToScreen can return
            // different positions. In this case the call
            // tip needs to be repositioned.
            if (!tip.Visible || tip.Location != p)
            {
                // invoke event hadlers
                var e = new ShowTipEventHandlerArgs();
                e.TextPosition = position;
                e.Definition = hint;
                e.ScreenPosition = p;
                handlers?.Invoke(this, e);
                if (e.Cancle)
                    return;

                // make sure the calltip window
                // is in front of all others
                tip.BringToFront();

                // show calltip
                var rect = GetWordBounds(position);
                rect.Location = PointToScreen(rect.Location);
                if (hint is string)
                    tip.Show(rect, (string)hint);
                else if (hint is Array)
                    tip.Show(rect, (Array)((Array)hint).GetValue(0), (Array)((Array)hint).GetValue(1));
            }
        }
Example #7
0
 private bool ShouldSerializeCallTip()
 {
     return(CallTip.ShouldSerialize());
 }