Siticone Ruler Control
The SiticoneRuler is a professional, high-precision measurement control for Windows Forms.
It supports both metric (Centimeters) and imperial (Inches) units, horizontal and vertical orientations, and features dual draggable markers for measuring distances or defining ranges.
It is fully DPI-aware and responsive, ensuring accuracy across different screen resolutions.
To ensure this control provides accurate real-world measurements on different screens, your application must be DPI-aware. Please uncomment or add the DPI-Aware settings in your
app.manifest file as detailed in the source code header.
Core Configuration
Configure the scale, orientation, and measurement units of the ruler.
| Property | Type | Description & Usage Example |
|---|---|---|
Orientation |
RulerOrientation |
ruler.Orientation = RulerOrientation.Vertical;
Sets the layout direction. Can be Horizontal (default) or Vertical.
|
Unit |
MeasurementUnit |
ruler.Unit = MeasurementUnit.Inches;
Defines the scale units: Centimeters or Inches.
|
StartValue |
decimal | ruler.StartValue = 10.0m; The value displayed at the origin (left or top edge) of the ruler. Can be adjusted by panning (Middle Mouse Button). |
MinValue |
decimal | ruler.MinValue = 0m; The absolute minimum value allowed for markers. |
MaxValue |
decimal | ruler.MaxValue = 100m; The absolute maximum value allowed for markers. |
Markers & Selection
The ruler features two interactive markers that can be used to measure distance or define a region.
| Property | Type | Description & Usage Example |
|---|---|---|
Marker1Value |
decimal | ruler.Marker1Value = 5.5m; The position of the first marker on the scale. |
Marker2Value |
decimal | ruler.Marker2Value = 12.0m; The position of the second marker on the scale. |
Value |
decimal | decimal distance = ruler.Value; Read-only. The absolute difference between Marker1 and Marker2. Useful for measuring length. |
Appearance & Styling
Customize the colors, fonts, and visual elements to match your application's theme.
| Property | Type | Description & Usage Example |
|---|---|---|
TickColor |
Color | ruler.TickColor = Color.Black; Color of the measurement lines (ticks) and text labels. |
MarkerColor |
Color | ruler.MarkerColor = Color.Red; Color of the vertical/horizontal lines indicating marker positions. |
SelectionColor |
Color | ruler.SelectionColor = Color.FromArgb(50, Color.Blue); Background fill color for the region between the two markers. |
GuideLineColor |
Color | ruler.GuideLineColor = Color.Gray; Color of the dotted lines that extend across the parent container. |
MarkerCircleSize |
float | ruler.MarkerCircleSize = 10f; Size of the draggable handle at the top/left of each marker. |
Interaction & Behavior
Configure how users interact with the ruler using mouse and keyboard.
| Property | Type | Description & Usage Example |
|---|---|---|
ShowGuideLines |
bool | ruler.ShowGuideLines = true; Draws dotted guide lines across the entire parent control (form or panel), useful for alignment. |
SnapToTicks |
bool | ruler.SnapToTicks = true; When dragging, markers automatically snap to the nearest tick mark (e.g., exact millimeters). |
EnableAnimations |
bool | ruler.EnableAnimations = true; Enables smooth transition animations when marker values are changed programmatically. |
EnableMarkerPulse |
bool | ruler.EnableMarkerPulse = true; Shows an animated pulse effect around the currently selected marker. |
ReadOnly |
bool | ruler.ReadOnly = false; Prevents user modification of markers or panning. |
Events
// 1. Value Changed
// Fires when the distance between markers changes.
ruler.ValueChanged += (s, e) =>
{
Console.WriteLine($"Measured Length: {e.NewValue} {e.Unit}");
Console.WriteLine($"Delta: {e.Difference}");
};
// 2. Marker Interaction
// Fires when a specific marker is moved.
ruler.MarkerValueChanged += (s, e) =>
{
if (e.MarkerIndex == 1)
Console.WriteLine($"Start Point: {e.Value}");
else
Console.WriteLine($"End Point: {e.Value}");
};
// 3. Selection Changed
// Fires when the user selects a different marker.
ruler.SelectedMarkerChanged += (s, e) =>
{
Console.WriteLine($"Active Marker: {e.SelectedMarkerIndex}");
};
Designer Experience
The control provides extensive Smart Tag support in the Visual Studio Designer.
| Category | Features |
|---|---|
Theme Presets |
One-click styling presets including: Deep Ocean, Emerald, Sunset, Corporate, Pastel, Midnight, Elegant, Glass, Neon, Primary, Secondary, Success, Error, Info, Light, Dark. |
Actions |
Copy Settings / Paste Settings: Easily duplicate complex ruler configurations across forms. Reset to Default: Restore factory settings. |
Detailed Usage Examples
Example 1: Basic Horizontal Centimeter Ruler
A standard horizontal ruler for measuring centimeters.
private SiticoneRuler CreateCmRuler()
{
var ruler = new SiticoneRuler
{
Dock = DockStyle.Top,
Height = 60,
Unit = SiticoneRuler.MeasurementUnit.Centimeters,
// Configuration
StartValue = 0,
MinValue = 0,
MaxValue = 50,
// Markers
Marker1Value = 0,
Marker2Value = 10,
// Styling
TickColor = Color.Black,
SelectionColor = Color.FromArgb(50, Color.SkyBlue)
};
ruler.ValueChanged += (s, e) =>
{
lblMeasurement.Text = $"Width: {e.NewValue:F2} cm";
};
return ruler;
}
Example 2: Vertical Layout Guide
A vertical ruler used as a layout guide with snapping and guide lines enabled.
private void SetupVerticalGuide(SiticoneRuler ruler)
{
ruler.Orientation = SiticoneRuler.RulerOrientation.Vertical;
ruler.Dock = DockStyle.Left;
ruler.Width = 60;
// Enable Guide Lines to show alignment across the form
ruler.ShowGuideLines = true;
ruler.GuideLineColor = Color.Red;
// Snap to ticks for precision
ruler.SnapToTicks = true;
// Aesthetics
ruler.MarkerColor = Color.Red;
ruler.TickColor = Color.DarkGray;
ruler.BackColor = Color.WhiteSmoke;
}
Example 3: Dynamic Theming
Applying a dark theme programmatically.
public void ApplyDarkTheme(SiticoneRuler ruler)
{
ruler.BackColor = Color.FromArgb(30, 30, 30);
ruler.TickColor = Color.LightGray;
ruler.ValueFont = new Font("Segoe UI", 10, FontStyle.Bold);
ruler.ForeColor = Color.White; // Measurement Text Color
ruler.MarkerColor = Color.Cyan;
ruler.MarkerCircleColor = Color.DarkCyan;
ruler.MarkerCircleBorderColor = Color.Cyan;
ruler.SelectionColor = Color.FromArgb(40, Color.Cyan);
ruler.GuideLineColor = Color.FromArgb(100, Color.White);
ruler.Invalidate();
}