本文整理汇总了C#中Gdk.Rectangle.Union方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Union方法的具体用法?C# Rectangle.Union怎么用?C# Rectangle.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Union方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSizeAllocated
protected override void OnSizeAllocated(Gdk.Rectangle alloc)
{
base.OnSizeAllocated (alloc);
int legend_height = LegendHeight ();
Gdk.Rectangle bar = new Rectangle (alloc.X + border, alloc.Y + border,
alloc.Width - 2 * border,
alloc.Height - 2 * border - glass.handle_height);
if (left.Allocation.Y != bar.Y || left.Allocation.X != bar.X) {
left.SetSizeRequest (-1, bar.Height);
this.Move (left, bar.X - Allocation.X, bar.Y - Allocation.Y);
}
if (right.Allocation.Y != bar.Y || right.Allocation.X != bar.X + bar.Width - right.Allocation.Width) {
right.SetSizeRequest (-1, bar.Height);
this.Move (right, bar.X - Allocation.X + bar.Width - right.Allocation.Width,
bar.Y - Allocation.Y);
}
background = new Rectangle (bar.X + left.Allocation.Width, bar.Y,
bar.Width - left.Allocation.Width - right.Allocation.Width,
bar.Height);
legend = new Rectangle (background.X, background.Y,
background.Width, legend_height);
action = background.Union (glass.Bounds ());
if (event_window != null)
event_window.MoveResize (action.X, action.Y, action.Width, action.Height);
this.Offset = this.Offset;
UpdateButtons ();
}
示例2: CreateIconWithShape
/// <summary>
/// Create a cursor icon with a shape that visually represents the tool's thickness.
/// </summary>
/// <param name="imgName">A string containing the name of the tool's icon image to use.</param>
/// <param name="shape">The shape to draw.</param>
/// <param name="shapeWidth">The width of the shape.</param>
/// <param name="imgToShapeX">The horizontal distance between the image's top-left corner and the shape center.</param>
/// <param name="imgToShapeX">The verical distance between the image's top-left corner and the shape center.</param>
/// <param name="shapeX">The X position in the returned Pixbuf that will be the center of the shape.</param>
/// <param name="shapeY">The Y position in the returned Pixbuf that will be the center of the shape.</param>
/// <returns>The new cursor icon with an shape that represents the tool's thickness.</returns>
protected Gdk.Pixbuf CreateIconWithShape(string imgName, CursorShape shape, int shapeWidth,
int imgToShapeX, int imgToShapeY,
out int shapeX, out int shapeY)
{
Gdk.Pixbuf img = PintaCore.Resources.GetIcon(imgName);
double zoom = 1d;
if (PintaCore.Workspace.HasOpenDocuments)
{
zoom = Math.Min(30d, PintaCore.Workspace.ActiveDocument.Workspace.Scale);
}
shapeWidth = (int)Math.Min(800d, ((double)shapeWidth) * zoom);
int halfOfShapeWidth = shapeWidth / 2;
// Calculate bounding boxes around the both image and shape
// relative to the image top-left corner.
Gdk.Rectangle imgBBox = new Gdk.Rectangle(0, 0, img.Width, img.Height);
Gdk.Rectangle shapeBBox = new Gdk.Rectangle(
imgToShapeX - halfOfShapeWidth,
imgToShapeY - halfOfShapeWidth,
shapeWidth,
shapeWidth);
// Inflate shape bounding box to allow for anti-aliasing
shapeBBox.Inflate(2, 2);
// To determine required size of icon,
// find union of the image and shape bounding boxes
// (still relative to image top-left corner)
Gdk.Rectangle iconBBox = imgBBox.Union (shapeBBox);
// Image top-left corner in icon co-ordinates
int imgX = imgBBox.Left - iconBBox.Left;
int imgY = imgBBox.Top - iconBBox.Top;
// Shape center point in icon co-ordinates
shapeX = imgToShapeX - iconBBox.Left;
shapeY = imgToShapeY - iconBBox.Top;
ImageSurface i = new ImageSurface(Format.ARGB32, iconBBox.Width, iconBBox.Height);
using (Context g = new Context(i))
{
// Don't show shape if shapeWidth less than 3,
if (shapeWidth > 3)
{
int diam = Math.Max (1, shapeWidth - 2);
Cairo.Rectangle shapeRect = new Cairo.Rectangle(shapeX - halfOfShapeWidth,
shapeY - halfOfShapeWidth,
diam,
diam);
Cairo.Color outerColor = new Cairo.Color (255, 255, 255, 0.5);
Cairo.Color innerColor = new Cairo.Color (0, 0, 0);
switch (shape)
{
case CursorShape.Ellipse:
g.DrawEllipse(shapeRect, outerColor, 1);
shapeRect = shapeRect.Inflate (-1, -1);
g.DrawEllipse(shapeRect, innerColor, 1);
break;
case CursorShape.Rectangle:
g.DrawRectangle(shapeRect, outerColor, 1);
shapeRect = shapeRect.Inflate (-1, -1);
g.DrawRectangle(shapeRect, innerColor, 1);
break;
}
}
// Draw the image
g.DrawPixbuf(img, new Cairo.Point(imgX, imgY));
}
return CairoExtensions.ToPixbuf(i);
}