private void _ImgMouseLeave(object sender, EventArgs e) { UiControlsMethod.PictureBoxEx Lg = (UiControlsMethod.PictureBoxEx)sender; Lg.BackColor = _leaveColor; Bitmap bmp_item = new Bitmap(Lg.Width, Lg.Height); Graphics gItem = Graphics.FromImage(bmp_item); gItem.DrawImage(_dropItemList[(int)Lg.Parent.Tag]._bmpItem, _bmpItemXY); UiDrawTextMethod _ds = new UiDrawTextMethod(); _ds.DrawString(bmp_item, _dropItemList[(int)Lg.Parent.Tag]._string, _fnt, _fntcolor, new Rectangle(_stringItemXY, bmp_item.Size)); Lg.Image = bmp_item; Lg.Update(); }
public void _setProgress(int _skip) { if (_skip == _maxNum) { _skip = _operationWidth; } else { var t = (decimal)_operationWidth / _maxNum; _skip = (int)(_skip * t); } Bitmap _progressImage = bmp_progress.Clone(new Rectangle(0, 0, bmp_progress.Width, bmp_progress.Height), System.Drawing.Imaging.PixelFormat.DontCare); Graphics _gblock = Graphics.FromImage(_progressImage); _gblock.DrawImage(gress_Left, m_set[6], m_set[8], gress_Left.Width, gress_Left.Height); for (int i = 0; i < _skip; i++) { _gblock.DrawImage(gress_Mid, m_set[6] + m_set[3] + i, m_set[8], 1, gress_Mid.Height); } _gblock.DrawImage(gress_Right, m_set[6] + m_set[3] + _skip, m_set[8], m_set[5], gress_Right.Height); _progress.Image = _progressImage; _progress.Update(); if (showFlag) { Bitmap bmp_flag = new Bitmap(_progressFlag.Width, _progressFlag.Height); Graphics gFlag = Graphics.FromImage(bmp_flag); gFlag.DrawImage(_bmpFlag, _skip + (_bmpFlag.Width / 2) + m_set[3] + m_set[5], 0, _bmpFlag.Width, _bmpFlag.Height); progressValue = (_skip / (float)_operationWidth * 100).ToString("#0"); int str_x = m_flag[1]; str_x = str_x - (progressValue.Length - 1) * 3; ud.DrawString( bmp_flag, progressValue + "%", fnt, txt_Color, new Rectangle(_skip + (_bmpFlag.Width / 2) + m_set[3] + m_set[5] + m_flag[1] + str_x, m_flag[2], 30, 20) ); _progressFlag.Image = bmp_flag; _progressFlag.Update(); } }
public void InitializeCalendar(Control _obj, int _timeType, string _setTime, int _dispType, Point _location, double _transparency) { _dayList.Clear(); obj = _obj; timeType = _timeType; setTime = _setTime; dispType = _dispType; location = _location; transparency = _transparency; int str_X = 0, str_Y = 0, skip_X = 0, skip_Y = 0; int head_X = 0, head_Y = 0; Size ImgSize; int cut_X = 0, cut_Y = 0; UiDrawTextMethod ud = new UiDrawTextMethod(); Font fnt; if (_timeType == 1) { try { string[] splitString = _setTime.Split(new string[] { "-" }, StringSplitOptions.None); dy = int.Parse(splitString[0]); dm = int.Parse(splitString[1]); } catch { } } else { dy = DateTime.Today.Year; dm = DateTime.Today.Month; dd = DateTime.Today.Day; } //year before last int qdy = dy; int qdm; if (dm == 1) { qdm = 12; qdy = dy - 1; } else { qdm = dm - 1; } int q_mday = DateTime.DaysInMonth(qdy, qdm); //Next year int ndy = dy + 1; int ndm; if ((dm + 1) == 13) { ndm = 1; } else { ndm = dm + 1; } // now int t_mday = DateTime.DaysInMonth(dy, dm); DateTime tmDate = new DateTime(dy, dm, 1); int t_week = (int)tmDate.DayOfWeek; if (t_week == 0) { t_week = 7; } string str_YMD; for (int i = 0; i < t_week - 1; i++) { if (dm == 1) { str_YMD = (dy - 1) + "-12-" + (q_mday - t_week + i + 2); } else { str_YMD = dy + "-" + (dm - 1) + "-" + (q_mday - t_week + i + 2); } addDay(q_mday - t_week + i + 2, Color.Gainsboro, false, str_YMD, new Rectangle(0, 0, 0, 0)); } for (int i = 0; i < t_mday; i++) { str_YMD = dy + "-" + dm + "-" + (i + 1); if (DateTime.Today.ToString("yyyy-M-d") == str_YMD) { addDay(i + 1, Color.Crimson, false, str_YMD, new Rectangle(0, 0, 0, 0)); } else { addDay(i + 1, Color.Black, false, str_YMD, new Rectangle(0, 0, 0, 0)); } } for (int i = 0; i < (42 - t_week - t_mday) + 1; i++) { if (dm == 12) { str_YMD = (dy + 1) + "-1-" + (i + 1); } else { str_YMD = dy + "-" + (dm + 1) + "-" + (i + 1); } addDay(i + 1, Color.Gainsboro, false, str_YMD, new Rectangle(0, 0, 0, 0)); } bkImg = new Bitmap(235, 185); switch (_dispType) { case 0: _bmp = SQK_Ui.Calendar.calendarResource.cal_1; bkImg = _bmp.Clone(new Rectangle(5, 5, 235, 185), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); str_X = 15; str_Y = 62; skip_X = 33; skip_Y = 21; head_X = 80; head_Y = 7; ImgSize = new Size(245, 200); cut_X = 5; cut_Y = 5; fnt = new Font("微软雅黑", 10, FontStyle.Bold); m_set = new int[4, 4] { { 5, 21, 11, 21 }, { 28, 38, 11, 21 }, { 194, 204, 11, 21 }, { 213, 228, 11, 21 } }; break; case 1: _bmp = SQK_Ui.Calendar.calendarResource.cal_2; bkImg = _bmp.Clone(new Rectangle(5, 5, 235, 185), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); str_X = 15; str_Y = 62; skip_X = 33; skip_Y = 21; head_X = 80; head_Y = 7; ImgSize = new Size(245, 200); cut_X = 5; cut_Y = 5; fnt = new Font("微软雅黑", 10, FontStyle.Bold); m_set = new int[4, 4] { { 5, 21, 11, 21 }, { 28, 38, 11, 21 }, { 194, 204, 11, 21 }, { 213, 228, 11, 21 } }; break; case 2: _bmp = SQK_Ui.Calendar.calendarResource.cal_3; bkImg = _bmp.Clone(new Rectangle(8, 8, 272, 284), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); str_X = 9; str_Y = 58; skip_X = 40; skip_Y = 40; head_X = 95; head_Y = 5; ImgSize = new Size(288, 300); cut_X = 8; cut_Y = 8; fnt = new Font("微软雅黑", 14, FontStyle.Bold); m_set = new int[4, 4] { { 8, 24, 5, 21 }, { 48, 58, 5, 21 }, { 211, 221, 5, 21 }, { 246, 261, 5, 21 } }; break; default: _bmp = SQK_Ui.Calendar.calendarResource.cal_1; bkImg = _bmp.Clone(new Rectangle(5, 5, 235, 185), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); str_X = 15; str_Y = 62; skip_X = 33; skip_Y = 21; head_X = 80; head_Y = 7; ImgSize = new Size(245, 200); cut_X = 5; cut_Y = 5; fnt = new Font("微软雅黑", 10, FontStyle.Bold); break; } ud.DrawString(bkImg, dy + "年" + dm + "月", fnt, Color.White, new Rectangle(head_X, head_Y, 120, 20)); for (int i = 0; i < 6; i++) { for (int u = 0; u < 7; u++) { if (_dayList[i * 7 + u].day < 10) { ud.DrawString(bkImg, _dayList[i * 7 + u].day.ToString(), fnt, _dayList[i * 7 + u].dcolor, new Rectangle(str_X + u * skip_X, str_Y + i * skip_Y, 25, 20)); _dayList[i * 7 + u].mouseRect = new Rectangle(str_X - 5 + u * skip_X, str_Y + i * skip_Y, 22, 18); } else { ud.DrawString(bkImg, _dayList[i * 7 + u].day.ToString(), fnt, _dayList[i * 7 + u].dcolor, new Rectangle(str_X - 5 + u * skip_X, str_Y + i * skip_Y, 25, 20)); _dayList[i * 7 + u].mouseRect = new Rectangle(str_X - 5 + u * skip_X, str_Y + i * skip_Y, 22, 18); } } } if (!_show) { calenForm = new AlphaForm(); calenForm.ShowInTaskbar = false; calenForm.ShowIcon = false; calenForm.FormBorderStyle = FormBorderStyle.None; calenForm.StartPosition = FormStartPosition.Manual; calenForm.Animation = AlphaForm.Animations.None; calenForm.Opacity = _transparency; calenForm.TopMost = true; calenForm.Size = new Size(_bmp.Width, _bmp.Height); calenForm.Location = _location; calenForm.窗体图像 = _bmp; pb.Size = ImgSize; pb.Location = new Point(cut_X, cut_Y); pb.Image = bkImg; pb.MouseMove += new MouseEventHandler(_MouseMove); pb.MouseClick += new MouseEventHandler(_MouseClick); pb.MouseDown += new MouseEventHandler(_MouseDown); calenForm.Controls.Add(pb); calenForm.Show(); _show = true; } else { pb.Image = bkImg; calenForm.SetOpacity(_transparency * 255); } }
public void add_dropItemList( int _type, Size panelSize, Bitmap bmpItem, Point bmpItemXY, string stringItem, Point stringItemXY, Font fnt, Color fnt_color, Color _selectBkColor, Bitmap select_bmpItem, Color select_fntcolor ) { switch (_type) { case 0: backcolor = Color.FromArgb(246, 246, 246); break; case 1: backcolor = Color.FromArgb(40, 45, 52); break; case 2: backcolor = Color.FromArgb(239, 238, 238); break; case 3: backcolor = Color.FromArgb(52, 73, 94); break; default: backcolor = Color.FromArgb(246, 246, 246); break; } _moveColor = _selectBkColor; _leaveColor = backcolor; _select_fntcolor = select_fntcolor; _bmpItemXY = bmpItemXY; _stringItem = stringItem; _stringItemXY = stringItemXY; _fnt = fnt; _fntcolor = fnt_color; UiControlsMethod.PanelEx _panel = new UiControlsMethod.PanelEx(); UiControlsMethod.PictureBoxEx _itemImage = new UiControlsMethod.PictureBoxEx(); _panel.Size = panelSize; _panel.BackColor = Color.Transparent; Bitmap bmp_item = new Bitmap(panelSize.Width, panelSize.Height); Graphics gItem = Graphics.FromImage(bmp_item); gItem.DrawImage(bmpItem, bmpItemXY); UiDrawTextMethod _ds = new UiDrawTextMethod(); _ds.DrawString(bmp_item, stringItem, fnt, fnt_color, new Rectangle(stringItemXY, panelSize)); _itemImage.BackColor = backcolor; _itemImage.Size = panelSize; _itemImage.Image = bmp_item; _itemImage.Location = new Point(0, 0); _itemImage.MouseMove += new MouseEventHandler(_ImgMouseMove); _itemImage.MouseLeave += new EventHandler(_ImgMouseLeave); _itemImage.Click += new EventHandler(_ImgClick); _panel.Controls.Add(_itemImage); _dropItemList.Add(new dropItem { item_font = fnt, dropItemPanel = _panel, _string = stringItem, _bmpItem = bmpItem, _select_bmpItem = select_bmpItem } ); }
public static void _showToolTips(Control _obj, Point _mousePoint) { if ((_obj.Visible) && (_toolTipsList.Count > 0)) { for (int i = 0; i < _toolTipsList.Count; i++) { if ( ((_mousePoint.X >= (_toolTipsList[i]._obj.Location.X + _toolTipsList[i].mouseRect.X)) && (_mousePoint.X <= (_toolTipsList[i]._obj.Location.X + _toolTipsList[i].mouseRect.X + _toolTipsList[i].mouseRect.Width))) && ((_mousePoint.Y >= (_toolTipsList[i]._obj.Location.Y + _toolTipsList[i].mouseRect.Y)) && (_mousePoint.Y <= (_toolTipsList[i]._obj.Location.Y + _toolTipsList[i].mouseRect.Y + _toolTipsList[i].mouseRect.Height))) ) { if (!_toolTipsList[i]._showTips) { _toolTipsList[i].FormTips = new AlphaForm(); _toolTipsList[i].FormTips.FormBorderStyle = FormBorderStyle.None; _toolTipsList[i].FormTips.StartPosition = FormStartPosition.Manual; _toolTipsList[i].FormTips.Location = new Point(_toolTipsList[i]._location.X + _toolTipsList[i]._obj.Location.X, _toolTipsList[i]._location.Y + _toolTipsList[i]._obj.Location.Y); _toolTipsList[i].FormTips.ShowInTaskbar = false; _toolTipsList[i].FormTips.ShowIcon = false; _toolTipsList[i].FormTips.SizeMode = SizeModes.None; _toolTipsList[i].FormTips.Opacity = _toolTipsList[i]._trans; _toolTipsList[i].FormTips.TopMost = true; switch (_toolTipsList[i]._animation) { case 0: _toolTipsList[i].FormTips.Animation = Animations.None; _toolTipsList[i].FormTips.AnimationSpeed = _toolTipsList[i]._animationSpeed; break; case 1: _toolTipsList[i].FormTips.Animation = Animations.Fading; _toolTipsList[i].FormTips.AnimationSpeed = _toolTipsList[i]._animationSpeed; break; case 2: _toolTipsList[i].FormTips.Animation = Animations.rotation; _toolTipsList[i].FormTips.AnimationSpeed = _toolTipsList[i]._animationSpeed; break; default: break; } switch (_toolTipsList[i]._tipsType) { case 1: _toolTipsList[i].FormTips.窗体图像 = SQK_Ui.Tooltips.TipsResource.tips_1; break; case 2: _toolTipsList[i].FormTips.窗体图像 = SQK_Ui.Tooltips.TipsResource.tips_2; break; case 3: _toolTipsList[i].FormTips.窗体图像 = SQK_Ui.Tooltips.TipsResource.tips_3; break; case 4: _toolTipsList[i].FormTips.窗体图像 = SQK_Ui.Tooltips.TipsResource.tips_4; break; case 5: // tips - 5 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(100, _toolTipsList[i]._size.Width, _toolTipsList[i]._size.Height); break; case 6: // tips - 6 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(121, _toolTipsList[i]._size.Width, SQK_Ui.Tooltips.TipsResource.tips_6.Height); break; case 7: // tips - 7 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(122, _toolTipsList[i]._size.Width, SQK_Ui.Tooltips.TipsResource.tips_7.Height); break; case 8: // tips - 8 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(123, _toolTipsList[i]._size.Width, SQK_Ui.Tooltips.TipsResource.tips_8.Height); break; case 9: // tips - 9 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(141, _toolTipsList[i]._size.Width, _toolTipsList[i]._size.Height); break; case 10: // tips - 10 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(142, _toolTipsList[i]._size.Width, _toolTipsList[i]._size.Height); break; case 11: // tips - 11 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(161, _toolTipsList[i]._size.Width, _toolTipsList[i]._size.Height); break; case 12: _toolTipsList[i].FormTips.窗体图像 = SQK_Ui.Tooltips.TipsResource.tips_12; break; case 13: // tips - 13 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(124, _toolTipsList[i]._size.Width, _toolTipsList[i]._size.Height); break; case 14: // tips - 14 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(125, _toolTipsList[i]._size.Width, _toolTipsList[i]._size.Height); break; case 15: // tips - 15 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(143, _toolTipsList[i]._size.Width, _toolTipsList[i]._size.Height); break; case 16: // tips - 16 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(144, _toolTipsList[i]._size.Width, _toolTipsList[i]._size.Height); break; case 17: // tips - 17 _toolTipsList[i].FormTips.窗体图像 = new CutPixelAlphaImage().CutAlphaFormImage(145, _toolTipsList[i]._size.Width, _toolTipsList[i]._size.Height); break; default: break; } if (_addImgList.Count > 0) { for (int t = 0; t < _addImgList.Count; t++) { if (_addImgList[t]._mainName == _toolTipsList[i]._tipsName) { Graphics _addbmp = Graphics.FromImage(_toolTipsList[i].FormTips.窗体图像); _addbmp.DrawImage(_addImgList[t]._image, _addImgList[t]._setXY); } } } if (_addStringList.Count > 0) { for (int t = 0; t < _addStringList.Count; t++) { if (_addStringList[t]._mainName == _toolTipsList[i]._tipsName) { UiDrawTextMethod ds = new UiDrawTextMethod(); ds.DrawString( _toolTipsList[i].FormTips.窗体图像, _addStringList[t]._string, _addStringList[t]._stringFont, _addStringList[t]._stringColor, new Rectangle(_addStringList[t]._stringXY.X, _addStringList[t]._stringXY.Y, _toolTipsList[i]._size.Width, _toolTipsList[i]._size.Height), _addStringList[t]._shadow, _addStringList[t]._distance ); } } } _toolTipsList[i].FormTips.Size = new Size(_toolTipsList[i].FormTips.窗体图像.Width, _toolTipsList[i].FormTips.窗体图像.Height); _toolTipsList[i]._showTips = true; _toolTipsList[i].FormTips.Show(); } } else { if (_toolTipsList[i]._showTips) { _toolTipsList[i]._showTips = false; _toolTipsList[i].FormTips.Close(); } } } } }
public void InitializeStyleButton( Control _obj, int _type, int _width, Bitmap _bmp, Point _bmplocation, Font fnt, string _string, Color _stringcolor, Rectangle _stringrec, Point _location, MouseEventHandler _click ) { Bitmap _BmpBlock; int[] cutImg; //cut image left,middle, right width; switch (_type) { case 0: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn1; cutImg = new int[3] { 40, 1, 10 }; break; case 1: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn2; cutImg = new int[3] { 40, 1, 10 }; break; case 2: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn3; cutImg = new int[3] { 40, 1, 10 }; break; case 3: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn4; cutImg = new int[3] { 40, 1, 10 }; break; case 4: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn5; cutImg = new int[3] { 40, 1, 10 }; break; case 5: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn6; cutImg = new int[3] { 40, 1, 10 }; break; case 6: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn7; cutImg = new int[3] { 40, 1, 10 }; break; case 7: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn8; cutImg = new int[3] { 40, 1, 10 }; break; case 8: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn9; cutImg = new int[3] { 40, 1, 10 }; break; case 9: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn10; cutImg = new int[3] { 40, 1, 10 }; break; case 10: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn11; cutImg = new int[3] { 10, 1, 10 }; break; case 11: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn12; cutImg = new int[3] { 10, 1, 10 }; break; case 12: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn13; cutImg = new int[3] { 3, 1, 3 }; break; case 13: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn14; cutImg = new int[3] { 3, 1, 3 }; break; case 14: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn15; cutImg = new int[3] { 45, 1, 12 }; break; case 15: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn16; cutImg = new int[3] { 45, 1, 12 }; break; case 16: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn17; cutImg = new int[3] { 45, 1, 12 }; break; case 17: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn18; cutImg = new int[3] { 45, 1, 12 }; break; case 18: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn19; cutImg = new int[3] { 45, 1, 12 }; break; case 19: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn20; cutImg = new int[3] { 45, 1, 12 }; break; case 20: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn21; cutImg = new int[3] { 45, 1, 12 }; break; case 21: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn22; cutImg = new int[3] { 45, 1, 12 }; break; default: _BmpBlock = SQK_Ui.StyleButton.StyleButtonResource.s_btn1; cutImg = new int[3] { 40, 1, 10 }; break; } Bitmap sep_Left = _BmpBlock.Clone(new Rectangle(0, 0, cutImg[0], _BmpBlock.Height), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); Bitmap sep_Middle = _BmpBlock.Clone(new Rectangle(cutImg[0], 0, cutImg[1], _BmpBlock.Height), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); Bitmap sep_Right = _BmpBlock.Clone(new Rectangle(_BmpBlock.Width - cutImg[2], 0, cutImg[2], _BmpBlock.Height), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); Bitmap bmpBtn = new Bitmap(cutImg[0] + _width + cutImg[2], _BmpBlock.Height); Graphics btnImg = Graphics.FromImage(bmpBtn); btnImg.DrawImage(sep_Left, 0, 0); for (int i = 0; i < _width; i++) { btnImg.DrawImage(sep_Middle, cutImg[0] + i, 0); } btnImg.DrawImage(sep_Right, cutImg[0] + _width, 0); btnImg.DrawImage(_bmp, _bmplocation); UiDrawTextMethod ds = new UiDrawTextMethod(); ds.DrawString(bmpBtn, _string, fnt, _stringcolor, _stringrec); UiControlsMethod.PictureBoxEx sbtn = new UiControlsMethod.PictureBoxEx(); sbtn.BackColor = Color.Transparent; sbtn.Size = new Size(cutImg[0] + _width + cutImg[2], _BmpBlock.Height); sbtn.Location = _location; sbtn.Image = bmpBtn; sbtn.MouseClick += _click; _obj.Controls.Add(sbtn); }