本文整理汇总了C#中nfloat类的典型用法代码示例。如果您正苦于以下问题:C# nfloat类的具体用法?C# nfloat怎么用?C# nfloat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
nfloat类属于命名空间,在下文中一共展示了nfloat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddBorder
public static void AddBorder(this UIView view, UIRectEdge edge, UIColor color, nfloat thickness) {
var border = new CALayer ();
var f = view.Frame;
switch(edge)
{
case UIRectEdge.Top:
border.Frame = new CGRect(0, 0, f.Width, thickness);
break;
case UIRectEdge.Bottom:
border.Frame = new CGRect (0, f.Height - thickness, f.Width, thickness);
break;
case UIRectEdge.Left:
border.Frame = new CGRect(0, 0, thickness, f.Height);
break;
case UIRectEdge.Right:
border.Frame = new CGRect(f.Width - thickness, 0, thickness, f.Height);
break;
default:
break;
}
border.BackgroundColor = color.CGColor;
view.Layer.AddSublayer (border);
}
示例2: Draw
public override void Draw(CGRect rect)
{
//Stopwatch s = new Stopwatch();
//s.Start();
//Console.WriteLine (" ----- SatBrightPickerView Draw");
CGContext context = UIGraphics.GetCurrentContext ();
CGColor[] gradColors = new CGColor[] {UIColor.FromHSBA(hue,1,1,1).CGColor,new CGColor(1,1,1,1)};
nfloat[] gradLocations = new nfloat[] { 0.0f, 1.0f };
var colorSpace = CGColorSpace.CreateDeviceRGB ();
CGGradient gradient = new CGGradient (colorSpace, gradColors, gradLocations);
context.DrawLinearGradient(gradient,new CGPoint(rect.Size.Width,0),new CGPoint(0,0),CGGradientDrawingOptions.DrawsBeforeStartLocation);
gradColors = new CGColor[] {new CGColor(0,0,0,0), new CGColor(0,0,0,1)};
gradient = new CGGradient(colorSpace,gradColors, gradLocations);
context.DrawLinearGradient(gradient,new CGPoint(0,0),new CGPoint(0,rect.Size.Height),CGGradientDrawingOptions.DrawsBeforeStartLocation);
gradient.Dispose();
colorSpace.Dispose();
//s.Stop();
//Console.WriteLine("-----> SatBright Draw time: " + s.Elapsed.ToString());
}
示例3: CropperResizerView
internal CropperResizerView(UIColor color = null, nfloat transparancy = default(nfloat), nfloat lineWidth = default(nfloat))
{
this.BackgroundColor = UIColor.Clear;
_color = color ?? UIColor.Red;
_transparancy = transparancy == 0 ? 0.8f : transparancy;
_lineWidth = lineWidth == 0 ? 3f : lineWidth;
}
示例4: DrawMapRect
/// <summary>
/// Draws the map rectangle.
/// </summary>
/// <param name="mapRect">Map rectangle.</param>
/// <param name="zoomScale">Zoom scale.</param>
/// <param name="context"> Graphics context.</param>
public override void DrawMapRect(MKMapRect mapRect, nfloat zoomScale, CGContext context)
{
base.DrawMapRect(mapRect, zoomScale, context);
var multiPolygons = (MultiPolygon)this.polygonOverlay;
foreach (var item in multiPolygons.Polygons)
{
var path = new CGPath();
this.InvokeOnMainThread(() =>
{
path = PolyPath(item.Polygon);
});
if (path != null)
{
context.SetFillColor(item.FillColor);
context.BeginPath();
context.AddPath(path);
context.DrawPath(CGPathDrawingMode.EOFill);
if (item.DrawOutlines)
{
context.BeginPath();
context.AddPath(path);
context.StrokePath();
}
}
}
}
示例5: CreatePieSegment
private UIImage CreatePieSegment(CGSize size, nfloat endAngle)
{
// Add the arc
var arc = new CGPath();
arc.MoveToPoint(size.Width / 2.0f, size.Height / 2.0f);
arc.AddLineToPoint(size.Width / 2.0f, 0);
arc.AddArc(size.Width / 2.0f, size.Height / 2.0f, size.Width / 2.0f, _startAngle, endAngle, false);
arc.AddLineToPoint(size.Width / 2.0f, size.Height / 2.0f);
// Stroke the arc
UIGraphics.BeginImageContextWithOptions(size, false, 0);
var context = UIGraphics.GetCurrentContext();
context.AddPath(arc);
context.SetFillColor(UIColor.FromRGBA(0f, 0f, 0f, 1f).CGColor);
context.FillPath();
// Get the mask image
var image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return image;
}
示例6: RCTTargetSize
private static CGSize RCTTargetSize(CGSize sourceSize, nfloat sourceScale,
CGSize destSize, nfloat destScale,
RCTResizeMode resizeMode,
bool allowUpscaling)
{
switch (resizeMode)
{
case RCTResizeMode.ScaleToFill:
if (!allowUpscaling)
{
nfloat scale = sourceScale / destScale;
destSize.Width = (nfloat)Math.Min(sourceSize.Width * scale, destSize.Width);
destSize.Height = (nfloat)Math.Min(sourceSize.Height * scale, destSize.Height);
}
return RCTCeilSize(destSize, destScale);
default: {
// Get target size
CGSize size = RCTTargetRect(sourceSize, destSize, destScale, resizeMode).Size;
if (!allowUpscaling)
{
// return sourceSize if target size is larger
if (sourceSize.Width * sourceScale < size.Width * destScale)
{
return sourceSize;
}
}
return size;
}
}
}
示例7: CropByX
public static UIImage CropByX(this UIImage image, nfloat x)
{
UIGraphics.BeginImageContextWithOptions(new CGSize(image.Size.Width - x, image.Size.Height), false, 0);
UIImage result = null;
using (CGContext context = UIGraphics.GetCurrentContext())
{
context.TranslateCTM(0, image.Size.Height);
context.ScaleCTM(1, -1);
context.DrawImage(new CGRect(CGPoint.Empty, image.Size), image.CGImage);
using (CGImage img = context.AsBitmapContext().ToImage())
{
result = new UIImage(img, image.CurrentScale, UIImageOrientation.Up);
img.Dispose();
}
context.Dispose();
UIGraphics.EndImageContext();
}
return result;
}
示例8: CalloutAnnotation
public CalloutAnnotation(int count, CGRect rect, nfloat lineWidth, UIColor color)
{
Path = UIBezierPath.FromOval(rect);
Path.LineWidth = lineWidth;
var center = new CGPoint (rect.GetMidX(), rect.GetMidY());
Center = center;
nfloat startAngle = (nfloat)(Math.PI * 0.75);
nfloat endAngle = (nfloat)(Math.PI * 0.60);
Clip = UIBezierPath.FromArc(center, center.X + lineWidth, startAngle, endAngle, true);
Clip.AddLineTo(center);
Clip.ClosePath();
Clip.LineWidth = lineWidth;
Tail = new UIBezierPath ();
Tail.MoveTo(new CGPoint (center.X - 11, center.Y + 9));
Tail.AddLineTo(new CGPoint (center.X - 11, center.Y + 18));
Tail.AddLineTo(new CGPoint (center.X - 3, center.Y + 13));
Tail.LineWidth = lineWidth;
Rect = rect;
Color = color;
Count = count;
}
示例9: DashboardGraphView
//FromRGB (234, 105, 92);
public DashboardGraphView(CGRect frame, int lineWidth, nfloat degrees)
{
_lineWidth = lineWidth;
_degrees = degrees;
this.Frame = new CGRect(frame.X, frame.Y, frame.Width, frame.Height);
this.BackgroundColor = UIColor.Clear;
}
示例10: Draw
//Generated with PaintCode 2.2
public override void Draw(CGRect rect)
{
base.Draw(rect);
// General Declarations
var colorSpace = CGColorSpace.CreateDeviceRGB();
var context = UIGraphics.GetCurrentContext();
// Color Declarations
var darkBlue = UIColor.FromRGBA(0.053f, 0.123f, 0.198f, 1.000f);
var lightBlue = UIColor.FromRGBA(0.191f, 0.619f, 0.845f, 1.000f);
// Gradient Declarations
var backgroundGradientColors = new CGColor [] {lightBlue.CGColor, darkBlue.CGColor};
var backgroundGradientLocations = new nfloat [] {0.0f, 1.0f};
var backgroundGradient = new CGGradient(colorSpace, backgroundGradientColors, backgroundGradientLocations);
// Rectangle Drawing
var rectangleRect = new CGRect(rect.GetMinX() + (float)Math.Floor(rect.Width * -0.12917f + 0.5f), rect.GetMinY() + (float)Math.Floor(rect.Height * 0.00000f + 0.5f), (float)Math.Floor(rect.Width * 1.00000f + 0.5f) - (float)Math.Floor(rect.Width * -0.12917f + 0.5f), (float)Math.Floor(rect.Height * 1.00000f + 0.5f) - (float)Math.Floor(rect.Height * 0.00000f + 0.5f));
var rectanglePath = UIBezierPath.FromRect(rectangleRect);
context.SaveState();
rectanglePath.AddClip();
context.DrawLinearGradient(backgroundGradient,
new PointF((float)rectangleRect.GetMidX(), (float)rectangleRect.GetMinY()),
new PointF((float)rectangleRect.GetMidX(), (float)rectangleRect.GetMaxY()),
0);
context.RestoreState();
}
示例11: DrawBorders
void DrawBorders(CGContext context, nfloat xMin, nfloat xMax, nfloat yMin, nfloat yMax, nfloat fWidth, nfloat fHeight)
{
if (BorderColorTop != null)
{
context.SetFillColor(BorderColorTop.CGColor);
context.FillRect(new CGRect(xMin, yMin, fWidth, BorderWidth.Top));
}
if (BorderColorLeft != null)
{
context.SetFillColor(BorderColorLeft.CGColor);
context.FillRect(new CGRect(xMin, yMin, BorderWidth.Left, fHeight));
}
if (BorderColorRight != null)
{
context.SetFillColor(BorderColorRight.CGColor);
context.FillRect(new CGRect(xMax - BorderWidth.Right, yMin, BorderWidth.Right, fHeight));
}
if (BorderColorBottom != null)
{
context.SetFillColor(BorderColorBottom.CGColor);
context.FillRect(new CGRect(xMin, yMax - BorderWidth.Bottom, fWidth, BorderWidth.Bottom));
}
}
示例12: ToImage
public static UIImage ToImage(this AtlassianIcon @this, nfloat size, bool cache = true)
{
var cacheDir = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User)[0].Path;
string extension = string.Empty;
if (Scale > 1 && Scale < 3)
{
extension = "@2x";
}
else if (Scale >= 3)
{
extension = "@3x";
}
var fileName = string.Format("atlassian-{0}-{1}{2}.png", (int)@this.CharacterCode, size, extension);
var combinedPath = Path.Combine(cacheDir, fileName);
if (File.Exists(combinedPath))
{
var img = cache ? UIImage.FromBundle(combinedPath) : UIImage.FromFile(combinedPath);
return img.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
}
else
{
var img = Graphics.ImageFromFont(UIFont.FromName("Atlassian-icons", size), @this.CharacterCode, UIColor.Black);
if (img == null)
return null;
var pngData = img.AsPNG();
pngData.Save(combinedPath, false);
return img.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
}
}
示例13: CreateImage
private UIImage CreateImage (NSString title, nfloat scale)
{
var titleAttrs = new UIStringAttributes () {
Font = UIFont.FromName ("HelveticaNeue", 13f),
ForegroundColor = Color.Gray,
};
var titleBounds = new CGRect (
new CGPoint (0, 0),
title.GetSizeUsingAttributes (titleAttrs)
);
var image = Image.TagBackground;
var imageBounds = new CGRect (
0, 0,
(float)Math.Ceiling (titleBounds.Width) + image.CapInsets.Left + image.CapInsets.Right + 4f,
(float)Math.Ceiling (titleBounds.Height) + image.CapInsets.Top + image.CapInsets.Bottom
);
titleBounds.X = image.CapInsets.Left + 2f;
titleBounds.Y = image.CapInsets.Top;
UIGraphics.BeginImageContextWithOptions (imageBounds.Size, false, scale);
try {
image.Draw (imageBounds);
title.DrawString (titleBounds, titleAttrs);
return UIGraphics.GetImageFromCurrentImageContext ();
} finally {
UIGraphics.EndImageContext ();
}
}
示例14: DropDownTable
/// <summary>
/// Initializes a new instance of UITableView.
/// </summary>
/// <param name="data">Source Data.</param>
/// <param name="cellHeight">cellHeight, use 0 for default.</param>
/// <param name="fSize">Cell Font size.</param>
/// <param name="cellSelectedBackgroundColor">Cell selected background color, Use Clear for default</param>
/// <param name="cellSelectedTextColor">Cell selected text color, Use Clear for default</param>
public DropDownTable(IList<string> data, nfloat cellHeight,
nfloat fSize, UIColor cellSelectedBackgroundColor, UIColor cellSelectedTextColor,
string selectedText = "") : base()
{
CellLayoutMarginsFollowReadableWidth = false;
this.MultipleTouchEnabled = true;
this._FontSize = fSize;
this._CellHeight = cellHeight;
this._CellSBackgroundColor = cellSelectedBackgroundColor;
this._CellSTextColor = cellSelectedTextColor;
Source = new DropDownSource (data, this._FontSize, this._CellHeight, this._CellSBackgroundColor,
this._CellSTextColor, selectedText);
//ContentInset = new UIEdgeInsets(0, -10, 0, 0);
LayoutMargins = UIEdgeInsets.Zero;
SeparatorInset = UIEdgeInsets.Zero;
// select default row
var idx = data.ToList().FindIndex(x => x == selectedText);
System.Diagnostics.Debug.WriteLine (idx);
if (idx >= 0) {
this.SelectRow (Foundation.NSIndexPath.FromItemSection (idx, 0), false, UITableViewScrollPosition.Top);
}
(Source as DropDownSource).OnSelected += RowSelected;
}
示例15: setSize
public void setSize()
{
//its iPhone. Find out which one?
CGSize result = UIScreen.MainScreen.Bounds.Size;
this.width = result.Width;
this.height = result.Height;
tableSize.Width = result.Width;
if(result.Height == 480)
{
labelMHWidth = 100;
tableSize.Height = 200;
textSize = 13;
}
else if(result.Height == 568)
{
labelMHWidth = 120;
tableSize.Height = 360;
textSize = 15;
}
else if(result.Height == 667)
{
labelMHWidth = 150;
tableSize.Height = 500;
textSize = 15;
}
else if(result.Height == 736)
{
labelMHWidth = 180;
tableSize.Height = 580;
textSize = 17;
}
}