當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。