Exemple #1
0
 protected override void OnTextChanged(EventArgs e)
 {
     base.OnTextChanged(e);
     if (_box != null)
     {
         if (this.Text != "")
         {
             _box.Items.Clear();
             var legalStrings = from item in _autoCompleteSource
                                where item.Name.ToUpper().StartsWith(this.Text.Trim().ToUpper())
                                select item.Name;
             if (legalStrings.Count <string>() > 0)
             {
                 foreach (string str in legalStrings)
                 {
                     _box.Items.Add(str);
                 }
                 if (_dropDown != null && dropDownEnabled)
                 {
                     UpdateDropDownSize();
                     _dropDown.Show(this, new Point(0, this.Height));
                     _dropDown.AutoClose = true;
                 }
             }
             else
             {
                 _dropDown.Close();
             }
         }
         else
         {
             _dropDown.Close();
         }
     }
 }
Exemple #2
0
 void colorPicker_ValueChanged(object sender, EventArgs e)
 {
     preViewLabel.ForeColor        = colorPicker.Color;
     colorButtonForTouch.BackColor = colorPicker.Color;
     colorButtonNormal.BackColor   = colorPicker.Color;
     colorDropDown.Close();
 }
Exemple #3
0
        void fontSizeButton_Click(object sender, EventArgs e)
        {
            if (_isTouch)
            {
                fontSizeListbox.Font = bigFont;
            }
            else
            {
                fontSizeListbox.Font = normalFont;
            }
            _isTouch = false;


            if (fontSizeDropDown.Visible)
            {
                fontSizeDropDown.Close();
            }
            else
            {
                var control = sender as Control;
                fontSizeDropDown.Tag = control;
                int selectedIndex = fontSizeListbox.SelectedIndex;
                fontSizeListbox.SelectedIndex = -1;
                fontSizeListbox.SelectedIndex = selectedIndex;
                fontSizeDropDown.Show(control, new Point(0, control.Height));
            }
        }
 void ClearFilterCtrl_Click(object sender, EventArgs e)
 {
     Filter.Clear();
     StrFilter = "";
     ApllyFilter();
     popup.Close();
 }
 void box_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Enter && box.SelectedIndex > -1)
     {
         drop.Close();
     }
 }
        // 下拉表格显示并触发事件
        private void PopupGridView(EventArgs e)
        {
            if (DataGridView.SelectedRows.Count > 0)
            {
                DataGridViewRow dgvRow = DataGridView.CurrentRow;
                m_SelectedIndex = DataGridView.CurrentRow.Index;
                if (m_sDisplayMember != String.Empty)
                {
                    Text = "";
                    string[] sDisplayList = m_sDisplayMember.Split(',');
                    foreach (string sDisplay in sDisplayList)
                    {
                        if (DataGridView.Columns.Contains(sDisplay))
                        {
                            Text += dgvRow.Cells[sDisplay].Value.ToString() + m_Separator;
                        }
                    }
                    Text = Text.TrimEnd('|');
                }
                else
                {
                    Text = dgvRow.Cells[0].Value.ToString();
                }

                RaiseAfterSelector(this, new AfterSelectorEventArgs(-1, -1, dgvRow));
            }
            dropDown.Close();
            m_blDropShow = false;
        }
Exemple #7
0
 public void ClosePopup()
 {
     if (dropdown != null)
     {
         dropdown.Close();
         DisposeCurrentDropdown();
     }
 }
Exemple #8
0
 /// <summary>
 /// 弹出下拉表格并触发选择后事件
 /// </summary>
 /// <param name="e"></param>
 private void Closeup(EventArgs e)
 {
     Text = SqlEditorControl.SqlText;
     if (AfterSelector != null)
     {
         AfterSelector(this, e);
     }
     dropDown.Close();
     m_blDropShow = false;
 }
Exemple #9
0
 // Очистить все фильтры
 private void ClearAllButton_Click(object sender, EventArgs e)
 {
     Filter.Clear();
     ApllyFilter();
     popup.Close();
     for (int i = 0; i < this.Columns.Count; i++)
     {
         this.Columns[i].HeaderCell.Style.BackColor = UnCheckedColor;
     }
 }
Exemple #10
0
 /// <summary>
 /// 弹出下拉表格并触发选择后事件
 /// </summary>
 /// <param name="e"></param>
 private void Closeup(EventArgs e)
 {
     Text = DSSelectControl.SelectedRefName;
     if (AfterSelector != null)
     {
         AfterSelector(this, e);
     }
     dropDown.Close();
     m_blDropShow = false;
 }
Exemple #11
0
        private void HandleMiniToolBarDropDownItemClosed(object sender, EventArgs e)
        {
            var dd = (ToolStripDropDownItem)sender;

            if (_isMouseOnMiniToolBar)
            {
                _needCloseMiniToolBarOnMouseLeave = true;
            }
            else
            {
                _miniToolBar.Close();
            }
        }
Exemple #12
0
 /// <summary>
 /// Closes this popup and every other next to it in the chain
 /// </summary>
 public void Close()
 {
     if (ToolStripDropDown != null)
     {
         ToolStripDropDown.Close();
     }
 }
 private void CloseDropDown()
 {
     if (tsDD.Visible)
     {
         tsDD.Close();
     }
 }
Exemple #14
0
 public void TreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     this.Text          = string.Empty;
     this.SelectedText  = TreeView.SelectedNode.Text;
     this.SelectedValue = TreeView.SelectedNode.Tag;
     ThisDropDown.Close();
 }
        private void AssignSelectDropDown()
        {
            ToolStripDropDown drop = new ToolStripDropDown();
            PhotoAlbum        a    = Manager.Album;

            for (int i = 0; i < a.Count; i++)
            {
                PictureBox box = new PictureBox();
                box.SizeMode = PictureBoxSizeMode.Zoom;
                box.Image    = a[i].Image;
                box.Dock     = DockStyle.Fill;

                ToolStripControlHost host = new ToolStripControlHost(box);
                host.AutoSize = false;
                host.Size     = new Size(tssSelect.Width, tssSelect.Width);
                host.Tag      = i;
                host.Click   += delegate(object o, EventArgs e)
                {
                    int x = (int)(o as ToolStripItem).Tag;
                    Manager.Index = x;
                    drop.Close();
                    DisplayAlbum();
                };
                drop.Items.Add(host);
            }
            if (drop.Items.Count > 0)
            {
                tssSelect.DropDown    = drop;
                tssSelect.DefaultItem = drop.Items[0];
            }
        }
 public void CloseDropDown()
 {
     if (TopControl == null || DropDownControl == null)
     {
         throw new InvalidOperationException("GenericDropDown controls not set");
     }
     m_dropDown.Close();
 }
Exemple #17
0
 private void listbox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_toolStripDropDown != null)
     {
         this.Text = _listbox.GetItemText(_listbox.SelectedItem);
         _toolStripDropDown.Close();
     }
 }
Exemple #18
0
 public void Close()
 {
     IsDropDown = false;
     if (DropDownContainer != null)
     {
         DropDownContainer.Close();
     }
 }
Exemple #19
0
        private void SetTextAndValue()
        {
            if (listBox.Items.Count == 0)
            {
                return;
            }

            string seltext = listBox.SelectedItem.ToString();


            string[] strs = seltext.Split(split);
            systemSetText       = true;
            this.Text           = strs[0];
            this.Tag            = strs[strs.Count() - 1];
            systemSetText       = false;
            this.SelectionStart = this.Text.Length;
            dropDown.Close();
        }
        /// <summary>
        /// 选择中时触发事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            myTreeNode myTree = TreeView.SelectedNode as myTreeNode;

            this.Text       = myTree.Text;
            this.NodeCode   = myTree.NodeCode;
            this.ParentNode = myTree.ParentNode;
            dropDown.Close();
        }
Exemple #21
0
        private void pictureBoxClose_Click(object sender, EventArgs e)
        {
            ToolStripDropDown menu = this.Parent as ToolStripDropDown;

            if (menu != null)
            {
                menu.Close();
            }
        }
Exemple #22
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);
            _dropDown     = new ToolStripDropDown();
            _box          = new ListBox();
            _box.Width    = this.Width - 2;
            _box.KeyDown += (KeyEventHandler)((sender, k) =>
            {
                if (k.KeyCode == Keys.Enter)
                {
                    this.Text = _box.SelectedItem.ToString();
                    _dropDown.Close();
                }
                _dropDown.AutoClose = true;
                if (k.KeyCode == Keys.Escape)
                {
                    _dropDown.Close();
                }
            });
            _box.Click += (EventHandler)((sender, arg) =>
            {
                this.Text = _box.SelectedItem.ToString();
                _dropDown.Close();
            });
            _box.MouseMove += (MouseEventHandler)((sender, m) =>
            {
                int index = _box.IndexFromPoint(m.Location);
                _box.SelectedIndex = index;
            });
            ToolStripControlHost host = new ToolStripControlHost(_box);

            host.AutoSize = false;
            host.Margin   = Padding.Empty;
            host.Padding  = Padding.Empty;
            _dropDown.Items.Add(host);
            _dropDown.Height    = _box.Height;
            _dropDown.AutoSize  = false;
            _dropDown.Margin    = Padding.Empty;
            _dropDown.Padding   = Padding.Empty;
            _dropDown.Size      = host.Size = _box.Size;
            _dropDown.AutoClose = false;
        }
Exemple #23
0
        void fontFamilyButton_Click(object sender, EventArgs e)
        {
            if (_isTouch)
            {
                fontFamilyListobx.Font = bigFont;
            }
            else
            {
                fontFamilyListobx.Font = normalFont;
            }
            _isTouch = false;

            if (fontFamilyDropDown.Visible)
            {
                fontFamilyDropDown.Close();
            }
            else
            {
                Control textControl = (sender as Control).Tag as Control;
                Control control     = sender as Control;
                fontFamilyDropDown.Tag = control;
                fontFamilyDropDown.Show(textControl, new Point(0, textControl.Height));
            }
        }
Exemple #24
0
        void Button_Click(object sender, EventArgs e)
        {
            dropDown.Width = Width;
            lb.Width       = Width;
            host.Width     = Width;

            if (dropDown.Visible)
            {
                dropDown.Close();
            }
            else
            {
                dropDown.Show(this, 0, Height);
            }
        }
Exemple #25
0
        private void OnButton_Click(object sender, EventArgs e)
        {
            SimpleButton btn = sender as SimpleButton;

            if (btn != null)
            {
                this.SelectedIndex = btn.TabIndex;
            }

            ToolStripDropDown parent = this.Parent as ToolStripDropDown;

            if (parent != null)
            {
                parent.Close(ToolStripDropDownCloseReason.ItemClicked);
            }
        }
        protected override void setupDropDown(ToolStripDropDownButton btn)
        {
            ToolStripDropDown dropDown = btn.DropDown;

            //dropDown.AutoSize = false;
            dropDown.Margin  = Padding.Empty;
            dropDown.Padding = Padding.Empty;
            host             = new ToolStripControlHost(control);

            host.Margin   = Padding.Empty;
            host.Padding  = Padding.Empty;
            host.AutoSize = false;
            host.Size     = control.Size;
            dropDown.Size = control.Size;
            //((ToolStripDropDownMenu)btn.DropDown).ShowImageMargin = false;
            //((ToolStripDropDownMenu)btn.DropDown).ShowItemToolTips = false;
            dropDown.Items.Add(host);
            dropDown.AutoClose     = false;
            control.BindingContext = bc;

            control.CloseBtn.Click += (s, a) => dropDown.Close();

            //host.Margin = Padding.Empty;
            //host.Padding = Padding.Empty;
            //btn.DropDown.Margin = Padding.Empty;
            //btn.DropDown.Padding = Padding.Empty;
            //host.Width = grid.Width*2;
            //host.Height = grid.Height * 2;
            //btn.DropDown.Width = host.Width;
            //btn.DropDown.Items.Add(host);

            //grid.SelectionChanged += (s, a) =>
            //{
            //    DataGridViewSelectedRowCollection rows = grid.SelectedRows;
            //    if (rows.Count > 0)
            //    {
            //        //DataGridViewRow row = rows[0];
            //        //object name = row.Cells[1].Value;
            //        //Console.WriteLine(name);
            //        SelectionManager.Instance.SelectedInstance = (InstanceDescriptor)Objects.getObject((string)rows[0].Cells[0].Value);
            //        //dropDown.Close();
            //    }

            //};

            base.setupDropDown(btn);
        }
Exemple #27
0
        public static void DropdownClosed(object sender, EventArgs e)
        {
            ToolStripDropDownItem ddItem = (ToolStripDropDownItem)sender;
            ToolStripDropDown     parent = ddItem.GetCurrentParent() as ToolStripDropDown;

            if (parent != null)
            {
                Point pos = parent.PointToClient(Cursor.Position);
                if (pos.X < 0 || pos.Y < 0 || pos.X > parent.Width || pos.Y > parent.Height)
                {
                    //When closing a dropdown, if the mouse isn't inside its parent, close all the parent, too.
                    parent.Close();
                }
            }

            _openedDropdowns.Remove(ddItem.DropDown);
        }
        // ********************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        /// <created>UPh,25.04.2015</created>
        /// <changed>UPh,25.04.2015</changed>
        // ********************************************************************************
        private void lblColors_MouseClick(object sender, MouseEventArgs e)
        {
            int col, row;

            if (HitTest(e.Location, out col, out row))
            {
                ToolStripDropDown host = Parent as ToolStripDropDown;
                if (host != null)
                {
                    host.Close();
                }

                if (ColorSelected != null)
                {
                    ColorSelected(this, new ColorSelectedEventArgs(ColorPalette[8 * row + col]));
                }
            }
        }
Exemple #29
0
        private void LstUndo_MouseClick(object sender, MouseEventArgs e)
        {
            IDocument frm = (IDocument)ActiveMdiChild;

            if (frm != null)
            {
                undoing = true;
                for (int i = 0; i <= lstUndo.IndexFromPoint(e.Location); i++)
                {
                    if (frm.CanUndo)
                    {
                        frm.Undo();
                    }
                }
                undoing = false;
                toolDropUndo.Close();
                frm.RequestUndoRedoStack();
            }
        }
Exemple #30
0
        public override void KeyPress(KeyPressEventArgs args)
        {
            bool isEnter  = args.KeyChar == '\n' || args.KeyChar == '\r';
            bool canEnter = m_dropDownOpen || ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) || !SpecialEnter;

            if (!char.IsControl(args.KeyChar) || (isEnter && canEnter))
            {
                if (isEnter && m_dropDownOpen)
                {
                    if (SelectedToolStripItem != null)
                    {
                        SelectedToolStripItem.PerformClick();
                    }
                    m_dropDown.Close();
                }
                else
                {
                    string newText = Text.Remove(SelectionStart, Math.Abs(SelectionLength)).Insert(SelectionStart, args.KeyChar + "");

                    bool acceptable = InputForm == MyTextBox.InputFormEnum.Text ||
                                      InputForm == MyTextBox.InputFormEnum.Decimal && decimal.TryParse(newText, NumberStyles.Number, CultureInfo.CurrentCulture, out var _) ||
                                      InputForm == MyTextBox.InputFormEnum.Integer && int.TryParse(newText, NumberStyles.Number, CultureInfo.CurrentCulture, out var _) ||
                                      InputForm == MyTextBox.InputFormEnum.Decimal && decimal.TryParse(newText + "0", NumberStyles.Number, CultureInfo.CurrentCulture, out var _) || //To catch "-" and "+"
                                      InputForm == MyTextBox.InputFormEnum.Integer && int.TryParse(newText + "0", NumberStyles.Number, CultureInfo.CurrentCulture, out var _) ||     //To catch "-" and "+"
                                      InputForm == MyTextBox.InputFormEnum.Path && StringUtil.IsAcceptablePathChar(args.KeyChar) ||
                                      InputForm == MyTextBox.InputFormEnum.FileName && IsAcceptableFileNameChar(args.KeyChar);

                    if (acceptable)
                    {
                        string textToInsert = "";
                        if (!char.IsControl(args.KeyChar))
                        {
                            textToInsert = args.KeyChar.ToString();
                        }
                        else if (args.KeyChar == '\r')
                        {
                            textToInsert = "\n"; //Currently newlines are considered like any other text in terms of resetting undo state
                        }
                        InsertText(textToInsert, GetCursorPosInt(), SelectionLength);
                    }
                }
            }
        }