Example #1
0
 /// <summary>
 /// ctor.
 /// </summary>
 public Window(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation)
     : base(contentRect, aStyle, bufferingType, deferCreation)
 {
     Delegate          = new WindowDelegate();
     _inputPane        = InputPane.GetForCurrentView();
     _inputPane.Window = this;
 }
Example #2
0
        public MainWindow(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation) : base(contentRect, aStyle, bufferingType, deferCreation)
        {
            // Define the User Interface of the Window here
            Title = "Window From Code";

            // Create the content view for the window and make it fill the window
            ContentView = new NSView(Frame);

            // Add UI Elements to window
            ClickMeButton = new NSButton(new CGRect(10, Frame.Height - 70, 100, 30))
            {
                AutoresizingMask = NSViewResizingMask.MinYMargin
            };
            ContentView.AddSubview(ClickMeButton);

            ClickMeLabel = new NSTextField(new CGRect(120, Frame.Height - 65, Frame.Width - 130, 20))
            {
                BackgroundColor  = NSColor.Clear,
                TextColor        = NSColor.Black,
                Editable         = false,
                Bezeled          = false,
                AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.MinYMargin,
                StringValue      = "Button has not been clicked yet."
            };
            ContentView.AddSubview(ClickMeLabel);
        }
Example #3
0
        public static void SetToDialogStyle(this Window window, Window parentWindow = null, bool closeable = true, bool centerToParent = true, bool setTransient = true)
        {
            if (parentWindow == null)
            {
                parentWindow = ApplicationCurrent.MainWindow;
            }
            if (centerToParent)
            {
                window.CenterToParentWindow(parentWindow);
            }
            if (setTransient)
            {
                window.TransientFor = parentWindow;
            }
            window.Deletable = closeable;
            if (!Platform.IsMac)
            {
                return;
            }
            NSWindowStyle nsWindowStyle = NSWindowStyle.Titled;

            if (closeable)
            {
                nsWindowStyle |= NSWindowStyle.Closable;
            }
            if (window.GdkWindow == null)
            {
                window.Show();
            }
            SetNSWindowStyle.GetNSWindow(window.GdkWindow).StyleMask = nsWindowStyle;
        }
        public AppKitDisplay()
        {
            NSApplication.Init();

            CGRect     screenFrame = NSScreen.MainScreen.Frame;
            RectangleF frame       = new RectangleF((float)screenFrame.X, (float)screenFrame.Y,
                                                    (float)screenFrame.Width * 0.74f, (float)screenFrame.Height * 0.74f);
            NSWindowStyle style = NSWindowStyle.Titled | NSWindowStyle.Closable |
                                  NSWindowStyle.Miniaturizable | NSWindowStyle.Resizable;

            _window = new WindowClass(frame, style, NSBackingStore.Buffered, false);
            _window.AppKitDisplay           = this;
            _window.ReleasedWhenClosed      = false;
            _window.BackgroundColor         = NSColor.Black;
            _window.IsOpaque                = true;
            _window.AcceptsMouseMovedEvents = true;
            string[] draggedTypes = { NSPasteboard.NSFilenamesType.ToString() };
            _window.RegisterForDraggedTypes(draggedTypes);
            _delegate        = new WindowDelegate(this, _window);
            _window.Delegate = _delegate;

            _textinputClient = new TextInputClient(this);
            _window.ContentView.AddSubview(_textinputClient);

            FillKeyTable();
        }
Example #5
0
        /// <summary>
        /// ctor.
        /// </summary>
        public Window(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation)
            : base(contentRect, aStyle, bufferingType, deferCreation)
        {
            Delegate          = new WindowDelegate(this);
            _inputPane        = InputPane.GetForCurrentView();
            _inputPane.Window = this;

            // Register the types that can be dragging into the window (effectively 'AllowDrop').
            // This must be done before dragging enters the window or dragging methods won't be invoked.
            // We register for all possible types and then confirm whether they
            // are actually supported within the draggingEntered and draggingUpdated methods.
            // This has a minor side effect in the standard UI (zoom effect) but is considered acceptable.
            RegisterForDraggedTypes(new string[]
            {
                NSPasteboard.NSPasteboardTypeUrl,
                NSPasteboard.NSPasteboardTypeTIFF,
                NSPasteboard.NSPasteboardTypePNG,
                NSPasteboard.NSPasteboardTypeHTML,
                NSPasteboard.NSPasteboardTypeRTF,
                NSPasteboard.NSPasteboardTypeRTFD,
                NSPasteboard.NSPasteboardTypeFileUrl,
                NSPasteboard.NSPasteboardTypeString

                /* For future use
                 * UTType.URL,
                 * UTType.Image,
                 * UTType.HTML,
                 * UTType.RTF,
                 * UTType.FileURL,
                 * UTType.PlainText,
                 */
            });
        }
Example #6
0
        public BrowserWindow(CGRect rect, NSWindowStyle windowStyle)
            : base(rect, windowStyle, NSBackingStore.Buffered, false)
        {
            DidResize += Window_DidResize;

            var masterCssData = File.ReadAllText("master.css", Encoding.UTF8);

            LiteHtmlView = new LiteHtmlNSView(new CGRect(0, 0, rect.Width, rect.Height), masterCssData);
            LiteHtmlView.LiteHtmlContainer.CaptionDefined    += LiteHtmlView_LiteHtmlContainer_CaptionDefined;
            LiteHtmlView.LiteHtmlContainer.ImportCssCallback  = (url, baseUrl) => Encoding.UTF8.GetString(DownloadResource(url, baseUrl));
            LiteHtmlView.LiteHtmlContainer.LoadImageCallback  = LoadImage;
            LiteHtmlView.LiteHtmlContainer.AnchorClicked     += LiteHtmlView_LiteHtmlContainer_AnchorClicked;
            LiteHtmlView.LiteHtmlContainer.DocumentSizeKnown += LiteHtmlView_DocumentSizeKnown;


            scrollView = new NSScrollView();
            scrollView.AutohidesScrollers    = true;
            scrollView.HasHorizontalScroller = true;
            scrollView.HasVerticalScroller   = true;
            scrollView.DocumentView          = LiteHtmlView;

            urlInput            = new NSTextField();
            urlInput.Activated += TextField_Activated;

            ContentView = new BrowserContentView();
            ContentView.AddSubview(scrollView);
            ContentView.AddSubview(urlInput);

            scrollView.ContentView.PostsBoundsChangedNotifications = true;
            NSNotificationCenter.DefaultCenter.AddObserver(NSView.BoundsChangedNotification, scrollViewScrolled, scrollView.ContentView);

            LayoutViews();
        }
		public KTBorderlessWindow(RectangleF contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation)
			: base(contentRect, aStyle, bufferingType, deferCreation)
		{
			BackgroundColor = NSColor.Clear;
			AlphaValue = 0.50f;
			IsOpaque = false;
			Level = NSWindowLevel.Floating;
		}
Example #8
0
 public static WindowStyle ToEtoWindowStyle(this NSWindowStyle style)
 {
     return(style.HasFlag(NSWindowStyle.Utility)
                         ? WindowStyle.Utility
                         : style.HasFlag(NSWindowStyle.Titled)
                         ? WindowStyle.Default
                         : WindowStyle.None);
 }
Example #9
0
        public AppDelegate()
        {
            NSWindowStyle style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;
            CGRect        rect  = new CGRect(100, 100, 1024, 768);

            this.window                 = new NSWindow(rect, style, NSBackingStore.Buffered, false);
            this.window.Title           = "AdvertisementSuperSlayer";
            this.window.TitleVisibility = NSWindowTitleVisibility.Hidden;
        }
Example #10
0
        public AppDelegate()
        {
            NSWindowStyle style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;
            var           rect  = new CoreGraphics.CGRect(200, 200, 800, 800);

            window = new NSWindow(rect, style, NSBackingStore.Buffered, false)
            {
                TitleVisibility = NSWindowTitleVisibility.Hidden
            };
        }
Example #11
0
 public static WindowStyle ToEtoWindowStyle(this NSWindowStyle style)
 {
     if (style.HasFlag(NSWindowStyle.Borderless))
     {
         return(WindowStyle.None);
     }
     else
     {
         return(WindowStyle.Default);
     }
 }
Example #12
0
        public CustomWindow(RectangleF rect, NSWindowStyle style, NSBackingStore backing, bool defer)
            : base(rect, NSWindowStyle.Borderless, backing, defer)
        {
            // Go transparent
            BackgroundColor = NSColor.Clear;

            // pull window to front
            //Level = NSWindowLevel.Status;
            IsOpaque  = false;
            HasShadow = true;
        }
Example #13
0
		public CustomWindow (RectangleF rect, NSWindowStyle style, NSBackingStore backing, bool defer)
			: base (rect, NSWindowStyle.Borderless, backing, defer) 
		{
			// Go transparent
			BackgroundColor = NSColor.Clear;
			
			// pull window to front
			//Level = NSWindowLevel.Status;
			IsOpaque = false;
			HasShadow = true;
		}
Example #14
0
        public AppDelegate()
        {
            NSWindowStyle style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;

            CoreGraphics.CGRect rect = new CoreGraphics.CGRect(200, 1000, 1024, 768);
            MainWindow = new NSWindow(rect, style, NSBackingStore.Buffered, false)
            {
                Title           = GlobalConstants.AppName,
                TitleVisibility = NSWindowTitleVisibility.Visible,
            };
        }
Example #15
0
        public AppDelegate()
        {
            const NSWindowStyle style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;

            var rect = new CoreGraphics.CGRect(200, 1000, 1024, 768);

            _window = new NSWindow(rect, style, NSBackingStore.Buffered, false)
            {
                Title           = "Project Memory for Mac",
                TitleVisibility = NSWindowTitleVisibility.Hidden
            };
        }
Example #16
0
        public AppDelegate()
        {
            const NSWindowStyle style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;

            var rect = new CoreGraphics.CGRect(0, 0, 1024, 768);

            window = new NSWindow(rect, style, NSBackingStore.Buffered, false)
            {
                Title           = "Xamarin.Forms on Mac!", // choose your own Title here
                TitleVisibility = NSWindowTitleVisibility.Visible
            };
        }
Example #17
0
        //[Export ("initWithContentRect:styleMask:backing:defer:"), CompilerGenerated]
        internal MonoWindow(NSRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation, XplatUICocoa driver)
            : base(contentRect, aStyle, bufferingType, deferCreation)
        {
            this.driver = driver;

            // Disable tabbing on Sierra until we properly support it
            var setTabbingModeSelector = new ObjCRuntime.Selector("setTabbingMode:");

            if (this.RespondsToSelector(setTabbingModeSelector))
            {
                this.SetValueForKey(NSNumber.FromInt32(2), new NSString("tabbingMode"));
            }
        }
Example #18
0
        public AppDelegate()
        {
            const NSWindowStyle style = NSWindowStyle.Titled | NSWindowStyle.Closable | NSWindowStyle.Miniaturizable | NSWindowStyle.Resizable;

            var rect = new CoreGraphics.CGRect(200, 200, 1024, 768);

            MainWindow = new NSWindow(rect, style, NSBackingStore.Buffered, false)
            {
                Title           = "Demo",
                TitleVisibility = NSWindowTitleVisibility.Hidden
            };
            MainWindow.Center();
            NSApplication.SharedApplication.MainMenu = new NSMenu();
        }
Example #19
0
 public LaunchWindow(CoreGraphics.CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation) :
     base(contentRect, aStyle, bufferingType, deferCreation)
 {
     Appearance = NSAppearance.GetAppearance(NSAppearance.NameVibrantDark);
     IsOpaque   = true;
     MovableByWindowBackground = true;
     ReleasedWhenClosed        = false;
     Title = NSBundle.MainBundle.GetName();
     TitlebarAppearsTransparent = true;
     TitleVisibility            = NSWindowTitleVisibility.Hidden;
     Toolbar = new NSToolbar()
     {
         ShowsBaselineSeparator = false
     };
 }
Example #20
0
        public AppDelegate()
        {
            const NSWindowStyle style = NSWindowStyle.Titled | NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Miniaturizable;

            var rect = new CoreGraphics.CGRect(200, 200, 1024, 768);

            MainWindow = new NSWindow(rect, style, NSBackingStore.Buffered, false)
            {
                Title                       = "MADSENSE Sample",
                TitleVisibility             = NSWindowTitleVisibility.Hidden,
                AutorecalculatesKeyViewLoop = true,
                FrameAutosaveName           = "com.madsense.XamarinForms.Sample"
            };

            NSApplication.SharedApplication.MainMenu = new NSMenu();
        }
Example #21
0
        public static NSWindowStyle ToNS(this WindowStyle style, NSWindowStyle existing)
        {
            const NSWindowStyle NONE_STYLE    = NSWindowStyle.Borderless;
            const NSWindowStyle DEFAULT_STYLE = NSWindowStyle.Titled;

            switch (style)
            {
            case WindowStyle.Default:
                return((existing & ~NONE_STYLE) | DEFAULT_STYLE);

            case WindowStyle.None:
                return((existing & ~DEFAULT_STYLE) | NONE_STYLE);

            default:
                throw new NotSupportedException();
            }
        }
Example #22
0
        public MainWindow(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation) : base(contentRect, aStyle, bufferingType, deferCreation)
        {
            // Define the User Interface of the Window here
            Title = "Window From Code";

            // Create the content view for the window and make it fill the window
            ContentView = new NSView(Frame);

            // Add UI Elements to window
            ClickMeButton = NSButton.CreateButton("Click Me!", ButtonClicked);
            ClickMeButton.TranslatesAutoresizingMaskIntoConstraints = false;
            ContentView.AddSubview(ClickMeButton);

            ClickMeLabel = NSTextField.CreateLabel("Button has not been clicked yet.");
            ClickMeLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            ContentView.AddSubview(ClickMeLabel);

            // Add constraints to window
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat(
                                           "V:|-[button]-[label]", NSLayoutFormatOptions.AlignAllLeading,
                                           "button", ClickMeButton, "label", ClickMeLabel));
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat(
                                           "H:|-[button]", NSLayoutFormatOptions.AlignAllFirstBaseline,
                                           "button", ClickMeButton));
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat(
                                           "H:|-[label]", NSLayoutFormatOptions.AlignAllFirstBaseline,
                                           "label", ClickMeLabel));

            var constraints = NSLayoutConstraint.FromVisualFormat(
                "H:[label]-|", NSLayoutFormatOptions.AlignAllFirstBaseline,
                "label", ClickMeLabel);

            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat(
                                           "H:[button]-(>=std)-|", NSLayoutFormatOptions.AlignAllFirstBaseline,
                                           "button", ClickMeButton, "std", constraints[0].Constant));
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat(
                                           "H:[label]-(>=std)-|", NSLayoutFormatOptions.AlignAllFirstBaseline,
                                           "label", ClickMeLabel, "std", constraints[0].Constant));

            constraints = NSLayoutConstraint.FromVisualFormat(
                "V:[label]-|", NSLayoutFormatOptions.AlignAllLeft,
                "label", ClickMeLabel);
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat(
                                           "V:[label]-(>=std)-|", NSLayoutFormatOptions.AlignAllFirstBaseline,
                                           "label", ClickMeLabel, "std", constraints[0].Constant));
        }
        public void SetWindowStyle(bool WS_CAPTION, bool WS_MAXIMIZEBOX, bool WS_MINIMIZEBOX)
        {
            NSWindowStyle mask = NSWindowStyle.Closable;

            if (WS_CAPTION)
            {
                mask |= NSWindowStyle.Titled;
            }
            if (WS_MAXIMIZEBOX)
            {
                mask |= NSWindowStyle.Resizable;
            }
            if (WS_MINIMIZEBOX)
            {
                mask |= NSWindowStyle.Miniaturizable;
            }
            this.StyleMask = mask;
        }
Example #24
0
        public static NSWindowStyle ToNS(this WindowStyle style, NSWindowStyle existing)
        {
            existing &= ~(NSWindowStyle.Utility | NSWindowStyle.Titled | NSWindowStyle.Borderless);
            switch (style)
            {
            case WindowStyle.Default:
                return(existing | NSWindowStyle.Titled);

            case WindowStyle.None:
                return(existing | NSWindowStyle.Borderless);

            case WindowStyle.Utility:
                return(existing | NSWindowStyle.Utility | NSWindowStyle.Titled);

            default:
                throw new NotSupportedException();
            }
        }
Example #25
0
		public MainWindow(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation): base (contentRect, aStyle,bufferingType,deferCreation) {
			// Define the User Interface of the Window here
			Title = "Window From Code";

			// Create the content view for the window and make it fill the window
			ContentView = new NSView (Frame);

			// Add UI Elements to window
			ClickMeButton = new NSButton (new CGRect (10, Frame.Height-70, 100, 30)){
				AutoresizingMask = NSViewResizingMask.MinYMargin
			};
			ContentView.AddSubview (ClickMeButton);

			ClickMeLabel = new NSTextField (new CGRect (120, Frame.Height - 65, Frame.Width - 130, 20)) {
				BackgroundColor = NSColor.Clear,
				TextColor = NSColor.Black,
				Editable = false,
				Bezeled = false,
				AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.MinYMargin,
				StringValue = "Button has not been clicked yet."
			};
			ContentView.AddSubview (ClickMeLabel);
		}
 public MacGameNSWindow(RectangleF rect, NSWindowStyle style, NSBackingStore backing, bool defer)
     : base(rect, style, backing, defer)
 {
 }
Example #27
0
 public PhiddleWindow(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation)
     : base(contentRect, aStyle, bufferingType, deferCreation)
 {
 }
Example #28
0
 public static WindowStyle ToEtoWindowStyle(this NSWindowStyle style)
 {
     return(style.HasFlag(NSWindowStyle.Borderless) ? WindowStyle.None : WindowStyle.Default);
 }
Example #29
0
		public MacGameNSWindow (RectangleF rect, NSWindowStyle style, NSBackingStore backing, bool defer)
		: base (rect, style, backing, defer)
		{}
Example #30
0
 public WindowWrapper(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation, NSScreen screen) : base(contentRect, aStyle, bufferingType, deferCreation, screen)
 {
     Initialize();
 }
 public AppStoreWindow(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation, NSScreen screen)
     : base(contentRect, aStyle, bufferingType, deferCreation, screen)
 {
 }
 public MacGameNSWindow(System.Drawing.RectangleF rect, NSWindowStyle style, NSBackingStore backing, Boolean defer)
     : base(rect, style, backing, defer)
 {
 }
		internal FormHelper (Form parent, RectangleF r, NSWindowStyle ws, NSBackingStore back, bool flag) : base(r, ws, back, flag)
		{
			m_parent = parent;
			this.WillClose += HandleHandleWillClose;
		}
Example #34
0
 public MyWindow(CGRect rect, NSWindowStyle style, NSBackingStore store, bool flag)
     : base(rect, style, store, flag)
 {
 }
Example #35
0
		public MyKeyWindow (CGRect rect, NSWindowStyle style, NSBackingStore store, bool deferCreation)
			: base (rect, style, store, deferCreation)
		{
		}
Example #36
0
		public static NSWindowStyle ToNS(this WindowStyle style, NSWindowStyle existing)
		{
			const NSWindowStyle NONE_STYLE = NSWindowStyle.Borderless;
			const NSWindowStyle DEFAULT_STYLE = NSWindowStyle.Titled;
			switch (style)
			{
				case WindowStyle.Default:
					return (existing & ~NONE_STYLE) | DEFAULT_STYLE;
				case WindowStyle.None:
					return (existing & ~DEFAULT_STYLE) | NONE_STYLE;
				default:
					throw new NotSupportedException();
			}
		}
 internal FormHelper(Form parent, NSRect r, NSWindowStyle ws, NSBackingStore back, bool flag) :
     base(r, ws, back, flag)
 {
     m_parent        = parent;
     this.WillClose += HandleHandleWillClose;
 }
Example #38
0
 public PreferencesWindow(CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation) : base(contentRect, aStyle, bufferingType, deferCreation)
 {
     ContentView = new NSView(Frame);
 }