Ejemplo n.º 1
0
        /// <summary>
        /// Initialise a NSStatusItem instance with an image, popover and event handling.
        /// </summary>
        /// <param name="image">Image.</param>
        /// <param name="popOver">Pop over.</param>
        public void InitStatusBarItem(string image, NSPopover popOver)
        {
            button = statusItem.Button;
            NSImage _image = new NSImage(image)
            {
                Template = true
            };

            button.Image  = _image;
            button.Action = new ObjCRuntime.Selector("toggle:");
            button.Target = this;

            this.popOver = popOver;

            eventMonitor = new EventMonitor((NSEventMask.LeftMouseDown | NSEventMask.RightMouseDown), MouseEventHandler);
            eventMonitor.Start();
        }
Ejemplo n.º 2
0
        public StatusBarHelper(NSPopover popover, string image)
        {
            //Initialisation
            statusBar  = new NSStatusBar();
            statusItem = statusBar.CreateStatusItem(NSStatusItemLength.Variable);

            button       = statusItem.Button;
            button.Image = new NSImage(image)
            {
                Template = true
            };

            button.Action = new ObjCRuntime.Selector("toggle:");
            button.Target = this;

            this.popover = popover;

            eventMonitor = new EventMonitor((NSEventMask.LeftMouseDown | NSEventMask.RightMouseDown), MouseEventHandler);
            eventMonitor.Start();
        }
Ejemplo n.º 3
0
        // Call to load from the XIB/NIB file
        public MainWindowController() : base("MainWindow")
        {
            Initialize();

            _newServer = new ConnectivityServer(true);
            _newServer.OnClientAskForConnection += _newServer_OnClientAskForConnection;
            _newServer.ClientConnected          += _newServer_ClientConnected;
            _newServer.ClientDisconnected       += _newServer_ClientDisconnected;
            _newServer.OnMessageReceived        += HandleOnMessageReceived;
            _newServer.StartServer();

            NSStatusItem sItem = NSStatusBar.SystemStatusBar.CreateStatusItem(25);

            NSStatusBarButton statBtn = sItem.Button;

            statBtn.Image = NSImage.ImageNamed("tbar_BarIcon");

            statBtn.Activated += (sender, e) => {
                NSApplication app = NSApplication.SharedApplication;
                app.ActivateIgnoringOtherApps(true);

                this.Window.MakeKeyAndOrderFront(null);
            };
        }
Ejemplo n.º 4
0
 void ShowPopover(NSObject sender)
 {
     button = statusItem.Button;
     popover.Show(button.Bounds, button, NSRectEdge.MaxYEdge);
     eventMonitor.Start();
 }