46 lines
2.2 KiB
C#
46 lines
2.2 KiB
C#
using System;
|
||
using System.Drawing;
|
||
using System.Windows.Forms;
|
||
using TemuKJD.UserComponent;
|
||
|
||
internal static class NumericRangeSmoke
|
||
{
|
||
[STAThread]
|
||
public static void Main()
|
||
{
|
||
using (var range = new UcNumericRange())
|
||
{
|
||
int width = range.Width;
|
||
var layout = (TableLayoutPanel)range.Controls[0];
|
||
var separator = (Label)layout.GetControlFromPosition(1, 0);
|
||
var margin = separator.Margin;
|
||
var cell = layout.GetControlFromPosition(0, 0);
|
||
var editor = (NumericUpDown)cell.Controls[0];
|
||
var text = (TextBox)(editor.Controls[0] is TextBox ? editor.Controls[0] : editor.Controls[1]);
|
||
var buttons = editor.Controls[0] == text ? editor.Controls[1] : editor.Controls[0];
|
||
range.SeparatorText = "~";
|
||
range.Compact = true;
|
||
var rightCell = layout.GetControlFromPosition(2, 0);
|
||
using (var bitmap = new Bitmap(range.Width, range.Height))
|
||
{
|
||
range.DrawToBitmap(bitmap, range.ClientRectangle);
|
||
int y = rightCell.Top + rightCell.Height / 2;
|
||
int border = bitmap.GetPixel(rightCell.Right - 1, y).ToArgb();
|
||
if (border == editor.BackColor.ToArgb() || border != bitmap.GetPixel(rightCell.Left, y).ToArgb())
|
||
throw new Exception("结束值输入框右边框未绘制");
|
||
}
|
||
if (range.Width != 112 || buttons.Left < cell.Width - 2 || text.Right < cell.Width - 4)
|
||
throw new Exception("紧凑模式未充分利用输入区域");
|
||
if (separator.Text != "~" || range.Width >= width || separator.Margin != Padding.Empty)
|
||
throw new Exception("紧凑布局或分隔文字错误");
|
||
range.Compact = false;
|
||
if (buttons.Right > cell.Width || text.Right > buttons.Left) throw new Exception("微调按钮未恢复");
|
||
if (range.Width != width || separator.Margin != margin)
|
||
throw new Exception("普通布局未恢复");
|
||
range.Width = 190;
|
||
range.Compact = true;
|
||
if (range.Width != 190) throw new Exception("自定义宽度被覆盖");
|
||
}
|
||
}
|
||
}
|