protected virtual void click_MouseDown(object sender, MouseEventArgs e)
        {
            if (_frmAnchor == null || _frmAnchor.IsDisposed || _frmAnchor.Visible == false)
            {
                if (this.Source != null && this.Source.Count > 0)
                {
                    int intRow = 0;
                    int intCom = 1;
                    var p      = this.PointToScreen(this.Location);
                    while (true)
                    {
                        int intScreenHeight = Screen.PrimaryScreen.Bounds.Height;
                        if ((p.Y + this.Height + this.Source.Count / intCom * 50 < intScreenHeight || p.Y - this.Source.Count / intCom * 50 > 0) &&
                            (_dropPanelHeight <= 0 ? true : (this.Source.Count / intCom * 50 <= _dropPanelHeight)))
                        {
                            intRow = this.Source.Count / intCom + (this.Source.Count % intCom != 0 ? 1 : 0);
                            break;
                        }
                        intCom++;
                    }
                    UCTimePanel ucTime = new UCTimePanel();
                    ucTime.IsShowBorder = true;
                    int intWidth = this.Width / intCom;
                    if (intWidth < _ItemWidth)
                    {
                        intWidth = _ItemWidth;
                    }
                    Size size = new Size(intCom * intWidth, intRow * 50);
                    ucTime.Size               = size;
                    ucTime.FirstEvent         = true;
                    ucTime.SelectSourceEvent += ucTime_SelectSourceEvent;
                    ucTime.Row    = intRow;
                    ucTime.Column = intCom;
                    List <KeyValuePair <string, string> > lst = new List <KeyValuePair <string, string> >();
                    foreach (var item in this.Source)
                    {
                        lst.Add(new KeyValuePair <string, string>(item.Key, item.Value));
                    }
                    ucTime.Source = lst;

                    ucTime.SetSelect(_selectedValue);

                    _frmAnchor       = new Forms.FrmAnchor(this, ucTime);
                    _frmAnchor.Load += (a, b) => { (a as Form).Size = size; };

                    _frmAnchor.Show(this.FindForm());
                }
            }
            else
            {
                _frmAnchor.Close();
            }
        }
Exemple #2
0
        /// <summary>
        /// Handles the BtnClick event of the UCDropDownBtn control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        void UCDropDownBtn_BtnClick(object sender, EventArgs e)
        {
            if (_frmAnchor == null || _frmAnchor.IsDisposed || _frmAnchor.Visible == false)
            {
                if (Btns != null && Btns.Length > 0)
                {
                    int intRow = 0;
                    int intCom = 1;
                    var p      = this.PointToScreen(this.Location);
                    while (true)
                    {
                        int intScreenHeight = Screen.PrimaryScreen.Bounds.Height;
                        if ((p.Y + this.Height + Btns.Length / intCom * 50 < intScreenHeight || p.Y - Btns.Length / intCom * 50 > 0) &&
                            (_dropPanelHeight <= 0 ? true : (Btns.Length / intCom * 50 <= _dropPanelHeight)))
                        {
                            intRow = Btns.Length / intCom + (Btns.Length % intCom != 0 ? 1 : 0);
                            break;
                        }
                        intCom++;
                    }
                    UCTimePanel ucTime = new UCTimePanel();
                    ucTime.IsShowBorder = true;
                    int intWidth = this.Width / intCom;

                    Size size = new Size(intCom * intWidth, intRow * 50);
                    ucTime.Size               = size;
                    ucTime.FirstEvent         = true;
                    ucTime.SelectSourceEvent += ucTime_SelectSourceEvent;
                    ucTime.Row    = intRow;
                    ucTime.Column = intCom;

                    List <KeyValuePair <string, string> > lst = new List <KeyValuePair <string, string> >();
                    foreach (var item in Btns)
                    {
                        lst.Add(new KeyValuePair <string, string>(item, item));
                    }
                    ucTime.Source = lst;

                    _frmAnchor       = new Forms.FrmAnchor(this, ucTime);
                    _frmAnchor.Load += (a, b) => { (a as Form).Size = size; };

                    _frmAnchor.Show(this.FindForm());
                }
            }
            else
            {
                _frmAnchor.Close();
            }
        }