Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
 void ctrlOwner_LostFocus(object sender, EventArgs e)
 {
     try
     {
         this.Hide();
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
Beispiel #4
0
 private void frmFullPictureViewer_SizeChanged(object sender, EventArgs e)
 {
     try
     {
         this.picMain.ZoomFit();
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
Beispiel #5
0
 void btnBig_Click(object sender, EventArgs e)
 {
     try
     {
         this.picMain.ZoomPlus();
     }
     catch (Exception ex)
     {
         CommonFuntion.OnDealError(this, ex);
     }
 }
Beispiel #6
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         this.TopMost = checkBox1.Checked;
     }
     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);
     }
 }
Beispiel #8
0
        public string Value4DBGet()
        {
            string strCode = "";

            if (mImg != null)
            {
                strCode = GetImageBase64(mImg);
                strCode = CommonFuntion.Zip(strCode);
            }

            return(strCode);
        }
Beispiel #9
0
        /// <summary>
        /// 从一个指定的图片,转换成数据库保存格式的字符串
        /// </summary>
        /// <param name="image">图片</param>
        /// <returns>数据库保存格式的字符串</returns>
        public static string GetValue4DBFromImage(Image image)
        {
            string strCode = "";

            if (image != null)
            {
                strCode = GetImageBase64(image);
                strCode = CommonFuntion.Zip(strCode);
            }

            return(strCode);
        }
Beispiel #10
0
 protected override void OnClick(EventArgs e)
 {
     try
     {
         mbIsExpanded = !mbIsExpanded;
         base.OnClick(e);
         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);
     }
 }
Beispiel #12
0
        protected override void OnLeave(EventArgs e)
        {
            base.OnLeave(e);

            try
            {
                mbIsEnter = false;
                Repaint();
            }
            catch (Exception ex)
            {
                CommonFuntion.OnDealError(this, ex);
            }
        }
Beispiel #13
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);
            }
        }
Beispiel #14
0
        private string GetImageBase64(Image img)
        {
            string s = "";

            if (mbImageFromStream)
            {
                s = Base64.ToBase64(mBuffers);
            }
            else
            {
                byte[] b = CommonFuntion.GetImageBytes(img);
                s = Base64.ToBase64(b);
            }

            return(s);
        }
Beispiel #15
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);
            }
        }
Beispiel #17
0
        /// <summary>
        /// 从数据库保存的图片数据转换成图片
        /// </summary>
        /// <param name="value">图片数据字符串</param>
        /// <returns>图片</returns>
        public static Image GetImageFromValue4DB(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }

            byte[] buffers = null;
            Image  img     = null;

            if (!string.IsNullOrEmpty(value))
            {
                string strCode = CommonFuntion.UnZip(value);
                img = ImageFromBase64(strCode, out buffers);
            }

            return(img);
        }
Beispiel #18
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);
            }
        }
Beispiel #19
0
        public void Value4DBSet(string value)
        {
            byte[] buffers = null;
            Image  img     = null;

            if (!string.IsNullOrEmpty(value))
            {
                string strCode = CommonFuntion.UnZip(value);
                img = ImageFromBase64(strCode, out buffers);
            }

            this.Image = img;

            if (buffers != null)
            {
                mbImageFromStream = true;
                mBuffers          = buffers;
            }
        }
Beispiel #20
0
        /// <summary>
        /// 从一个指定的文件,转换成数据库保存格式的字符串
        /// </summary>
        /// <param name="strFile">文件全名,含扩展名及路径</param>
        /// <returns>数据库保存格式的字符串</returns>
        public static string GetValue4DBFromFile(string strFullFileName)
        {
            string strCode = "";

            if (!File.Exists(strFullFileName))
            {
                throw new FileNotFoundException();
            }

            using (Image image = Image.FromFile(strFullFileName))
            {
                if (image != null)
                {
                    strCode = GetImageBase64(image);
                    strCode = CommonFuntion.Zip(strCode);
                }
            }

            return(strCode);
        }
Beispiel #21
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);
     }
 }
Beispiel #22
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);
            }
        }
Beispiel #23
0
 /// <summary>
 /// 计算字符串转为单字节字符的长度
 /// </summary>
 /// <param name="StringToCount">字符串</param>
 /// <returns>单字节长度</returns>
 public static int StringSingleByteLen(string StringToCount)
 {
     return(CommonFuntion.StringSBCSLength(StringToCount));
 }