Esempio n. 1
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            Save_geometry();

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
                if (contextMenuStrip1 != null)
                {
                    contextMenuStrip1.Dispose();
                }
                if (copyToolStripMenuItem != null)
                {
                    copyToolStripMenuItem.Dispose();
                }
                if (log_output != null)
                {
                    log_output.Dispose();
                }
                if (selectAllToolStripMenuItem != null)
                {
                    selectAllToolStripMenuItem.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Esempio n. 2
0
        public override void Execute()
        {
            _window = null;
            if (_listBox != null)
            {
                _listBox.Dispose();
            }
            _listBox = null;

            Initialise();

            if (PageExists("TextEditor", "SQL"))
            {
                _showLineNumbers = ReadProperty <bool>("TextEditor", "SQL", "ShowLineNumbers", false);
            }
            else
            {
                _showLineNumbers = ReadProperty <bool>("TextEditor", "AllLanguages", "ShowLineNumbers", false);
            }

            _listBox.Items.Clear();
            _listBox.Items.AddRange(GetItems().ToArray());
            _listBox.Height = Math.Min(300, Math.Max(150, _listBox.Items.Count * 20));

            var point  = new Point(0, 0);
            var cursor = AddIn.VirtualCursor;

            int lineNumberWidth = _showLineNumbers ? LineNumber_Width : 25;

            point.X += lineNumberWidth + Border_Width + (int)(cursor.Column * Math.Ceiling(_fontSize.Width));
            point.Y += Border_Width + (int)(cursor.Row * Math.Ceiling(_fontSize.Height + 2));

            _listBox.Location = new Point(point.X, point.Y);
            InternalExecute();
        }
Esempio n. 3
0
        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// If disposing equals false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference
        /// other objects. Only unmanaged resources can be disposed.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                    if (listBox != null)
                    {
                        listBox.Dispose();
                    }
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                listBox = null;

                // Note disposing has been done.
                disposed = true;
            }
        }
Esempio n. 4
0
        private void _CreateListBox(string filter)
        {
            if (_listBox != null)
            {
                _listBox = null;
                return;
            }
            if (!_listBoxOpened)
            {
                _listBox = new ListBox();
                //listBox.scrollDirection = 1;
                //listBox.ItemWidth = Width;
                //listBox.ItemHeight = 20;
                _listBox.FixedHeight = true;
                _listBox.Font        = Font;
                _listBox.BringToFront();
                _listBox.Context = true;
                _listBox.Width   = Width;
                _listBox.Height  = _listBox.ItemHeight * (Items.Count > MaxDropDownItems ? MaxDropDownItems : Items.Count);
                if (_listBox.Height < _listBox.ItemHeight)
                {
                    _listBox.Height = _listBox.ItemHeight;
                }
                foreach (var item in Items)
                {
                    if (DropDownStyle == ComboBoxStyle.DropDownList || String.IsNullOrEmpty(filter))
                    {
                        _listBox.Items.Add(item);
                    }
                    else
                    {
                        if (item.ToString().ToLower().Contains(filter.ToLower()))
                        {
                            _listBox.Items.Add(item);
                        }
                    }
                }
                for (int i = 0; i < Items.Count; i++)
                {
                    if (Items.IsDisabled(i))
                    {
                        _listBox.Items.Disable(i);
                        //Application.Log(i);
                    }
                }
                if (SelectedIndex > -1)
                {
                    _listBox.ScrollIndex = SelectedIndex;
                }
                _listBox.SelectedIndex = SelectedIndex;

                var gpoint = PointToScreen(Point.Zero);
                _listBox.Location              = gpoint + new Point(0, Height);
                _listBox.SelectedValueChanged += (object sender, EventArgs args) =>
                {
                    if (_listBox != null)
                    {
                        for (int i = 0; i < Items.Count; i++)
                        {
                            if (Items[i] == _listBox.SelectedItem)
                            {
                                _filter      = _listBox.SelectedItem.ToString();
                                SelectedItem = _listBox.SelectedItem;
                                break;
                            }
                        }
                        //SelectedIndex = _listBox.SelectedIndex;
                        _listBox.Dispose();
                        _listBox = null;
                    }
                };
                _listBox.OnDisposing += (object sender, EventArgs args) =>
                {
                    var clientRect = new System.Drawing.Rectangle(0, 0, Width, Height);
                    var contains   = clientRect.Contains(PointToClient(MousePosition));
                    if (!contains)
                    {
                        _listBoxOpened = false;
                    }
                    else
                    {
                        _listBoxOpened = !_listBoxOpened;
                    }
                    _listBox = null;
                };
            }
            else
            {
                _listBoxOpened = false;
            }
        }
Esempio n. 5
0
        private void _CreateListBox(string filter)
        {
            if (_listBox != null)
            {
                _listBox = null;
                return;
            }
            if (!_listBoxOpened)
            {
                _listBox = new ListBox();
                //listBox.scrollDirection = 1;
                //listBox.ItemWidth = Width;
                //listBox.ItemHeight = 20;
                _listBox.FixedHeight = true;
                _listBox.Font = Font;
                _listBox.BringToFront();
                _listBox.Context = true;
                _listBox.Width = Width;
                _listBox.Height = _listBox.ItemHeight * (Items.Count > MaxDropDownItems ? MaxDropDownItems : Items.Count);
                if (_listBox.Height < _listBox.ItemHeight) _listBox.Height = _listBox.ItemHeight;
                bool selectedIndexChanged = false;
                for (int i = 0; i < Items.Count; i++)
                {
                    var item = Items[i];
                    if (DropDownStyle == ComboBoxStyle.DropDownList || String.IsNullOrEmpty(filter))
                        _listBox.Items.Add(item);
                    else
                    {
                        var itemString = item.ToString();
                        if (itemString.ToLower().Contains(filter.ToLower()))
                        {
                            _listBox.Items.Add(item);
                            if (itemString == filter)
                            {
                                _listBox.SelectedIndex = i;
                                selectedIndexChanged = true;
                            }
                        }
                    }
                }
                for (int i = 0; i < Items.Count; i++)
                    if (Items.IsDisabled(i))
                    {
                        _listBox.Items.Disable(i);
                        //Application.Log(i);
                    }
                if (selectedIndexChanged == false)
                {
                    if (SelectedIndex > -1)
                        _listBox.ScrollIndex = SelectedIndex;
                    _listBox.SelectedIndex = SelectedIndex;
                }

                var gpoint = PointToScreen(Point.Zero);
                _listBox.Location = gpoint + new Point(0, Height);
                _listBox.SelectedValueChanged += (object sender, EventArgs args) =>
                {
                    if (_listBox != null)
                    {
                        for (int i = 0; i < Items.Count; i++)
                            if (Items[i] == _listBox.SelectedItem)
                            {
                                _filter = _listBox.SelectedItem.ToString();
                                SelectedItem = _listBox.SelectedItem;
                                break;
                            }
                        //SelectedIndex = _listBox.SelectedIndex;
                        _listBox.Dispose();
                        _listBox = null;
                    }
                };
                _listBox.OnDisposing += (object sender, EventArgs args) =>
                {
                    var clientRect = new System.Drawing.Rectangle(0, 0, Width, Height);
                    var contains = clientRect.Contains(PointToClient(MousePosition));
                    if (!contains)
                        _listBoxOpened = false;
                    else
                        _listBoxOpened = !_listBoxOpened;
                    _listBox = null;
                };
            }
            else
                _listBoxOpened = false;
        }