本文整理汇总了C#中System.Drawing.RectangleF.GetMinX方法的典型用法代码示例。如果您正苦于以下问题:C# RectangleF.GetMinX方法的具体用法?C# RectangleF.GetMinX怎么用?C# RectangleF.GetMinX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.RectangleF
的用法示例。
在下文中一共展示了RectangleF.GetMinX方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateClippingPath
internal static CGPath CreateClippingPath(RectangleF rect, float radius)
{
var path = new CGPath();
path.MoveToPoint(rect.GetMinX(), rect.GetMinY());
path.AddLineToPoint(rect.GetMinX(), rect.GetMaxY() - radius);
path.AddArcToPoint(rect.GetMinX(), rect.GetMaxY(), rect.GetMinX() + radius, rect.GetMaxY(), radius);
path.AddLineToPoint(rect.GetMaxX() - radius, rect.GetMaxY());
path.AddArcToPoint(rect.GetMaxX(), rect.GetMaxY(), rect.GetMaxX(), rect.GetMaxY() - radius, radius);
path.AddLineToPoint(rect.GetMaxX(), rect.GetMinY());
path.CloseSubpath();
return path;
}
示例2: DrawRect
public override void DrawRect (System.Drawing.RectangleF area, UIViewPrintFormatter formatter)
{
base.DrawRect (area, formatter);
CGContext context = UIGraphics.GetCurrentContext ();
UIColor shadow;
shadow = UIColor.Clear;
UIColor chevronColor = this.Color;
SizeF shadowOffset = new SizeF (0.1F, 1.1F);
Single shadowBlurRadius = 0F;
RectangleF frame = new RectangleF (this.Bounds.X, this.Bounds.Y, this.Bounds.Width, this.Bounds.Height);
UIBezierPath chevronPath = new UIBezierPath ();
chevronPath.MoveTo (new PointF (frame.GetMinX () + 0.22000F * frame.Width, frame.GetMinY () + 0.01667F * frame.Height));
chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.98000F * frame.Width, frame.GetMinY() + 0.48333F * frame.Height));
chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.22000F * frame.Width, frame.GetMinY() + 0.98333F * frame.Height));
chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.02000F * frame.Width, frame.GetMinY() + 0.81667F * frame.Height));
chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.54000F * frame.Width, frame.GetMinY() + 0.48333F * frame.Height));
chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.02000F * frame.Width, frame.GetMinY() + 0.15000F * frame.Height));
chevronPath.AddLineTo (new PointF (frame.GetMinX() + 0.22000F * frame.Width, frame.GetMinY() + 0.01667F * frame.Height));
chevronPath.ClosePath ();
context.SaveState ();
context.SetShadowWithColor (shadowOffset, shadowBlurRadius, shadow.CGColor);
chevronColor.SetFill ();
chevronPath.Fill ();
context.RestoreState ();
}
示例3: Draw
public override void Draw (RectangleF rect)
{
using (var context = UIGraphics.GetCurrentContext ()) {
// get the scale from the context by getting the current transform matrix, then asking for
// its "a" component, which is one of the two scale components. We could also ask for "d".
// This assumes (safely) that the view is being scaled equally in both dimensions.
var scale = context.GetCTM ().xx;
CATiledLayer tiledLayer = (CATiledLayer)this.Layer;
var tileSize = tiledLayer.TileSize;
// Even at scales lower than 100%, we are drawing into a rect in the coordinate system of the full
// image. One tile at 50% covers the width (in original image coordinates) of two tiles at 100%.
// So at 50% we need to stretch our tiles to double the width and height; at 25% we need to stretch
// them to quadruple the width and height; and so on.
// (Note that this means that we are drawing very blurry images as the scale gets low. At 12.5%,
// our lowest scale, we are stretching about 6 small tiles to fill the entire original image area.
// But this is okay, because the big blurry image we're drawing here will be scaled way down before
// it is displayed.)
tileSize.Width /= scale;
tileSize.Height /= scale;
// calculate the rows and columns of tiles that intersect the rect we have been asked to draw
int firstCol = (int)Math.Floor (rect.GetMinX () / tileSize.Width);
int lastCol = (int)Math.Floor ((rect.GetMaxX () - 1) / tileSize.Width);
int firstRow = (int)Math.Floor (rect.GetMinY () / tileSize.Height);
int lastRow = (int)Math.Floor ((rect.GetMaxY () - 1) / tileSize.Height);
for (int row = firstRow; row <= lastRow; row++) {
for (int col = firstCol; col <= lastCol; col++) {
UIImage tile = TileForScale (scale, row, col);
var tileRect = new RectangleF (tileSize.Width * col, tileSize.Height * row, tileSize.Width, tileSize.Height);
// if the tile would stick outside of our bounds, we need to truncate it so as to avoid
// stretching out the partial tiles at the right and bottom edges
tileRect.Intersect (this.Bounds);
tile.Draw (tileRect);
}
}
}
}
示例4: FillRoundedRect
void FillRoundedRect (RectangleF rect, CGContext context)
{
float radius = 10.0f;
context.BeginPath ();
context.SetGrayFillColor (0.0f, this.Opacity);
context.MoveTo (rect.GetMinX () + radius, rect.GetMinY ());
context.AddArc (rect.GetMaxX () - radius, rect.GetMinY () + radius, radius, (float)(3 * Math.PI / 2), 0f, false);
context.AddArc (rect.GetMaxX () - radius, rect.GetMaxY () - radius, radius, 0, (float)(Math.PI / 2), false);
context.AddArc (rect.GetMinX () + radius, rect.GetMaxY () - radius, radius, (float)(Math.PI / 2), (float)Math.PI, false);
context.AddArc (rect.GetMinX () + radius, rect.GetMinY () + radius, radius, (float)Math.PI, (float)(3 * Math.PI / 2), false);
context.ClosePath ();
context.FillPath ();
}
示例5: 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();
}
示例6: 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;
}
示例7: ViewDidLoad
//.........这里部分代码省略.........
// Palette 2
// Wireup the 2nd palette from the .xib file and style it
// to be a popup tray. Touch it's dragTab to open and close it.
if (propertyTray != null) {
// Are we on an iPhone?
if (UserInterfaceIdiomIsPhone) {
// Move subview into view and attach it to the master view
propertyTray.MoveTo(new PointF(0,170));
View.AddSubview(propertyTray);
// iPhone specific settings
propertyTray.orientation=UIActionTrayOrientation.Right;
} else {
// iPad specific settings
propertyTray.orientation=UIActionTrayOrientation.Top;
}
// Set tray type
propertyTray.trayType=UIActionTrayType.Popup;
propertyTray.tabLocation=UIActionTrayTabLocation.TopOrLeft;
propertyTray.tabType=UIActionTrayTabType.IconAndTitle;
propertyTray.CloseTray (false);
// Style tray
propertyTray.tabWidth=125f;
propertyTray.icon=UIImage.FromFile ("Images/icon_measures.png");
propertyTray.title="Properties";
// Add this tray to the manager's collection
trayManager.AddTray (propertyTray);
}
// Palette 3
// Wireup the 3rd palette from the .xib file and style it
// to be an auto closing popup. When the user selects something
// from it's content area, it is automatically closed.
if (toolsTray != null) {
// Are we on an iPhone?
if (UserInterfaceIdiomIsPhone) {
// Move the subview into view and attach it to the master view
toolsTray.MoveTo (new PointF(0,0));
View.AddSubview(toolsTray);
// Adjust tab location
toolsTray.tabLocation=UIActionTrayTabLocation.Custom;
toolsTray.tabOffset=5f;
// iPhone specific settings
toolsTray.orientation=UIActionTrayOrientation.Right;
} else {
// iPad specific settings
toolsTray.orientation=UIActionTrayOrientation.Top;
}
// Set tray type
toolsTray.trayType=UIActionTrayType.AutoClosingPopup;
toolsTray.tabType=UIActionTrayTabType.IconOnly;
toolsTray.tabType=UIActionTrayTabType.CustomDrawn;
toolsTray.CloseTray (false);
// Style tray
toolsTray.tabWidth=50f;
toolsTray.appearance.background=UIColor.FromRGB (38,38,38);
// Custom draw the tray's drag tab
toolsTray.CustomDrawDragTab+= (tray, rect) => {
// Mix background color
UIColor tabColor;
if (tray.frameType==UIActionTrayFrameType.None) {
tabColor=tray.appearance.background.ColorWithAlpha (tray.appearance.tabAlpha);
} else {
tabColor=tray.appearance.frame.ColorWithAlpha (tray.appearance.tabAlpha);
}
// Save current context
var context = UIGraphics.GetCurrentContext();
// Draw tab in the given bounds
var bodyPath = UIBezierPath.FromRect(rect);
tabColor.SetFill();
bodyPath.Fill();
// Draw icon
var icon=UIImage.FromFile ("Images/icon_pencil.png");
var y=rect.GetMinY()+5f;
var tabIconRect = new RectangleF(rect.GetMinX() + 1, y, 30, 30);
var tabIconPath = UIBezierPath.FromRect(tabIconRect);
context.SaveState();
tabIconPath.AddClip();
icon.Draw(new RectangleF((float)Math.Floor(tabIconRect.GetMinX() + 1f), (float)Math.Floor(y + 0.5f), icon.Size.Width, icon.Size.Height),CGBlendMode.Normal,tray.appearance.tabAlpha);
context.RestoreState();
};
// Add this tray to the manager's collection
trayManager.AddTray (toolsTray);
}
}
示例8: 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();
}
}
示例9: AddRoundedRectToPath
public static void AddRoundedRectToPath(CGContext context, RectangleF rect, float ovalWidth, float ovalHeight)
{
float fw, fh;
if (ovalWidth == 0 || ovalHeight == 0)
{
context.AddRect(rect);
return;
}
context.SaveState();
context.TranslateCTM(rect.GetMinX(), rect.GetMinY());
context.ScaleCTM(ovalWidth, ovalHeight);
fw = rect.Width / ovalWidth;
fh = rect.Height / ovalHeight;
context.MoveTo(fw, fh / 2);
context.AddArcToPoint(fw, fh, fw / 2, fh, 1);
context.AddArcToPoint(0, fh, 0, fh / 2, 1);
context.AddArcToPoint(0, 0, fw / 2, 0, 1);
context.AddArcToPoint(fw, 0, fw, fh / 2, 1);
context.ClosePath();
context.RestoreState();
}
示例10: 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();
}
示例11: Draw
public override void Draw(RectangleF a_rect)
{
// Set the back color to black
GL.ClearColor (0.0f, 0.0f, 0.0f, 1.0f);
// Clear all old bits
GL.Clear ((int)(All.ColorBufferBit));
GL.PushMatrix();
RectangleF bds;
if (_vertical)
{
GL.Scale (1f, -1f, 1f);
bds = new RectangleF (0f, -1f,
this.Bounds.Width * _scaleFactor,
this.Bounds.Height * _scaleFactor);
} else {
GL.Translate(0f, this.Bounds.Height * _scaleFactor, 0f);
GL.Rotate(-90f, 0f, 0f, 1f);
bds = new RectangleF (0f, 1f,
this.Bounds.Height * _scaleFactor,
this.Bounds.Width * _scaleFactor);
}
if (_numLights == 0)
{
int i;
float currentTop = 0f;
for (i=0; i<_colorThresholds.Length; i++)
{
LevelMeterColorThreshold thisThresh = _colorThresholds[i];
float val = Math.Min (thisThresh.maxValue, _level);
RectangleF rect = new RectangleF(
0,
(bds.Height) * currentTop,
bds.Width,
(bds.Height) * (val - currentTop)
);
float [] vertices = new float[] {
rect.GetMinX (), rect.GetMinY (),
rect.GetMaxX (), rect.GetMinY (),
rect.GetMinX (), rect.GetMaxY (),
rect.GetMaxX (), rect.GetMaxY ()
};
CGColor clr = thisThresh.color.CGColor;
if (clr.NumberOfComponents != 4)
goto bail;
float [] rgba;
rgba = clr.Components;
GL.Color4 (rgba[0], rgba[1], rgba[2], _maxIntensity);
GL.VertexPointer(2, All.Float, 0, vertices);
GL.EnableClientState (All.VertexArray);
GL.DrawArrays(All.TriangleStrip, 0, 4);
if (_level < thisThresh.maxValue)
break;
currentTop = val;
}
}
else
{
int light_i;
float lightMinVal = 0f;
float insetAmount, lightVSpace;
lightVSpace = bds.Height / (float)_numLights;
if (lightVSpace < 4f)
insetAmount = 0f;
else if (lightVSpace < 8f)
insetAmount = 0.5f;
else
insetAmount = 1f;
int peakLight = -1;
if (_peakLevel > 0f)
{
peakLight = (int)(_peakLevel * _numLights);
if (peakLight >= _numLights)
peakLight = (int)(_numLights - 1);
}
for (light_i=0; light_i<_numLights; light_i++)
{
float lightMaxVal = (float)(light_i + 1) / (float)_numLights;
float lightIntensity;
RectangleF lightRect;
UIColor lightColor;
if (light_i == peakLight)
{
lightIntensity = _maxIntensity;
//.........这里部分代码省略.........
示例12: DetermineGeometry
//.........这里部分代码省略.........
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;
yArrowOffset = Math.Max(yArrowOffset, Properties.TopBgMargin + Properties.ArrowMargin);
yArrowOffset = Math.Min(yArrowOffset, size.Height - Properties.BottomBgMargin - Properties.ArrowMargin - leftArrowImage.Size.Height);
arrowRect = new RectangleF(xArrowOffset, yArrowOffset, leftArrowImage.Size.Width, leftArrowImage.Size.Height);
break;
}
case UIPopoverArrowDirection.Right: {
anchorPoint = new PointF(anchorRect.GetMinX(), anchorRect.GetMidY());
xArrowOffset = size.Width - Properties.RightBgMargin;
yArrowOffset = size.Height / 2 - rightArrowImage.Size.Width / 2;
offset = new PointF(anchorPoint.X - xArrowOffset - rightArrowImage.Size.Width, anchorPoint.Y - yArrowOffset - rightArrowImage.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;
yArrowOffset = Math.Max(yArrowOffset, Properties.TopBgMargin + Properties.ArrowMargin);
yArrowOffset = Math.Min(yArrowOffset, size.Height - Properties.BottomBgMargin - Properties.ArrowMargin - rightArrowImage.Size.Height);
arrowRect = new RectangleF(xArrowOffset, yArrowOffset, rightArrowImage.Size.Width, rightArrowImage.Size.Height);
break;
}
}
//end switch statement
// var bgFrame = bgRect.RectOffset(offset.X, offset.Y);
// var bgFrame = RectangleFExtensions.Offset(bgRect, offset.X, offset.Y);
var bgFrame = bgRect;
bgFrame.X += offset.X;