Пример #1
0
        internal AutocompleteListView(FastColoredTextBox tb)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
            base.Font    = new Font(FontFamily.GenericSansSerif, 9);
            visibleItems = new List <AutocompleteItem>();
            VerticalScroll.SmallChange = ItemHeight;
            MaximumSize        = new Size(Size.Width, 180);
            toolTip.ShowAlways = false;
            AppearInterval     = 500;
            timer.Tick        += new EventHandler(timer_Tick);
            SelectedColor      = Color.Orange;
            HoveredColor       = Color.Red;
            ToolTipDuration    = 3000;
            toolTip.Popup     += ToolTip_Popup;

            this.tb = tb;

            tb.KeyDown          += new KeyEventHandler(tb_KeyDown);
            tb.SelectionChanged += new EventHandler(tb_SelectionChanged);
            tb.KeyPressed       += new KeyPressEventHandler(tb_KeyPressed);

            Form form = tb.FindForm();

            if (form != null)
            {
                form.LocationChanged += delegate { SafetyClose(); };
                form.ResizeBegin     += delegate { SafetyClose(); };
                form.FormClosing     += delegate { SafetyClose(); };
                form.LostFocus       += delegate { SafetyClose(); };
            }

            tb.LostFocus += (o, e) =>
            {
                if (Menu != null && !Menu.IsDisposed)
                {
                    if (!Menu.Focused)
                    {
                        SafetyClose();
                    }
                }
            };

            tb.Scroll += delegate { SafetyClose(); };

            this.VisibleChanged += (o, e) =>
            {
                if (this.Visible)
                {
                    DoSelectedVisible();
                }
            };
        }
Пример #2
0
        internal AutocompleteListView(FastColoredTextBox tb)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
            if (HMS.PFC.Families.Length > 0)               // By WendyH
            {
                base.Font = new Font(HMS.PFC.Families[0], 10f, FontStyle.Regular, GraphicsUnit.Point);
            }
            else
            {
                base.Font = new Font("Segoe UI", 9, FontStyle.Regular, GraphicsUnit.Point);
            }
            visibleItems = new AutocompleteItems();
            VerticalScroll.SmallChange = ItemHeight;
            MaximumSize        = new Size(Size.Width, 180);
            toolTip.ShowAlways = false;
            AppearInterval     = 250;
            timer.Tick        += new EventHandler(timer_Tick);
            SelectedColor      = Color.Orange;
            HoveredColor       = Color.Red;
            ToolTipDuration    = 10000;
            this.tb            = tb;

            tb.KeyDown          += new KeyEventHandler(tb_KeyDown);
            tb.SelectionChanged += new EventHandler(tb_SelectionChanged);
            tb.KeyPressed       += new KeyPressEventHandler(tb_KeyPressed);

            Form form = tb.FindForm();

            if (form != null)
            {
                form.LocationChanged += (o, e) => Menu.Close();
                form.ResizeBegin     += (o, e) => Menu.Close();
                form.FormClosing     += (o, e) => Menu.Close();
                form.LostFocus       += (o, e) => Menu.Close();
            }

            tb.LostFocus += (o, e) => {
                if (!Menu.Focused)
                {
                    Menu.Close();
                }
            };

            tb.Scroll += (o, e) => Menu.Close();

            this.VisibleChanged += (o, e) => {
                if (this.Visible)
                {
                    DoSelectedVisible();
                }
            };
        }
        internal AutocompleteListView(FastColoredTextBox tb)
        {
            SetStyle(
                ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
            Font         = new Font(FontFamily.GenericSansSerif, 9);
            VisibleItems = new List <AutocompleteItem>();
            VerticalScroll.SmallChange = ItemHeight;
            MaximumSize        = new Size(Size.Width, 180);
            ToolTip.ShowAlways = false;
            AppearInterval     = 500;
            _timer.Tick       += timer_Tick;
            SelectedColor      = Color.Orange;
            HoveredColor       = Color.Red;
            ToolTipDuration    = 3000;

            _tb = tb;

            tb.KeyDown          += tb_KeyDown;
            tb.SelectionChanged += tb_SelectionChanged;
            tb.KeyPressed       += tb_KeyPressed;

            var form = tb.FindForm();

            if (form != null)
            {
                form.LocationChanged += (o, e) => Menu.Close();
                form.ResizeBegin     += (o, e) => Menu.Close();
                form.FormClosing     += (o, e) => Menu.Close();
                form.LostFocus       += (o, e) => Menu.Close();
            }

            tb.LostFocus += (o, e) => { if (!Menu.Focused)
                                        {
                                            Menu.Close();
                                        }
            };

            tb.Scroll += (o, e) => Menu.Close();

            VisibleChanged += (o, e) =>
            {
                if (Visible)
                {
                    DoSelectedVisible();
                }
            };
        }
        internal AutocompleteListView(FastColoredTextBox tb)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
            base.Font    = new Font(FontFamily.GenericSansSerif, 9);
            visibleItems = new List <AutocompleteItem>();
            itemHeight   = Font.Height + 2;
            VerticalScroll.SmallChange = itemHeight;
            BackColor          = Color.White;
            MaximumSize        = new Size(600, 180);
            toolTip.ShowAlways = false;
            toolTip.UseFading  = false;
            AppearInterval     = 200;
            timer.Tick        += new EventHandler(timer_Tick);

            this.tb = tb;

            tb.KeyDown          += new KeyEventHandler(tb_KeyDown);
            tb.SelectionChanged += new EventHandler(tb_SelectionChanged);
            tb.KeyPressed       += new KeyPressEventHandler(tb_KeyPressed);

            Form form = tb.FindForm();

            if (form != null)
            {
                form.LocationChanged += (o, e) => Menu.Close();
                form.ResizeBegin     += (o, e) => Menu.Close();
                form.FormClosing     += (o, e) => Menu.Close();
                form.LostFocus       += (o, e) => Menu.Close();
            }

            tb.LostFocus += (o, e) =>
            {
                if (!Menu.Focused)
                {
                    Menu.Close();
                }
            };

            tb.Scroll += (o, e) => Menu.Close();
        }