本文整理汇总了C#中System.Drawing.RectangleF.GetMidX方法的典型用法代码示例。如果您正苦于以下问题:C# RectangleF.GetMidX方法的具体用法?C# RectangleF.GetMidX怎么用?C# RectangleF.GetMidX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.RectangleF
的用法示例。
在下文中一共展示了RectangleF.GetMidX方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw (RectangleF rect)
{
rect = RectangleF.Inflate (rect, 4, 4);
rect = new RectangleF ((rect.Size.Width - rect.Size.Height) / 2 + 4, 8, rect.Size.Height, rect.Size.Height);
UIBezierPath path = UIBezierPath.FromOval (rect);
UIColor.Black.SetStroke ();
UIColor.White.SetFill ();
path.LineWidth = 2;
path.Fill ();
path.Stroke ();
UIBezierPath rightEye, leftEye, mouth = new UIBezierPath ();
if (MovingRight) {
rightEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () - 5, rect.Y + 15), 4, 0, 180, true);
leftEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () + 10, rect.Y + 15), 4, 0, 180, true);
mouth.MoveTo (new PointF (rect.GetMidX (), rect.Y + 30));
mouth.AddLineTo (new PointF (rect.GetMidX () + 13, rect.Y + 30));
} else {
rightEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () - 10, rect.Y + 15), 4, 0, 180, true);
leftEye = UIBezierPath.FromArc (new PointF (rect.GetMidX () - 10, rect.Y + 15), 4, 0, 180, true);
mouth.MoveTo (new PointF (rect.GetMidX (), rect.Y + 30));
mouth.MoveTo (new PointF (rect.GetMidX (), rect.Y + 30));
}
rightEye.LineWidth = 2;
rightEye.Stroke ();
leftEye.LineWidth = 2;
leftEye.Stroke ();
mouth.LineWidth = 2;
mouth.Stroke ();
}
示例2: LayoutAttributesForElementsInRect
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect(RectangleF rect)
{
var array = base.LayoutAttributesForElementsInRect (rect);
var visibleRect = new RectangleF (CollectionView.ContentOffset, CollectionView.Bounds.Size);
for (int i = 0; i < array.Length; i++)
{
var attributes = array[i];
if (attributes.Frame.IntersectsWith(rect))
{
float distance = visibleRect.GetMidX () - attributes.Center.X;
float normalizedDistance = distance / ACTIVE_DISTANCE;
if (Math.Abs (distance) < ACTIVE_DISTANCE)
{
//This disables the zooming (zoom is configured for horizontal scrolling)
//float zoom = 1 + ZOOM_FACTOR * (1 - Math.Abs (normalizedDistance));
//attributes.Transform3D = CATransform3D.MakeScale (zoom, zoom, 1.0f);
attributes.ZIndex = 1;
}
}
}
return array;
}
示例3: Draw
public override void Draw (RectangleF rect)
{
rect = rect.Inset (4, 4);
UIBezierPath path = UIBezierPath.FromArc (new PointF (rect.GetMidX (), rect.GetMidY ()), rect.Size.Width / 2, 0, 180, true);
path.LineWidth = 8;
UIColor.White.SetFill ();
path.Fill ();
UIColor.Black.SetStroke ();
path.Stroke ();
}
示例4: LayoutAttributesForElementsInRect
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect(RectangleF rect)
{
var array = base.LayoutAttributesForElementsInRect (rect);
var visibleRect = new RectangleF (CollectionView.ContentOffset, CollectionView.Bounds.Size);
foreach (var attributes in array) {
if (attributes.Frame.IntersectsWith (rect)) {
float distance = visibleRect.GetMidX () - attributes.Center.X;
float normalizedDistance = distance / ACTIVE_DISTANCE;
if (Math.Abs (distance) < ACTIVE_DISTANCE) {
float zoom = 1 + ZOOM_FACTOR * (1 - Math.Abs (normalizedDistance));
attributes.Transform3D = CATransform3D.MakeScale (zoom, zoom, 1.0f);
attributes.ZIndex = 1;
}
}
}
return array;
}
示例5: GetCellBorderPath
public CGPath GetCellBorderPath(RectangleF rect)
{
var cornerRadius = 10;
float minx = rect.GetMinX(), midx = rect.GetMidX(), maxx = rect.GetMaxX();
float miny = rect.GetMinY(), midy = rect.GetMidY(), maxy = rect.GetMaxY();
CGPath path = new CGPath();
var cellPosition = CellPosition;
if (cellPosition == CellPosition.Top)
{
minx = minx + 1;
miny = miny + 1;
maxx = maxx - 1;
path.MoveToPoint(minx, maxy);
path.AddArcToPoint(minx, miny, midx, miny, cornerRadius);
path.AddArcToPoint(maxx, miny, maxx, maxy, cornerRadius);
path.AddLineToPoint(maxx, maxy);
}
else if (cellPosition == CellPosition.Bottom)
{
minx = minx + 1;
maxx = maxx - 1;
maxy = maxy - 1;
path.MoveToPoint(minx, miny);
path.AddArcToPoint(minx, maxy, midx, maxy, cornerRadius);
path.AddArcToPoint(maxx, maxy, maxx, miny, cornerRadius);
path.AddLineToPoint(maxx, miny);
}
else if (cellPosition == CellPosition.Middle)
{
minx = minx + 1;
maxx = maxx - 1;
path.MoveToPoint(minx, miny);
path.AddLineToPoint(maxx, miny);
path.AddLineToPoint(maxx, maxy);
path.AddLineToPoint(minx, maxy);
}
else if (cellPosition == CellPosition.Single)
{
minx = minx + 1;
miny = miny + 1;
maxx = maxx - 1;
maxy = maxy - 1;
path.MoveToPoint(minx, midy);
path.AddArcToPoint(minx, miny, midx, miny, cornerRadius);
path.AddArcToPoint(maxx, miny, maxx, midy, cornerRadius);
path.AddArcToPoint(maxx, maxy, midx, maxy, cornerRadius);
path.AddArcToPoint(minx, maxy, minx, midy, cornerRadius);
}
path.CloseSubpath();
return path;
}
示例6: Draw
public override void Draw (RectangleF rect)
{
UIView head = ((WalkingDead)Superview).head;
UIBezierPath path = new UIBezierPath ();
path.LineCapStyle = CGLineCap.Round;
RectangleF headFrame = head.Frame;
if (!MovingRight) {
rect.X -= 20;
path.MoveTo (new PointF (rect.GetMidX () + 20, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () + 20 + rect.Size.Width / 6, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () + 20 + rect.Size.Width / 6 + 10, headFrame.GetMaxY () + 10 + 20));
} else {
path.MoveTo (new PointF (rect.GetMidX () - 20, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () - 20 - rect.Size.Width / 6, headFrame.GetMaxY () + 10));
path.AddLineTo (new PointF (rect.GetMidX () - 20 - rect.Size.Width / 6 - 10, headFrame.GetMaxY () + 10 + 20));
}
UIColor.Black.SetStroke ();
path.LineWidth = 12;
path.Stroke ();
UIColor.White.SetStroke ();
path.LineWidth = 8;
path.Stroke ();
}
示例7: Draw
void Draw(RectangleF rect)
{
//// Color Declarations
//// Frames
var bgFrame = new RectangleF(0, 0, rect.Width, rect.Height);
//// Subframes
var circleGroup = new RectangleF(bgFrame.GetMinX() + (float)Math.Floor(bgFrame.Width * 0.13437f + 0.5f), bgFrame.GetMinY() + (float)Math.Floor(bgFrame.Height * 0.12500f + 0.5f), (float)Math.Floor(bgFrame.Width * 0.85938f + 0.5f) - (float)Math.Floor(bgFrame.Width * 0.13437f + 0.5f), (float)Math.Floor(bgFrame.Height * 0.84688f + 0.5f) - (float)Math.Floor(bgFrame.Height * 0.12500f + 0.5f));
//// Abstracted Attributes
var progressOvalEndAngle = Progress;
//// circleGroup
{
//// outerOval Drawing
var outerOvalPath = UIBezierPath.FromOval(new RectangleF(circleGroup.GetMinX() + (float)Math.Floor(circleGroup.Width * 0.00216f) + 0.5f, circleGroup.GetMinY() + (float)Math.Floor(circleGroup.Height * 0.00000f + 0.5f), (float)Math.Floor(circleGroup.Width * 0.99784f) - (float)Math.Floor(circleGroup.Width * 0.00216f), (float)Math.Floor(circleGroup.Height * 1.00000f + 0.5f) - (float)Math.Floor(circleGroup.Height * 0.00000f + 0.5f)));
OuterColor.SetFill();
outerOvalPath.Fill();
//// progressOval Drawing
var progressOvalRect = new RectangleF(circleGroup.GetMinX() + (float)Math.Floor(circleGroup.Width * 0.00216f) + 0.5f, circleGroup.GetMinY() + (float)Math.Floor(circleGroup.Height * 0.00000f + 0.5f), (float)Math.Floor(circleGroup.Width * 0.99784f) - (float)Math.Floor(circleGroup.Width * 0.00216f), (float)Math.Floor(circleGroup.Height * 1.00000f + 0.5f) - (float)Math.Floor(circleGroup.Height * 0.00000f + 0.5f));
var progressOvalPath = new UIBezierPath();
progressOvalPath.AddArc(new PointF(progressOvalRect.GetMidX(), progressOvalRect.GetMidY()), progressOvalRect.Width / 2, (float)(270 * Math.PI / 180), (float)(progressOvalEndAngle * Math.PI / 180), true);
progressOvalPath.AddLineTo(new PointF(progressOvalRect.GetMidX(), progressOvalRect.GetMidY()));
progressOvalPath.ClosePath();
InnerColor.SetFill();
progressOvalPath.Fill();
//// innerOval Drawing
var innerOvalPath = UIBezierPath.FromOval(new RectangleF(circleGroup.GetMinX() + (float)Math.Floor(circleGroup.Width * 0.09052f + 0.5f), circleGroup.GetMinY() + (float)Math.Floor(circleGroup.Height * 0.09091f + 0.5f), (float)Math.Floor(circleGroup.Width * 0.90948f + 0.5f) - (float)Math.Floor(circleGroup.Width * 0.09052f + 0.5f), (float)Math.Floor(circleGroup.Height * 0.91342f + 0.5f) - (float)Math.Floor(circleGroup.Height * 0.09091f + 0.5f)));
InsideColor.SetFill();
innerOvalPath.Fill();
}
}
示例8: SSDrawRoundedRect
public void SSDrawRoundedRect(CGContext context, RectangleF rect, float cornerRadius)
{
var minx = rect.GetMinX();
var midx = rect.GetMidX();
var maxx = rect.GetMaxX();
var miny = rect.GetMinY();
var midy = rect.GetMidY();
var maxy = rect.GetMaxY();
context.MoveTo(minx, midy);
context.AddArcToPoint(minx, miny, midx, miny, cornerRadius);
context.AddArcToPoint(maxx, miny, maxx, midy, cornerRadius);
context.AddArcToPoint(maxx, maxy, midx, maxy, cornerRadius);
context.AddArcToPoint(minx, maxy, minx, midy, cornerRadius);
context.ClosePath();
context.FillPath();
}
示例9: DrawLinearGradient
private void DrawLinearGradient(CGContext context, RectangleF rect, CGColor startColor, CGColor endColor)
{
CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB ();
float [] locations = { 0.0f, 1.0f };
CGColor [] colors = new CGColor[] { startColor, endColor };
CGGradient gradient = new CGGradient (colorSpace, colors, locations);
PointF startPoint = new PointF (rect.GetMidX (), rect.GetMinY ());
PointF endPoint = new PointF (rect.GetMidX (), rect.GetMaxY ());
context.SaveState ();
context.AddPath (UIBezierPath.FromRoundedRect (rect, 10).CGPath);
context.Clip ();
context.DrawLinearGradient (gradient, startPoint, endPoint, 0);
context.RestoreState ();
}
示例10: DrawWindowBackgroundGradient
private void DrawWindowBackgroundGradient(RectangleF drawingRect, CGPath clippingPath)
{
var window = (AppStoreWindow)Window;
clippingPath.ApplyClippingPathInCurrentContext();
if (window.IsTextured())
{
// If this is a textured window, we can draw the real background gradient and noise pattern
var contentBorderThickness = window.TitleBarHeight;
if (window.IsFullScreen())
{
contentBorderThickness -= window.MinimumTitleBarHeight();
}
window.SetAutorecalculatesContentBorderThickness(false, NSRectEdge.MaxYEdge);
window.SetContentBorderThickness(contentBorderThickness, NSRectEdge.MaxYEdge);
NSGraphicsExtensions.DrawWindowBackground(drawingRect);
}
else
{
// Not textured, we have to fake the background gradient and noise pattern
var drawsAsMainWindow = window.DrawsAsMainWindow();
var startColor = drawsAsMainWindow ? window.TitleBarStartColor : window.InactiveTitleBarStartColor;
var endColor = drawsAsMainWindow ? window.TitleBarEndColor : window.InactiveTitleBarEndColor;
if (startColor == default(NSColor))
startColor = AppStoreWindow.DefaultTitleBarStartColor(drawsAsMainWindow);
if (endColor == default(NSColor))
endColor = AppStoreWindow.DefaultTitleBarEndColor(drawsAsMainWindow);
var context = NSGraphicsContext.CurrentContext.GraphicsPort;
var gradient = DrawingHelper.CreateGraidentWithColors(startColor, endColor);
context.DrawLinearGradient(gradient, new PointF(drawingRect.GetMidX(), drawingRect.GetMinY()), new PointF(drawingRect.GetMidX(), drawingRect.GetMaxY()), 0);
if (drawsAsMainWindow)
{
var noiseRect = new RectangleF(1.0f, 1.0f, drawingRect.Width, drawingRect.Height);
if (window.ShowBaselineSeparator)
{
var separatorHeight = BaselineSeparatorFrame.Height;
noiseRect.Y -= separatorHeight;
noiseRect.Height += separatorHeight;
}
NSGraphicsContext.CurrentContext.SaveGraphicsState();
var noiseClippingPath = DrawingHelper.CreateClippingPath(noiseRect, CORNER_CLIP_RADIUS);
context.AddPath(noiseClippingPath);
context.Clip();
DrawNoise(0.1f);
NSGraphicsContext.CurrentContext.RestoreGraphicsState();
}
}
if (window.ShowBaselineSeparator)
{
DrawBaselineSeparator(BaselineSeparatorFrame);
}
}
示例11: DrawRect
public override void DrawRect (RectangleF dirtyRect)
{
// Don't draw if we don't have a font or a title.
if (Font == null || Title == string.Empty)
return;
// Initialize the text matrix to a known value
CGContext context = NSGraphicsContext.CurrentContext.GraphicsPort;
context.TextMatrix = CGAffineTransform.MakeIdentity ();
// Draw a white background
NSColor.White.Set ();
context.FillRect (dirtyRect);
//CTLineRef line = CTLineCreateWithAttributedString((CFAttributedStringRef)self.attributedString);
CTLine line = new CTLine (AttributedString);
int glyphCount = line.GlyphCount;
if (glyphCount == 0)
return;
GlyphArcInfo[] glyphArcInfo = new GlyphArcInfo[glyphCount];
PrepareGlyphArcInfo (line, glyphCount, glyphArcInfo);
// Move the origin from the lower left of the view nearer to its center.
context.SaveState ();
context.TranslateCTM (dirtyRect.GetMidX (), dirtyRect.GetMidY () - Radius / 2);
// Stroke the arc in red for verification.
context.BeginPath ();
context.AddArc (0, 0, Radius, (float)Math.PI, 0, true);
context.SetRGBStrokeColor (1, 0, 0, 1);
context.StrokePath ();
// Rotate the context 90 degrees counterclockwise.
context.RotateCTM ((float)PI_2);
// Now for the actual drawing. The angle offset for each glyph relative to the previous
// glyph has already been calculated; with that information in hand, draw those glyphs
// overstruck and centered over one another, making sure to rotate the context after each
// glyph so the glyphs are spread along a semicircular path.
PointF textPosition = new PointF (0, Radius);
context.TextPosition = textPosition;
var runArray = line.GetGlyphRuns ();
var runCount = runArray.Count ();
var glyphOffset = 0;
var runIndex = 0;
for (; runIndex < runCount; runIndex++) {
var run = runArray[runIndex];
var runGlyphCount = run.GlyphCount;
bool drawSubstitutedGlyphsManually = false;
CTFont runFont = run.GetAttributes ().Font;
// Determine if we need to draw substituted glyphs manually. Do so if the runFont is not
// the same as the overall font.
NSFont rrunFont = new NSFont (runFont.Handle);
// used for comparison
if (DimsSubstitutedGlyphs && Font != rrunFont) {
drawSubstitutedGlyphsManually = true;
}
var runGlyphIndex = 0;
for (; runGlyphIndex < runGlyphCount; runGlyphIndex++) {
var glyphRange = new NSRange (runGlyphIndex, 1);
context.RotateCTM (-(glyphArcInfo[runGlyphIndex + glyphOffset].angle));
// Center this glyph by moving left by half its width.
var glyphWidth = glyphArcInfo[runGlyphIndex + glyphOffset].width;
var halfGlyphWidth = glyphWidth / 2.0;
var positionForThisGlyph = new PointF (textPosition.X - (float)halfGlyphWidth, textPosition.Y);
// Glyphs are positioned relative to the text position for the line, so offset text position leftwards by this glyph's
// width in preparation for the next glyph.
textPosition.X -= glyphWidth;
CGAffineTransform textMatrix = run.TextMatrix;
textMatrix.x0 = positionForThisGlyph.X;
textMatrix.y0 = positionForThisGlyph.Y;
context.TextMatrix = textMatrix;
if (!drawSubstitutedGlyphsManually)
run.Draw (context, glyphRange);
else {
// We need to draw the glyphs manually in this case because we are effectively applying a graphics operation by
// setting the context fill color. Normally we would use kCTForegroundColorAttributeName, but this does not apply
// as we don't know the ranges for the colors in advance, and we wanted demonstrate how to manually draw.
var cgFont = runFont.ToCGFont ();
var glyph = run.GetGlyphs (glyphRange);
var position = run.GetPositions (glyphRange);
context.SetFont (cgFont);
context.SetFontSize (runFont.Size);
context.SetRGBFillColor (0.25f, 0.25f, 0.25f, 1);
context.ShowGlyphsAtPositions (glyph, position, 1);
//.........这里部分代码省略.........
示例12: DetermineGeometry
public void DetermineGeometry(SizeF size, RectangleF anchorRect, RectangleF displayArea, UIPopoverArrowDirection supportedDirections)
{
_Offset = PointF.Empty;
_BackgroundRect = RectangleF.Empty;
_ArrowRect = RectangleF.Empty;
PopoverArrowDirection = UIPopoverArrowDirection.Unknown;
var biggestSurface = 0.0f;
var currentMinMargin = 0.0f;
var upArrowImage = UIImage.FromBundle(this.Properties.UpArrowImage);
var downArrowImage = UIImage.FromBundle(this.Properties.DownArrowImage);
var leftArrowImage = UIImage.FromBundle(this.Properties.LeftArrowImage);
var rightArrowImage = UIImage.FromBundle(this.Properties.RightArrowImage);
foreach(var direction in (UIPopoverArrowDirection[])Enum.GetValues(typeof(UIPopoverArrowDirection))) {
if(supportedDirections.HasFlag(direction)) {
var bgRect = RectangleF.Empty;
var arrowRect = RectangleF.Empty;
var offset = PointF.Empty;
var xArrowOffset = 0.0f;
var yArrowOffset = 0.0f;
var anchorPoint = PointF.Empty;
switch(direction) {
case UIPopoverArrowDirection.Up: {
anchorPoint = new PointF(anchorRect.GetMidX(), anchorRect.GetMaxY());
xArrowOffset = size.Width / 2 - upArrowImage.Size.Width / 2;
yArrowOffset = Properties.TopBgMargin - upArrowImage.Size.Height;
offset = new PointF(anchorPoint.X - xArrowOffset - upArrowImage.Size.Width / 2, anchorPoint.Y - yArrowOffset);
bgRect = new RectangleF(0, 0, size.Width, size.Height);
if(offset.X < 0) {
xArrowOffset += offset.X;
offset.X = 0;
}
else if(offset.X + size.Width > displayArea.Size.Width) {
xArrowOffset += (offset.X + size.Width - displayArea.Size.Width);
offset.X = displayArea.Size.Width - size.Width;
}
xArrowOffset = Math.Max(xArrowOffset, Properties.LeftBgMargin + Properties.ArrowMargin);
xArrowOffset = Math.Min(xArrowOffset, size.Width - Properties.RightBgMargin - Properties.ArrowMargin - upArrowImage.Size.Width);
arrowRect = new RectangleF(xArrowOffset, yArrowOffset, upArrowImage.Size.Width, upArrowImage.Size.Height);
break;
}
case UIPopoverArrowDirection.Down: {
anchorPoint = new PointF(anchorRect.GetMidX(), anchorRect.GetMinY());
xArrowOffset = size.Width / 2 - downArrowImage.Size.Width / 2;
yArrowOffset = size.Height - Properties.BottomBgMargin;
offset = new PointF(anchorPoint.X - xArrowOffset - downArrowImage.Size.Width / 2,
anchorPoint.Y - yArrowOffset - downArrowImage.Size.Height);
bgRect = new RectangleF(0, 0, size.Width, size.Height);
if(offset.X < 0) {
xArrowOffset += offset.X;
offset.X = 0;
}
else if(offset.X + size.Width > displayArea.Size.Width) {
xArrowOffset += (offset.X + size.Width - displayArea.Size.Width);
offset.X = displayArea.Size.Width - size.Width;
}
//cap arrow offset;
xArrowOffset = Math.Max(xArrowOffset, Properties.LeftBgMargin + Properties.ArrowMargin);
xArrowOffset = Math.Min(xArrowOffset, size.Width - Properties.RightBgMargin - Properties.ArrowMargin - downArrowImage.Size.Width);
arrowRect = new RectangleF(xArrowOffset, yArrowOffset, downArrowImage.Size.Width, downArrowImage.Size.Height);
break;
}
case UIPopoverArrowDirection.Left: {
anchorPoint = new PointF(anchorRect.GetMaxX(), anchorRect.GetMidY());
xArrowOffset = Properties.LeftBgMargin - leftArrowImage.Size.Width;
yArrowOffset = size.Height / 2 - leftArrowImage.Size.Height / 2;
offset = new PointF(anchorPoint.X - xArrowOffset, anchorPoint.Y - yArrowOffset - leftArrowImage.Size.Height / 2);
bgRect = new RectangleF(0, 0, size.Width, size.Height);
if(offset.Y < 0) {
yArrowOffset += offset.Y;
offset.Y = 0;
}
else if(offset.Y + size.Height > displayArea.Size.Height) {
yArrowOffset += (offset.Y + size.Height) - displayArea.Size.Height;
offset.Y = displayArea.Size.Height - size.Height;
}
//cap arrow offset;
//.........这里部分代码省略.........