本文整理汇总了C#中System.Drawing.RectangleF.GetMidY方法的典型用法代码示例。如果您正苦于以下问题:C# RectangleF.GetMidY方法的具体用法?C# RectangleF.GetMidY怎么用?C# RectangleF.GetMidY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.RectangleF
的用法示例。
在下文中一共展示了RectangleF.GetMidY方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 ();
}
示例2: 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;
}
示例3: 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();
}
}
示例4: 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();
}
示例5: 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);
//.........这里部分代码省略.........
示例6: 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;
//.........这里部分代码省略.........