本文整理匯總了C#中Xwt.Rectangle.Offset方法的典型用法代碼示例。如果您正苦於以下問題:C# Rectangle.Offset方法的具體用法?C# Rectangle.Offset怎麽用?C# Rectangle.Offset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Xwt.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Offset方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ToScreenBounds
public Rectangle ToScreenBounds (Window w, Rectangle r)
{
r = AdjustedRect (r);
var wb = w.ScreenBounds;
return r.Offset (wb.Location);
}
示例2: OnDraw
protected override void OnDraw(Context ctx, Rectangle dirtyRect)
{
base.OnDraw (ctx, dirtyRect);
if (!pset) {
ParentWindow.BoundsChanged += delegate {
QueueDraw ();
};
pset = true;
}
ctx.Rectangle (Bounds);
ctx.SetColor (Colors.LightGray);
ctx.Fill ();
var size = Size;
size.Width--;
size.Height--;
var fx = size.Width / Desktop.Bounds.Width;
if (Desktop.Bounds.Height * fx > size.Height)
fx = size.Height / Desktop.Bounds.Height;
if (Desktop.Bounds.X < 0)
ctx.Translate (-Desktop.Bounds.X * fx, 0);
if (Desktop.Bounds.Y < 0)
ctx.Translate (0, -Desktop.Bounds.Y * fx);
ctx.SetLineWidth (1);
foreach (var s in Desktop.Screens) {
if (s.Bounds != s.VisibleBounds) {
var vr = new Rectangle ((int)(s.Bounds.X * fx), (int)(s.Bounds.Y * fx), (int)(s.Bounds.Width * fx), (int)(s.Bounds.Height * fx));
vr = vr.Offset (0.5, 0.5);
ctx.Rectangle (vr);
ctx.SetColor (Colors.White);
ctx.FillPreserve ();
ctx.SetColor (Colors.Black);
ctx.Stroke ();
}
var r = new Rectangle ((int)(s.VisibleBounds.X * fx), (int)(s.VisibleBounds.Y * fx), (int)(s.VisibleBounds.Width * fx), (int)(s.VisibleBounds.Height * fx));
r = r.Offset (0.5, 0.5);
ctx.Rectangle (r);
ctx.SetColor (new Color (0.4, 0.62, 0.83));
ctx.FillPreserve ();
ctx.SetColor (Colors.Black);
ctx.Stroke ();
TextLayout tl = new TextLayout (ctx);
tl.Text = s.DeviceName;
tl.Font = Font;
ctx.DrawTextLayout (tl, r.Center.X - tl.Width / 2, r.Center.Y - tl.Height / 2);
}
var wr = ParentWindow.ScreenBounds;
wr = new Rectangle ((int)(wr.X * fx), (int)(wr.Y * fx), (int)(wr.Width * fx), (int)(wr.Height * fx));
ctx.Rectangle (wr);
ctx.SetColor (Colors.Azure.WithAlpha (0.5));
ctx.FillPreserve ();
ctx.SetColor (Colors.Azure);
ctx.Stroke ();
}