本文整理汇总了C#中ImageLayout类的典型用法代码示例。如果您正苦于以下问题:C# ImageLayout类的具体用法?C# ImageLayout怎么用?C# ImageLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageLayout类属于命名空间,在下文中一共展示了ImageLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBackgroundImage
public static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
{
if (g == null)
{
throw new ArgumentNullException("g");
}
if (backgroundImageLayout == ImageLayout.Tile)
{
using (TextureBrush brush = new TextureBrush(backgroundImage, WrapMode.Tile))
{
if (scrollOffset != Point.Empty)
{
Matrix transform = brush.Transform;
transform.Translate((float) scrollOffset.X, (float) scrollOffset.Y);
brush.Transform = transform;
}
g.FillRectangle(brush, clipRect);
return;
}
}
Rectangle rect = CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout);
if ((rightToLeft == RightToLeft.Yes) && (backgroundImageLayout == ImageLayout.None))
{
rect.X += clipRect.Width - rect.Width;
}
using (SolidBrush brush2 = new SolidBrush(backColor))
{
g.FillRectangle(brush2, clipRect);
}
if (!clipRect.Contains(rect))
{
if ((backgroundImageLayout == ImageLayout.Stretch) || (backgroundImageLayout == ImageLayout.Zoom))
{
rect.Intersect(clipRect);
g.DrawImage(backgroundImage, rect);
}
else if (backgroundImageLayout == ImageLayout.None)
{
rect.Offset(clipRect.Location);
Rectangle destRect = rect;
destRect.Intersect(clipRect);
Rectangle rectangle3 = new Rectangle(Point.Empty, destRect.Size);
g.DrawImage(backgroundImage, destRect, rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height, GraphicsUnit.Pixel);
}
else
{
Rectangle rectangle4 = rect;
rectangle4.Intersect(clipRect);
Rectangle rectangle5 = new Rectangle(new Point(rectangle4.X - rect.X, rectangle4.Y - rect.Y), rectangle4.Size);
g.DrawImage(backgroundImage, rectangle4, rectangle5.X, rectangle5.Y, rectangle5.Width, rectangle5.Height, GraphicsUnit.Pixel);
}
}
else
{
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetWrapMode(WrapMode.TileFlipXY);
g.DrawImage(backgroundImage, rect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttr);
imageAttr.Dispose();
}
}
示例2: VGScrollImage
///////////////////////////////////////////////////////////////////////////////
// Defining Constants //
///////////////////////////////////////////////////////////////////////////////
#region CONSTANTS
#endregion //CONSTANTS
///////////////////////////////////////////////////////////////////////////////
// Defining Variables, Enumerations, Events //
///////////////////////////////////////////////////////////////////////////////
#region FIELDS
#endregion //FIELDS
///////////////////////////////////////////////////////////////////////////////
// Construction and Initializing methods //
///////////////////////////////////////////////////////////////////////////////
#region CONSTRUCTION
/// <summary>
/// Initializes a new instance of the VGScrollImage class.
/// When newShapeDrawAction is set to None, only the image will
/// be drawn, with Edge an additional border is drawn,
/// with fill an additional (hopefully transparent) fill is drawn over the image.
/// </summary>
/// <param name="newShapeDrawAction">Drawing action: Edge, Fill, Both, None</param>
/// <param name="newPen">Pen for additional borderline.</param>
/// <param name="newBrush">Brush for additional fills.</param>
/// <param name="newFont">Font for drawing name</param>
/// <param name="newFontColor">Font color for drawing name.</param>
/// <param name="newImageFile">filename without path</param>
/// <param name="newPath">path to image file</param>
/// <param name="newLayout"><see cref="ImageLayout"/> of the image</param>
/// <param name="newAlpha">The transparency alpha for this image.0=transparent,1=opaque</param>
/// <param name="newCanvas"><see cref="Size"/> of the owning original canvas</param>
/// <param name="newStyleGroup">Group Enumeration, <see cref="VGStyleGroup"/></param>
/// <param name="newName">Name of Element</param>
/// <param name="newElementGroup">Element group description</param>
public VGScrollImage(
ShapeDrawAction newShapeDrawAction,
Pen newPen,
Brush newBrush,
Font newFont,
Color newFontColor,
string newImageFile,
string newPath,
ImageLayout newLayout,
float newAlpha,
Size newCanvas,
VGStyleGroup newStyleGroup,
string newName,
string newElementGroup)
: base(
newShapeDrawAction,
newPen,
newBrush,
newFont,
newFontColor,
newImageFile,
newPath,
newLayout,
newAlpha,
newCanvas,
newStyleGroup,
newName,
newElementGroup,
false)
{
}
示例3: CalculateBackgroundImageRectangle
internal static Rectangle CalculateBackgroundImageRectangle(Rectangle bounds, Image backgroundImage, ImageLayout imageLayout)
{
Rectangle rectangle = bounds;
if (backgroundImage != null)
{
switch (imageLayout)
{
case ImageLayout.None:
rectangle.Size = backgroundImage.Size;
return rectangle;
case ImageLayout.Tile:
return rectangle;
case ImageLayout.Center:
{
rectangle.Size = backgroundImage.Size;
Size size = bounds.Size;
if (size.Width > rectangle.Width)
{
rectangle.X = (size.Width - rectangle.Width) / 2;
}
if (size.Height > rectangle.Height)
{
rectangle.Y = (size.Height - rectangle.Height) / 2;
}
return rectangle;
}
case ImageLayout.Stretch:
rectangle.Size = bounds.Size;
return rectangle;
case ImageLayout.Zoom:
{
Size size2 = backgroundImage.Size;
float num = ((float) bounds.Width) / ((float) size2.Width);
float num2 = ((float) bounds.Height) / ((float) size2.Height);
if (num >= num2)
{
rectangle.Height = bounds.Height;
rectangle.Width = (int) ((size2.Width * num2) + 0.5);
if (bounds.X >= 0)
{
rectangle.X = (bounds.Width - rectangle.Width) / 2;
}
return rectangle;
}
rectangle.Width = bounds.Width;
rectangle.Height = (int) ((size2.Height * num) + 0.5);
if (bounds.Y >= 0)
{
rectangle.Y = (bounds.Height - rectangle.Height) / 2;
}
return rectangle;
}
}
}
return rectangle;
}
示例4: CalculateBackgroundImageRectangle
internal static Rectangle CalculateBackgroundImageRectangle(Rectangle bounds, Image backgroundImage, ImageLayout imageLayout) {
Rectangle result = bounds;
if (backgroundImage != null) {
switch (imageLayout) {
case ImageLayout.Stretch:
result.Size = bounds.Size;
break;
case ImageLayout.None:
result.Size = backgroundImage.Size;
break;
case ImageLayout.Center:
result.Size = backgroundImage.Size;
Size szCtl = bounds.Size;
if (szCtl.Width > result.Width) {
result.X = (szCtl.Width - result.Width) / 2;
}
if (szCtl.Height > result.Height) {
result.Y = (szCtl.Height - result.Height) / 2;
}
break;
case ImageLayout.Zoom:
Size imageSize = backgroundImage.Size;
float xRatio = (float)bounds.Width / (float)imageSize.Width;
float yRatio = (float)bounds.Height / (float)imageSize.Height;
if (xRatio < yRatio) {
//width should fill the entire bounds.
result.Width = bounds.Width;
// preserve the aspect ratio by multiplying the xRatio by the height
// adding .5 to round to the nearest pixel
result.Height = (int) ((imageSize.Height * xRatio) +.5);
if (bounds.Y >= 0)
{
result.Y = (bounds.Height - result.Height) /2;
}
}
else {
// width should fill the entire bounds
result.Height = bounds.Height;
// preserve the aspect ratio by multiplying the xRatio by the height
// adding .5 to round to the nearest pixel
result.Width = (int) ((imageSize.Width * yRatio) +.5);
if (bounds.X >= 0)
{
result.X = (bounds.Width - result.Width) /2;
}
}
break;
}
}
return result;
}
示例5: layout
public static PictureBox layout(this PictureBox pictureBox, ImageLayout imageLayout)
{
return pictureBox.invokeOnThread(
() =>
{
pictureBox.BackgroundImageLayout = imageLayout;
return pictureBox;
});
}
示例6: ConstructSpecial
public void ConstructSpecial(string bitmapResName, ImageLayout bitmapLayout, string tagLine, Color tagColor)
{
GeneralLooks = SplashLooks.Special;
lblMainVersion.Visible = false;
picCup.Visible = false;
lblTitle.Visible = false;
lblSeparator.Visible = false;
lblTagLine.Visible = false;
ArrangeSpecial(bitmapResName, bitmapLayout, tagLine, tagColor);
}
示例7: ImageMemoryBarrier
public ImageMemoryBarrier(Image image, ImageLayout oldLayout, ImageLayout newLayout, AccessFlags sourceAccesMask, AccessFlags destinationAccessMask, uint sourceQueueFamilyIndex, uint destinationQueueFamilyIndex, ImageSubresourceRange subresourceRange)
{
StructureType = StructureType.ImageMemoryBarrier;
Next = IntPtr.Zero;
Image = image;
SubresourceRange = subresourceRange;
OldLayout = oldLayout;
NewLayout = newLayout;
SourceAccessMask = sourceAccesMask;
DestinationAccessMask = destinationAccessMask;
SourceQueueFamilyIndex = sourceQueueFamilyIndex;
DestinationQueueFamilyIndex = destinationQueueFamilyIndex;
}
示例8: PEImage
/// <summary>
/// Constructor
/// </summary>
/// <param name="imageStreamCreator">The PE stream creator</param>
/// <param name="imageLayout">Image layout</param>
/// <param name="verify">Verify PE file data</param>
public PEImage(IImageStreamCreator imageStreamCreator, ImageLayout imageLayout, bool verify)
{
try {
this.imageStreamCreator = imageStreamCreator;
this.peType = ConvertImageLayout(imageLayout);
ResetReader();
this.peInfo = new PEInfo(imageStream, verify);
Initialize();
}
catch {
Dispose();
throw;
}
}
示例9: ShowDialog
/// <summary>
/// Shows the dialog.
/// </summary>
/// <param name="labelText">The label text.</param>
/// <param name="title">The title.</param>
/// <param name="i">The i.</param>
/// <param name="maxlen">The maxlen.</param>
/// <param name="il">The il.</param>
/// <returns></returns>
public string[] ShowDialog(string labelText, string title, Image i, int maxlen = -1,
ImageLayout il = ImageLayout.Center)
{
Text = title;
label.Text = labelText;
imagepanel.BackgroundImage = i;
imagepanel.BackgroundImageLayout = il;
if (maxlen >= 0)
textbox.MaxLength = maxlen;
ShowDialog();
return returnvalue;
}
示例10: DrawBackgroundImage
public static void DrawBackgroundImage(
Graphics g,
Image backgroundImage,
Color backColor,
ImageLayout backgroundImageLayout,
Rectangle bounds,
Rectangle clipRect)
{
DrawBackgroundImage(
g,
backgroundImage,
backColor,
backgroundImageLayout,
bounds,
clipRect,
Point.Empty,
RightToLeft.No);
}
示例11: DrawBackgroundImage
public static void DrawBackgroundImage(
System.Drawing.Graphics g,
Image backgroundImage,
Color backColor,
ImageLayout backgroundImageLayout,
Rectangle bounds,
Rectangle clipRect,
Point scrollOffset)
{
DrawBackgroundImage(
g,
backgroundImage,
backColor,
backgroundImageLayout,
bounds,
clipRect,
scrollOffset,
RightToLeft.No);
}
示例12: RenderBackgroundImage
public static void RenderBackgroundImage(this Graphics Graphics, Rectangle ClientRectangle, Color BackColor, Int32 Width, Int32 Height, ImageLayout ImageLayout, Image BackgroundImage)
{
Graphics.SetClip(ClientRectangle);
Graphics.SmoothingMode = SmoothingMode.HighQuality;
Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
Graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle);
if (BackgroundImage != null) {
switch (ImageLayout) {
case ImageLayout.Center:
Graphics.DrawImageUnscaled(BackgroundImage, Width / 2 - BackgroundImage.Width / 2, Height / 2 - BackgroundImage.Height / 2);
break;
case ImageLayout.None:
Graphics.DrawImageUnscaled(BackgroundImage, 0, 0);
break;
case ImageLayout.Stretch:
Graphics.DrawImage(BackgroundImage, 0, 0, Width, Height);
break;
case ImageLayout.Tile:
var pixelOffsetX = 0;
var pixelOffsetY = 0;
while (pixelOffsetX < Width) {
pixelOffsetY = 0;
while (pixelOffsetY < Height) {
Graphics.DrawImageUnscaled(BackgroundImage, pixelOffsetX, pixelOffsetY);
pixelOffsetY += BackgroundImage.Height;
}
pixelOffsetX += BackgroundImage.Width;
}
break;
case ImageLayout.Zoom:
if ((Single)(BackgroundImage.Width / Width) < (Single)(BackgroundImage.Height / Height))
Graphics.DrawImage(BackgroundImage, 0, 0, Height, Height);
else
Graphics.DrawImage(BackgroundImage, 0, 0, Width, Width);
break;
}
}
}
示例13: BejelformAlapInit
public virtual void BejelformAlapInit(Bejelentkezo bejel, Bitmap bitmap, ImageLayout layout, string formszov, Icon icon)
{
InitializeComponent();
// ErrorProvider.ContainerControl = containerControl1;
this.panel1.BackgroundImage = bitmap;
this.panel1.BackgroundImageLayout = layout;
Bejel = bejel;
alkid = Bejel.alkid;
kezeloidkar = bejel.KezeloIdkArray;
Sqlinterface.RendszerUserConn(Bejel.Rendszerconn, Bejel.Userconn);
Sqlinterface.Select(kezelok, Bejel.Userconn, "KEZELOK", "", "", false);
string maidat = DateTime.Today.ToShortDateString();
if (maidat.EndsWith("."))
maidat = maidat.Substring(0, maidat.Length - 1);
if (bejel.Rgazdaid=="-1") // kell egy rendszergazda
{
label2.Text = "Rendszergazda:";
textBox2.UseSystemPasswordChar = false;
kezelorow = null;
}
else
textBox2.UseSystemPasswordChar = true;
label5.Text = formszov;
if (icon != null)
this.Icon = icon;
vanujceg = Bejel.Vanujceg;
label4.Visible=vanujceg;
comboBox1.Visible=vanujceg;
if (vanujceg)
{
string ho_nap = ".01.01";
int jelenev = DateTime.Today.Year;
string[] itemek = new string[] { (jelenev - 1).ToString() + ho_nap, jelenev.ToString() + ho_nap, (jelenev + 1).ToString() + ho_nap };
comboBox1.Items.AddRange(itemek);
comboBox1.SelectedIndex = 1;
}
// this.Focus();
textBox1.Focus();
}
示例14: FreeDrawing
/// <summary>
/// Default constructor of the FreeDraw form.
/// </summary>
public FreeDrawing(Image background, ImageLayout layout, Size imageSize)
{
InitializeComponent();
panelDrawing.BackgroundImage = background;
panelDrawing.BackgroundImageLayout = layout;
if (layout == ImageLayout.Tile)
{
panelDrawing.Width = imageSize.Width;
panelDrawing.Height = imageSize.Height;
this.BackgroundImage = null;
}
else
{
panelDrawing.Width = background.Width;
panelDrawing.Height = background.Height;
}
//TODO: Get the real values.
this.Width = panelDrawing.Width + 40;
this.Height = panelDrawing.Height + 66 + 20;
if (this.Width < 400) this.Width = 400;
if (this.Height < 215) this.Height = 215;
panelDrawing.EraseAll();
#region Localize Labels
this.Text = Resources.Title_FreeDrawing;
lblBrushSize.Text = Resources.Label_BrushSize;
lblEraserSize.Text = Resources.Label_EraserSize;
#endregion
}
示例15: Load
/// <summary>
/// Creates a <see cref="ModuleDefMD"/> instance from a memory location
/// </summary>
/// <param name="addr">Address of a .NET module/assembly</param>
/// <param name="options">Module creation options or <c>null</c></param>
/// <param name="imageLayout">Image layout of the file in memory</param>
/// <returns>A new <see cref="ModuleDefMD"/> instance</returns>
public static ModuleDefMD Load(IntPtr addr, ModuleCreationOptions options, ImageLayout imageLayout)
{
return Load(MetaDataCreator.Load(addr, imageLayout), options);
}