本文整理汇总了C#中CGSize类的典型用法代码示例。如果您正苦于以下问题:C# CGSize类的具体用法?C# CGSize怎么用?C# CGSize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CGSize类属于命名空间,在下文中一共展示了CGSize类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HIPImageCropperView
public HIPImageCropperView(CGRect frame, CGSize cropSize, CropperViewPosition position, CropHoleType cropHoleType = CropHoleType.Square)
: base(frame)
{
_maskPosition = position;
_cropHoleType = cropHoleType;
_cropSize = cropSize;
this.BackgroundColor = UIColor.Black;
this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
this.ClipsToBounds = true;
ScrollView = new UIScrollView();
ImageView = new UIImageView();
OverlayView = new UIView()
{
UserInteractionEnabled = false,
BackgroundColor = UIColor.Black.ColorWithAlpha(0.6f),
AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
};
LoadIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White)
{
HidesWhenStopped = true,
AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin |
UIViewAutoresizing.FlexibleRightMargin |
UIViewAutoresizing.FlexibleBottomMargin |
UIViewAutoresizing.FlexibleTopMargin
};
}
开发者ID:ProstoKorol,项目名称:HIPImageCropperXamarin,代码行数:30,代码来源:HIPImageCropperView.cs
示例2: CreateFrameBuffer
protected override void CreateFrameBuffer ()
{
nfloat screenScale = UIScreen.MainScreen.Scale;
CAEAGLLayer eaglLayer = (CAEAGLLayer) Layer;
CGSize size = new CGSize (
(int) Math.Round (screenScale * eaglLayer.Bounds.Size.Width),
(int) Math.Round (screenScale * eaglLayer.Bounds.Size.Height));
try {
ContextRenderingApi = EAGLRenderingAPI.OpenGLES3;
base.CreateFrameBuffer ();
int depthRenderbuffer;
GL.GenRenderbuffers (1, out depthRenderbuffer);
GL.BindRenderbuffer (RenderbufferTarget.Renderbuffer, depthRenderbuffer);
GL.RenderbufferStorage (RenderbufferTarget.Renderbuffer, RenderbufferInternalFormat.DepthComponent16, (int)size.Width, (int)size.Height);
GL.FramebufferRenderbuffer (FramebufferTarget.Framebuffer, FramebufferSlot.DepthAttachment, RenderbufferTarget.Renderbuffer, depthRenderbuffer);
Console.WriteLine ("using ES 3.0");
Console.WriteLine ("version: {0} glsl version: {1}", GL.GetString (StringName.Version), GL.GetString (StringName.ShadingLanguageVersion));
} catch (Exception e) {
throw new Exception ("Looks like OpenGL ES 3.0 not available", e);
}
cube.Initialize ();
cube.LoadTexture (LoadBitmapData);
SetupProjection ();
}
开发者ID:xamarin,项目名称:mobile-samples,代码行数:29,代码来源:EAGLView.cs
示例3: GetFontSize
private static void GetFontSize(UILabel label, CGSize size, int maxFontSize, int minFontSize)
{
label.Frame = new CGRect(CGPoint.Empty, size);
var fontSize = maxFontSize;
var constraintSize = new CGSize(label.Frame.Width, nfloat.MaxValue);
while (fontSize > minFontSize)
{
label.Font = UIFont.FromName(label.Font.Name, fontSize);
using (var nativeString = new NSString(label.Text))
{
var textRect = nativeString.GetBoundingRect(
constraintSize,
NSStringDrawingOptions.UsesFontLeading,
new UIStringAttributes { Font = label.Font},
null
);
if (textRect.Size.Height <= label.Frame.Height)
{
break;
}
}
fontSize -= 2;
}
}
开发者ID:anthonylowther21,项目名称:DebtCalculator,代码行数:26,代码来源:FontAwesomeImageHelper.cs
示例4: 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 (View.Frame.Size);
using (CGBitmapContext context = new CGBitmapContext (IntPtr.Zero,
(int)bitmapSize.Width, (int)bitmapSize.Height, 8,
(int)(4 * bitmapSize.Width), CGColorSpace.CreateDeviceRGB (),
CGImageAlphaInfo.PremultipliedFirst)) {
// declare vars
UIImage apressImage = UIImage.FromFile ("icon-114.png");
CGPoint imageOrigin = new CGPoint ((imageView.Frame.Width / 2) - (apressImage.CGImage.Width / 2), (imageView.Frame.Height / 2) - (apressImage.CGImage.Height / 2));
CGRect imageRect = new CGRect (imageOrigin.X, imageOrigin.Y, apressImage.CGImage.Width, apressImage.CGImage.Height);
// draw the image
context.DrawImage (imageRect, apressImage.CGImage);
// output the drawing to the view
imageView.Image = UIImage.FromImage (context.ToImage ());
}
}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:33,代码来源:Controller.cs
示例5: SignatureController
public SignatureController ()
: base(new UINavigationController())
{
var navController = ContentViewController as UINavigationController;
navController.ViewControllers = new UIViewController[] { new ContentController(this) };
PopoverContentSize = new CGSize(665, 400);
}
开发者ID:felipecembranelli,项目名称:MyXamarinSamples,代码行数:7,代码来源:SignatureController.cs
示例6: ImageFromFont
public static UIImage ImageFromFont(string text, UIColor iconColor, CGSize iconSize, string fontName)
{
UIGraphics.BeginImageContextWithOptions(iconSize, false, 0);
var textRect = new CGRect(CGPoint.Empty, iconSize);
var path = UIBezierPath.FromRect(textRect);
UIColor.Clear.SetFill();
path.Fill();
var font = UIFont.FromName(fontName, iconSize.Width);
using (var label = new UILabel() { Text = text, Font = font })
{
GetFontSize(label, iconSize, 500, 5);
font = label.Font;
}
iconColor.SetFill();
using (var nativeString = new NSString(text))
{
nativeString.DrawString(textRect, new UIStringAttributes
{
Font = font,
ForegroundColor = iconColor,
BackgroundColor = UIColor.Clear,
ParagraphStyle = new NSMutableParagraphStyle
{
Alignment = UITextAlignment.Center
}
});
}
var image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
image = image.ImageWithRenderingMode (UIImageRenderingMode.AlwaysOriginal);
return image;
}
开发者ID:anthonylowther21,项目名称:DebtCalculator,代码行数:34,代码来源:FontAwesomeImageHelper.cs
示例7: ViewWillAppear
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
CGSize sz = Image.Size;
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
if (UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.Portrait || UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.PortraitUpsideDown) {
sz = new CGSize(UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Width * (sz.Height/sz.Width));
}
else {
sz = new CGSize((UIScreen.MainScreen.Bounds.Height-NavigationController.NavigationBar.Bounds.Height) * (sz.Width/sz.Height), UIScreen.MainScreen.Bounds.Height-NavigationController.NavigationBar.Bounds.Height);
}
}
else {
if (sz.Width > sz.Height) {
sz = new CGSize(PopoverSize.Height * (sz.Width/sz.Height), PopoverSize.Height);
}
else {
sz = new CGSize(PopoverSize.Width, PopoverSize.Width * (sz.Height/sz.Width));
}
}
imageView.Frame = new CGRect(0, 0, sz.Width, sz.Height);
imageView.Image = Image;
scrollView.ContentSize = sz;
scrollView.MinimumZoomScale = 0.25f;
scrollView.MaximumZoomScale = 5f;
scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => {return imageView;};
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) {
scrollView.ScrollRectToVisible(new CGRect(Image.Size.Width/2 - 300, Image.Size.Height/2 - 300, 600, 600), true);
}
}
开发者ID:yingfangdu,项目名称:BNR,代码行数:34,代码来源:ImageViewController.cs
示例8: ViewWillTransitionToSize
public void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
{
// This API sometime cannot return the correct value.
// Maybe this is the Xamarin or iOS bug
// https://bugzilla.xamarin.com/show_bug.cgi?id=37064
var menu = _basePage.SlideMenu;
double NavigationBarHeight = 0;
// this is used for rotation
double bigValue = UIScreen.MainScreen.Bounds.Height > UIScreen.MainScreen.Bounds.Width ? UIScreen.MainScreen.Bounds.Height : UIScreen.MainScreen.Bounds.Width;
double smallValue = UIScreen.MainScreen.Bounds.Height < UIScreen.MainScreen.Bounds.Width ? UIScreen.MainScreen.Bounds.Height : UIScreen.MainScreen.Bounds.Width;
if (toSize.Width < toSize.Height) {
ScreenSizeHelper.ScreenHeight = bigValue;
// this is used for mutiltasking
ScreenSizeHelper.ScreenWidth = toSize.Width < smallValue ? toSize.Width : smallValue;
NavigationBarHeight = bigValue - toSize.Height;
} else {
ScreenSizeHelper.ScreenHeight = smallValue;
ScreenSizeHelper.ScreenWidth = toSize.Width < bigValue ? toSize.Width : bigValue;
NavigationBarHeight = smallValue - toSize.Height;
}
if (_dragGesture == null)
return;
menu.PageBottomOffset = NavigationBarHeight;
_dragGesture.UpdateLayoutSize (menu);
var rect = _dragGesture.GetHidePosition ();
menu.Layout (new Xamarin.Forms.Rectangle (
rect.left,
rect.top,
(rect.right - rect.left),
(rect.bottom - rect.top)));
_dragGesture.LayoutHideStatus ();
}
开发者ID:XnainA,项目名称:SlideOverKit,代码行数:34,代码来源:SlideOverKitiOSHandler.cs
示例9: GetSizeForChildContentContainer
public override CGSize GetSizeForChildContentContainer (IUIContentContainer contentContainer, CGSize parentContainerSize)
{
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
return parentContainerSize;
else
return new CGSize(parentContainerSize.Width / 3, parentContainerSize.Height);
}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:7,代码来源:OverlayPresentationController.cs
示例10: 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;
}
}
}
开发者ID:petlack,项目名称:FFImageLoading,代码行数:33,代码来源:NSDataExtensions.cs
示例11: InGameScene
public InGameScene (CGSize size) : base (size)
{
BackgroundColor = AppKit.NSColor.FromCalibratedRgba (0.15f, 0.15f, 0.3f, 1f);
timeLabel = LabelWithText ("Time", 24);
AddChild (timeLabel);
CGRect af = timeLabel.CalculateAccumulatedFrame ();
timeLabel.Position = new CGPoint (Frame.Size.Width - af.Size.Width, Frame.Size.Height - (af.Size.Height));
timeLabelValue = LabelWithText ("102:00", 20);
AddChild (timeLabelValue);
CGRect timeLabelValueSize = timeLabelValue.CalculateAccumulatedFrame ();
timeLabelValue.Position = new CGPoint (Frame.Size.Width - af.Size.Width - timeLabelValueSize.Size.Width - 10, Frame.Size.Height - af.Size.Height);
scoreLabel = LabelWithText ("Score", 24);
AddChild (scoreLabel);
af = scoreLabel.CalculateAccumulatedFrame ();
scoreLabel.Position = new CGPoint (af.Size.Width * 0.5f, Frame.Size.Height - af.Size.Height);
scoreLabelValue = LabelWithText ("0", 24);
AddChild (scoreLabelValue);
scoreLabelValue.Position = new CGPoint (af.Size.Width * 0.75f + (timeLabelValueSize.Size.Width), Frame.Size.Height - af.Size.Height);
// Add drop shadows to each label above.
timeLabelValueShadow = DropShadowOnLabel (timeLabelValue);
timeLabelShadow = DropShadowOnLabel (timeLabel);
scoreLabelShadow = DropShadowOnLabel (scoreLabel);
scoreLabelValueShadow = DropShadowOnLabel (scoreLabelValue);
}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:31,代码来源:InGameScene.cs
示例12: 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;
}
开发者ID:Manne990,项目名称:XamTest,代码行数:26,代码来源:CircularProgressViewRenderer.cs
示例13: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
ClearsSelectionOnViewWillAppear = false;
ContentSizeForViewInPopover = new CGSize (320, 600);
TableView.Source = new TableSource ();
}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:7,代码来源:RootViewController.cs
示例14: NativeMeasureOverride
protected override CGSize NativeMeasureOverride(CGSize availableSize)
{
var size = base.NativeMeasureOverride(availableSize);
size.Height = MathF.Max(size.Height, DefaultSize + this.Margin.VerticalThicknessF());
size.Width = MathF.Max(size.Width, DefaultSize + this.Margin.HorizontalThicknessF());
return size;
}
开发者ID:evnik,项目名称:UIFramework,代码行数:7,代码来源:ProgressRing.iOS.cs
示例15: DidFinishLaunching
public override void DidFinishLaunching(NSNotification notification)
{
// Start the progress indicator animation.
loadingProgressIndicator.StartAnimation (this);
gameLogo.Image = new NSImage (NSBundle.MainBundle.PathForResource ("logo", "png"));
archerButton.Image = new NSImage (NSBundle.MainBundle.PathForResource ("button_archer", "png"));
warriorButton.Image = new NSImage (NSBundle.MainBundle.PathForResource ("button_warrior", "png"));
// The size for the primary scene - 1024x768 is good for OS X and iOS.
var size = new CGSize (1024, 768);
// Load the shared assets of the scene before we initialize and load it.
scene = new AdventureScene (size);
scene.LoadSceneAssetsWithCompletionHandler (() => {
scene.Initialize ();
scene.ScaleMode = SKSceneScaleMode.AspectFill;
SKView.PresentScene (scene);
loadingProgressIndicator.StopAnimation (this);
loadingProgressIndicator.Hidden = true;
NSAnimationContext.CurrentContext.Duration = 2.0f;
((NSButton)archerButton.Animator).AlphaValue = 1.0f;
((NSButton)warriorButton.Animator).AlphaValue = 1.0f;
scene.ConfigureGameControllers();
});
SKView.ShowsFPS = true;
SKView.ShowsDrawCount = true;
SKView.ShowsNodeCount = true;
}
开发者ID:W3SS,项目名称:mac-ios-samples,代码行数:34,代码来源:AppDelegate.cs
示例16: TilingView
public TilingView(string name, CGSize size)
: base(new CGRect (CGPoint.Empty, size))
{
ImageName = name;
var tiledLayer = (CATiledLayer)this.Layer;
tiledLayer.LevelsOfDetail = 4;
}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:7,代码来源:TilingView.cs
示例17: DrawPathAsBackground
// Draws our animation path on the background image, just to show it
void DrawPathAsBackground ()
{
// create our offscreen bitmap context
var bitmapSize = new CGSize (View.Frame.Size);
using (var context = new CGBitmapContext (
IntPtr.Zero,
(int)bitmapSize.Width, (int)bitmapSize.Height, 8,
(int)(4 * bitmapSize.Width), CGColorSpace.CreateDeviceRGB (),
CGImageAlphaInfo.PremultipliedFirst)) {
// convert to View space
var affineTransform = CGAffineTransform.MakeIdentity ();
// invert the y axis
affineTransform.Scale (1f, -1f);
// move the y axis up
affineTransform.Translate (0, View.Frame.Height);
context.ConcatCTM (affineTransform);
// actually draw the path
context.AddPath (animationPath);
context.SetStrokeColor (UIColor.LightGray.CGColor);
context.SetLineWidth (3f);
context.StrokePath ();
// set what we've drawn as the backgound image
backgroundImage.Image = UIImage.FromImage (context.ToImage ());
}
}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:29,代码来源:LayerAnimationScreen.xib.cs
示例18: PrimaryCell
public PrimaryCell( CGSize parentSize, UITableViewCellStyle style, string cellIdentifier ) : base( style, cellIdentifier )
{
BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );
SelectionStyle = UITableViewCellSelectionStyle.None;
Image = new UIImageView( );
Image.BackgroundColor = UIColor.Yellow;
Image.ContentMode = UIViewContentMode.ScaleAspectFill;
Image.Layer.AnchorPoint = CGPoint.Empty;
AddSubview( Image );
// Banner Image
Image.Image = new UIImage( NSBundle.MainBundle.BundlePath + "/" + PrivateConnectConfig.MainPageHeaderImage );
Image.SizeToFit( );
// resize the image to fit the width of the device
nfloat imageAspect = Image.Bounds.Height / Image.Bounds.Width;
Image.Frame = new CGRect( 0, 0, parentSize.Width, parentSize.Width * imageAspect );
Title = new UILabel( );
Title.Text = ConnectStrings.Main_Connect_Header;
Title.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Bold, ControlStylingConfig.Large_FontSize );
Title.Layer.AnchorPoint = CGPoint.Empty;
Title.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );
Title.LineBreakMode = UILineBreakMode.TailTruncation;
Title.TextAlignment = UITextAlignment.Center;
Title.Frame = new CGRect( 5, Image.Frame.Bottom, parentSize.Width - 10, 0 );
Title.SizeToFit( );
AddSubview( Title );
}
开发者ID:Higherbound,项目名称:HBMobileApp,代码行数:31,代码来源:ConnectMainPageViewController.cs
示例19: ResultsScreen
public ResultsScreen (CGSize size) : base (size)
{
var timeLabel = new SKLabelNode ("GillSans-Bold") {
Text = "Time: " + GameInfo.GameTimeInSeconds,
FontSize = 24,
Position = new CGPoint (FrameMidX, FrameMidY + 120)
};
var modeLabel = new SKLabelNode ("GillSans-Bold") {
Text = "Mode: " + GameInfo.GameMode,
FontSize = 24,
Position = new CGPoint (FrameMidX, FrameMidY + 60)
};
var scoreLabel = new SKLabelNode ("GillSans-Bold") {
Text = "Score: " + GameInfo.CurrentTaps,
FontSize = 30,
Position = new CGPoint (FrameMidX, FrameMidY)
};
doneButton = new SKLabelNode ("GillSans-Bold") {
Text = "Done",
FontSize = 24,
FontColor = ButtonColor,
Position = new CGPoint (FrameMidX, FrameMidY - 90)
};
AddChild (timeLabel);
AddChild (modeLabel);
AddChild (scoreLabel);
AddChild (doneButton);
}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:28,代码来源:ResultsScreen.cs
示例20: Draw
public override void Draw(CGRect rect)
{
base.Draw(rect);
var inset = this.TextContainerInset;
var leftInset = inset.Left + this.TextContainer.LineFragmentPadding;
var rightInset = inset.Left + this.TextContainer.LineFragmentPadding;
var maxSize = new CGSize()
{
Width = this.Frame.Width - (leftInset + rightInset),
Height = this.Frame.Height - (inset.Top + inset.Bottom)
};
var size = new NSString(this.Placeholder).StringSize(this.PlaceholderFont, maxSize, UILineBreakMode.WordWrap);
var frame = new CGRect(new CGPoint(leftInset, inset.Top), size);
this.placeholderLabel = new UILabel(frame)
{
BackgroundColor = UIColor.Clear,
Font = this.PlaceholderFont,
LineBreakMode = UILineBreakMode.WordWrap,
Lines = 0,
Text = this.Placeholder,
TextColor = this.PlaceholderColor
};
this.Add(this.placeholderLabel);
}
开发者ID:robert-waggott,项目名称:Xamarin.PlaceholderEnabledUITextView,代码行数:27,代码来源:PlaceholderEnabledUITextView.cs
注:本文中的CGSize类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论