using System;
using System.Drawing;
using System.Windows.Forms;
namespace _27639257
{
public partial class RulerBox : UserControl
{
/// <summary>
/// Initializes a new instance of the <see cref="RulerBox"/> class.
/// </summary>
public RulerBox()
{
InitializeComponent();
this.label1.Left = this.textBox1.ClientRectangle.Left;
}
/// <summary>
/// Handles the FontChanged event of the RulerBox control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void RulerBox_FontChanged(object sender, EventArgs e)
{
this.textBox1.Font = this.label1.Font = this.Font;
}
/// <summary>
/// Handles the Paint event of the label1 control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
private void label1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
SizeF sizeofW = g.MeasureString("W", this.Font, 0, StringFormat.GenericTypographic);
float halfWidth = (sizeofW.Width / 2F);
float halfHeight = (sizeofW.Height / 2F);
for (float i = (halfWidth + (this.textBox1.Bounds.Left - this.textBox1.ClientRectangle.Left)), x = 1; i < this.ClientRectangle.Width; i += sizeofW.Width, x++)
{
if (x % 10 == 0)
{
g.DrawString(x.ToString(), this.Font, Brushes.Black, (i - halfWidth), 1);
g.DrawLine(Pens.Black, i, halfHeight + 5, i, this.label1.ClientRectangle.Height);
}
else
{
g.DrawLine(Pens.Black, i, halfHeight + 8, i, this.label1.ClientRectangle.Height);
}
}
}
/// <summary>
/// Performs the work of setting the specified bounds of this control.
/// </summary>
/// <param name="x">The new <see cref="P:System.Windows.Forms.Control.Left"/> property value of the control.</param>
/// <param name="y">The new <see cref="P:System.Windows.Forms.Control.Top"/> property value of the control.</param>
/// <param name="width">The new <see cref="P:System.Windows.Forms.Control.Width"/> property value of the control.</param>
/// <param name="height">The new <see cref="P:System.Windows.Forms.Control.Height"/> property value of the control.</param>
/// <param name="specified">A bitwise combination of the <see cref="T:System.Windows.Forms.BoundsSpecified"/> values.</param>
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
{
base.SetBoundsCore(x, y, width, this.textBox1.Height + this.label1.Height, specified);
}
/// <summary>
/// Handles the Resize event of the RulerBox control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void RulerBox_Resize(object sender, EventArgs e)
{
this.label1.Width = this.textBox1.Width = this.Width;
}
}
}