public void Draw(Graphics g) { DrawBorderHandler(g, PositionRect, backColor); if (selected) { //選中時邊框變 CustomRectangle rect = new CustomRectangle(x - 4, y - 4, 8, 8); g.DrawRectangle(new Pen(Color.Black), rect.ToRectangle()); } }
public static CustomRectangle ToCustomRectangle(RectangleF re) { CustomRectangle cus = new CustomRectangle(); cus.X = re.X; cus.Y = re.Y; cus.Width = re.Width; cus.Height = re.Height; return(cus); }
private void VistaCPUInfo_Resize(object sender, EventArgs e) { if (positionRect == null) { positionRect = new CustomRectangle(); } positionRect.Width = 202; positionRect.Height = 159; positionRect.Top = (int)(this.ClientSize.Height < 159 ? 0 : (this.ClientSize.Height - 159) / 2f); positionRect.Left = (int)(this.ClientSize.Width < 202 ? 0 : (this.ClientSize.Width - 202) / 2f); if (!this.timer.Enabled) { this.timer.Enabled = true; } this.Invalidate(); }
public bool MouseHitTest(PointF pt) { CustomRectangle rect = new CustomRectangle(x - 5, y - 5, 10, 10); //判斷選中時加點誤差,使選中更加順利 return(rect.IsPointFInRectangle(pt.X, pt.Y)); }
private void DrawBorderHandler(Graphics g, CustomRectangle rect, Color clr) { g.FillRectangle(new SolidBrush(clr), rect.ToRectangleF()); g.DrawRectangle(new Pen(Color.Black), rect.ToRectangle()); }