示例#1
0
 void popoverDidClose(NSNotification note)
 {
     Console.WriteLine("done");
     _popover = null;
 }
 public virtual NSWindow DetachableWindowForPopover(NSPopover popover)
 {
     NSWindow window = this.detachedWindow;
     if (popover.Appearance == NSPopoverAppearance.NSPopoverAppearanceHUD) {
         window = this.detachedHUDWindow;
     }
     return window;
 }
示例#3
0
		void DestroyPopover (object sender, EventArgs args)
		{
			if (popover != null)
				popover.Close ();
			popover = null;
		}
示例#4
0
		void HandleViewBookmarksBtnActivated (object sender, EventArgs e)
		{
			var popover = new NSPopover ();
			popover.Behavior = NSPopoverBehavior.Transient;
			popover.ContentViewController = new BookmarkAssistantController (AppDelegate.BookmarkManager.GetAllBookmarks ());
			popover.Show (new RectangleF (0, 0, 0, 0), (NSView)sender, NSRectEdge.MinYEdge);
		}
示例#5
0
partial         void ShowNotes(NSObject sender)
        {
            using (NSPopover popover = new NSPopover ()) {
                var controller = new ShowNotesPopupController ();
                controller.NoteNodeClicked += (s, e) => LoadNote (e.NoteId);
                popover.Behavior = NSPopoverBehavior.Transient;
                popover.ContentViewController = controller;
                popover.Show (RectangleF.Empty, sender as NSView, NSRectEdge.MaxYEdge);
            }
        }
示例#6
0
		void DestroyPopover ()
		{
			oldLayer = null;
			if (popover != null)
				popover.Close ();
			popover = null;
		}
示例#7
0
 public BookmarkPopoverController(NSPopover popover, BookmarkManager.Entry entry) : base("BookmarkPopover", NSBundle.MainBundle)
 {
     this.parentPopover = popover;
     this.entry         = entry;
     Initialize();
 }
		public BookmarkPopoverController (NSPopover popover, BookmarkManager.Entry entry) : base ("BookmarkPopover", NSBundle.MainBundle)
		{
			this.parentPopover = popover;
			this.entry = entry;
			Initialize ();
		}
示例#9
0
        public void Show(Popover.Position orientation, Widget referenceWidget, Rectangle positionRect, Widget child)
        {
            var refBackend = Toolkit.GetBackend(referenceWidget) as IWidgetBackend;

            NSView refView = (refBackend as EmbedNativeWidgetBackend)?.EmbeddedView;

            if (refView == null)
            {
                refView = (refBackend as ViewBackend)?.Widget;
            }

            if (refView == null)
            {
                if (referenceWidget.Surface.ToolkitEngine.Type == ToolkitType.Gtk)
                {
                    try {
                        refView = GtkQuartz.GetView(refBackend.NativeWidget);
                        var rLocation = refView.ConvertRectToView(refView.Frame, null).Location.ToXwtPoint();
                        if (referenceWidget.WindowBounds.Location != rLocation)
                        {
                            positionRect.X += referenceWidget.WindowBounds.Location.X - rLocation.X;
                            positionRect.Y += referenceWidget.WindowBounds.Location.Y - rLocation.Y;
                        }
                    } catch (Exception ex) {
                        throw new ArgumentException("Widget belongs to an unsupported Toolkit", nameof(referenceWidget), ex);
                    }
                }
                else if (referenceWidget.Surface.ToolkitEngine != ApplicationContext.Toolkit)
                {
                    throw new ArgumentException("Widget belongs to an unsupported Toolkit", nameof(referenceWidget));
                }
            }

            // If the rect is empty, the coordinates of the rect will be ignored.
            // Set the width and height, for the positioning to function correctly.
            if (Math.Abs(positionRect.Width) < double.Epsilon)
            {
                positionRect.Width = referenceWidget.Size.Width;
            }
            if (Math.Abs(positionRect.Height) < double.Epsilon)
            {
                positionRect.Height = referenceWidget.Size.Height;
            }

            DestroyPopover();

            popover = new NSAppearanceCustomizationPopover {
                Behavior = NSPopoverBehavior.Transient
            };
            controller = new FactoryViewController(this, child, popover)
            {
                BackgroundColor = backgroundColor
            };
            popover.ContentViewController = controller;
            popover.Delegate = controller;

            // if the reference has a custom appearance, use it for the popover
            if (refView.EffectiveAppearance.Name != NSAppearance.NameAqua)
            {
                controller.EffectiveAppearanceName = refView.EffectiveAppearance.Name;

                if (popover is INSAppearanceCustomization)
                {
                    ((INSAppearanceCustomization)popover).SetAppearance(refView.EffectiveAppearance);
                }
            }

            popover.Show(positionRect.ToCGRect(),
                         refView,
                         ToRectEdge(orientation));
        }
 // Call to load from the XIB/NIB file
 public AddAnnotationViewController(NSPopover parentPopover) : base("AddAnnotationView", NSBundle.MainBundle)
 {
     ParentPopover = parentPopover;
     Initialize();
 }
示例#11
0
 // Call to load from the XIB/NIB file
 public HistoryPopoverController(NSPopover popover, int bookID) : base("HistoryPopover", NSBundle.MainBundle)
 {
     parentPopover = popover;
     BookID        = bookID;
     Initialize();
 }
示例#12
0
 // Call to load from the XIB/NIB file
 public EditTagsViewController(NSPopover popoverView, object viewController) : base("EditTagsView", NSBundle.MainBundle)
 {
     this.ParentConroller = viewController;
     ParentPopover        = popoverView;
     Initialize();
 }
示例#13
0
		public void Show (Xwt.Popover.Position orientation, Xwt.Widget referenceWidget, Xwt.Rectangle positionRect, Xwt.Widget child)
		{
			popover = MakePopover (child, BackgroundColor);
			popover.Delegate = new PopoverDelegate (sink);
			ViewBackend backend = (ViewBackend)Toolkit.GetBackend (referenceWidget);
			var reference = backend.Widget;

			// If the position rect is empty, the coordinates of the rect will be ignored.
			// Width and Height of the rect must be > Epsilon, for the positioning to function correctly.
			if (Math.Abs (positionRect.Width) < double.Epsilon)
				positionRect.Width = 1;
			if (Math.Abs (positionRect.Height) < double.Epsilon)
				positionRect.Height = 1;
			positionRect = new Rectangle(positionRect.X, positionRect.Y, positionRect.Width * 2, positionRect.Height); //It appears to be necessary to multiply the width by a factor of 2

			popover.Show (positionRect.ToCGRect (),
			              reference,
			              ToRectEdge (orientation));
		}
        public virtual void PopoverDidClose(NSNotification notification)
        {
            NSString closeReason = notification.UserInfo.ValueForKey<NSString> (NSPopover.NSPopoverCloseReasonKey);
            if (closeReason != null) {
                // closeReason can be:
                //      NSPopoverCloseReasonStandard
                //      NSPopoverCloseReasonDetachToWindow
            }

            this.myPopover.Release ();
            this.myPopover = null;
        }
示例#15
0
		public void Show (Xwt.Popover.Position orientation, Xwt.Widget referenceWidget, Xwt.Rectangle positionRect, Xwt.Widget child)
		{
			popover = MakePopover (child);
			ViewBackend backend = (ViewBackend)Toolkit.GetBackend (referenceWidget);
			var reference = backend.Widget;
			popover.Show (positionRect.ToRectangleF (),
			              reference,
			              ToRectEdge (orientation));
		}
        public void CreatePopover()
        {
            if (this.myPopover == null) {
                // create and setup our popover
                this.myPopover = new NSPopover ();

                // the popover retains us and we retain the popover,
                // we drop the popover whenever it is closed to avoid a cycle
                //
                // use a different view controller content if normal vs. HUD appearance
                //
                if (this.popoverType.SelectedRow == 0) {
                    this.myPopover.ContentViewController = this.popoverViewController;
                } else {
                    this.myPopover.ContentViewController = this.popoverViewControllerHUD;
                }
                this.myPopover.Appearance = (NSPopoverAppearance)(int)this.popoverType.SelectedRow;
                this.myPopover.Animates = (this.animatesCheckbox.State == NSCellStateValue.NSOnState);

                // AppKit will close the popover when the user interacts with a user interface element outside the popover.
                // note that interacting with menus or panels that become key only when needed will not cause a transient popover to close.
                this.myPopover.Behavior = NSPopoverBehavior.NSPopoverBehaviorTransient;

                // so we can be notified when the popover appears or closes
                this.myPopover.Delegate = this;
            }
        }
示例#17
0
 public ServerInfoPopOverController(VMCAServerNode node, NSPopover popover) : base("ServerInfoPopOver", NSBundle.MainBundle)
 {
     this.parentPopover = popover;
     this.serverNode    = node;
 }
示例#18
0
 public void Show(Xwt.Popover.Position orientation, Xwt.Widget referenceWidget, Xwt.Rectangle positionRect, Xwt.Widget child)
 {
     var controller = new FactoryViewController (child);
     popover = new NSPopover ();
     popover.Behavior = NSPopoverBehavior.Transient;
     popover.ContentViewController = controller;
     IMacViewBackend backend = (IMacViewBackend)Toolkit.GetBackend (referenceWidget);
     var reference = backend.View;
     popover.Show (System.Drawing.RectangleF.Empty,
                   reference,
                   ToRectEdge (orientation));
 }
示例#19
0
		void CreatePopoverForLayer (CALayer layer)
		{
			popover = new NSPopover {
				ContentViewController = new NSViewController (null, null),
				Animates = false
			};

			string tooltip = layerToStatus [layer.Name].ToolTip;
			if (tooltip == null)
				return;

			var attrString = GetPopoverString (tooltip);

			var height = attrString.BoundingRectWithSize (new CGSize (230, nfloat.MaxValue),
				NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin).Height;
			
			popover.ContentViewController.View = new NSTextField {
				Frame = new CGRect (0, 0, 230, height + 14),
				DrawsBackground = false,
				Bezeled = true,
				Editable = false,
				Cell = new VerticallyCenteredTextFieldCell (yOffset: -1),
			};
			((NSTextField)popover.ContentViewController.View).AttributedStringValue = attrString;
		}
        //ToolBar Events

        partial void ShowServerInfo (NSObject sender)
        {
            var popover = new NSPopover ();
            popover.Behavior = NSPopoverBehavior.Transient;
            popover.ContentViewController = new ServerInfoPopOverController (this.Servernode, popover);
            popover.Show (CoreGraphics.CGRect.Empty, (NSView)sender, NSRectEdge.MinYEdge);
        }
 public ServerInfoPopOverController (VMCAServerNode node, NSPopover popover) : base ("ServerInfoPopOver", NSBundle.MainBundle)
 {
     this.parentPopover = popover;
     this.serverNode = node;
 }
示例#22
0
		void CreatePopoverCommon (nfloat width, string text)
		{
			popover = new NSPopover {
				ContentViewController = new NSViewController (null, null),
				Animates = false
			};

			var attrString = GetPopoverString (text);

			var height = attrString.BoundingRectWithSize (new CGSize (width, nfloat.MaxValue),
				NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin).Height;
			
			popover.ContentViewController.View = new NSTextField {
				Frame = new CGRect (0, 0, width, height + 14),
				DrawsBackground = false,
				Bezeled = true,
				Editable = false,
				Cell = new VerticallyCenteredTextFieldCell (yOffset: -1),
			};
			((NSTextField)popover.ContentViewController.View).AttributedStringValue = attrString;
		}
 public bool ShouldDetach(NSPopover popover) => true;
示例#24
0
		void HandleViewBookmarksBtnActivated (object sender, EventArgs e)
		{
			if (!AppDelegate.IsOnLion) {
				ShowNonLionAlert ();
				return;
			}
			var popover = new NSPopover ();
			popover.Behavior = NSPopoverBehavior.Transient;
			popover.ContentViewController = new BookmarkAssistantController (AppDelegate.BookmarkManager.GetAllBookmarks ());
			popover.Show (new RectangleF (0, 0, 0, 0), viewBookmarksBtn, NSRectEdge.MinYEdge);
		}
示例#25
0
		public void Show (Xwt.Popover.Position orientation, Xwt.Widget referenceWidget, Xwt.Rectangle positionRect, Xwt.Widget child)
		{
			popover = MakePopover (child, BackgroundColor);
			ViewBackend backend = (ViewBackend)Toolkit.GetBackend (referenceWidget);
			var reference = backend.Widget;

			// If the position rect is empty, the coordinates of the rect will be ignored.
			// Width and Height of the rect must be > Epsilon, for the positioning to function correctly.
			if (Math.Abs (positionRect.Width) < double.Epsilon)
				positionRect.Width = 1;
			if (Math.Abs (positionRect.Height) < double.Epsilon)
				positionRect.Height = 1;

			popover.Show (positionRect.ToCGRect (),
			              reference,
			              ToRectEdge (orientation));
		}
示例#26
0
		void HandleAddBookmarkBtnActivated (object sender, EventArgs e)
		{
			var title = string.IsNullOrWhiteSpace (currentTitle) ? "No Title" : currentTitle;
			
			var entry = new BookmarkManager.Entry () { Name = title, Url = currentUrl, Notes = string.Empty };
			AppDelegate.BookmarkManager.AddBookmark (entry);
			var popover = new NSPopover ();
			popover.Behavior = NSPopoverBehavior.Transient;
			popover.ContentViewController = new BookmarkPopoverController (popover, entry);
			popover.Show (new RectangleF (0, 0, 0, 0), (NSView)sender, NSRectEdge.MinYEdge);
		}
        void GuiFirewallSwitchControl_ValueChanged(object sender, EventArgs e)
        {
            if (__MainViewModel != null)
            {
                if (__MainViewModel.IsKillSwitchEnabled != GuiFirewallSwitchControl.Value)
                {
                    __MainViewModel.IsKillSwitchEnabled = GuiFirewallSwitchControl.Value;
                }
            }

            // If VPN is ON but Firewall is off - show notification:
            // e.g."We recommend you to keep it always turned on when you are connected to VPN."
            CustomSwitchControl switchCtrl = sender as CustomSwitchControl;

            if (__MainViewModel.IsKillSwitchEnabled == false &&
                __MainViewModel.ConnectionState != ServiceState.Disconnected &&
                switchCtrl != null)
            {
                if (__GuiPopoverFirewallIsOff == null)
                {
                    // create and show popover
                    __GuiPopoverFirewallIsOff = new NSPopover();
                    NSViewController popoverController = new NSViewController();
                    popoverController.View = GuiFirewallOffInfoView;

                    __GuiPopoverFirewallIsOff.ContentViewController = popoverController;
                    __GuiPopoverFirewallIsOff.Behavior   = NSPopoverBehavior.Transient;
                    __GuiPopoverFirewallIsOff.Appearance = NSPopoverAppearance.HUD;

                    // auto-close after 6 seconds inteval
                    __TimerAutoClosePopoverFirewall = new Timer()
                    {
                        Interval = 6000, AutoReset = false
                    };
                    __TimerAutoClosePopoverFirewall.Elapsed += (theSender, evt) =>
                    {
                        InvokeOnMainThread(() =>
                        {
                            try
                            {
                                if (__GuiPopoverFirewallIsOff != null && __GuiPopoverFirewallIsOff.Shown)
                                {
                                    __GuiPopoverFirewallIsOff.Close();
                                }
                            }
                            catch { }
                        });
                    };
                }

                __TimerAutoClosePopoverFirewall.Stop();
                __GuiPopoverFirewallIsOff.Show(switchCtrl.Bounds, switchCtrl, NSRectEdge.MinYEdge);
                __TimerAutoClosePopoverFirewall.Start();
            }
            else
            {
                if (__GuiPopoverFirewallIsOff != null)
                {
                    __GuiPopoverFirewallIsOff.Close();
                }
            }
        }