当前位置: 首页>>代码示例>>C#>>正文


C# AppKit.NSView类代码示例

本文整理汇总了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);
		}
开发者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


注:本文中的MonoMac.AppKit.NSView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。