本文整理汇总了C#中System.Drawing.RectangleF.Offset方法的典型用法代码示例。如果您正苦于以下问题:C# RectangleF.Offset方法的具体用法?C# RectangleF.Offset怎么用?C# RectangleF.Offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.RectangleF
的用法示例。
在下文中一共展示了RectangleF.Offset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadView
public override void LoadView()
{
View = new UIView();
View.BackgroundColor = UIColor.LightGray;
RectangleF f = new RectangleF(10,10,300, 44);
UsernameTextField = new UITextField(f) {
Placeholder = "Username",
BorderStyle = UITextBorderStyle.RoundedRect,
AutocapitalizationType = UITextAutocapitalizationType.None,
AutocorrectionType = UITextAutocorrectionType.No
};
View.AddSubview(UsernameTextField);
f.Offset(new PointF(0, f.Height + 10));
PasswordTextField = new UITextField(f) {
Placeholder = "Password",
BorderStyle = UITextBorderStyle.RoundedRect,
SecureTextEntry = true
};
View.AddSubview(PasswordTextField);
f.Offset(new PointF(0, f.Height + 10));
UIButton button = UIButton.FromType(UIButtonType.RoundedRect);
button.SetTitle("Login", UIControlState.Normal);
button.Frame = f;
button.TouchUpInside += LoginHandler;
View.AddSubview(button);
}
示例2: ScaleImageTo16x16
public static Image ScaleImageTo16x16(Image img, bool bForceNewObject)
{
if (img == null) { Debug.Assert(false); return null; }
int w = img.Width;
int h = img.Height;
int sw = 16;
int sh = 16;
if ((w == sw) && (h == sh) && !bForceNewObject)
return img;
Bitmap bmp = new Bitmap(sw, sh, img.PixelFormat);
using (Graphics g = Graphics.FromImage(bmp))
{
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
RectangleF rSource = new RectangleF(0, 0, w, h);
RectangleF rDest = new RectangleF(0, 0, sw, sh);
// Prevent border drawing bug
rSource.Offset(-0.5f, -0.5f);
g.DrawImage(img, rDest, rSource, GraphicsUnit.Pixel);
}
return bmp;
}
示例3: Render
public override void Render(View3D view, Viewport viewport)
{
m_View.Resize(new System.Drawing.Rectangle(0, 0, (int)viewport.Width, (int)viewport.Height), (int)viewport.Width, (int)viewport.Height);
float x, y, w, h;
float widthPerImage = (float)(viewport.Width / m_KinectColorImages.Count);
float heightPerImage = (widthPerImage / 4) * 3;
RectangleF imageBounds = new RectangleF(0, (viewport.Height - heightPerImage) * 0.5f, widthPerImage, heightPerImage);
switch (KinectImageMode)
{
case KinectImageMode.Color:
foreach (KinectColorImageTexture color in m_KinectColorImages)
{
UiStyleHelper.CovertToVertCoords(imageBounds, m_View.WindowSize, m_View.PixelSize, out x, out y, out w, out h);
color.Rectangle = new RectangleF(x, y, w, h);
color.Update();
color.Render(m_View);
imageBounds.Offset(widthPerImage, 0);
}
break;
case KinectImageMode.RawDepth:
case KinectImageMode.DepthBackgroundImage:
case KinectImageMode.DepthBackgroundRemoved:
foreach (KinectDepthImageTexture depth in m_KinectDepthImages)
{
UiStyleHelper.CovertToVertCoords(imageBounds, m_View.WindowSize, m_View.PixelSize, out x, out y, out w, out h);
depth.Rectangle = new RectangleF(x, y, w, h);
switch (KinectImageMode)
{
case KinectImageMode.RawDepth:
depth.ImageType = KinectDepthImageType.RawDepth;
break;
case KinectImageMode.DepthBackgroundImage:
depth.ImageType = KinectDepthImageType.DepthBackgroundImage;
break;
case KinectImageMode.DepthBackgroundRemoved:
depth.ImageType = KinectDepthImageType.DepthBackgroundRemoved;
break;
default:
break;
}
depth.Update();
depth.Render(m_View);
imageBounds.Offset(widthPerImage, 0);
}
break;
default:
break;
}
}
示例4: Hit
internal override bool Hit(PointF p)
{
RectangleF r = new RectangleF(p, new SizeF(0,0));
RectangleF env = new RectangleF(this.mCurrentPoint,new SizeF(10,10));
env.Offset(-5,-5);
mHovered = env.Contains(r);
//Debug.WriteLine("(" + p.X + "," + p.Y + ") c " + "(" + mCurrentPoint.X + "," + mCurrentPoint.Y +")");
return mHovered;
}
示例5: DrawFancyText
static void DrawFancyText(string text, Color color, Graphics g, RectangleF rect)
{
Font font = new Font("Palatino Linotype", 24, FontStyle.Bold | FontStyle.Italic);
SizeF actual = g.MeasureString(text, font);
float scale = Math.Max(actual.Width / (rect.Width * 0.95F), actual.Height / (rect.Height * 0.95F));
font = new Font(font.FontFamily, font.Size / scale, font.Style);
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
float offset = font.Size / 20F;
StringFormat format = new StringFormat(StringFormat.GenericDefault);
format.LineAlignment = StringAlignment.Center;
format.Alignment = StringAlignment.Center;
rect.Offset(offset, offset);
g.DrawString(text, font, Brushes.Gray, rect, format);
rect.Offset(-offset, -offset);
using (Brush b = new SolidBrush(color))
g.DrawString(text, font, b, rect, format);
font.Dispose();
}
示例6: Draw
public static void Draw(Graphics graphics, Pen border, Brush background,
RectangleF rectangle, float cornerRadius)
{
Debug.Assert(rectangle.Height >= (2 * cornerRadius));
GraphicsPath rectanglePath = new GraphicsPath();
float halfBorder = border.Width * 0.5f;
rectangle.Offset(halfBorder, halfBorder);
rectangle.Height -= border.Width;
rectangle.Width -= border.Width;
if (rectangle.Height > (2 * cornerRadius))
{
// Top left
rectanglePath.AddArc(rectangle.Left, rectangle.Top,
cornerRadius * 2, cornerRadius * 2,
180, 90);
// Top right
rectanglePath.AddArc(rectangle.Right - (2 * cornerRadius), rectangle.Top,
cornerRadius * 2, cornerRadius * 2,
270, 90);
// Bottom right
rectanglePath.AddArc(rectangle.Right - (2 * cornerRadius), rectangle.Bottom - (2 * cornerRadius),
cornerRadius * 2, cornerRadius * 2,
0, 90);
// Bottom left
rectanglePath.AddArc(rectangle.Left, rectangle.Bottom - (2 * cornerRadius),
cornerRadius * 2, cornerRadius * 2,
90, 90);
}
else
{
// Left
rectanglePath.AddArc(rectangle.Left, rectangle.Top,
cornerRadius * 2, cornerRadius * 2,
90, 180);
// Right
rectanglePath.AddArc(rectangle.Right - (2 * cornerRadius), rectangle.Top,
cornerRadius * 2, cornerRadius * 2,
270, 180);
}
rectanglePath.CloseFigure();
graphics.FillPath(background, rectanglePath);
graphics.DrawPath(border, rectanglePath);
rectanglePath.Dispose();
}
示例7: ShowDetails
public void ShowDetails(Element element, RectangleF cellFrame)
{
cellFrame.Offset(PeriodicTable.Frame.Location);
detailsView.CellFrame = cellFrame;
detailsView.Frame = cellFrame;
detailsView.BackgroundColor = PeriodicCell.GetBackgroundColor(element.GroupName);
UIView.Animate(1.2, 0, UIViewAnimationOptions.CurveEaseInOut,
() =>
{
detailsView.Hidden = false;
detailsView.Alpha = 1;
detailsView.Frame = this.View.Bounds;
},
() => { detailsView.SetNeedsLayout(); }
);
}
示例8: GetWorldBounds
public override RectangleF GetWorldBounds()
{
float xmin = float.MaxValue;
float xmax = float.MinValue;
float ymin = float.MaxValue;
float ymax = float.MinValue;
foreach (var p in this.Points)
{
xmin = Math.Min(xmin, p.X);
xmax = Math.Max(xmax, p.X);
ymin = Math.Min(ymin, p.Y);
ymax = Math.Max(ymax, p.Y);
}
RectangleF bounds = new RectangleF(xmin, ymin, xmax - xmin, ymax - ymin);
bounds.Offset(this.Position);
return bounds;
}
示例9: DrawHorizontalTicks
private void DrawHorizontalTicks(Graphics g, Color color)
{
RectangleF ef;
int num = (base.Maximum / base.TickFrequency) - 1;
Pen pen = new Pen(color);
RectangleF ef2 = new RectangleF((float)(ChannelBounds.Left + (ThumbBounds.Width / 2)), (float)(ThumbBounds.Top - 5), 0f, 3f);
RectangleF ef3 = new RectangleF((float)((ChannelBounds.Right - (ThumbBounds.Width / 2)) - 1), (float)(ThumbBounds.Top - 5), 0f, 3f);
float x = (ef3.Right - ef2.Left) / ((float)(num + 1));
if (base.TickStyle != TickStyle.BottomRight)
{
g.DrawLine(pen, ef2.Left, ef2.Top, ef2.Right, ef2.Bottom);
g.DrawLine(pen, ef3.Left, ef3.Top, ef3.Right, ef3.Bottom);
ef = ef2;
ef.Height--;
ef.Offset(x, 1f);
int num3 = num - 1;
for (int i = 0; i <= num3; i++)
{
g.DrawLine(pen, ef.Left, ef.Top, ef.Left, ef.Bottom);
ef.Offset(x, 0f);
}
}
ef2.Offset(0f, (float)(ThumbBounds.Height + 6));
ef3.Offset(0f, (float)(ThumbBounds.Height + 6));
if (base.TickStyle != TickStyle.TopLeft)
{
g.DrawLine(pen, ef2.Left, ef2.Top, ef2.Left, ef2.Bottom);
g.DrawLine(pen, ef3.Left, ef3.Top, ef3.Left, ef3.Bottom);
ef = ef2;
ef.Height--;
ef.Offset(x, 0f);
int num5 = num - 1;
for (int j = 0; j <= num5; j++)
{
g.DrawLine(pen, ef.Left, ef.Top, ef.Left, ef.Bottom);
ef.Offset(x, 0f);
}
}
pen.Dispose();
}
示例10: LoadView
public override void LoadView()
{
View = new UIView () {
BackgroundColor = UIColor.LightGray
};
RectangleF f = new RectangleF (10, 10, 300, 40);
DisplayNameLabel = new UILabel(f) {
Font = UIFont.BoldSystemFontOfSize(20)
};
View.AddSubview (DisplayNameLabel);
f.Offset (new PointF(0, f.Height + 10));
FullNameLabel = new UILabel (f) {
TextColor = UIColor.DarkGray
};
View.AddSubview (FullNameLabel);
f.Offset(new PointF(0, f.Height + 10));
MemberSinceLabel = new UILabel (f) {
Font = UIFont.ItalicSystemFontOfSize(14)
};
View.AddSubview (MemberSinceLabel);
}
示例11: WillRotate
//Recipe 2-2 Adding Reorientation Support to the Preceding Subview Example
public override void WillRotate(UIInterfaceOrientation toInterfaceOrientation, double duration)
{
var appRect = new RectangleF();
appRect.Offset(new PointF(0.0f, 0.0f));
//Adjust the frame based on the actual orientation
if(toInterfaceOrientation == UIInterfaceOrientation.LandscapeLeft ||
toInterfaceOrientation == UIInterfaceOrientation.LandscapeRight)
{
appRect.Size = new SizeF(480.0f, 300.0f);
}
else
{
appRect.Size = new SizeF(320.0f, 460.0f);
}
//Resize each subview accordingly
var offset = -32.0f;
foreach(var subview in contentView.Subviews)
{
var frame = RectangleF.Inflate(appRect, offset, offset);
subview.Frame = frame;
offset -= 32.0f;
}
}
示例12: DrawText
protected virtual void DrawText(Graphics g)
{
RectangleF layoutRect =
new RectangleF(0, 0, this.Width,
this.Height - ButtonShadowOffset);
int LabelShadowOffset = 1;
StringFormat fmt = new StringFormat();
fmt.Alignment = StringAlignment.Center;
fmt.LineAlignment = StringAlignment.Center;
// Draw the shadow below the label
layoutRect.Offset(0, LabelShadowOffset);
SolidBrush textShadowBrush = new SolidBrush(Color.Gray);
g.DrawString(Text, Font, textShadowBrush, layoutRect, fmt);
textShadowBrush.Dispose();
// and the label itself
layoutRect.Offset(0, -LabelShadowOffset);
SolidBrush brushFiller = new SolidBrush(Color.Black);
g.DrawString(Text, Font, brushFiller, layoutRect, fmt);
brushFiller.Dispose();
}
示例13: LayoutSubviews
public override void LayoutSubviews()
{
base.LayoutSubviews ();
ImageView.Frame = new RectangleF(10, 10, 50, 50);
TextLabel.Frame = new RectangleF(70, 10, 240, 20);
var detailsFrame = new RectangleF(TextLabel.Frame.Location, TextLabel.Frame.Size);
detailsFrame.Offset(0, 25);
detailsFrame.Height = CalculatePostHeight() - 45;
DetailTextLabel.Frame = detailsFrame;
}
示例14: Paint
public void Paint(ChartPaintEventArgs e)
{
var g = e.Graphics;
var chart = e.Chart;
// dragging outline / trail
if (DraggedRect != RectangleF.Empty)
g.DrawRectangle(Pens.Red, DraggedRect);
// insertion indicator line
if (Row != int.MinValue)
{
float y = e.Chart._ChartRowToChartCoord(Row) + e.Chart.BarHeight / 2.0f;
g.DrawLine(Pens.CornflowerBlue, new PointF(0, y), new PointF(e.Chart.Width, y));
}
// tool tip
if (_mToolTipMouse != Point.Empty && _mToolTipText != string.Empty)
{
var size = g.MeasureString(_mToolTipText, chart.Font).ToSize();
var tooltiprect = new RectangleF(_mToolTipMouse, size);
tooltiprect.Offset(0, -tooltiprect.Height);
var textstart = new PointF(tooltiprect.Left, tooltiprect.Top);
tooltiprect.Inflate(5, 5);
g.FillRectangle(Brushes.LightYellow, tooltiprect);
g.DrawString(_mToolTipText, chart.Font, Brushes.Black, textstart);
}
}
示例15: DrawBlueShirt
public static void DrawBlueShirt(RectangleF frame, float shirtAngle, float shirtScaleFactor)
{
//// General Declarations
var context = UIGraphics.GetCurrentContext();
//// Color Declarations
var blueShirtBase = UIColor.FromRGBA(0.173f, 0.435f, 0.702f, 1.000f);
var blueShirtBaseRGBA = new float[4];
blueShirtBase.GetRGBA(out blueShirtBaseRGBA[0], out blueShirtBaseRGBA[1], out blueShirtBaseRGBA[2], out blueShirtBaseRGBA[3]);
var blueShirtStroke = UIColor.FromRGBA((blueShirtBaseRGBA[0] * 0.7f + 0.3f), (blueShirtBaseRGBA[1] * 0.7f + 0.3f), (blueShirtBaseRGBA[2] * 0.7f + 0.3f), (blueShirtBaseRGBA[3] * 0.7f + 0.3f));
//// Shadow Declarations
var blueShirtShadow = blueShirtBase.CGColor;
var blueShirtShadowOffset = new SizeF(2.1f, 2.1f);
var blueShirtShadowBlurRadius = 3.0f;
//// shirtBezier Drawing
context.SaveState();
context.TranslateCTM(frame.GetMinX() + 61.94f, frame.GetMinY() + 59.36f);
context.RotateCTM(-shirtAngle * (float)Math.PI / 180.0f);
context.ScaleCTM(shirtScaleFactor, shirtScaleFactor);
UIBezierPath shirtBezierPath = new UIBezierPath();
shirtBezierPath.MoveTo(new PointF(-27.46f, -43.29f));
shirtBezierPath.AddCurveToPoint(new PointF(-11.8f, -30.19f), new PointF(-27.46f, -43.29f), new PointF(-15.62f, -33.38f));
shirtBezierPath.AddLineTo(new PointF(-10.9f, -30.19f));
shirtBezierPath.AddCurveToPoint(new PointF(-10.59f, -29.78f), new PointF(-10.8f, -30.05f), new PointF(-10.7f, -29.92f));
shirtBezierPath.AddCurveToPoint(new PointF(10.42f, -29.78f), new PointF(-4.79f, -22.48f), new PointF(4.62f, -22.48f));
shirtBezierPath.AddCurveToPoint(new PointF(10.74f, -30.19f), new PointF(10.53f, -29.92f), new PointF(10.63f, -30.05f));
shirtBezierPath.AddCurveToPoint(new PointF(11.8f, -30.19f), new PointF(10.74f, -30.19f), new PointF(11.13f, -30.19f));
shirtBezierPath.AddCurveToPoint(new PointF(27.46f, -43.29f), new PointF(15.62f, -33.38f), new PointF(27.46f, -43.29f));
shirtBezierPath.AddLineTo(new PointF(48.92f, -10.09f));
shirtBezierPath.AddLineTo(new PointF(32.09f, 3.99f));
shirtBezierPath.AddCurveToPoint(new PointF(27.12f, -3.69f), new PointF(32.09f, 3.99f), new PointF(30.0f, 0.76f));
shirtBezierPath.AddCurveToPoint(new PointF(27.12f, 43.29f), new PointF(27.12f, 17.36f), new PointF(27.12f, 43.29f));
shirtBezierPath.AddLineTo(new PointF(-27.46f, 43.29f));
shirtBezierPath.AddCurveToPoint(new PointF(-27.46f, -3.18f), new PointF(-27.46f, 43.29f), new PointF(-27.46f, 17.78f));
shirtBezierPath.AddCurveToPoint(new PointF(-32.09f, 3.99f), new PointF(-30.16f, 1.0f), new PointF(-32.09f, 3.99f));
shirtBezierPath.AddLineTo(new PointF(-48.92f, -10.09f));
shirtBezierPath.AddLineTo(new PointF(-27.46f, -43.29f));
shirtBezierPath.ClosePath();
context.SaveState();
context.SetShadowWithColor(blueShirtShadowOffset, blueShirtShadowBlurRadius, blueShirtShadow);
blueShirtBase.SetFill();
shirtBezierPath.Fill();
context.RestoreState();
blueShirtStroke.SetStroke();
shirtBezierPath.LineWidth = 8.0f;
shirtBezierPath.Stroke();
context.RestoreState();
//// Text Drawing
context.SaveState();
context.TranslateCTM(frame.GetMinX() + 62.0f, frame.GetMinY() + 61.95f);
context.RotateCTM(-shirtAngle * (float)Math.PI / 180.0f);
context.ScaleCTM(shirtScaleFactor, shirtScaleFactor);
RectangleF textRect = new RectangleF(-24.7f, -25.61f, 50.0f, 50.0f);
var textPath = UIBezierPath.FromRect(textRect);
UIColor.Red.SetStroke();
textPath.LineWidth = 1.0f;
textPath.Stroke();
{
var textContent = "?";
UIColor.White.SetFill();
var textFont = UIFont.FromName("HelveticaNeue-Bold", 36.0f);
textRect.Offset(0.0f, (textRect.Height - new NSString(textContent).StringSize(textFont, textRect.Size).Height) / 2.0f);
new NSString(textContent).DrawString(textRect, textFont, UILineBreakMode.WordWrap, UITextAlignment.Center);
}
context.RestoreState();
}