本文整理汇总了C#中MonoMac.AppKit.NSView类的典型用法代码示例。如果您正苦于以下问题:C# NSView类的具体用法?C# NSView怎么用?C# NSView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSView类属于MonoMac.AppKit命名空间,在下文中一共展示了NSView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: LoadView
public override void LoadView ()
{
var view = new NSView(new RectangleF(0,100,320,500));
//view.BackgroundColor = NSColor.Gray;
View = view;
ViewDidLoad ();
}
示例3: BringSubviewToFront
public static void BringSubviewToFront(this NSView superView, NSView theView)
{
if(theView == null || !superView.Subviews.Contains(theView))
return;
theView.RemoveFromSuperview();
superView.AddSubview(theView);
}
示例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 ();
}
示例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);
}
示例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
}
示例7: SetNativeView
void SetNativeView (NSView aView)
{
if (innerView != null)
innerView.RemoveFromSuperview ();
innerView = aView;
innerView.Frame = Widget.Bounds;
Widget.AddSubview (innerView);
}
示例8: SetContent
public void SetContent (object nativeWidget)
{
if (nativeWidget is NSView) {
if (ViewObject == null)
innerView = (NSView)nativeWidget;
else
SetNativeView ((NSView)nativeWidget);
}
}
示例9: AddSubview
public void AddSubview(NSView view, float extent)
{
base.AddSubview(view);
_children.Add(new Child
{
View = view,
Extent = extent,
});
}
示例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;
}
示例11: ViewWillMoveToSuperview
public override void ViewWillMoveToSuperview (NSView newSuperview)
{
if (newSuperview != null)
{
base.ViewWillMoveToSuperview (newSuperview);
if (_controller != null)
_controller.RefreshBasket ();
}
}
示例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);
}
示例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;
}
示例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));
});
}
示例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
}