本文整理汇总了C#中CGRect类的典型用法代码示例。如果您正苦于以下问题:C# CGRect类的具体用法?C# CGRect怎么用?C# CGRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CGRect类属于命名空间,在下文中一共展示了CGRect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: NativeArrange
protected override void NativeArrange(CGRect finalRect)
{
this.ScrollView.ContentSize = finalRect.Size;
// That's right. We don't need to rearrange page;
////base.NativeArrange(finalRect);
}
开发者ID:MuffPotter,项目名称:UIFramework,代码行数:7,代码来源:AppercodePage.iOS.cs
示例2: ShareUrl
public void ShareUrl(object sender, Uri uri)
{
var item = new NSUrl(uri.AbsoluteUri);
var activityItems = new NSObject[] { item };
UIActivity[] applicationActivities = null;
var activityController = new UIActivityViewController (activityItems, applicationActivities);
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
{
var window = UIApplication.SharedApplication.KeyWindow;
var pop = new UIPopoverController (activityController);
var barButtonItem = sender as UIBarButtonItem;
if (barButtonItem != null)
{
pop.PresentFromBarButtonItem(barButtonItem, UIPopoverArrowDirection.Any, true);
}
else
{
var rect = new CGRect(window.RootViewController.View.Frame.Width / 2, window.RootViewController.View.Frame.Height / 2, 0, 0);
pop.PresentFromRect (rect, window.RootViewController.View, UIPopoverArrowDirection.Any, true);
}
}
else
{
var viewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
viewController.PresentViewController(activityController, true, null);
}
}
开发者ID:zdd910,项目名称:CodeHub,代码行数:29,代码来源:ActionMenuFactory.cs
示例3: SetupOutlineView
// This sets up a NSOutlineView for demonstration
internal static NSView SetupOutlineView (CGRect frame)
{
// Create our NSOutlineView and set it's frame to a reasonable size. It will be autosized via the NSClipView
NSOutlineView outlineView = new NSOutlineView () {
Frame = frame
};
// Every NSOutlineView must have at least one column or your Delegate will not be called.
NSTableColumn column = new NSTableColumn ("Values");
outlineView.AddColumn (column);
// You must set OutlineTableColumn or the arrows showing children/expansion will not be drawn
outlineView.OutlineTableColumn = column;
// Setup the Delegate/DataSource instances to be interrogated for data and view information
// In Unified, these take an interface instead of a base class and you can combine these into
// one instance.
outlineView.Delegate = new OutlineViewDelegate ();
outlineView.DataSource = new OutlineViewDataSource ();
// NSOutlineView expects to be hosted inside an NSClipView and won't draw correctly otherwise
NSClipView clipView = new NSClipView (frame) {
AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable
};
clipView.DocumentView = outlineView;
return clipView;
}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:27,代码来源:NSOutlineViewExample.cs
示例4: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
// Create the chart
View.BackgroundColor = UIColor.White;
nfloat margin = UserInterfaceIdiomIsPhone ? 10 : 50;
CGRect frame = new CGRect (margin, margin, View.Bounds.Width - 2 * margin, View.Bounds.Height - 2 * margin);
chart = new ShinobiChart (frame) {
Title = "Apple Stock Price",
AutoresizingMask = ~UIViewAutoresizing.None,
LicenseKey = "" // TODO: add your trail licence key here!
};
// Add a discountinuous date axis
chart.XAxis = new SChartDateTimeAxis () {
Title = "Date",
EnableGesturePanning = true,
EnableGestureZooming = true
};
chart.YAxis = new SChartNumberAxis () {
Title = "Price (USD)",
EnableGesturePanning = true,
EnableGestureZooming = true
};
// Add to the view
View.AddSubview (chart);
chart.DataSource = new CandlestickChartDataSource ();
}
开发者ID:bocoop,项目名称:MichelinMD,代码行数:32,代码来源:CandlestickChartViewController.cs
示例5: AddBox
private void AddBox (string title, CGRect frame, int level, NSColor color)
{
var node = Utils.SCBoxNode (title, frame, color, 2.0f, true);
node.Scale = new SCNVector3 (0.02f, 0.02f, 0.02f);
node.Position = new SCNVector3 (-5, 1.5f * level, 10);
ContentNode.AddChildNode (node);
}
开发者ID:hitchingsh,项目名称:mac-samples,代码行数:7,代码来源:SlideArchitecture.cs
示例6: AnimationForSeries
public override CAAnimation AnimationForSeries(TKChart chart, TKChartSeries series, TKChartSeriesRenderState state, CGRect rect)
{
double duration = 0.5;
List<CAAnimation> animations = new List<CAAnimation> ();
for (int i = 0; i<(int)state.Points.Count; i++) {
string keyPath = string.Format ("seriesRenderStates.{0}.points.{1}.y", series.Index, i);
TKChartVisualPoint point = (TKChartVisualPoint)state.Points.ObjectAtIndex((uint)i);
double oldY = rect.Height;
double half = oldY + (point.Y - oldY)/2.0;
CAKeyFrameAnimation a = (CAKeyFrameAnimation)CAKeyFrameAnimation.GetFromKeyPath(keyPath);
a.KeyTimes = new NSNumber[] { new NSNumber (0), new NSNumber (0), new NSNumber (1) };
a.Values = new NSObject[] { new NSNumber (oldY), new NSNumber (half), new NSNumber (point.Y) };
a.Duration = duration;
a.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.EaseOut);
animations.Add(a);
}
CAAnimationGroup group = new CAAnimationGroup ();
group.Duration = duration;
group.Animations = animations.ToArray();
return group;
}
开发者ID:joelconnects,项目名称:ios-sdk,代码行数:25,代码来源:CustomAnimationAreaChart.cs
示例7: MyOpenGLView
public MyOpenGLView (CGRect frame,NSOpenGLContext context) : base(frame)
{
var attribs = new object [] {
NSOpenGLPixelFormatAttribute.Accelerated,
NSOpenGLPixelFormatAttribute.NoRecovery,
NSOpenGLPixelFormatAttribute.DoubleBuffer,
NSOpenGLPixelFormatAttribute.ColorSize, 24,
NSOpenGLPixelFormatAttribute.DepthSize, 16 };
pixelFormat = new NSOpenGLPixelFormat (attribs);
if (pixelFormat == null)
Console.WriteLine ("No OpenGL pixel format");
// NSOpenGLView does not handle context sharing, so we draw to a custom NSView instead
openGLContext = new NSOpenGLContext (pixelFormat, context);
openGLContext.MakeCurrentContext ();
// Synchronize buffer swaps with vertical refresh rate
openGLContext.SwapInterval = true;
// Initialize our newly created view.
InitGL ();
SetupDisplayLink ();
// Look for changes in view size
// Note, -reshape will not be called automatically on size changes because NSView does not export it to override
notificationProxy = NSNotificationCenter.DefaultCenter.AddObserver (NSView.GlobalFrameChangedNotification, HandleReshape);
}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:31,代码来源:MyOpenGLView.cs
示例8: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// set the background color of the view to white
View.BackgroundColor = UIColor.White;
// instantiate a new image view that takes up the whole screen and add it to
// the view hierarchy
CGRect imageViewFrame = new CGRect (0, -NavigationController.NavigationBar.Frame.Height, View.Frame.Width, View.Frame.Height);
imageView = new UIImageView (imageViewFrame);
View.AddSubview (imageView);
// create our offscreen bitmap context
// size
CGSize bitmapSize = new CGSize (imageView.Frame.Size);
using (CGBitmapContext context = new CGBitmapContext (IntPtr.Zero,
(int)bitmapSize.Width, (int)bitmapSize.Height, 8,
(int)(4 * bitmapSize.Width), CGColorSpace.CreateDeviceRGB (),
CGImageAlphaInfo.PremultipliedFirst)) {
// draw our coordinates for reference
DrawCoordinateSpace (context);
// draw our flag
DrawFlag (context);
// add a label
DrawCenteredTextAtPoint (context, 384, 700, "Stars and Stripes", 60);
// output the drawing to the view
imageView.Image = UIImage.FromImage (context.ToImage ());
}
}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:34,代码来源:Controller.cs
示例9: 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 ();
}
}
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:32,代码来源:TagChipCache.cs
示例10: FinishedLaunching
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
// Two disjoint rects
var r1 = new CGRect (50, 50, 10, 10);
var r2 = new CGRect (100, 100, 10, 10);
// This condradicts with Apple's doc – https://developer.apple.com/reference/coregraphics/cgrectnull
// The null rectangle. This is the rectangle returned when, for example, you intersect two disjoint rectangles.
// Note that the null rectangle is not the same as the zero rectangle.
// For example, the union of a rectangle with the null rectangle is the original rectangle (that is, the null rectangle contributes nothing).
var tmp = r1;
tmp.Intersect (r2); // this is mutable method
Console.WriteLine (tmp.IsNull ()); // Expected true, but result is false
tmp = CGRectIntersection (r1, r2);
Console.WriteLine (tmp.IsNull ()); // Expected true, actual true
// This should be CGRectNull
var rectNull = new CGRect (nfloat.PositiveInfinity, nfloat.PositiveInfinity, 0, 0);
Console.WriteLine (rectNull.IsNull ()); // Expected true, actual true
// CGRectEmpty and CGRectNull are different
var union1 = r1.UnionWith (CGRect.Empty); // new rect {0, 0, 60, 60}
Console.WriteLine (union1);
var union2 = r1.UnionWith (rectNull); // r1
Console.WriteLine (union2);
return true;
}
开发者ID:rzaitov,项目名称:selfContained,代码行数:29,代码来源:AppDelegate.cs
示例11: GridCollectionView
/// <summary>
/// Initializes a new instance of the <see cref="GridCollectionView"/> class.
/// </summary>
/// <param name="frm">The FRM.</param>
public GridCollectionView(CGRect frm)
: base(frm, new UICollectionViewFlowLayout())
{
AutoresizingMask = UIViewAutoresizing.All;
ContentMode = UIViewContentMode.ScaleToFill;
RegisterClassForCell(typeof(GridViewCell), new NSString (GridViewCell.Key));
}
开发者ID:robertohuertasm,项目名称:Xamarin-Forms-Labs,代码行数:11,代码来源:GridCollectionView.cs
示例12: TouchDrawView
public TouchDrawView(CGRect rect)
: base(rect)
{
linesInProcess = new Dictionary<string, Line>();
this.BackgroundColor = UIColor.White;
this.MultipleTouchEnabled = true;
UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(tap);
this.AddGestureRecognizer(tapRecognizer);
UITapGestureRecognizer dbltapRecognizer = new UITapGestureRecognizer(dblTap);
dbltapRecognizer.NumberOfTapsRequired = 2;
this.AddGestureRecognizer(dbltapRecognizer);
UILongPressGestureRecognizer pressRecognizer = new UILongPressGestureRecognizer(longPress);
this.AddGestureRecognizer(pressRecognizer);
moveRecognizer = new UIPanGestureRecognizer(moveLine);
moveRecognizer.WeakDelegate = this;
moveRecognizer.CancelsTouchesInView = false;
this.AddGestureRecognizer(moveRecognizer);
UISwipeGestureRecognizer swipeRecognizer = new UISwipeGestureRecognizer(swipe);
swipeRecognizer.Direction = UISwipeGestureRecognizerDirection.Up;
swipeRecognizer.NumberOfTouchesRequired = 3;
this.AddGestureRecognizer(swipeRecognizer);
selectedColor = UIColor.Red;
}
开发者ID:yingfangdu,项目名称:BNR,代码行数:29,代码来源:TouchDrawView.cs
示例13: ViewDidLayoutSubviews
public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews ();
UIView[] subviews = View.Subviews.Where (v => v != NavigationBar).ToArray ();
var toolBarViews = subviews.Where (v => v is UIToolbar).ToArray ();
var otherViews = subviews.Where (v => !(v is UIToolbar)).ToArray ();
nfloat toolbarHeight = 0;
foreach (var uIView in toolBarViews) {
uIView.SizeToFit ();
uIView.Frame = new CGRect {
X = 0,
Y = View.Bounds.Height - uIView.Frame.Height,
Width = View.Bounds.Width,
Height = uIView.Frame.Height,
};
var thisToolbarHeight = uIView.Frame.Height;
if (toolbarHeight < thisToolbarHeight) {
toolbarHeight = thisToolbarHeight;
}
}
var othersHeight = View.Bounds.Height - toolbarHeight;
var othersFrame = new CGRect (View.Bounds.X, View.Bounds.Y, View.Bounds.Width, othersHeight);
foreach (var uIView in otherViews) {
uIView.Frame = othersFrame;
}
}
开发者ID:powerdude,项目名称:XamarinSamples,代码行数:31,代码来源:PatchedNavigationRenderer.cs
示例14: Create
public static BaseItemView Create (CGRect frame, NodeViewController nodeViewController, TreeNode node, string filePath, UIColor kleur)
{
var view = BaseItemView.Create(frame, nodeViewController, node, kleur);
UIWebView webView = new UIWebView();
string extension = Path.GetExtension (filePath);
if (extension == ".odt") {
string viewerPath = NSBundle.MainBundle.PathForResource ("over/viewer/index", "html");
Uri fromUri = new Uri(viewerPath);
Uri toUri = new Uri(filePath);
Uri relativeUri = fromUri.MakeRelativeUri(toUri);
String relativePath = Uri.UnescapeDataString(relativeUri.ToString());
NSUrl finalUrl = new NSUrl ("#" + relativePath.Replace(" ", "%20"), new NSUrl(viewerPath, false));
webView.LoadRequest(new NSUrlRequest(finalUrl));
webView.ScalesPageToFit = true;
view.ContentView = webView;
return view;
} else {
NSUrl finalUrl = new NSUrl (filePath, false);
webView.LoadRequest(new NSUrlRequest(finalUrl));
webView.ScalesPageToFit = true;
view.ContentView = webView;
return view;
}
}
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:30,代码来源:WebItemView.cs
示例15: AddText
/// <summary>
/// Adds the text.
/// </summary>
/// <param name="image">The image.</param>
/// <param name="text">The text.</param>
/// <param name="point">The point.</param>
/// <param name="font">The font.</param>
/// <param name="color">The color.</param>
/// <param name="alignment">The alignment.</param>
/// <returns>UIImage.</returns>
public static UIImage AddText(
this UIImage image,
string text,
CGPoint point,
UIFont font,
UIColor color,
UITextAlignment alignment = UITextAlignment.Left)
{
//var labelRect = new RectangleF(point, new SizeF(image.Size.Width - point.X, image.Size.Height - point.Y));
var h = text.StringHeight(font, image.Size.Width);
var labelRect = new CGRect(point, new CGSize(image.Size.Width - point.X, h));
var label = new UILabel(labelRect)
{
Font = font,
Text = text,
TextColor = color,
TextAlignment = alignment,
BackgroundColor = UIColor.Clear
};
var labelImage = label.ToNativeImage();
using (var context = image.Size.ToBitmapContext())
{
var rect = new CGRect(new CGPoint(0, 0), image.Size);
context.DrawImage(rect, image.CGImage);
context.DrawImage(labelRect, labelImage.CGImage);
context.StrokePath();
return UIImage.FromImage(context.ToImage());
}
}
开发者ID:Jaskomal,项目名称:Xamarin-Forms-Labs,代码行数:42,代码来源:UIImageExtensions.cs
示例16: UpdateUI
void UpdateUI ()
{
var x = 44 + 6;
if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0))
x += 15; // okay, we need a more thorough iOS 7 update than this, but for now this'll have to do
var fn = person.FirstNameAndInitials;
firstNameLabel.Text = fn;
var fnw = string.IsNullOrEmpty (fn) ?
0.0f :
UIStringDrawing.StringSize (fn, NormalFont).Width;
var f = new CGRect (x, 4, fnw + 4, 20);
firstNameLabel.Frame = f;
var ln = person.SafeLastName;
lastNameLabel.Text = ln;
var lnw = string.IsNullOrEmpty (ln) ?
0.0f :
UIStringDrawing.StringSize (ln, BoldFont).Width;
f.X = f.Right;
f.Width = lnw;
lastNameLabel.Frame = f;
detailsLabel.Text = person.TitleAndDepartment ?? string.Empty;
detailsLabel.Frame = new CGRect (x, 25, 258, 14);
}
开发者ID:felipecembranelli,项目名称:MyXamarinSamples,代码行数:27,代码来源:PersonCell.cs
示例17: iOSCardsView
public iOSCardsView(CGRect frame)
: base(frame)
{
this.Setup();
this.Draw(frame);
}
开发者ID:harrysaggu,项目名称:xamarin-plugins,代码行数:7,代码来源:iOSCardsView.cs
示例18: Email
private void Email(string exportType)
{
if(!MFMailComposeViewController.CanSendMail)
return;
var title = exampleInfo.Title + "." + exportType;
NSData nsData = null;
string attachmentType = "text/plain";
var rect = new CGRect(0,0,800,600);
switch(exportType)
{
case "png":
nsData = View.ToPng(rect);
attachmentType = "image/png";
break;
case "pdf":
nsData = View.ToPdf(rect);
attachmentType = "text/x-pdf";
break;
}
var mail = new MFMailComposeViewController ();
mail.SetSubject("OxyPlot - " + title);
mail.SetMessageBody ("Please find attached " + title, false);
mail.Finished += HandleMailFinished;
mail.AddAttachmentData(nsData, attachmentType, title);
this.PresentViewController (mail, true, null);
}
开发者ID:Celderon,项目名称:oxyplot,代码行数:29,代码来源:GraphViewController.cs
示例19: Draw
public override void Draw(CGRect rect)
{
var context = UIGraphics.GetCurrentContext();
var bounds = Bounds;
UIColor background = Enabled ? pressed ? HighlightedColor : NormalColor : DisabledColor;
nfloat alpha = 1;
CGPath container = GraphicsUtil.MakeRoundedRectPath(bounds, 14);
context.AddPath(container);
context.Clip();
using (var cs = CGColorSpace.CreateDeviceRGB())
{
var topCenter = new CGPoint(bounds.GetMidX(), 0);
var midCenter = new CGPoint(bounds.GetMidX(), bounds.GetMidY());
var bottomCenter = new CGPoint(bounds.GetMidX(), bounds.GetMaxY());
using (
var gradient = new CGGradient(cs, new[] { 0.23f, 0.23f, 0.23f, alpha, 0.47f, 0.47f, 0.47f, alpha },
new nfloat[] { 0, 1 }))
{
context.DrawLinearGradient(gradient, topCenter, bottomCenter, 0);
}
container = GraphicsUtil.MakeRoundedRectPath(bounds.Inset(1, 1), 13);
context.AddPath(container);
context.Clip();
using (
var gradient = new CGGradient(cs, new[] { 0.05f, 0.05f, 0.05f, alpha, 0.15f, 0.15f, 0.15f, alpha },
new nfloat[] { 0, 1 }))
{
context.DrawLinearGradient(gradient, topCenter, bottomCenter, 0);
}
var nb = bounds.Inset(4, 4);
container = GraphicsUtil.MakeRoundedRectPath(nb, 10);
context.AddPath(container);
context.Clip();
background.SetFill();
context.FillRect(nb);
using (var gradient = new CGGradient(cs, new nfloat[] { 1, 1, 1, .35f, 1, 1, 1, 0.06f }, new nfloat[] { 0, 1 }))
{
context.DrawLinearGradient(gradient, topCenter, midCenter, 0);
}
context.SetLineWidth(2);
context.AddPath(container);
context.ReplacePathWithStrokedPath();
context.Clip();
using (
var gradient = new CGGradient(cs, new nfloat[] { 1, 1, 1, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f }, new nfloat[] { 0, 1 })
)
{
context.DrawLinearGradient(gradient, topCenter, bottomCenter, 0);
}
}
}
开发者ID:MvvmCross,项目名称:MvvmCross,代码行数:60,代码来源:GlassButton.cs
示例20: DrawRect
public override void DrawRect(CGRect dirtyRect)
{
var g = Graphics.FromCurrentContext();
// NSView does not have a background color so we just use Clear to white here
g.Clear(Color.White);
//RectangleF ClientRectangle = this.Bounds;
CGRect ClientRectangle = dirtyRect;
// Following codes draw a line from (0, 0) to (1, 1) in unit of inch:
/*g.PageUnit = GraphicsUnit.Inch;
Pen blackPen = new Pen(Color.Black, 1/g.DpiX);
g.DrawLine(blackPen, 0, 0, 1, 1);*/
// Following code shifts the origin to the center of
// client area, and then draw a line from (0,0) to (1, 1) inch:
g.PageUnit = GraphicsUnit.Inch;
g.TranslateTransform(((float)ClientRectangle.Width / g.DpiX) / 2,
((float)ClientRectangle.Height / g.DpiY) / 2);
Pen greenPen = new Pen(Color.Green, 1 / g.DpiX);
g.DrawLine(greenPen, 0, 0, 1, 1);
g.Dispose ();
}
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:25,代码来源:DrawingView.cs
注:本文中的CGRect类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论