本文整理汇总了C#中System.Drawing.SizeF类的典型用法代码示例。如果您正苦于以下问题:C# SizeF类的具体用法?C# SizeF怎么用?C# SizeF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SizeF类属于System.Drawing命名空间,在下文中一共展示了SizeF类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DrawStringML
private static void DrawStringML(this Graphics G, string Text, Font font, Brush brush, float x, ref float y, float mX)
{
string[] words = Text.Split(' ');
float tempX = x;
float totalSpace = mX - x;
SizeF measureWord = new SizeF(0, font.GetHeight());
float tempWordWidth = 0;
foreach (string word in words)
{
//measure word width (based in font size)
tempWordWidth = G.MeasureString(word + " ", font).Width;
measureWord.Width += tempWordWidth;
//check if the word fits in free line space
//if not then change line
if (measureWord.Width > totalSpace)
{
y += font.GetHeight();
tempX = x;
measureWord.Width = tempWordWidth;
}
G.DrawString(word + " ", font, brush, tempX, y);
tempX += tempWordWidth;
}
y += font.GetHeight();
}
开发者ID:Hli4S,项目名称:TestMeApp,代码行数:25,代码来源:Print.cs
示例2: GetNextPoint
public unsafe Point GetNextPoint(Rectangle rectTrack, byte* pIn, Size sizeIn, double[] Qu, double[] PuY0)
{
double[] w = new double[256];//方向权值
for (int i = 0; i < 256; i++)
{
w[i] = Math.Sqrt(Qu[i] / PuY0[i]);
}
PointF center = new PointF(
(float)rectTrack.Left + (float)rectTrack.Width / 2,
(float)rectTrack.Top + (float)rectTrack.Height / 2);
SizeF H = new SizeF((float)rectTrack.Width / 2, (float)rectTrack.Height / 2);
double numeratorX = 0, numeratorY = 0;//分子
double denominatorX = 0, denominatorY = 0;//分母
for (int y = rectTrack.Top; y < rectTrack.Bottom; y++)
{
for (int x = rectTrack.Left; x < rectTrack.Right; x++)
{
int index = DataManager.GetIndex(x, y, sizeIn.Width);
byte u = pIn[index];
//计算以高斯分布为核函数自变量X的值
double X = ((Math.Pow((x - center.X), 2) + Math.Pow((y - center.Y), 2))
/ (Math.Pow(H.Width, 2) + Math.Pow(H.Height, 2)));
//负的高斯分布核函数的值
double Gi = -Math.Exp(-Math.Pow(X, 2) / 2) / Math.Sqrt(2 * Math.PI);
numeratorX += x * w[u] * Gi;
numeratorY += y * w[u] * Gi;
denominatorX += w[u] * Gi;
denominatorY += w[u] * Gi;
}
}
return new Point((int)(numeratorX / denominatorX), (int)(numeratorY / denominatorY));
}
开发者ID:dalinhuang,项目名称:my-computer-vision,代码行数:34,代码来源:MeanShift.cs
示例3: Operation
/// <summary>
/// 主要作業方法
/// </summary>
public Image Operation()
{
Graphics g = Graphics.FromImage(image);
_mask_pos_x = (image.Width / 2) + _Xoffset;
SizeF steSize = new SizeF();
for (int i = _FontMaxSize; i >= _FontMinSize; i--)
{
using (Font testFont = new Font(_FontFamily, i, FontStyle.Bold))
{
steSize = g.MeasureString(_text, testFont);
if ((ushort)steSize.Width < (ushort)_Width || i == _FontMinSize)
{
using (SolidBrush semiTransBrush = new SolidBrush(_fontcolor))
{
StringFormat StrFormat = new StringFormat();
StrFormat.Alignment = StringAlignment.Center;
g.DrawString(_text, testFont, semiTransBrush, new PointF(_mask_pos_x, _mask_pos_y), StrFormat);
semiTransBrush.Dispose();
}
testFont.Dispose();
break;
}
}
}
return image;
}
开发者ID:patw0929,项目名称:patw-aspnet-appcode,代码行数:32,代码来源:DrawTextCenter.cs
示例4: Measure
public override SizeF Measure(Graphics graphics)
{
if (this.Image != null)
{
SizeF size = new Size(GraphConstants.MinimumItemWidth, GraphConstants.MinimumItemHeight);
if (this.Width.HasValue)
size.Width = Math.Max(size.Width, this.Width.Value);
else
size.Width = Math.Max(size.Width, this.Image.Width);
if (this.Height.HasValue)
size.Height = Math.Max(size.Height, this.Height.Value);
else
size.Height = Math.Max(size.Height, this.Image.Height);
return size;
} else
{
var size = new SizeF(GraphConstants.MinimumItemWidth, GraphConstants.MinimumItemHeight);
if (this.Width.HasValue)
size.Width = Math.Max(size.Width, this.Width.Value);
if (this.Height.HasValue)
size.Height = Math.Max(size.Height, this.Height.Value);
return size;
}
}
开发者ID:coreafive,项目名称:XLE,代码行数:29,代码来源:NodeImageItem.cs
示例5: CursorMove
public static void CursorMove(Point endPt, int speed = 20)
{
Point startPt = new Point((Size)Cursor.Position); // starting point
PointF nextPt = new PointF(0, 0); // stores next point to move
Size differencePt;
double magnitude; // magnitude of total path
SizeF moveSize = new SizeF(); // Stores size of next movement
if (startPt == endPt) return;
do
{
magnitude = Math.Sqrt(Math.Pow(endPt.X - Cursor.Position.X, 2) + Math.Pow(endPt.Y - Cursor.Position.Y, 2));
// give the step size a magnitude of 1
moveSize.Width = (float)((endPt.X - Cursor.Position.X) / magnitude);
moveSize.Height = (float)((endPt.Y - Cursor.Position.Y) / magnitude);
nextPt = PointF.Add(new PointF(Cursor.Position.X + nextPt.X.GetDecimal(), Cursor.Position.Y + nextPt.Y.GetDecimal()), moveSize);
// Get the movement size
differencePt = Size.Subtract(new Size(Convert.ToInt32(nextPt.X), Convert.ToInt32(nextPt.Y)), (Size)Cursor.Position);
// Move the cursor to its next step
Cursor.Position = Point.Add(Cursor.Position, differencePt);
if (Rand(1, speed) == 1) Wait(10);
Application.DoEvents();
} while (!(Cursor.Position.X == endPt.X && Cursor.Position.Y == endPt.Y));
}
开发者ID:LRih,项目名称:Auto-Bot,代码行数:33,代码来源:Macro.cs
示例6: GridWindow
// Methods
public GridWindow()
{
this.components = null;
this.size = (SizeF) new Size(10, 10);
this.color = System.Drawing.Color.Gray;
this.InitializeComponent();
}
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:8,代码来源:GridWindow.cs
示例7: WoodenTheme
public WoodenTheme()
{
CellBackgroundColor = UIColor.FromWhiteAlpha(1f, 0.2f);
TextColor = UIColor.DarkTextColor;
TextShadowColor = UIColor.FromWhiteAlpha(0.8f, 1.0f);
TextShadowOffset = new SizeF(0, 1);
BackgroundUri = new Uri ("file://" + Path.GetFullPath("Images/wood.jpg"));
SeparatorColor = UIColor.Black;
TextColor = UIColor.FromWhiteAlpha(1f, 0.8f);
TextShadowColor = UIColor.Brown.ColorWithAlpha(0.8f);
TextShadowOffset = new SizeF(0, 1);
DetailTextColor = UIColor.FromWhiteAlpha(1f, 0.8f);
DetailTextShadowColor = UIColor.Brown.ColorWithAlpha(0.8f);
DetailTextShadowOffset = new SizeF(0, 1);
BarTintColor = UIColor.Brown;
BarStyle = UIBarStyle.Default;
HeaderTextColor = UIColor.FromRGB(92, 69, 0);
HeaderTextShadowColor = UIColor.FromWhiteAlpha(1f, 0.6f);
FooterTextColor = UIColor.FromWhiteAlpha(1f, 0.8f);
FooterTextShadowColor = UIColor.FromWhiteAlpha(0f, 0.2f);
}
开发者ID:RobertKozak,项目名称:MonoMobile.Views.Themes,代码行数:28,代码来源:WoodenTheme.cs
示例8: CreateImage
private static UIImage CreateImage(string color)
{
try
{
var red = color.Substring(0, 2);
var green = color.Substring(2, 2);
var blue = color.Substring(4, 2);
var redB = System.Convert.ToByte(red, 16);
var greenB = System.Convert.ToByte(green, 16);
var blueB = System.Convert.ToByte(blue, 16);
var size = new SizeF(28f, 28f);
var cgColor = UIColor.FromRGB(redB, greenB, blueB).CGColor;
UIGraphics.BeginImageContextWithOptions(size, false, 0);
var ctx = UIGraphics.GetCurrentContext();
ctx.SetLineWidth(1.0f);
ctx.SetStrokeColor(cgColor);
ctx.AddEllipseInRect(new RectangleF(0, 0, size.Width, size.Height));
ctx.SetFillColor(cgColor);
ctx.FillPath();
var image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return image;
}
catch
{
return null;
}
}
开发者ID:treejames,项目名称:CodeFramework,代码行数:32,代码来源:LabelElement.cs
示例9: CreateRoundedRectangle
public static GraphicsPath CreateRoundedRectangle(SizeF size, PointF location)
{
int cornerSize = (int)GraphConstants.CornerSize * 2;
int connectorSize = (int)GraphConstants.ConnectorSize;
int halfConnectorSize = (int)Math.Ceiling(connectorSize / 2.0f);
var height = size.Height;
var width = size.Width;
var halfWidth = width / 2.0f;
var halfHeight = height / 2.0f;
var connectorOffset = (int)Math.Floor((GraphConstants.MinimumItemHeight - GraphConstants.ConnectorSize) / 2.0f);
var left = location.X;
var top = location.Y;
var right = location.X + width;
var bottom = location.Y + height;
var path = new GraphicsPath(FillMode.Winding);
path.AddArc(left, top, cornerSize, cornerSize, 180, 90);
path.AddArc(right - cornerSize, top, cornerSize, cornerSize, 270, 90);
path.AddArc(right - cornerSize, bottom - cornerSize, cornerSize, cornerSize, 0, 90);
path.AddArc(left, bottom - cornerSize, cornerSize, cornerSize, 90, 90);
path.CloseFigure();
return path;
}
开发者ID:fluffyfreak,项目名称:Graph,代码行数:25,代码来源:GraphRenderer.cs
示例10: CreateTextTexture
/// <summary>
/// Create a texture of the given text in the given font.
/// </summary>
/// <param name="text">Text to display.</param>
/// <param name="font">Font to display the text as.</param>
/// <param name="size">Provides the size of the texture.</param>
/// <returns>Int32 Handle to the texture.</returns>
public static int CreateTextTexture(string text, Font font, out SizeF size)
{
int textureId;
size = GetStringSize(text, font);
using (Bitmap textBitmap = new Bitmap((int)size.Width, (int)size.Height))
{
GL.GenTextures(1, out textureId);
GL.BindTexture(TextureTarget.Texture2D, textureId);
BitmapData data =
textBitmap.LockBits(new Rectangle(0, 0, textBitmap.Width, textBitmap.Height),
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter,
(int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter,
(int)TextureMagFilter.Linear);
GL.Finish();
textBitmap.UnlockBits(data);
var gfx = System.Drawing.Graphics.FromImage(textBitmap);
gfx.Clear(Color.Transparent);
gfx.TextRenderingHint = TextRenderingHint.AntiAlias;
gfx.DrawString(text, font, new SolidBrush(Color.White), new RectangleF(0, 0, size.Width + 10, size.Height));
BitmapData data2 = textBitmap.LockBits(new Rectangle(0, 0, textBitmap.Width, textBitmap.Height),
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, textBitmap.Width, textBitmap.Height, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data2.Scan0);
textBitmap.UnlockBits(data2);
gfx.Dispose();
}
return textureId;
}
开发者ID:aevv,项目名称:Biscuit,代码行数:42,代码来源:TextureManager.cs
示例11: Measure
public override SizeF Measure(Graphics graphics)
{
if (!string.IsNullOrWhiteSpace(this.Text))
{
if (this.TextSize.IsEmpty)
{
var size = new Size(GraphConstants.MinimumItemWidth, GraphConstants.MinimumItemHeight);
if (this.Input.Enabled != this.Output.Enabled)
{
if (this.Input.Enabled)
this.TextSize = graphics.MeasureString(this.Text, SystemFonts.MenuFont, size, GraphConstants.LeftMeasureTextStringFormat);
else
this.TextSize = graphics.MeasureString(this.Text, SystemFonts.MenuFont, size, GraphConstants.RightMeasureTextStringFormat);
} else
this.TextSize = graphics.MeasureString(this.Text, SystemFonts.MenuFont, size, GraphConstants.CenterMeasureTextStringFormat);
this.TextSize.Width = Math.Max(size.Width, this.TextSize.Width + ColorBoxSize + Spacing);
this.TextSize.Height = Math.Max(size.Height, this.TextSize.Height);
}
return this.TextSize;
} else
{
return new SizeF(GraphConstants.MinimumItemWidth, GraphConstants.TitleHeight + GraphConstants.TopHeight);
}
}
开发者ID:coreafive,项目名称:XLE,代码行数:26,代码来源:NodeColorItem.cs
示例12: SetAllocatedSize
public void SetAllocatedSize(SizeF allocatedSize)
{
Debug.Assert(allocatedSize.Width >= tipRequiredSize.Width &&
allocatedSize.Height >= tipRequiredSize.Height);
tipAllocatedSize = allocatedSize; OnAllocatedSizeChanged();
}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:7,代码来源:TipSection.cs
示例13: State
public State(SizeF gameArea)
{
Area = gameArea;
//Load in all the tile definitions
readTileDefinitions(@"gamedata\tileProperties.csv");
}
开发者ID:shaunfallis,项目名称:RPG,代码行数:7,代码来源:State.cs
示例14: GetCell
public override UITableViewCell GetCell (UITableView tv)
{
var cell = tv.DequeueReusableCell (CellKey);
if (cell == null){
cell = new UITableViewCell (UITableViewCellStyle.Default, CellKey);
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
} else
RemoveTag (cell, 1);
SizeF captionSize = new SizeF (0, 0);
if (Caption != null && ShowCaption){
cell.TextLabel.Text = Caption;
captionSize = cell.TextLabel.StringSize (Caption, UIFont.FromName (cell.TextLabel.Font.Name, UIFont.LabelFontSize));
captionSize.Width += 10; // Spacing
}
if (slider == null){
slider = new UISlider (new RectangleF (10f + captionSize.Width, 12f, 280f - captionSize.Width, 7f)){
BackgroundColor = UIColor.Clear,
MinValue = this.MinValue,
MaxValue = this.MaxValue,
Continuous = true,
Value = this.Value,
Tag = 1
};
slider.ValueChanged += delegate {
Value = slider.Value;
};
} else {
slider.Value = Value;
}
cell.ContentView.AddSubview (slider);
return cell;
}
开发者ID:henrikweimenhog,项目名称:MonoTouch.Dialog,代码行数:35,代码来源:FloatElement.cs
示例15: GenerateCapsule
private static GraphicsPath GenerateCapsule( this Graphics graphics, RectangleF rectangle ) {
float diameter;
RectangleF arc;
GraphicsPath path = new GraphicsPath();
try {
if( rectangle.Width > rectangle.Height ) {
diameter = rectangle.Height;
SizeF sizeF = new SizeF( diameter, diameter );
arc = new RectangleF( rectangle.Location, sizeF );
path.AddArc( arc, 90, 180 );
arc.X = rectangle.Right - diameter;
path.AddArc( arc, 270, 180 );
} else if( rectangle.Width < rectangle.Height ) {
diameter = rectangle.Width;
SizeF sizeF = new SizeF( diameter, diameter );
arc = new RectangleF( rectangle.Location, sizeF );
path.AddArc( arc, 180, 180 );
arc.Y = rectangle.Bottom - diameter;
path.AddArc( arc, 0, 180 );
} else
path.AddEllipse( rectangle );
} catch { path.AddEllipse( rectangle ); } finally { path.CloseFigure(); }
return path;
}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:25,代码来源:GraphicsExtension.cs
示例16: DrawPathAsBackground
// Draws our animation path on the background image, just to show it
protected void DrawPathAsBackground ()
{
// create our offscreen bitmap context
var bitmapSize = new SizeF (View.Frame.Size);
using (var context = new CGBitmapContext (
IntPtr.Zero,
(int)bitmapSize.Width, (int)bitmapSize.Height, 8,
(int)(4 * bitmapSize.Width), CGColorSpace.CreateDeviceRGB (),
CGImageAlphaInfo.PremultipliedFirst)) {
// convert to View space
var affineTransform = CGAffineTransform.MakeIdentity ();
// invert the y axis
affineTransform.Scale (1f, -1f);
// move the y axis up
affineTransform.Translate (0, View.Frame.Height);
context.ConcatCTM (affineTransform);
// actually draw the path
context.AddPath (animationPath);
context.SetStrokeColor (UIColor.LightGray.CGColor);
context.SetLineWidth (3f);
context.StrokePath ();
// set what we've drawn as the backgound image
backgroundImage.Image = UIImage.FromImage (context.ToImage());
}
}
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:29,代码来源:LayerAnimationScreen.xib.cs
示例17: GraniteTheme
public GraniteTheme()
{
CellBackgroundImage = UIImage.FromFile("Images/granite.jpg");
SeparatorColor = UIColor.Black;
TextShadowColor = UIColor.LightGray;
TextShadowOffset = new SizeF(-1, -1);
}
开发者ID:RobertKozak,项目名称:MonoMobile.Views.Themes,代码行数:7,代码来源:GraniteTheme.cs
示例18: Ball_TestBounceOnWallHit
public void Ball_TestBounceOnWallHit()
{
RectangleF gf = GameManager.gameField;
SizeF target;
//Test left wall bounce
Ball b = new RegularBall(new PointF(gf.Left + 1.0f, gf.Bottom / 2));
b.moveVector = new SizeF(-1.0f, 1.0f);
target = new SizeF(b.moveVector.Width * -1, b.moveVector.Height);
b.Update();
b.Update();
b.Update();
Assert.AreEqual(target, b.moveVector);
//Test right wall bounce
b = new RegularBall(new PointF(gf.Right - 1.0f, gf.Bottom / 2));
b.moveVector = new SizeF(1.0f, 1.0f);
target = new SizeF(b.moveVector.Width * -1, b.moveVector.Height);
b.Update();
b.Update();
b.Update();
Assert.AreEqual(target, b.moveVector);
//Test top wall bounce
b = new RegularBall(new PointF(gf.Right / 2, gf.Top - 1.0f));
b.moveVector = new SizeF(1.0f, -1.0f);
target = new SizeF(b.moveVector.Width, b.moveVector.Height * -1);
b.Update();
b.Update();
b.Update();
Assert.AreEqual(target, b.moveVector);
}
开发者ID:Chronophobe,项目名称:STV_Stage1,代码行数:32,代码来源:BallTest.cs
示例19: SparkleAbout
public SparkleAbout()
: base()
{
SetFrame (new RectangleF (0, 0, 360, 288), true);
Center ();
StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Titled);
Title = "About SparkleShare";
MaxSize = new SizeF (360, 288);
MinSize = new SizeF (360, 288);
HasShadow = true;
BackingType = NSBackingStore.Buffered;
CreateAbout ();
MakeKeyAndOrderFront (this);
SparkleShare.Controller.NewVersionAvailable += delegate (string new_version) {
InvokeOnMainThread (delegate {
UpdatesTextField.StringValue = "A newer version (" + new_version + ") is available!";
UpdatesTextField.TextColor =
NSColor.FromCalibratedRgba (0.96f, 0.47f, 0.0f, 1.0f); // Tango Orange #2
});
};
SparkleShare.Controller.VersionUpToDate += delegate {
InvokeOnMainThread (delegate {
UpdatesTextField.StringValue = "You are running the latest version.";
UpdatesTextField.TextColor =
NSColor.FromCalibratedRgba (0.31f, 0.60f, 0.02f, 1.0f); // Tango Chameleon #3
});
};
SparkleShare.Controller.CheckForNewVersion ();
}
开发者ID:forkmerge,项目名称:SparkleShare,代码行数:34,代码来源:SparkleAbout.cs
示例20: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
Font font = new Font("Microsoft Sans Serif", 36F,
System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point,
((byte)(0)));
SizeF stringSize = new SizeF();
String str = " ";
int rowHeight;
int textWidth;
int xAdjust = 0;
stringSize = e.Graphics.MeasureString(str, font, 800);
rowHeight = (int)stringSize.Height +
(int)stringSize.Height;
textWidth = ((int)stringSize.Width);
g.RotateTransform(-20);
for (int x = 0; x < (this.Width / textWidth) + 2; x++)
{
for (int y = 0; y < 2 * (this.Height / rowHeight) + 2; y++)
{
xAdjust = textWidth / 2;
g.DrawString(str, font, System.Drawing.Brushes.Red, new Point(x * textWidth - xAdjust, y * rowHeight));
}
}
}
开发者ID:wee2tee,项目名称:SN_Net,代码行数:29,代码来源:TransparentPanel.cs
注:本文中的System.Drawing.SizeF类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论