Example #1
0
        public DialogResult ShowDialog(Window parent)
        {
            var parentWindow = parent?.ParentWindow.ControlObject as NSWindow ?? NSApplication.SharedApplication.KeyWindow;

            if (parentWindow != null)
            {
                Control.ParentWindow = parentWindow;
            }

            var selectedFont = Font.ToNS() ?? NSFont.UserFontOfSize(NSFont.SystemFontSize);
            var helper       = FontDialogHelper.Instance = new FontDialogHelper {
                Handler = this, Font = selectedFont
            };

            if (parentWindow != null && parentWindow == NSApplication.SharedApplication.ModalWindow)
            {
                NSNotificationCenter.DefaultCenter.AddObserver(helper, new Selector("modalClosed:"), new NSString("NSWindowWillCloseNotification"), parentWindow);
            }

            var manager = NSFontManager.SharedFontManager;

            manager.Target       = null;
            manager.Action       = new Selector("changeFont:"); // in case it was set to something else
            Control.Delegate     = helper;
            manager.WeakDelegate = helper;                      // using the delegate makes it work with modal dialogs, see: https://stackoverflow.com/a/9506984/981187
            manager.SetSelectedFont(selectedFont, false);

            manager.OrderFrontFontPanel(parentWindow);
            Control.MakeKeyWindow();             // make key so when it loses key we can reset the delegate

            return(DialogResult.None);           // signal that we are returning right away!
        }
Example #2
0
        void UpdateFont()
        {
            var fontSize = (int)Math.Round(Prefs.UI.Font.GetSize());

            Preferences.DefaultFixedFontSize = fontSize;
            Preferences.DefaultFontSize      = fontSize;

            Preferences.FixedFontFamily     = NSFont.UserFixedPitchFontOfSize(0).FontName;
            Preferences.SansSerifFontFamily = NSFont.UserFontOfSize(0).FontName;
        }
Example #3
0
        void PrepareTextAttributes()
        {
            mTextAttributes = new NSMutableDictionary();
            NSFontManager fontManager = NSFontManager.SharedFontManager;
            NSFont        font        = NSFont.UserFontOfSize(75.0f);

            if (Bold)
            {
                font = fontManager.ConvertFont(font, NSFontTraitMask.Bold);
            }
            if (Italic)
            {
                font = fontManager.ConvertFont(font, NSFontTraitMask.Italic);
            }
            mTextAttributes.Add(NSStringAttributeKey.Font, font);
            mTextAttributes.Add(NSStringAttributeKey.ForegroundColor, NSColor.Black);
        }
Example #4
0
        public NSFont CreateFont(float size)
        {
            // we have a postcript name, use that to create the font
            if (!string.IsNullOrEmpty(PostScriptName))
            {
                // if we try to get a system font by name we get errors now..
                if (PostScriptName == SystemFontName)
                {
                    return(NSFont.SystemFontOfSize(size));
                }
                if (PostScriptName == BoldSystemFontName)
                {
                    return(NSFont.BoldSystemFontOfSize(size));
                }

                // always return something...
                var font = NSFont.FromFontName(PostScriptName, size) ?? NSFont.UserFontOfSize(size);
                return(font);
            }

            var family = (FontFamilyHandler)Widget.Family.Handler;

            return(FontHandler.CreateFont(family.MacName, size, Traits, Weight));
        }
Example #5
0
        public override NSMenu MenuForEvent(NSEvent theEvent)
        {
            CGPoint pt  = this.ConvertPointToView(theEvent.LocationInWindow, null);
            int     row = (int)this.GetRow(pt);

            if (row >= 0)
            {
                NSObject obj = this.ItemAtRow(row);
                if (obj != null)
                {
                    NSMenu menu = new NSMenu();
                    menu.Font = NSFont.UserFontOfSize((float)12.0);
                    if (obj is ServerNode)
                    {
                        ServerNode serverNode = obj as ServerNode;
                        if (serverNode.IsLoggedIn)
                        {
//							NSMenuItem logout = new NSMenuItem ("Logout", serverNode.OnLogout);
//
//							var image = NSImage.ImageNamed ("NSLockLockedTemplate");
//							logout.Image = image;
//							logout.Image.Size = new CGSize{ Width = (float)16.0, Height = (float)16.0 };
//							menu.AddItem (logout);

                            NSMenuItem addNewTenant = new NSMenuItem("Add New Tenant", serverNode.OnAddNewTenant);
                            var        image        = NSImage.ImageNamed("NSAddTemplate");
                            addNewTenant.Image      = image;
                            addNewTenant.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(addNewTenant);

//							NSMenuItem addExistingTenant = new NSMenuItem ("Add Existing Tenant", serverNode.OnAddExistingTenant);
//							image = NSImage.ImageNamed ("NSAddTemplate");
//							addExistingTenant.Image = image;
//							addExistingTenant.Image.Size = new CGSize{ Width = (float)16.0, Height = (float)16.0 };
//							menu.AddItem (addExistingTenant);

                            NSMenuItem activeDirectory = new NSMenuItem("Active Directory", serverNode.OnShowActiveDirectory);
                            image = NSImage.ImageNamed("NSNetwork");
                            activeDirectory.Image      = image;
                            activeDirectory.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(activeDirectory);

                            NSMenuItem getComputers = new NSMenuItem("Computers", serverNode.OnShowComputers);
                            image = NSImage.ImageNamed("NSComputer");
                            getComputers.Image      = image;
                            getComputers.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(getComputers);

                            NSMenuItem tokenWizard = new NSMenuItem("Diagnostics", serverNode.ShowTokenWizard);
                            image                  = NSImage.ImageNamed("NSRevealFreestandingTemplate");
                            tokenWizard.Image      = image;
                            tokenWizard.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(tokenWizard);

//							NSMenuItem httpTransport = new NSMenuItem ("Show HTTP Transport", serverNode.ShowHttpTransport);
//							image = NSImage.ImageNamed ("NSBookmarksTemplate");
//							httpTransport.Image = image;
//							httpTransport.Image.Size =  new CGSize{ Width = (float)16.0, Height = (float)16.0 };
//							menu.AddItem (httpTransport);
                        }
//						else {
//							NSMenuItem login = new NSMenuItem ("Login", serverNode.OnLogin);
//							var image = NSImage.ImageNamed ("NSLockLockedTemplate");
//							login.Image = image;
//							login.Image.Size = new CGSize{ Width = (float)16.0, Height = (float)16.0 };
//							menu.AddItem (login);
//
//							NSMenuItem delete = new NSMenuItem ("Delete", serverNode.DeleteServer);
//							image = NSImage.ImageNamed ("NSTrashFull");
//							delete.Image = image;
//							delete.Image.Size = new CGSize{ Width = (float)16.0, Height = (float)16.0 };
//							menu.AddItem (delete);
//						}
                    }
                    else if (obj is TenantNode)
                    {
                        TenantNode tenantNode = obj as TenantNode;
//						NSMenuItem deleteTenant = new NSMenuItem ("Delete", tenantNode.Delete);
//						var image = NSImage.ImageNamed ("Delete_Object_64.png");
//						deleteTenant.Image = image;
//						deleteTenant.Image.Size =  new CGSize{ Width = (float)16.0, Height = (float)16.0 };
//						menu.AddItem (deleteTenant);

                        NSMenuItem showConfig = new NSMenuItem("Tenant Configuration", tenantNode.ShowConfiguration);
                        var        image      = NSImage.ImageNamed("config.png");
                        showConfig.Image      = image;
                        showConfig.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(showConfig);
                    }
                    else if (obj is IdentitySourcesNode)
                    {
                        IdentitySourcesNode identitySources = obj as IdentitySourcesNode;

                        NSMenuItem refreshSource = new NSMenuItem("Refresh", identitySources.Refresh);
                        var        image         = NSImage.ImageNamed("NSRefresh");
                        refreshSource.Image      = image;
                        refreshSource.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(refreshSource);
                    }
                    else if (obj is IdentitySourceNode)
                    {
                        IdentitySourceNode identitySourceNode = obj as IdentitySourceNode;

                        NSMenuItem refreshSource = new NSMenuItem("Refresh", identitySourceNode.Refresh);
                        var        image         = NSImage.ImageNamed("NSRefresh");
                        refreshSource.Image      = image;
                        refreshSource.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(refreshSource);

                        if (!identitySourceNode.IsDefaultDomain)
                        {
                            NSMenuItem setAsDefault = new NSMenuItem("Set as default domain", identitySourceNode.SetAsDefault);
                            menu.AddItem(setAsDefault);
                        }
                    }
                    else if (obj is UsersNode)
                    {
                        UsersNode  node = obj as UsersNode;
                        NSMenuItem item = null;
                        if (node.IsSystemDomain)
                        {
                            item = new NSMenuItem("Add New User", node.AddNewUser);
                            var image1 = NSImage.ImageNamed("Add_User_64.png");
                            item.Image      = image1;
                            item.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(item);
                        }
                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is SolutionUsersNode)
                    {
                        SolutionUsersNode node = obj as SolutionUsersNode;
                        NSMenuItem        item = null;

                        if (node.IsSystemDomain)
                        {
                            item = new NSMenuItem("Add New Solution User", node.AddNewUser);
                            var image1 = NSImage.ImageNamed("Add_User_64.png");
                            item.Image      = image1;
                            item.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(item);
                        }

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is GroupsNode)
                    {
                        GroupsNode node = obj as GroupsNode;
                        NSMenuItem item = null;

                        if (node.IsSystemDomain)
                        {
                            item = new NSMenuItem("Add New Group", node.AddNewGroup);
                            var image1 = NSImage.ImageNamed("Add_Group_64.png");
                            item.Image      = image1;
                            item.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(item);
                        }

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is RelyingPartyNode)
                    {
                        RelyingPartyNode node = obj as RelyingPartyNode;
                        NSMenuItem       item = null;

                        item = new NSMenuItem("Add Relying Party", node.AddRelyingParty);
                        var image1 = NSImage.ImageNamed("NSAddTemplate");
                        item.Image      = image1;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is OidcClientNode)
                    {
                        OidcClientNode node = obj as OidcClientNode;
                        NSMenuItem     item = null;

                        item = new NSMenuItem("Add OIDC Client", node.AddOidcClient);
                        var image1 = NSImage.ImageNamed("NSAddTemplate");
                        item.Image      = image1;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is IdentityProvidersNode)
                    {
                        IdentityProvidersNode node = obj as IdentityProvidersNode;
                        NSMenuItem            item = null;

                        item = new NSMenuItem("Add External Identity Provider", node.AddExternalIdentityProvider);
                        menu.AddItem(item);

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is TrustedCertificateNode)
                    {
                        TrustedCertificateNode node = obj as TrustedCertificateNode;
                        NSMenuItem             item = null;

                        item = new NSMenuItem("Add Certificate Chain", node.AddCertificateChain);
                        var image = NSImage.ImageNamed("certificate.png");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

                        item            = new NSMenuItem("Refresh", node.Refresh);
                        image           = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is ExternalDomainsNode)
                    {
                        ExternalDomainsNode node = obj as ExternalDomainsNode;
                        NSMenuItem          item = null;

                        item = new NSMenuItem("Add New External Domain", node.AddNewExternalDomain);
                        var image1 = NSImage.ImageNamed("NSAddTemplate");
                        item.Image      = image1;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is ExternalDomainNode)
                    {
                        ExternalDomainNode node = obj as ExternalDomainNode;
                        NSMenuItem         item = null;

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

                        item            = new NSMenuItem("Properties", node.View);
                        image           = NSImage.ImageNamed("config.png");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

//						item = new NSMenuItem ("Delete", node.Delete);
//						image = NSImage.ImageNamed ("NSTrashFull");
//						item.Image = image;
//						item.Image.Size =  new CGSize{ Width = (float)16.0, Height = (float)16.0 };
//						menu.AddItem (item);
                    }
                    NSMenu.PopUpContextMenu(menu, theEvent, theEvent.Window.ContentView);
                }
            }
            return(base.MenuForEvent(theEvent));
        }
Example #6
0
        public override NSMenu MenuForEvent(NSEvent theEvent)
        {
            CGPoint pt  = this.ConvertPointToView(theEvent.LocationInWindow, null);
            int     row = (int)this.GetRow(pt);

            if (row >= 0)
            {
                NSObject obj = this.ItemAtRow(row);
                if (obj != null)
                {
                    NSMenu menu = new NSMenu();
                    menu.Font = NSFont.UserFontOfSize((float)12.0);
                    if (obj is ServerNode)
                    {
                        ServerNode serverNode = obj as ServerNode;
                        if (serverNode.IsLoggedIn)
                        {
                            NSMenuItem addNewTenant = new NSMenuItem("Add New Tenant", serverNode.OnAddNewTenant);
                            var        image        = NSImage.ImageNamed("NSAddTemplate");
                            addNewTenant.Image      = image;
                            addNewTenant.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(addNewTenant);

                            NSMenuItem aboutServer = new NSMenuItem("About", serverNode.OnShowAbout);
                            image                  = NSImage.ImageNamed("NSInfo");
                            aboutServer.Image      = image;
                            aboutServer.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(aboutServer);

                            var enable = serverNode != null && serverNode.Children.Count > 0 && ((TenantNode)serverNode.Children [0]).IsSystemTenant;

                            if (enable)
                            {
                                NSMenuItem getComputers = new NSMenuItem("Computers", serverNode.OnShowComputers);
                                image = NSImage.ImageNamed("NSComputer");
                                getComputers.Image      = image;
                                getComputers.Image.Size = new CGSize {
                                    Width = (float)16.0, Height = (float)16.0
                                };
                                menu.AddItem(getComputers);
                            }

                            NSMenuItem tokenWizard = new NSMenuItem("Diagnostics", serverNode.ShowTokenWizard);
                            image                  = NSImage.ImageNamed("NSSmartBadgeTemplate");
                            tokenWizard.Image      = image;
                            tokenWizard.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(tokenWizard);
                        }
                    }
                    else if (obj is TenantNode)
                    {
                        TenantNode tenantNode = obj as TenantNode;
                        NSMenuItem showConfig = new NSMenuItem("Tenant Configuration", tenantNode.ShowConfiguration);
                        var        image      = NSImage.ImageNamed("config.png");
                        showConfig.Image      = image;
                        showConfig.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(showConfig);
                    }
                    else if (obj is IdentitySourcesNode)
                    {
                        IdentitySourcesNode identitySources = obj as IdentitySourcesNode;

                        NSMenuItem refreshSource = new NSMenuItem("Refresh", identitySources.Refresh);
                        var        image         = NSImage.ImageNamed("NSRefresh");
                        refreshSource.Image      = image;
                        refreshSource.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(refreshSource);
                    }
                    else if (obj is IdentitySourceNode)
                    {
                        IdentitySourceNode identitySourceNode = obj as IdentitySourceNode;

                        NSMenuItem refreshSource = new NSMenuItem("Refresh", identitySourceNode.Refresh);
                        var        image         = NSImage.ImageNamed("NSRefresh");
                        refreshSource.Image      = image;
                        refreshSource.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(refreshSource);

                        if (!identitySourceNode.IsDefaultDomain)
                        {
                            NSMenuItem setAsDefault = new NSMenuItem("Set as default domain", identitySourceNode.SetAsDefault);
                            menu.AddItem(setAsDefault);
                        }
                    }
                    else if (obj is UsersNode)
                    {
                        UsersNode  node = obj as UsersNode;
                        NSMenuItem item = null;
                        if (node.IsSystemDomain)
                        {
                            item = new NSMenuItem("Add New User", node.AddNewUser);
                            var image1 = NSImage.ImageNamed("Add_User_64.png");
                            item.Image      = image1;
                            item.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(item);
                        }
                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is SolutionUsersNode)
                    {
                        SolutionUsersNode node = obj as SolutionUsersNode;
                        NSMenuItem        item = null;

                        if (node.IsSystemDomain)
                        {
                            item = new NSMenuItem("Add New Solution User", node.AddNewUser);
                            var image1 = NSImage.ImageNamed("Add_User_64.png");
                            item.Image      = image1;
                            item.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(item);
                        }

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is GroupsNode)
                    {
                        GroupsNode node = obj as GroupsNode;
                        NSMenuItem item = null;

                        if (node.IsSystemDomain)
                        {
                            item = new NSMenuItem("Add New Group", node.AddNewGroup);
                            var image1 = NSImage.ImageNamed("Add_Group_64.png");
                            item.Image      = image1;
                            item.Image.Size = new CGSize {
                                Width = (float)16.0, Height = (float)16.0
                            };
                            menu.AddItem(item);
                        }

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is RelyingPartyNode)
                    {
                        RelyingPartyNode node = obj as RelyingPartyNode;
                        NSMenuItem       item = null;

                        item = new NSMenuItem("Add Relying Party", node.AddRelyingParty);
                        var image1 = NSImage.ImageNamed("NSAddTemplate");
                        item.Image      = image1;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is OidcClientNode)
                    {
                        OidcClientNode node = obj as OidcClientNode;
                        NSMenuItem     item = null;

                        item = new NSMenuItem("Add OIDC Client", node.AddOidcClient);
                        var image1 = NSImage.ImageNamed("NSAddTemplate");
                        item.Image      = image1;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is IdentityProvidersNode)
                    {
                        IdentityProvidersNode node = obj as IdentityProvidersNode;
                        NSMenuItem            item = null;

                        item = new NSMenuItem("Add External Identity Provider", node.AddExternalIdentityProvider);
                        menu.AddItem(item);

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is TrustedCertificateNode)
                    {
                        TrustedCertificateNode node = obj as TrustedCertificateNode;
                        NSMenuItem             item = null;

                        item = new NSMenuItem("Add Certificate Chain", node.AddCertificateChain);
                        var image = NSImage.ImageNamed("certificate.png");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

                        item            = new NSMenuItem("Refresh", node.Refresh);
                        image           = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is ExternalDomainsNode)
                    {
                        ExternalDomainsNode node = obj as ExternalDomainsNode;
                        NSMenuItem          item = null;

                        item = new NSMenuItem("Add New External Domain", node.AddNewExternalDomain);
                        var image1 = NSImage.ImageNamed("NSAddTemplate");
                        item.Image      = image1;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    else if (obj is ExternalDomainNode)
                    {
                        ExternalDomainNode node = obj as ExternalDomainNode;
                        NSMenuItem         item = null;

                        item = new NSMenuItem("Refresh", node.Refresh);
                        var image = NSImage.ImageNamed("NSRefresh");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);

                        item            = new NSMenuItem("Properties", node.View);
                        image           = NSImage.ImageNamed("config.png");
                        item.Image      = image;
                        item.Image.Size = new CGSize {
                            Width = (float)16.0, Height = (float)16.0
                        };
                        menu.AddItem(item);
                    }
                    NSMenu.PopUpContextMenu(menu, theEvent, theEvent.Window.ContentView);
                }
            }
            return(base.MenuForEvent(theEvent));
        }