Esempio n. 1
0
        private void lstBox_Click(object sender, EventArgs e)
        {
            try
            {
                // 估计是因为 popup 出来的窗口没有焦点,鼠标点击某行无法令该行选中
                // 所以这里要自己实现这个鼠标点击选中的功能
                Point point = lstBox.PointToClient(Control.MousePosition);
                int   index = 0;
                for (index = 0; index < lstBox.Items.Count; index++)
                {
                    Rectangle rect = lstBox.GetItemRectangle(index);
                    if (rect.Contains(point))
                    {
                        lstBox.SelectedIndex = index;
                        break;
                    }
                }

                // 返回
                SelectRowReturn(lstBox.SelectedIndex);
            }
            catch (Exception ex)
            {
                CommonFuntion.OnDealError(this, ex);
            }
        }
Esempio n. 2
0
        private void pnlButton_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                if (mbMouseDownInAdd && mrectAdd.Contains(e.Location))
                {
                    mbMouseDownInAdd     = false;
                    mbMouseDownInManager = false;

                    pnlButton.Invalidate(mrectAdd);
                    pnlButton.Update();
                    OnAddClicked(EventArgs.Empty);
                }
                else if (mbMouseDownInManager && mrectManager.Contains(e.Location))
                {
                    mbMouseDownInAdd     = false;
                    mbMouseDownInManager = false;

                    pnlButton.Invalidate(mrectManager);
                    pnlButton.Update();
                    OnManageClicked(EventArgs.Empty);
                }
                else if (mbMouseDownInAdd || mbMouseDownInManager)
                {
                    mbMouseDownInAdd     = false;
                    mbMouseDownInManager = false;
                    pnlButton.Invalidate();
                    pnlButton.Update();
                }
            }
            catch (Exception ex)
            {
                CommonFuntion.OnDealError(this, ex);
            }
        }
 private void tsCalendar_DateSelected(object sender, DateRangeEventArgs e)
 {
     try
     {
         DateSelected(e.Start);
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
 void ctrlOwner_LostFocus(object sender, EventArgs e)
 {
     try
     {
         this.Hide();
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
Esempio n. 5
0
 private void frmFullPictureViewer_SizeChanged(object sender, EventArgs e)
 {
     try
     {
         this.picMain.ZoomFit();
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
Esempio n. 6
0
 void btnBig_Click(object sender, EventArgs e)
 {
     try
     {
         this.picMain.ZoomPlus();
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
Esempio n. 7
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         this.TopMost = checkBox1.Checked;
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
Esempio n. 8
0
 protected override void OnClick(EventArgs e)
 {
     try
     {
         mbIsExpanded = !mbIsExpanded;
         base.OnClick(e);
         Repaint();
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
Esempio n. 9
0
        protected override void OnLeave(EventArgs e)
        {
            base.OnLeave(e);

            try
            {
                mbIsEnter = false;
                Repaint();
            }
            catch (Exception ex)
            {
                CommonFuntion.OnDealError(this, ex);
            }
        }
 private void tsCalendar_DateChanged(object sender, DateRangeEventArgs e)
 {
     try
     {
         // 解决一个 Bug: 在年份中选择以往的年份时,控件显示不正常
         this.tsCalendar.DateSelected -= new System.Windows.Forms.DateRangeEventHandler(this.tsCalendar_DateSelected);
         this.tsCalendar.SetDate(e.Start);
         this.tsCalendar.DateSelected += new System.Windows.Forms.DateRangeEventHandler(this.tsCalendar_DateSelected);
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
Esempio n. 11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            try
            {
                Image img = null;
                if (mbIsExpanded)
                {
                    img = LB.Properties.Resources.SeparatorArrowClose;
                }
                else
                {
                    img = LB.Properties.Resources.SeparatorArrow;
                }
                Graphics g              = e.Graphics;
                int      iWidth         = ( int )g.MeasureString(this.Text, this.Font).Width + img.Width + 10;
                int      iRightLineLeft = MC_iTextLeft + iWidth;
                mRect = new Rectangle(MC_iTextLeft, 2, iWidth, this.Font.Height);

                int iTop = this.Height / 2 - 1;
                using (Pen pen = new Pen(mSepColor1))
                {
                    g.DrawLine(pen, MC_iLineLeft, iTop, MC_iTextLeft, iTop);
                    g.DrawLine(pen, iRightLineLeft, iTop, this.Width - MC_iLineLeft, iTop);
                }
                using (Pen pen = new Pen(mSepColor2))
                {
                    g.DrawLine(pen, MC_iLineLeft, iTop + 1, MC_iTextLeft, iTop + 1);
                    g.DrawLine(pen, iRightLineLeft, iTop + 1, this.Width - MC_iLineLeft, iTop + 1);
                }
                using (Pen pen = new Pen(mSepColor3))
                {
                    g.DrawLine(pen, MC_iLineLeft, iTop + 2, MC_iTextLeft, iTop + 2);
                    g.DrawLine(pen, iRightLineLeft, iTop + 2, this.Width - MC_iLineLeft, iTop + 2);
                }

                g.DrawImage(img, MC_iTextLeft + 3, 2);
                Color clr = mbIsEnter ? mTextColorHover : this.ForeColor;
                using (SolidBrush brush = new SolidBrush(clr))
                {
                    g.DrawString(this.Text, this.Font, brush, MC_iTextLeft + img.Width + 5, 2);
                }
            }
            catch (Exception ex)
            {
                CommonFuntion.OnDealError(this, ex);
            }
        }
Esempio n. 12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            try
            {
                using (SolidBrush brush = new SolidBrush(this.ForeColor))
                {
                    e.Graphics.DrawString(this.Text, this.Font, brush, this.TextPoint);
                }
            }
            catch (Exception ex)
            {
                CommonFuntion.OnDealError(this, ex);
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                mFilter = new TSPopupWindowMessageFilter(this, mOwnerControl);
                Application.AddMessageFilter(mFilter);

                // Win7 下与 XP\2003 等,Calendar 的大小不一
                this.ClientSize = tsCalendar.Size;
            }
            catch (Exception ex)
            {
                CommonFuntion.OnDealError(this, ex);
            }
        }
Esempio n. 14
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                mFilter = new TSPopupWindowMessageFilter(this, mOwnerControl);
                Application.AddMessageFilter(mFilter);

                if (!this.ManageButtonVisible)
                {
                    this.Height = 200;
                }
            }
            catch (Exception ex)
            {
                CommonFuntion.OnDealError(this, ex);
            }
        }
Esempio n. 15
0
 private void pnlButton_MouseMove(object sender, MouseEventArgs e)
 {
     try
     {
         if (mbMouseDownInAdd && !mrectAdd.Contains(e.Location))
         {
             mbMouseDownInAdd = false;
             pnlButton.Invalidate(mrectAdd);
         }
         else if (mbMouseDownInManager && !mrectManager.Contains(e.Location))
         {
             mbMouseDownInManager = false;
             pnlButton.Invalidate(mrectManager);
         }
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
Esempio n. 16
0
        private void lstBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            try
            {
                int iIndex = e.Index;
                if (iIndex < 0 || mdvSource == null || mdvSource.Count == 0 || iIndex + 1 > mdvSource.Count)
                {
                    return;
                }

                DataRowView drv = this.mdvSource[iIndex];

                e.DrawBackground();
                Color colorFont = this.ForeColor;
                Color colorLine = Color.LightGray;

                //// System.Diagnostics.Debug.WriteLine( "OnDrawItem:" + e.Index.ToString() + "  -------------------" );

                if ((e.State & DrawItemState.Selected) == DrawItemState.Selected ||
                    (e.State & DrawItemState.Focus) == DrawItemState.Focus ||
                    (e.State & DrawItemState.HotLight) == DrawItemState.HotLight)
                {
                    e.DrawFocusRectangle();
                    colorFont = this.BackColor;
                    colorLine = this.BackColor;

                    //// System.Diagnostics.Debug.WriteLine( "DrawFocusRectangle: State = " + e.State.ToString() );
                }

                using (Pen pen = new Pen(colorLine))
                {
                    using (SolidBrush brush = new SolidBrush(colorFont))
                    {
                        int iLeft = 0;
                        for (int i = 0, j = this.mListColumns.Count; i < j; i++)
                        {
                            // 分隔线
                            if (i > 0)
                            {
                                e.Graphics.DrawLine(pen,
                                                    (float)(e.Bounds.X + iLeft - 2), e.Bounds.Y,
                                                    (float)(e.Bounds.X + iLeft - 2), e.Bounds.Y + e.Bounds.Height);
                            }

                            // 字段的值
                            string strCur = GetCellValueString(drv, this.mListColumns[i]);

                            if (strCur != "")
                            {
                                e.Graphics.DrawString(strCur, this.Font, brush,
                                                      (float)(e.Bounds.X + iLeft + 2), e.Bounds.Y + 1);
                            }

                            //// System.Diagnostics.Debug.WriteLine( "DrawString: Font = " + colorFont.ToString() + "\tState = " + e.State.ToString() );

                            if (this.mlstColumnWidth.Count > i)                                 // 多线程进入?不加判断会出错
                            {
                                iLeft += this.mlstColumnWidth[i];
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonFuntion.OnDealError(this, ex);
            }
        }