Esempio n. 1
0
        private void ListItem_MouseEnter(object sender, EventArgs e)
        {
            ((ComboPopoutItem)sender).Selected = true;

            if (m_cpiLastSelected != null)
            {
                m_cpiLastSelected.Selected = false;
            }

            m_cpiLastSelected = (ComboPopoutItem)sender;
        }
Esempio n. 2
0
        public ComboBox()
        {
            InitializeComponent();

            m_cpiLastSelected = null;

            m_clListControls = new List <ComboPopoutItem>();

            m_Panel  = new Panel();
            m_tsHost = new ToolStripControlHost(m_Panel);

            m_tsDropDown          = new ToolStripDropDown();
            m_tsDropDown.AutoSize = false;
            m_tsDropDown.Items.Add(m_tsHost);

            m_scItems              = new StringCollectionWithEvents();
            m_scItems.ItemAdded   += new StringCollectionWithEvents.ItemAddedEventHandler(m_scItems_ItemAdded);
            m_scItems.ItemRemoved += new StringCollectionWithEvents.ItemRemovedEventHandler(m_scItems_ItemRemoved);
            m_iSelectedIndex       = -1;

            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.SetStyle(ControlStyles.UserPaint, true);
            this.UpdateStyles();

            BorderColor = Color.FromArgb(152, 152, 152);
            BorderPen   = new Pen(BorderColor);

            this.Paint  += new PaintEventHandler(ComboBox_Paint);
            this.Resize += new EventHandler(ComboBox_Resize);

            Radius   = 5.0f;
            Diameter = 10.0f;

            GradientPen = new Pen(Color.Black);

            GradientStart  = Color.FromArgb(252, 252, 252);
            GradientFinish = Color.FromArgb(223, 223, 223);
            UpdateGradients();

            UpdateRegion();

            pFontSize       = 10;
            pFont           = FontVault.GetFontVault().GetFont(FontVault.AvailableFonts.MyriadPro, pFontSize);
            MeasureLbl.Font = pFont;

            TextColor = Color.Black;
            TextBrush = new SolidBrush(TextColor);

            this.MouseUp += new MouseEventHandler(ComboBox_MouseUp);

            UpdateRegion();
        }
Esempio n. 3
0
        private void m_scItems_ItemAdded(object sender, string sNewStr)
        {
            ComboPopoutItem cpiNewItem = new ComboPopoutItem();

            cpiNewItem.Text = sNewStr;

            cpiNewItem.Click      += new EventHandler(ListItem_Click);
            cpiNewItem.MouseEnter += new EventHandler(ListItem_MouseEnter);

            m_clListControls.Add(cpiNewItem);
            m_Panel.Controls.Add(cpiNewItem);
        }
Esempio n. 4
0
        public void UpdateLayout()
        {
            this.Height = (pItems.Count * ComboPopoutItem.CONTROL_HEIGHT) + 2;

            ComboPopoutItem CurItem;
            int             X;

            if (pItems.Count > PopoutItems.Count)
            {
                int Count = pItems.Count - PopoutItems.Count;

                for (int i = 0; i < Count; i++)
                {
                    CurItem            = new ComboPopoutItem();
                    CurItem.MouseMove += new MouseEventHandler(PopupItem_MouseMove);
                    CurItem.Click     += new EventHandler(PopupItem_Click);
                    CurItem.Visible    = true;
                    PopoutItems.Add(CurItem);
                    this.Controls.Add(CurItem);
                }
            }

            if (pItems.Count < PopoutItems.Count)
            {
                for (int i = 0; i < PopoutItems.Count - pItems.Count; i++)
                {
                    PopoutItems.RemoveAt(0);
                }
            }

            X = 1;

            for (int i = 0; i < pItems.Count; i++)
            {
                CurItem = (ComboPopoutItem)PopoutItems[i];

                CurItem.Text  = pItems[i];
                CurItem.Top   = X;
                CurItem.Left  = 1;
                CurItem.Width = this.Width - 2;

                if (i == pSelectedIndex)
                {
                    CurItem.Checked = true;
                }
                else
                {
                    CurItem.Checked = false;
                }

                X += CurItem.Height;
            }
        }
Esempio n. 5
0
        private void ListItem_Click(object sender, EventArgs e)
        {
            if (m_iSelectedIndex > -1)
            {
                m_clListControls[m_iSelectedIndex].Checked = false;
            }

            m_iSelectedIndex = m_clListControls.IndexOf((ComboPopoutItem)sender);

            if (SelectedIndexChanged != null)
            {
                SelectedIndexChanged(this, EventArgs.Empty);
            }

            m_tsDropDown.Hide();
            m_cpiLastSelected = null;
            m_clListControls[m_iSelectedIndex].Checked = true;

            this.Invalidate();
        }