/// <summary> /// Specifies whether this System.Drawing.Size structure has the same dimensions as the specified System.Drawing.Size structure. /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(Size other) { return m_Width == other.m_Width && m_Height == other.m_Height; }
/// <summary> /// Enlarges this System.Drawing.Rectangle by the specified amount. /// </summary> /// <param name="size">The amount to inflate this System.Drawing.Rectangle</param> public void Inflate(Size size) { m_Width += size.Width; m_Height += size.Height; }
/// <summary> /// Initializes a new instance of the System.Drawing.Point class from a System.Drawing.Size. /// </summary> /// <param name="sz">A System.Drawing.Size that specifies the coordinates for the new System.Drawing.Point.</param> public Point(Size sz) : this(sz.Width, sz.Height) { }
/// <summary> /// Initializes a new instance of the System.Drawing.Rectangle class with the specified location and size. /// </summary> /// <param name="location">A System.Drawing.Point that represents the upper-left corner of the rectangular region.</param> /// <param name="size">A System.Drawing.Size that represents the width and height of the rectangular region.</param> public Rectangle(Point location, Size size) : this(location.X, location.Y, size.Width, size.Height) { }
/// <summary> /// Draw a simple battery to the screen /// </summary> /// <param name="screen"></param> /// <param name="batteryPosition"></param> /// <param name="batteryWidth"></param> /// <param name="batteryHeight"></param> /// <param name="borderThickness"></param> /// <param name="batteryColor"></param> /// <param name="backColor"></param> public Size DrawBattery(Bitmap screen, Point batteryPosition, int batteryWidth, int batteryHeight, int borderThickness, Color batteryColor, Color backColor, bool charging, int batteryLevel) { //calculate filler double fillerWidth = (batteryWidth - (borderThickness*1)); double percent = ((double)batteryLevel * 0.01); double actualFillerWidth = fillerWidth*percent; //calculate nub double nubHight = batteryHeight*0.5; double nubWidth = batteryHeight*0.1; double nubTop = (((double) batteryHeight)/2) - (nubHight/2); Point nubPosition = new Point(batteryPosition.X + batteryWidth, batteryPosition.Y + (int) System.Math.Floor(nubTop)); //draw filler int paintedFiller = (int) actualFillerWidth; if (paintedFiller < 0) paintedFiller = 0; screen.DrawRectangle(backColor, 1, batteryPosition.X + 1, batteryPosition.Y + 1, paintedFiller, batteryHeight - 2, 0, 0, batteryColor, 0, 0, batteryColor, 0, 0, 255); //draw main battery outline screen.DrawRectangle(batteryColor, borderThickness, batteryPosition.X, batteryPosition.Y, batteryWidth, batteryHeight, 0, 0, backColor, 0, 0, backColor, 0, 0, 0); //draw battery nub screen.DrawRectangle(batteryColor, 1, nubPosition.X, nubPosition.Y, (int) nubWidth, (int) nubHight, 0, 0, batteryColor, 0, 0, batteryColor, 0, 0, 255); //draw inner border var batterySize = new Size(batteryWidth + (int) nubWidth, batteryHeight); if (charging) { //draw charging indicator double iconHeight = (int)(nubHight*0.20); double iconTop = batteryPosition.Y + ((double)batteryHeight/2 - iconHeight/2)+1; double iconLeft = batteryPosition.X + 4; double iconWidth = (int)(iconLeft + actualFillerWidth - 5); screen.DrawLine(backColor, (int)iconHeight, (int)iconLeft, (int)iconTop, (int)iconWidth, (int)iconTop); } return batterySize; }