Пример #1
0
        /// <summary>
        /// 功能描述:重置面板
        /// 作  者:HZH
        /// 创建日期:2019-06-25 15:02:05
        /// 任务编号:POS
        /// </summary>
        public void ReloadPanel()
        {
            if (row <= 0 || column <= 0)
            {
                return;
            }
            SelectBtn = null;
            this.panMain.Controls.Clear();
            this.panMain.ColumnCount = column;
            this.panMain.ColumnStyles.Clear();
            for (int i = 0; i < column; i++)
            {
                this.panMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            }

            this.panMain.RowCount = row;
            this.panMain.RowStyles.Clear();
            for (int i = 0; i < row; i++)
            {
                this.panMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            }

            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < column; j++)
                {
                    UCBtnExt btn = new UCBtnExt();
                    btn.BackColor    = System.Drawing.Color.Transparent;
                    btn.BtnBackColor = System.Drawing.Color.Transparent;
                    btn.BtnFont      = new System.Drawing.Font("微软雅黑", 10F);
                    btn.BtnForeColor = System.Drawing.Color.FromArgb(66, 66, 66);
                    btn.ConerRadius  = 5;
                    btn.Dock         = DockStyle.Fill;
                    btn.FillColor    = System.Drawing.Color.White;
                    btn.Font         = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
                    btn.Cursor       = Cursor.Current;
                    btn.IsShowRect   = true;
                    btn.IsRadius     = true;
                    btn.IsShowTips   = false;
                    btn.Name         = "btn_" + i + "_" + j;
                    btn.RectColor    = System.Drawing.Color.White;
                    btn.RectWidth    = 1;
                    btn.Width        = this.Width;
                    btn.TabIndex     = 0;
                    btn.TipsText     = "";
                    btn.BtnClick    += btn_BtnClick;
                    this.panMain.Controls.Add(btn, j, i);
                }
            }

            if (Source != null)
            {
                SetSource(Source);
            }
        }
Пример #2
0
 /// <summary>
 /// 设置选中项
 /// </summary>
 /// <param name="strKey">The string key.</param>
 public void SetSelect(string strKey)
 {
     foreach (UCBtnExt item in this.panMain.Controls)
     {
         if (item.Tag != null && item.Tag.ToStringExt() == strKey)
         {
             SelectBtn = item;
             return;
         }
     }
     SelectBtn = new UCBtnExt();
 }
Пример #3
0
 /// <summary>
 /// Sets the selected.
 /// </summary>
 private void SetSelected()
 {
     if (m_selectItem != null && m_selectItem.Count > 0 && DataSource != null && DataSource.Count > 0)
     {
         try
         {
             ControlHelper.FreezeControl(flowLayoutPanel1, true);
             if (m_isMultiple)
             {
                 foreach (var item in m_selectItem)
                 {
                     var lst = this.flowLayoutPanel1.Controls.Find(item, false);
                     if (lst.Length == 1)
                     {
                         var btn = lst[0] as UCBtnExt;
                         btn.RectColor = System.Drawing.Color.FromArgb(255, 77, 59);
                     }
                 }
             }
             else
             {
                 UCBtnExt btn = null;
                 foreach (var item in m_selectItem)
                 {
                     var lst = this.flowLayoutPanel1.Controls.Find(item, false);
                     if (lst.Length == 1)
                     {
                         btn = lst[0] as UCBtnExt;
                         break;
                     }
                 }
                 if (btn != null)
                 {
                     m_selectItem = new List <string>()
                     {
                         btn.Name
                     };
                     btn.RectColor = System.Drawing.Color.FromArgb(255, 77, 59);
                 }
             }
         }
         finally
         {
             ControlHelper.FreezeControl(flowLayoutPanel1, false);
         }
     }
 }
Пример #4
0
 /// <summary>
 /// Reloads this instance.
 /// </summary>
 private void Reload()
 {
     try
     {
         ControlHelper.FreezeControl(flowLayoutPanel1, true);
         this.flowLayoutPanel1.Controls.Clear();
         if (DataSource != null)
         {
             foreach (var item in DataSource)
             {
                 UCBtnExt btn = new UCBtnExt();
                 btn.BackColor    = System.Drawing.Color.Transparent;
                 btn.BtnBackColor = System.Drawing.Color.White;
                 btn.BtnFont      = new System.Drawing.Font("微软雅黑", 10F);
                 btn.BtnForeColor = System.Drawing.Color.Gray;
                 btn.BtnText      = item.Value;
                 btn.ConerRadius  = 5;
                 btn.Cursor       = System.Windows.Forms.Cursors.Hand;
                 btn.FillColor    = System.Drawing.Color.White;
                 btn.Font         = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
                 btn.IsRadius     = true;
                 btn.IsShowRect   = true;
                 btn.IsShowTips   = false;
                 btn.Location     = new System.Drawing.Point(5, 5);
                 btn.Margin       = new System.Windows.Forms.Padding(5);
                 btn.Name         = item.Key;
                 btn.RectColor    = System.Drawing.Color.FromArgb(224, 224, 224);
                 btn.RectWidth    = 1;
                 btn.Size         = new System.Drawing.Size(72, 38);
                 btn.TabStop      = false;
                 btn.BtnClick    += btn_BtnClick;
                 this.flowLayoutPanel1.Controls.Add(btn);
             }
         }
     }
     finally
     {
         ControlHelper.FreezeControl(flowLayoutPanel1, false);
     }
     SetSelected();
 }
Пример #5
0
        /// <summary>
        /// Handles the MouseDown event of the btnKeybord control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
        private void btnKeybord_MouseDown(object sender, MouseEventArgs e)
        {
            if (keyBoardType == Scada.Controls.Controls.KeyBoardType.Null)
            {
                return;
            }
            m_intSelectionStart           = this.txtInput.SelectionStart;
            m_intSelectionLength          = this.txtInput.SelectionLength;
            this.FindForm().ActiveControl = this;
            this.FindForm().ActiveControl = this.txtInput;
            switch (keyBoardType)
            {
            case KeyBoardType.UCKeyBorderAll_EN:
                if (m_frmAnchor == null)
                {
                    if (m_frmAnchor == null)
                    {
                        UCKeyBorderAll key = new UCKeyBorderAll();
                        key.CharType      = KeyBorderCharType.CHAR;
                        key.RetractClike += (a, b) =>
                        {
                            m_frmAnchor.Hide();
                        };
                        m_frmAnchor = new Forms.FrmAnchor(this, key);
                        m_frmAnchor.VisibleChanged += (a, b) =>
                        {
                            if (m_frmAnchor.Visible)
                            {
                                this.txtInput.SelectionStart  = m_intSelectionStart;
                                this.txtInput.SelectionLength = m_intSelectionLength;
                            }
                        };
                    }
                }
                break;

            case KeyBoardType.UCKeyBorderAll_Num:

                if (m_frmAnchor == null)
                {
                    UCKeyBorderAll key = new UCKeyBorderAll();
                    key.CharType      = KeyBorderCharType.NUMBER;
                    key.RetractClike += (a, b) =>
                    {
                        m_frmAnchor.Hide();
                    };
                    m_frmAnchor = new Forms.FrmAnchor(this, key);
                    m_frmAnchor.VisibleChanged += (a, b) =>
                    {
                        if (m_frmAnchor.Visible)
                        {
                            this.txtInput.SelectionStart  = m_intSelectionStart;
                            this.txtInput.SelectionLength = m_intSelectionLength;
                        }
                    };
                }

                break;

            case KeyBoardType.UCKeyBorderNum:
                if (m_frmAnchor == null)
                {
                    UCKeyBorderNum key = new UCKeyBorderNum();
                    m_frmAnchor = new Forms.FrmAnchor(this, key);
                    m_frmAnchor.VisibleChanged += (a, b) =>
                    {
                        if (m_frmAnchor.Visible)
                        {
                            this.txtInput.SelectionStart  = m_intSelectionStart;
                            this.txtInput.SelectionLength = m_intSelectionLength;
                        }
                    };
                }
                break;

            case Scada.Controls.Controls.KeyBoardType.UCKeyBorderHand:

                m_frmAnchor = new Forms.FrmAnchor(this, new Size(504, 361));
                m_frmAnchor.VisibleChanged += m_frmAnchor_VisibleChanged;
                m_frmAnchor.Disposed       += m_frmAnchor_Disposed;
                Panel p = new Panel();
                p.Dock = DockStyle.Fill;
                p.Name = "keyborder";
                m_frmAnchor.Controls.Add(p);

                UCBtnExt btnDelete = new UCBtnExt();
                btnDelete.Name        = "btnDelete";
                btnDelete.Size        = new Size(80, 28);
                btnDelete.FillColor   = Color.White;
                btnDelete.IsRadius    = false;
                btnDelete.ConerRadius = 1;
                btnDelete.IsShowRect  = true;
                btnDelete.RectColor   = Color.FromArgb(189, 197, 203);
                btnDelete.Location    = new Point(198, 332);
                btnDelete.BtnFont     = new System.Drawing.Font("微软雅黑", 8);
                btnDelete.BtnText     = "删除";
                btnDelete.BtnClick   += (a, b) =>
                {
                    SendKeys.Send("{BACKSPACE}");
                };
                m_frmAnchor.Controls.Add(btnDelete);
                btnDelete.BringToFront();

                UCBtnExt btnEnter = new UCBtnExt();
                btnEnter.Name        = "btnEnter";
                btnEnter.Size        = new Size(82, 28);
                btnEnter.FillColor   = Color.White;
                btnEnter.IsRadius    = false;
                btnEnter.ConerRadius = 1;
                btnEnter.IsShowRect  = true;
                btnEnter.RectColor   = Color.FromArgb(189, 197, 203);
                btnEnter.Location    = new Point(278, 332);
                btnEnter.BtnFont     = new System.Drawing.Font("微软雅黑", 8);
                btnEnter.BtnText     = "确定";
                btnEnter.BtnClick   += (a, b) =>
                {
                    SendKeys.Send("{ENTER}");
                    m_frmAnchor.Hide();
                };
                m_frmAnchor.Controls.Add(btnEnter);
                btnEnter.BringToFront();
                m_frmAnchor.VisibleChanged += (a, b) =>
                {
                    if (m_frmAnchor.Visible)
                    {
                        this.txtInput.SelectionStart  = m_intSelectionStart;
                        this.txtInput.SelectionLength = m_intSelectionLength;
                    }
                };
                break;
            }
            if (!m_frmAnchor.Visible)
            {
                m_frmAnchor.Show(this.FindForm());
            }
            if (KeyboardClick != null)
            {
                KeyboardClick(sender, e);
            }
        }
Пример #6
0
        /// <summary>
        /// Sets the type of the select.
        /// </summary>
        /// <param name="btn">The BTN.</param>
        private void SetSelectType(UCBtnExt btn)
        {
            try
            {
                ControlHelper.FreezeControl(this, true);
                if (m_thisBtn != null)
                {
                    m_thisBtn.FillColor    = Color.White;
                    m_thisBtn.BtnForeColor = Color.FromArgb(255, 77, 59);
                }
                m_thisBtn = btn;
                if (m_thisBtn != null)
                {
                    m_thisBtn.FillColor    = Color.FromArgb(255, 77, 59);
                    m_thisBtn.BtnForeColor = Color.White;

                    List <KeyValuePair <string, string> > lstSource = new List <KeyValuePair <string, string> >();
                    panTime.SuspendLayout();

                    if (btn == btnYear)
                    {
                        panLeft.Visible  = true;
                        panRight.Visible = true;
                    }
                    else
                    {
                        panLeft.Visible  = false;
                        panRight.Visible = false;
                    }

                    if (btn == btnYear)
                    {
                        panTime.Row    = 5;
                        panTime.Column = 6;
                        int intYear = m_dt.Year - m_dt.Year % 30;
                        for (int i = 0; i < 30; i++)
                        {
                            lstSource.Add(new KeyValuePair <string, string>((intYear + i).ToString(), (intYear + i).ToString()));
                        }
                    }
                    else if (btn == btnMonth)
                    {
                        panTime.Row    = 3;
                        panTime.Column = 4;
                        for (int i = 1; i <= 12; i++)
                        {
                            lstSource.Add(new KeyValuePair <string, string>(i.ToString(), i.ToString().PadLeft(2, '0') + "月\r\n" + (("2019-" + i + "-01").ToDate().ToString("MMM", System.Globalization.CultureInfo.CreateSpecificCulture("en-GB")))));
                        }
                    }
                    else if (btn == btnDay)
                    {
                        panTime.Column = 7;
                        int intDayCount = DateTime.DaysInMonth(m_dt.Year, m_dt.Month);
                        int intIndex    = (int)(m_dt.DayOfWeek);
                        panTime.Row = (intDayCount + intIndex) / 7 + ((intDayCount + intIndex) % 7 != 0 ? 1 : 0);
                        for (int i = 0; i < intIndex; i++)
                        {
                            lstSource.Add(new KeyValuePair <string, string>("", ""));
                        }
                        for (int i = 1; i <= intDayCount; i++)
                        {
                            lstSource.Add(new KeyValuePair <string, string>(i.ToString(), i.ToString().PadLeft(2, '0')));
                        }
                    }
                    else if (btn == btnHour)
                    {
                        panTime.Row    = 4;
                        panTime.Column = 6;
                        for (int i = 0; i <= 24; i++)
                        {
                            lstSource.Add(new KeyValuePair <string, string>(i.ToString(), i.ToString() + "时"));
                        }
                    }
                    else if (btn == btnMinute)
                    {
                        panTime.Row    = 5;
                        panTime.Column = 12;
                        for (int i = 0; i <= 60; i++)
                        {
                            lstSource.Add(new KeyValuePair <string, string>(i.ToString(), i.ToString().PadLeft(2, '0')));
                        }
                    }
                    panTime.Source = lstSource;
                    panTime.SetSelect(btn.Tag.ToStringExt());
                    panTime.ResumeLayout(true);

                    // panTime.Enabled = true;
                }
            }
            finally
            {
                ControlHelper.FreezeControl(this, false);
            }
        }
Пример #7
0
        /// <summary>
        /// Reloads the page.
        /// </summary>
        private void ReloadPage()
        {
            try
            {
                ControlHelper.FreezeControl(tableLayoutPanel, true);
                List <int> lst = new List <int>();

                if (PageCount <= 9)
                {
                    for (var i = 1; i <= PageCount; i++)
                    {
                        lst.Add(i);
                    }
                }
                else
                {
                    if (this.PageIndex <= 6)
                    {
                        for (var i = 1; i <= 7; i++)
                        {
                            lst.Add(i);
                        }
                        lst.Add(-1);
                        lst.Add(PageCount);
                    }
                    else if (this.PageIndex > PageCount - 6)
                    {
                        lst.Add(1);
                        lst.Add(-1);
                        for (var i = PageCount - 6; i <= PageCount; i++)
                        {
                            lst.Add(i);
                        }
                    }
                    else
                    {
                        lst.Add(1);
                        lst.Add(-1);
                        var begin = PageIndex - 2;
                        var end   = PageIndex + 2;
                        if (end > PageCount)
                        {
                            end   = PageCount;
                            begin = end - 4;
                            if (PageIndex - begin < 2)
                            {
                                begin = begin - 1;
                            }
                        }
                        else if (end + 1 == PageCount)
                        {
                            end = PageCount;
                        }
                        for (var i = begin; i <= end; i++)
                        {
                            lst.Add(i);
                        }
                        if (end != PageCount)
                        {
                            lst.Add(-1);
                            lst.Add(PageCount);
                        }
                    }
                }

                for (int i = 0; i < 9; i++)
                {
                    UCBtnExt c = (UCBtnExt)this.tableLayoutPanel.Controls.Find("p" + (i + 1), false)[0];
                    if (i >= lst.Count)
                    {
                        c.Visible = false;
                    }
                    else
                    {
                        if (lst[i] == -1)
                        {
                            c.BtnText = "...";
                            c.Enabled = false;
                        }
                        else
                        {
                            c.BtnText = lst[i].ToString();
                            c.Enabled = true;
                        }
                        c.Visible = true;
                        if (lst[i] == PageIndex)
                        {
                            c.RectColor = Color.FromArgb(255, 77, 59);
                        }
                        else
                        {
                            c.RectColor = Color.FromArgb(223, 223, 223);
                        }
                    }
                }
                ShowBtn(PageIndex > 1, PageIndex < PageCount);
            }
            finally
            {
                ControlHelper.FreezeControl(tableLayoutPanel, false);
            }
        }