public void Init(Graphics gform_, float xFormPos_, float yFormPos_, float xmax_, float ymax_) { gform = gform_; xFormPos = xFormPos_; yFormPos = yFormPos_; areaxmax = xmax_; areaymax = ymax_; LeftOffset = 5; RightOffset = 85; TopOffset = 22; DownOffset = 23; xstart = LeftOffset; ystart = DownOffset; xend = areaxmax - RightOffset; yend = areaymax - TopOffset; draww = xend - xstart; drawh = yend - ystart; ChartButton selButton = GetSelectedButton(); float bx = 4; float bxadd = 3; float sx = 26; float bsizeh = 18; /* * buttonMonth = new ChartButton(new PointF(bx, areaymax - bsizeh), new PointF(sx, bsizeh-2), "M"); * bx += sx + bxadd; * buttonWeek = new ChartButton(new PointF(bx, areaymax - bsizeh), new PointF(sx, bsizeh - 2), "W"); * bx += sx + bxadd; * buttonDay = new ChartButton(new PointF(bx, areaymax - bsizeh), new PointF(sx, bsizeh - 2), "D"); * bx += sx + bxadd; * buttonHour = new ChartButton(new PointF(bx, areaymax - bsizeh), new PointF(sx, bsizeh - 2), "H"); * bx += sx + bxadd; * buttonMin15 = new ChartButton(new PointF(bx, areaymax - bsizeh), new PointF(sx, bsizeh - 2), "M15"); * bx += sx + bxadd; * buttonMin5 = new ChartButton(new PointF(bx, areaymax - bsizeh), new PointF(sx, bsizeh - 2), "M5"); * bx += sx + 12; * // sx = 30; */ buttonZoomPlus = new ChartButton(new PointF(bx, areaymax - bsizeh), new PointF(sx, bsizeh - 2), "+"); bx += sx + bxadd; buttonZoomMinus = new ChartButton(new PointF(bx, areaymax - bsizeh), new PointF(sx, bsizeh - 2), "-"); bmap = new Bitmap((int)areaxmax, (int)areaymax); g = Graphics.FromImage(bmap); if (selButton != null) { SelectButton(selButton.text); } }
private bool MouseOnButton(ChartButton button) { if (mouseareax >= button.pos.X && mouseareax <= button.pos.X + button.size.X) { if (mouseareay >= button.pos.Y && mouseareay <= button.pos.Y + button.size.Y) { return(true); } } return(false); }
private void DrawButton(ChartButton button) { if (button.clicked) { DrawRectangle(Pens.Red, Brushes.LightCoral, button.pos, button.size, true); } else { DrawRectangle(Pens.Red, Brushes.DarkGray, button.pos, button.size, true); } PointF pos = new PointF(button.pos.X, button.pos.Y + button.size.Y); SizeF strsize = Helper.StringSize(g, style.strLabelSelFont, button.text); pos.X += button.size.X / 2 - strsize.Width / 2; DrawString(Brushes.Black, style.strLabelSelFont, pos, button.text); }