本文整理汇总了C#中MonoMac.AppKit.NSView类的典型用法代码示例。如果您正苦于以下问题:C# NSView类的具体用法?C# NSView怎么用?C# NSView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSView类属于MonoMac.AppKit命名空间,在下文中一共展示了NSView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GraphicsHandler
public GraphicsHandler(NSView view)
{
this.view = view;
graphicsContext = NSGraphicsContext.FromWindow(view.Window);
graphicsContext = graphicsContext.IsFlipped ? graphicsContext : NSGraphicsContext.FromGraphicsPort(graphicsContext.GraphicsPortHandle, true);
disposeContext = true;
Control = graphicsContext.GraphicsPort;
view.PostsFrameChangedNotifications = true;
AddObserver(NSView.FrameChangedNotification, FrameDidChange, view);
// if control is in a scrollview, we need to trap when it's scrolled as well
var parent = view.Superview;
while (parent != null)
{
var scroll = parent as NSScrollView;
if (scroll != null)
{
scroll.ContentView.PostsBoundsChangedNotifications = true;
AddObserver(NSView.BoundsChangedNotification, FrameDidChange, scroll.ContentView);
}
parent = parent.Superview;
}
SetDefaults();
InitializeContext(view.IsFlipped);
}
开发者ID:alexandrebaker,项目名称:Eto,代码行数:27,代码来源:GraphicsHandler.cs
示例2: LoadView
public override void LoadView ()
{
var view = new NSView(new RectangleF(0,100,320,500));
//view.BackgroundColor = NSColor.Gray;
View = view;
ViewDidLoad ();
}
开发者ID:Dexyon,项目名称:MvvmCross-Samples,代码行数:7,代码来源:Views.cs
示例3: BringSubviewToFront
public static void BringSubviewToFront(this NSView superView, NSView theView)
{
if(theView == null || !superView.Subviews.Contains(theView))
return;
theView.RemoveFromSuperview();
superView.AddSubview(theView);
}
开发者ID:mcneel,项目名称:MonoMac.Windows.Form,代码行数:7,代码来源:NSViewExtender.cs
示例4: ViewDidLoad
public override void ViewDidLoad ()
{
View = new NSView (new RectangleF (0, 0, 320, 400));
base.ViewDidLoad ();
var textEditFirst = new NSTextField(new System.Drawing.RectangleF(0,0,320,40));
View.AddSubview (textEditFirst);
var textEditSecond = new NSTextField(new System.Drawing.RectangleF(0,50,320,40));
View.AddSubview(textEditSecond);
var slider = new NSSlider(new System.Drawing.RectangleF(0,150,320,40));
slider.MinValue = 0;
slider.MaxValue = 100;
slider.IntValue = 23;
View.AddSubview(slider);
var labelFull = new NSTextField(new System.Drawing.RectangleF(0,100,320,40));
labelFull.Editable = false;
labelFull.Bordered = false;
labelFull.AllowsEditingTextAttributes = false;
labelFull.DrawsBackground = false;
View.AddSubview (labelFull);
var sw = new NSButton(new RectangleF(0,200,320,40));
sw.SetButtonType (NSButtonType.Switch);
View.AddSubview (sw);
//sw.AddObserver()
var set = this.CreateBindingSet<SecondViewController, SecondViewModel> ();
set.Bind (textEditFirst).For(v => v.StringValue).To (vm => vm.FirstName);
set.Bind (textEditSecond).For(v => v.StringValue).To (vm => vm.LastName);
set.Bind (labelFull).Described("SliderValue + ' ' + OnOffValue").For("StringValue");
set.Bind (slider).For("IntValue").To (vm => vm.SliderValue);
set.Bind (sw).For(c => c.State).To (vm => vm.OnOffValue);
set.Apply ();
}
开发者ID:Dexyon,项目名称:MvvmCross-Samples,代码行数:35,代码来源:FirstViewController.cs
示例5: GetLocation
public static Point GetLocation (NSView view, NSEvent theEvent)
{
var loc = view.ConvertPointFromView (theEvent.LocationInWindow, null);
if (!view.IsFlipped)
loc.Y = view.Frame.Height - loc.Y;
return Generator.ConvertF (loc);
}
开发者ID:hultqvist,项目名称:Eto,代码行数:7,代码来源:Generator.cs
示例6: LoadView
public override void LoadView ()
{
var backend = (ViewBackend)Toolkit.GetBackend (child);
view = ((ViewBackend)backend).NativeWidget as NSView;
backend.SetAutosizeMode (true);
ForceChildLayout ();
// FIXME: unset when the popover is closed
}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:8,代码来源:PopoverBackend.cs
示例7: SetNativeView
void SetNativeView (NSView aView)
{
if (innerView != null)
innerView.RemoveFromSuperview ();
innerView = aView;
innerView.Frame = Widget.Bounds;
Widget.AddSubview (innerView);
}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:8,代码来源:EmbedNativeWidgetBackend.cs
示例8: SetContent
public void SetContent (object nativeWidget)
{
if (nativeWidget is NSView) {
if (ViewObject == null)
innerView = (NSView)nativeWidget;
else
SetNativeView ((NSView)nativeWidget);
}
}
开发者ID:m13253,项目名称:xwt,代码行数:9,代码来源:EmbedNativeWidgetBackend.cs
示例9: AddSubview
public void AddSubview(NSView view, float extent)
{
base.AddSubview(view);
_children.Add(new Child
{
View = view,
Extent = extent,
});
}
开发者ID:johansson,项目名称:pierce,代码行数:9,代码来源:Box.cs
示例10: GetCredentials
public ICredentials GetCredentials (Uri uri, IWebProxy proxy, CredentialType credentialType, ICredentials existingCredentials, bool retrying)
{
bool result = false;
DispatchService.GuiSyncDispatch (() => {
using (var ns = new NSAutoreleasePool ()) {
var message = string.Format ("{0} needs {1} credentials to access {2}.", BrandingService.ApplicationName,
credentialType == CredentialType.ProxyCredentials ? "proxy" : "request", uri.Host);
NSAlert alert = NSAlert.WithMessage ("Credentials Required", "OK", "Cancel", null, message);
alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;
NSView view = new NSView (new RectangleF (0, 0, 313, 91));
var creds = Utility.GetCredentialsForUriFromICredentials (uri, existingCredentials);
var usernameLabel = new NSTextField (new RectangleF (17, 55, 71, 17)) {
Identifier = "usernameLabel",
StringValue = "Username:",
Alignment = NSTextAlignment.Right,
Editable = false,
Bordered = false,
DrawsBackground = false,
Bezeled = false,
Selectable = false,
};
view.AddSubview (usernameLabel);
var usernameInput = new NSTextField (new RectangleF (93, 52, 200, 22));
usernameInput.StringValue = creds != null ? creds.UserName : string.Empty;
view.AddSubview (usernameInput);
var passwordLabel = new NSTextField (new RectangleF (22, 23, 66, 17)) {
StringValue = "Password:",
Alignment = NSTextAlignment.Right,
Editable = false,
Bordered = false,
DrawsBackground = false,
Bezeled = false,
Selectable = false,
};
view.AddSubview (passwordLabel);
var passwordInput = new NSSecureTextField (new RectangleF (93, 20, 200, 22));
passwordInput.StringValue = creds != null ? creds.Password : string.Empty;
view.AddSubview (passwordInput);
alert.AccessoryView = view;
result = alert.RunModal () == 1;
username = usernameInput.StringValue;
password = passwordInput.StringValue;
}
});
return result ? new NetworkCredential (username, password) : null;
}
开发者ID:fedorw,项目名称:monodevelop,代码行数:56,代码来源:MacProxyCredentialProvider.cs
示例11: ViewWillMoveToSuperview
public override void ViewWillMoveToSuperview (NSView newSuperview)
{
if (newSuperview != null)
{
base.ViewWillMoveToSuperview (newSuperview);
if (_controller != null)
_controller.RefreshBasket ();
}
}
开发者ID:robertmiles3,项目名称:xamarin-store-app,代码行数:10,代码来源:ShoppingBasketView.cs
示例12: MouseUp
public static void MouseUp(NSView view, IControlMouseInteraction control, NSEvent theEvent, bool isRightButton)
{
var button = MouseButtonType.Right;
if(!isRightButton)
button = GetMouseButtonType(theEvent);
var point = GetMouseLocation(view, theEvent);
var keysHeld = GetKeysHeld(theEvent);
//Console.WriteLine("GenericControlHelper - MouseUp - point: {0} button: {1} bounds: {2}", point, button, view.Bounds);
control.MouseUp(point.X, point.Y, button, keysHeld);
}
开发者ID:pascalfr,项目名称:MPfm,代码行数:11,代码来源:GenericControlHelper.cs
示例13: ViewStringForToolTip
public NSString ViewStringForToolTip(NSView view, NSObject tooltipTag, PointF point, IntPtr data)
{
int index = data.ToInt32();
if (index >= 0 && index < imageViewItems.Count)
{
return (NSString) imageViewItems[index].Keywords;
}
logger.Info("Nothing for {0}", index);
return null;
}
开发者ID:kevintavog,项目名称:MapThis,代码行数:11,代码来源:ImageViewDelegate.cs
示例14: DrawInteriorWithFrame
public override void DrawInteriorWithFrame (RectangleF cellFrame, NSView inView)
{
CGContext ctx = NSGraphicsContext.CurrentContext.GraphicsPort;
var backend = new CGContextBackend {
Context = ctx,
InverseViewTransform = ctx.GetCTM ().Invert ()
};
Frontend.ApplicationContext.InvokeUserCode (delegate {
Frontend.Draw (backend, new Rectangle (cellFrame.X, cellFrame.Y, cellFrame.Width, cellFrame.Height));
});
}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:12,代码来源:CanvasTableCell.cs
示例15: LoadView
public override void LoadView ()
{
var backend = (ViewBackend)Toolkit.GetBackend (child);
view = ((ViewBackend)backend).NativeWidget as NSView;
if (view.Layer == null)
view.WantsLayer = true;
if (BackgroundColor != null)
view.Layer.BackgroundColor = BackgroundColor;
backend.SetAutosizeMode (true);
ForceChildLayout ();
// FIXME: unset when the popover is closed
}
开发者ID:m13253,项目名称:xwt,代码行数:13,代码来源:PopoverBackend.cs
示例16: SetNativeView
void SetNativeView (NSView aView)
{
if (innerView != null)
innerView.RemoveFromSuperview ();
innerView = aView;
innerView.Frame = Widget.Bounds;
innerView.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;
innerView.TranslatesAutoresizingMaskIntoConstraints = true;
Widget.AutoresizesSubviews = true;
Widget.AddSubview (innerView);
}
开发者ID:m13253,项目名称:xwt,代码行数:13,代码来源:EmbedNativeWidgetBackend.cs
示例17: DrawWithFrame
public override void DrawWithFrame (RectangleF cellFrame, NSView inView)
{
borderColor.SetFill ();
NSGraphics.RectFill (
new RectangleF (
cellFrame.X + padding / 2,
cellFrame.Y + padding / 2,
cellFrame.Width - padding,
cellFrame.Height - padding
)
);
base.DrawWithFrame (cellFrame, inView);
}
开发者ID:RafasTavares,项目名称:mac-samples,代码行数:15,代码来源:CustomCatTextAttachmentCell.cs
示例18: Colourize
public static void Colourize(NSView control, Color color, Action drawAction)
{
var size = control.Frame.Size;
if (size.Width <= 0 || size.Height <= 0)
return;
var image = new NSImage(size);
image.LockFocusFlipped(control.IsFlipped);
drawAction();
image.UnlockFocus();
var ciImage = CIImage.FromCGImage(image.CGImage);
SD.SizeF realSize;
if (control.RespondsToSelector(selConvertSizeToBacking))
realSize = control.ConvertSizeToBacking(size);
else
realSize = control.ConvertSizeToBase(size);
if (control.IsFlipped)
{
var affineTransform = new NSAffineTransform();
affineTransform.Translate(0, realSize.Height);
affineTransform.Scale(1, -1);
var filter1 = new CIAffineTransform();
filter1.Image = ciImage;
filter1.SetValueForKey(affineTransform, CIInputTransform);
ciImage = filter1.ValueForKey(CIOutputImage) as CIImage;
}
var filter2 = new CIColorControls();
filter2.SetDefaults();
filter2.Image = ciImage;
filter2.Saturation = 0.0f;
ciImage = filter2.ValueForKey(CIOutputImage) as CIImage;
var filter3 = new CIColorMatrix();
filter3.SetDefaults();
filter3.Image = ciImage;
filter3.RVector = new CIVector(0, color.R, 0);
filter3.GVector = new CIVector(color.G, 0, 0);
filter3.BVector = new CIVector(0, 0, color.B);
ciImage = filter3.ValueForKey(CIOutputImage) as CIImage;
ciImage.Draw(new SD.RectangleF(SD.PointF.Empty, size), new SD.RectangleF(SD.PointF.Empty, realSize), NSCompositingOperation.SourceOver, 1);
}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:46,代码来源:MacEventView.cs
示例19: Colourize
public static void Colourize (NSView control, Color color, Action drawAction)
{
var size = control.Frame.Size;
var image = new NSImage (size);
image.LockFocusFlipped (control.IsFlipped);
drawAction ();
image.UnlockFocus ();
var ciImage = CIImage.FromData (image.AsTiff ());
if (control.IsFlipped) {
var realSize = control.ConvertSizeToBase (size);
var affineTransform = new NSAffineTransform ();
affineTransform.Translate (0, realSize.Height);
affineTransform.Scale (1, -1);
var filter1 = CIFilter.FromName ("CIAffineTransform");
filter1.SetValueForKey (ciImage, CIInputImage);
filter1.SetValueForKey (affineTransform, CIInputTransform);
ciImage = filter1.ValueForKey (CIOutputImage) as CIImage;
}
var filter2 = CIFilter.FromName ("CIColorControls");
filter2.SetDefaults ();
filter2.SetValueForKey (ciImage, CIInputImage);
filter2.SetValueForKey (new NSNumber (0.0f), CIInputSaturation);
ciImage = filter2.ValueForKey (CIOutputImage) as CIImage;
var filter3 = CIFilter.FromName ("CIColorMatrix");
filter3.SetDefaults ();
filter3.SetValueForKey (ciImage, CIInputImage);
filter3.SetValueForKey (new CIVector (0, color.R, 0), CIInputRVector);
filter3.SetValueForKey (new CIVector (color.G, 0, 0), CIInputGVector);
filter3.SetValueForKey (new CIVector (0, 0, color.B), CIInputBVector);
ciImage = filter3.ValueForKey (CIOutputImage) as CIImage;
image = new NSImage (size);
var rep = NSCIImageRep.FromCIImage (ciImage);
image.AddRepresentation (rep);
image.Draw (SD.PointF.Empty, new SD.RectangleF (SD.PointF.Empty, size), NSCompositingOperation.SourceOver, 1);
/* Use this when implemented in maccore:
ciImage.Draw (SD.PointF.Empty, new SD.RectangleF (SD.PointF.Empty, size), NSCompositingOperation.SourceOver, 1);
*/
}
开发者ID:majorsilence,项目名称:Eto,代码行数:44,代码来源:MacEventView.cs
示例20: Colourize
public static void Colourize(NSView control, Color color, Action drawAction)
{
var size = control.Frame.Size;
if (size.Width <= 0 || size.Height <= 0)
return;
var image = new NSImage(size);
image.LockFocusFlipped(!control.IsFlipped);
drawAction();
image.UnlockFocus();
var ciImage = CIImage.FromCGImage(image.CGImage);
CGSize realSize;
if (control.RespondsToSelector(selConvertSizeToBacking))
realSize = control.ConvertSizeToBacking(size);
else
realSize = control.ConvertSizeToBase(size);
var filter2 = new CIColorControls();
filter2.SetDefaults();
filter2.Image = ciImage;
filter2.Saturation = 0.0f;
ciImage = (CIImage)filter2.ValueForKey(CIOutputImage);
var filter3 = new CIColorMatrix();
filter3.SetDefaults();
filter3.Image = ciImage;
filter3.RVector = new CIVector(0, color.R, 0);
filter3.GVector = new CIVector(color.G, 0, 0);
filter3.BVector = new CIVector(0, 0, color.B);
ciImage = (CIImage)filter3.ValueForKey(CIOutputImage);
// create separate context so we can force using the software renderer, which is more than fast enough for this
var ciContext = CIContext.FromContext(NSGraphicsContext.CurrentContext.GraphicsPort, new CIContextOptions { UseSoftwareRenderer = true });
ciContext.DrawImage(ciImage, new CGRect(CGPoint.Empty, size), new CGRect(CGPoint.Empty, realSize));
}
开发者ID:gene-l-thomas,项目名称:Eto,代码行数:37,代码来源:MacEventView.cs
注:本文中的MonoMac.AppKit.NSView类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论