Example #1
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            var    isRetina            = NSScreen.MainScreen.BackingScaleFactor > 1.0;
            string statusItemImageName = $"StatusBarImage{(isRetina ? "@2x" : "")}.png";

            _statusItem        = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusItemLength.Variable);
            _statusItem.Image  = new NSImage(statusItemImageName);
            _statusItem.Target = this;
            _statusItem.Action = new ObjCRuntime.Selector("MenuAction");

            var container = TinyIoCContainer.Current;

            RegisterServices(container);
            UseRepositoryMonitor(container);

            _pop          = new NSPopover();
            _pop.Behavior = NSPopoverBehavior.Transient;
            _pop.Delegate = this;
            _pop.ContentViewController = new PopupViewController();

            _eventMonitor = NSEvent.AddGlobalMonitorForEventsMatchingMask(NSEventMask.KeyDown, HandleGlobalEventHandler);

            _updateTimer = new Timer(CheckForUpdatesAsync, null, 5000, Timeout.Infinite);

            _ipcServer = new IpcServer(new DefaultIpcEndpoint(), this);
            _ipcServer.Start();
        }
Example #2
0
        public StatusIcon() : base() {
            using (var a = new NSAutoreleasePool()) {
                this.CreateAnimationFrames();

                this.status_item = NSStatusBar.SystemStatusBar.CreateStatusItem(28);
                this.status_item.HighlightMode = true;
                this.status_item.Image = this.animation_frames[0];

                this.status_item.Image               = this.animation_frames[0];
                this.status_item.Image.Size          = new SizeF(16, 16);
                this.status_item.AlternateImage      = this.animation_frames_active[0];
                this.status_item.AlternateImage.Size = new SizeF(16, 16);

                this.CreateMenu();
            }

            this.Controller.UpdateIconEvent += delegate(int icon_frame) {
                using (var a = new NSAutoreleasePool()) {
                    BeginInvokeOnMainThread(delegate {
                        if (icon_frame > -1) {
                            this.status_item.Image               = this.animation_frames[icon_frame];
                            this.status_item.Image.Size          = new SizeF(16, 16);
                            this.status_item.AlternateImage      = this.animation_frames_active[icon_frame];
                            this.status_item.AlternateImage.Size = new SizeF(16, 16);

                        } else {
                            this.status_item.Image               = this.error_image;
                            this.status_item.AlternateImage      = this.error_image_active;
                            this.status_item.Image.Size          = new SizeF(16, 16);
                            this.status_item.AlternateImage.Size = new SizeF(16, 16);
                        }
                    });
                }
            };

            this.Controller.UpdateMenuEvent += delegate {
                using (var a = new NSAutoreleasePool()) {
                    this.InvokeOnMainThread(() => this.CreateMenu());
                }
            };

            this.Controller.UpdateSuspendSyncFolderEvent += delegate(string reponame) {
                using (var a = new NSAutoreleasePool()){
                    this.InvokeOnMainThread(delegate {
                        foreach (var repoItem in this.repoItems) {
                            if (repoItem.RepositoryName == reponame) {
                                foreach (var repo in Program.Controller.Repositories) {
                                    if (repo.Name.Equals(reponame)) {
                                        repoItem.Status = repo.Status;
                                        break;
                                    }
                                }

                                break;
                            }
                        }
                    });
                }
            };
        }
Example #3
0
        public TrayIcon()
        {
            NSStatusBar bar = new NSStatusBar();

            _trayIcon          = bar.CreateStatusItem(NSStatusItemLength.Square);
            _trayIcon.Behavior = NSStatusItemBehavior.RemovalAllowed;
        }
Example #4
0
		public override void AwakeFromNib ()
		{
			statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (-1);
			statusItem.Menu = statusMenu;
			statusItem.Image = NSImage.ImageNamed ("homestatus");
			statusItem.HighlightMode = true;
		}
Example #5
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            var isRetina        = NSScreen.MainScreen.BackingScaleFactor > 1.0;
            var isBigSurOrNewer = NSProcessInfo.ProcessInfo.IsOperatingSystemAtLeastVersion(new NSOperatingSystemVersion(11, 0, 0));

            string statusItemImageName = $"StatusBarImage{(isBigSurOrNewer ? "Template" : "")}{(isRetina ? "@2x" : "")}.png";

            _statusItem       = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusItemLength.Variable);
            _statusItem.Image = new NSImage(statusItemImageName)
            {
                Template = isBigSurOrNewer
            };                                                                                               // defining as template will make the icon work in light/dark mode and reduced transparency (see #137)
            _statusItem.Target = this;
            _statusItem.Action = new ObjCRuntime.Selector("MenuAction");

            var container = TinyIoCContainer.Current;

            RegisterServices(container);
            UseRepositoryMonitor(container);

            _pop          = new NSPopover();
            _pop.Behavior = NSPopoverBehavior.Transient;
            _pop.Delegate = this;
            _pop.ContentViewController = new PopupViewController();

            _eventMonitor = NSEvent.AddGlobalMonitorForEventsMatchingMask(NSEventMask.KeyDown, HandleGlobalEventHandler);

            _updateTimer = new Timer(CheckForUpdatesAsync, null, 5000, Timeout.Infinite);

            _ipcServer = new IpcServer(new DefaultIpcEndpoint(), this);
            _ipcServer.Start();
        }
        public override void DidFinishLaunching(NSNotification notification)
        {
            LocalExtensionManager = new ExtensionManager("com.userfilesystem.vfs.app", "ITHitFS6");

            NSMenu menu = new NSMenu();

            NSMenuItem installMenuItem   = new NSMenuItem("Install FS Extension", (a, b) => { LocalExtensionManager.InstallExtension(); });
            NSMenuItem uninstallMenuItem = new NSMenuItem("Uninstall FS Extension", (a, b) => { LocalExtensionManager.UninstallExtension(); });
            NSMenuItem exitMenuItem      = new NSMenuItem("Quit", (a, b) => { NSApplication.SharedApplication.Terminate(this); });

            menu.AddItem(installMenuItem);
            menu.AddItem(uninstallMenuItem);
            menu.AddItem(exitMenuItem);

            StatusItem               = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
            StatusItem.Menu          = menu;
            StatusItem.Image         = NSImage.ImageNamed("TrayIcon.png");
            StatusItem.HighlightMode = true;

            NSDictionary userData = AppGroupSettings.SaveSharedSettings("appsettings.json");

            if (!Directory.Exists(userData[AppGroupSettings.LocalPathId] as NSString))
            {
                NSAlert alert = NSAlert.WithMessage("Path is not found", null, null, null, "");
                alert.RunModal();

                NSApplication.SharedApplication.Terminate(this);
            }
        }
        public MonoMacTrayApplication(IReport errorHandler, IObservable <Icon> icon, IObservable <string> title, Menu menu)
        {
            // Display tray icon in upper-right-hand corner of the screen
            _item = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
            _item.HighlightMode = true;

            // Remove the system tray icon from upper-right hand corner of the screen
            // (works without adjusting the LSUIElement setting in Info.plist)
            NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Accessory;

            _notifier = new MonoMacNotifier(NSUserNotificationCenter.DefaultUserNotificationCenter, errorHandler);

            UserClicked = DataBinding.ObservableFromNativeEvent <EventArgs>(_item, "DoubleClick").Select(_ => 1);

            if (menu != default(Menu))
            {
                MenuBuilder.CreateMenu(menu, errorHandler).ToObservable().Subscribe(m =>
                                                                                    Fusion.Application.MainThread.InvokeAsync(() => _item.Menu = m));
            }

            if (icon != null)
            {
                icon.Subscribe(i => MainThread.BeginInvoke(() => SetIcon(i)));
            }

            if (title != null)
            {
                title.Subscribe(t => MainThread.BeginInvoke(() => SetTitle(t)));
            }

            ((AppDelegate)NSApplication.SharedApplication.Delegate).Terminates.Subscribe(_ => Dispose());
        }
Example #8
0
        private void CreateNsMenu()
        {
            var menu = new NSMenu();

            statusItem               = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
            statusItem.Menu          = menu;
            statusItem.Image         = NSImage.ImageNamed("statusicon");
            statusItem.HighlightMode = true;

            menu.RemoveAllItems();

            browseMenuItem = new NSMenuItem("Browse Media Library", "b", delegate {
                Browse(NSApplication.SharedApplication);
            });
            menu.AddItem(browseMenuItem);

            configureMenuItem = new NSMenuItem("Configure Media Browser", "c", delegate {
                Configure(NSApplication.SharedApplication);
            });
            menu.AddItem(configureMenuItem);

            communityMenuItem = new NSMenuItem("Visit Community", "v", delegate {
                Community(NSApplication.SharedApplication);
            });
            menu.AddItem(communityMenuItem);

            quitMenuItem = new NSMenuItem("Quit", "q", delegate {
                Quit(NSApplication.SharedApplication);
            });
            menu.AddItem(quitMenuItem);
        }
Example #9
0
        public WindowSidebar()
        {
            PInvokeUtils.RECT rc = new PInvokeUtils.RECT();

            var flags = SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ALPHA |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_MAIN |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ENABLE_DEBUG |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_TOOL;
            var wnd = this;

            wnd.CreateWindow(rc, flags);
            wnd.Title = Consts.AppName;

            var deleg = new WindowDelegate();

            wnd._nsview.Window.Delegate  = deleg;
            wnd._nsview.Window.Level     = NSWindowLevel.Floating;
            wnd._nsview.Window.StyleMask = wnd._nsview.Window.StyleMask & ~NSWindowStyle.Resizable;

            // Create status bar item
            _sItem       = NSStatusBar.SystemStatusBar.CreateStatusItem(26);
            _sItem.Image = NSImage.FromStream(File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/drop.png"));
            //_sItem.AlternateImage = NSImage.FromStream(File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/icon_menubarX2.png"));
            _sItem.Image.Template = true;
            _sItem.Action         = new ObjCRuntime.Selector("OnIconClick");
            _sItem.Target         = deleg;
        }
Example #10
0
		private void CreateNsMenu() {

			var menu = new NSMenu ();

			statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
			statusItem.Menu = menu;
			statusItem.Image = NSImage.ImageNamed("statusicon");
			statusItem.HighlightMode = true;

			menu.RemoveAllItems ();

			browseMenuItem = new NSMenuItem ("Browse Media Library", "b", delegate {
				Browse (NSApplication.SharedApplication);
			});
			menu.AddItem (browseMenuItem);

			configureMenuItem = new NSMenuItem ("Configure Media Browser", "c", delegate {
				Configure (NSApplication.SharedApplication);
			});
			menu.AddItem (configureMenuItem);

			communityMenuItem = new NSMenuItem ("Visit Community", "v", delegate {
				Community (NSApplication.SharedApplication);
			});
			menu.AddItem (communityMenuItem);

			quitMenuItem = new NSMenuItem ("Quit", "q", delegate {
				Quit (NSApplication.SharedApplication);
			});
			menu.AddItem (quitMenuItem);
		}
Example #11
0
        public AppDelegate()
        {
            NSStatusBar  bar        = NSStatusBar.SystemStatusBar;
            NSStatusItem statusItem = bar.CreateStatusItem(NSStatusItemLength.Square);

            ActionCentre = new ApplicationIconActionCenter(statusItem, SynchronizationContext.Current);
        }
Example #12
0
 public override void AwakeFromNib()
 {
     statusItem               = NSStatusBar.SystemStatusBar.CreateStatusItem(-1);
     statusItem.Menu          = statusMenu;
     statusItem.Image         = NSImage.ImageNamed("homestatus");
     statusItem.HighlightMode = true;
 }
Example #13
0
        public WindowSidebar()
        {
            var frm = NSScreen.MainScreen.VisibleFrame;

            PInvokeUtils.RECT rc = new PInvokeUtils.RECT()
            {
                right  = 670,
                bottom = (int)frm.Height - 50
            };

            var flags = SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ALPHA |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_MAIN |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ENABLE_DEBUG |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_TOOL;
            var wnd = this;

            wnd.CreateWindow(rc, flags);
            wnd.Title = Consts.AppName;

            var deleg = new WindowDelegate();

            wnd._nsview.Window.Delegate = deleg;
            wnd._nsview.Window.Level    = NSWindowLevel.Floating;

            // Create status bar item
            _sItem                = NSStatusBar.SystemStatusBar.CreateStatusItem(25);
            _sItem.Image          = NSImage.FromStream(File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/drop.png"));
            _sItem.Image.Template = true;
            _sItem.Action         = new ObjCRuntime.Selector("OnIconClick");
            _sItem.Target         = deleg;
            _sItem.HighlightMode  = true;
        }
Example #14
0
 public void CreateMenuBarIcon()
 {
     StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusItemLength.Variable);
     //StatusItem.Menu = notifyMenu;
     StatusItem.Menu          = MnuTray;
     StatusItem.Image         = NSImage.ImageNamed("menubar_light_red.png");
     StatusItem.HighlightMode = true;
 }
Example #15
0
        private MenuBarHelper()
        {
            this.popOver = new NSPopover();

            this.statusBar = NSStatusBar.SystemStatusBar;
            this.menuItem  = this.statusBar
                             .CreateStatusItem(NSStatusItemLength.Variable);
        }
Example #16
0
 public BaseStatusBarItem()
 {
     _statusItem      = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusItemLength.Variable);
     _statusItem.Menu = new NSMenu
     {
         Delegate = new StatusBarItemMenuDelegate(OnMenuWillOpen, OnMenuDidClose)
     };
 }
Example #17
0
 void InitializeStatusBar()
 {
     // creating the status item with a length of -2 is equivalent to the call
     // [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]
     mainItem = NSStatusBar.SystemStatusBar.CreateStatusItem(-2);
     mainItem.HighlightMode = true;
     mainItem.Menu          = menu;
     mainItem.View          = new StatusItemView(mainItem, ItemDropped);
 }
Example #18
0
        void CreateStatusItems()
        {
            // Create the status bar item
            statusBarItem = PopupMenu.CreateStatusBarItem();
            statusBarItem.Button.Activated += StatusItemActivated;

            // Create the popup
            popup = new PopupMenuItems();
        }
Example #19
0
        public AppDelegate()
        {
            NSStatusBar  bar        = NSStatusBar.SystemStatusBar;
            NSStatusItem statusItem = bar.CreateStatusItem(NSStatusItemLength.Square);

            statusItem.Button.Image = NSImage.ImageNamed(NSImageName.StatusAvailable);

            this.actionCenter = new ApplicationActionCenter(statusItem);
        }
Example #20
0
 public StatusBarController()
 {
     statusBar  = new NSStatusBar();
     statusItem = statusBar.CreateStatusItem(NSStatusItemLength.Variable);
     popOver    = new NSPopover();
     ViewController.QuitButtonClicked    += HandleQuitButtonClicked;
     ViewController.AboutMenuItemClicked += HandleAboutMenuItemClicked;
     storyboard       = NSStoryboard.FromName("Main", null);
     windowController = storyboard.InstantiateControllerWithIdentifier("AboutWindow") as NSWindowController;
 }
Example #21
0
 private void SetStatusItem()
 {
     if (_statusItem == null)
     {
         _statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
     }
     _statusItem.Menu          = statusMenu;
     _statusItem.Image         = NSImage.FromStream(System.IO.File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/icon.icns"));
     _statusItem.HighlightMode = true;
 }
Example #22
0
        public void RemoveTray()
        {
            if (StatusBarItem == null)
            {
                return;
            }

            NSStatusBar.SystemStatusBar.RemoveStatusItem(StatusBarItem);
            StatusBarItem = null;
        }
Example #23
0
        public override NSApplicationTerminateReply ApplicationShouldTerminate(NSApplication sender)
        {
            // Clean up all of the panels, and disposable resources
            if (_statusItem != null)
            {
                _statusItem.Dispose();
                _statusItem = null;
            }

            return NSApplicationTerminateReply.Now;
        }
Example #24
0
        public override void FinishedLaunching(NSObject notification)
        {
            //			mainWindowController = new MainWindowController ();
            //			mainWindowController.Window.MakeKeyAndOrderFront (this);

            // Construct menu that will be displayed when tray icon is clicked
            var notifyMenu = new NSMenu();
            var exitMenuItem = new NSMenuItem("Quit",
                (a,b) => {
                    NSApplication.SharedApplication.Terminate(this);
                    //System.Environment.Exit(0);
                });

            var startMidiModMenuItem = new NSMenuItem("Run",
                (a,b) => { RunMidiMod(); });

            var mappingmodMidiModMenuItem = new NSMenuItem("Mapping Mod",
                (a,b) => { ActivateMappingMod(); });

            statusMenuItem = new NSMenuItem("STATUS",
                (a,b) => {  });
            statusMenuItem.Enabled = false;

            var versionMenuItem = new NSMenuItem("Version 1.0",
                (a,b) => {  });
            versionMenuItem.Enabled = false;

            var seperatorItem = NSMenuItem.SeparatorItem;

            notifyMenu.AutoEnablesItems = false;

            // Just add 'Quit' command
            notifyMenu.AddItem (statusMenuItem);
            notifyMenu.AddItem (versionMenuItem);
            notifyMenu.AddItem (seperatorItem);
            notifyMenu.AddItem (startMidiModMenuItem);
            notifyMenu.AddItem (mappingmodMidiModMenuItem);
            notifyMenu.AddItem(exitMenuItem);

            // Display tray icon in upper-right-hand corner of the screen
            sItem = NSStatusBar.SystemStatusBar.CreateStatusItem(16); //def 16
            sItem.Menu = notifyMenu;
            sItem.Title = "MidiMod";
            sItem.ToolTip = "Midi Mod";
            sItem.Image = NSImage.FromStream(System.IO.File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/9b244f1232672041.icns"));
            sItem.HighlightMode = true;

            UpdateStatus ("Mod not startet");

            // Remove the system tray icon from upper-right hand corner of the screen
             	// (works without adjusting the LSUIElement setting in Info.plist)
            NSApplication.SharedApplication.ActivationPolicy =
                NSApplicationActivationPolicy.Accessory;
        }
Example #25
0
        public override void Init(string[] args)
        {
            NSApplication.Init();
            m_app = NSApplication.SharedApplication;
            m_app.ActivateIgnoringOtherApps(true);

            m_statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(32);
            m_statusItem.HighlightMode = true;

            base.Init(args);
        }
Example #26
0
        public override NSApplicationTerminateReply ApplicationShouldTerminate(NSApplication sender)
        {
            // Clean up all of the panels, and disposable resources
            if (_statusItem != null)
            {
                _statusItem.Dispose();
                _statusItem = null;
            }

            return(NSApplicationTerminateReply.Now);
        }
Example #27
0
        public override void Init(string[] args)
        {
            NSApplication.Init();
            m_app = NSApplication.SharedApplication;
            m_app.ActivateIgnoringOtherApps(true);

            m_statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(32);
            m_statusItem.HighlightMode = true;

            base.Init(args);
        }
 public StatusPanelController(PanelController panelController)
 {
     _panelController = panelController;
     _statusItem      = NSStatusBar.SystemStatusBar.CreateStatusItem(StatusItemViewWidth);
     _statusItemView  = new StatusItemView(_statusItem)
     {
         Image          = NSImage.ImageNamed("Status"),
         AlternateImage = NSImage.ImageNamed("StatusHighlighted")
     };
     _statusItemView.StatusItemClicked += HandleStatusItemClicked;
     _panelController.StatusItemView    = _statusItemView;
 }
 public StatusPanelController(PanelController panelController)
 {
     _panelController = panelController;
     _statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(StatusItemViewWidth);
     _statusItemView = new StatusItemView(_statusItem)
     {
         Image = NSImage.ImageNamed("Status"),
         AlternateImage = NSImage.ImageNamed("StatusHighlighted")
     };
     _statusItemView.StatusItemClicked += HandleStatusItemClicked;
     _panelController.StatusItemView = _statusItemView;
 }
Example #30
0
        public SparkleStatusIcon() : base()
        {
            Animation = CreateAnimation();

            StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(28);
            StatusItem.HighlightMode = true;


            SetNormalState();
            CreateMenu();

            Menu.Delegate = new SparkleStatusIconMenuDelegate();


            SparkleShare.Controller.FolderSizeChanged += delegate {
                InvokeOnMainThread(delegate {
                    if (!Animation.Enabled)
                    {
                        SetNormalState();
                    }

                    UpdateMenu();
                });
            };

            SparkleShare.Controller.FolderListChanged += delegate {
                InvokeOnMainThread(delegate {
                    SetNormalState();
                    CreateMenu();
                });
            };

            SparkleShare.Controller.OnIdle += delegate {
                InvokeOnMainThread(delegate {
                    SetNormalState();
                    UpdateMenu();
                });
            };

            SparkleShare.Controller.OnSyncing += delegate {
                InvokeOnMainThread(delegate {
                    SetAnimationState();
                    UpdateMenu();
                });
            };

            SparkleShare.Controller.OnError += delegate {
                InvokeOnMainThread(delegate {
                    SetNormalState(true);
                    UpdateMenu();
                });
            };
        }
Example #31
0
        public AppDelegate()
        {
            NSStatusBar  bar        = NSStatusBar.SystemStatusBar;
            NSStatusItem statusItem = bar.CreateStatusItem(NSStatusItemLength.Square);

            ActionCentre = new ApplicationIconActionCenter(statusItem, SynchronizationContext.Current);

            Client = new GitHubClient(Product)
            {
                Credentials = new Credentials(Secrets.GithubToken)
            };
        }
        public SparkleStatusIcon()
            : base()
        {
            Animation = CreateAnimation ();

            StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
            StatusItem.HighlightMode = true;

            SetNormalState ();
            CreateMenu ();

            Menu.Delegate = new SparkleStatusIconMenuDelegate ();

            SparkleShare.Controller.FolderSizeChanged += delegate {
                InvokeOnMainThread (delegate {

                    if (!Animation.Enabled)
                        SetNormalState ();

                    UpdateMenu ();

                });
            };

            SparkleShare.Controller.FolderListChanged += delegate {
                InvokeOnMainThread (delegate {
                    SetNormalState ();
                    CreateMenu ();
                });
            };

            SparkleShare.Controller.OnIdle += delegate {
                InvokeOnMainThread (delegate {
                    SetNormalState ();
                    UpdateMenu ();
                });
            };

            SparkleShare.Controller.OnSyncing += delegate {
                InvokeOnMainThread (delegate {
                    SetAnimationState ();
                    UpdateMenu ();
                });
            };

            SparkleShare.Controller.OnError += delegate {
                 InvokeOnMainThread (delegate {
                    SetNormalState (true);
                    UpdateMenu ();
                });
            };
        }
 public StatusPanelController(PanelController panelController)
 {
     _panelController = panelController;
     _statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(StatusItemViewWidth);
     _statusItemView = new StatusItemView(_statusItem)
     {
         Image = NSImage.ImageNamed(ImagePath),
         AlternateImage = NSImage.ImageNamed(HighlightImagePath)
     };
     _statusItemView.StatusItemClicked += OnStatusItemClicked;
     _panelController.StatusItemView = _statusItemView;
     _panelController.StatusController = this;
 }
 public StatusPanelController(PanelController panelController)
 {
     _panelController = panelController;
     _statusItem      = NSStatusBar.SystemStatusBar.CreateStatusItem(StatusItemViewWidth);
     _statusItemView  = new StatusItemView(_statusItem)
     {
         Image          = NSImage.ImageNamed(ImagePath),
         AlternateImage = NSImage.ImageNamed(HighlightImagePath)
     };
     _statusItemView.StatusItemClicked += OnStatusItemClicked;
     _panelController.StatusItemView    = _statusItemView;
     _panelController.StatusController  = this;
 }
Example #35
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            var storyboard = NSStoryboard.FromName("Main", null);

            _controller = storyboard.InstantiateControllerWithIdentifier("WindowController") as NSWindowController;

            _item = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusItemLength.Variable);
            _item.Button.Image = NSImage.ImageNamed("status_enabled");
            _item.Menu         = new NSMenu();

            var watcherItem = new NSMenuItem("Disable watcher");

            watcherItem.Activated += (sender, e) => {
                _isAppEnabled      = !_isAppEnabled;
                watcherItem.Title  = _isAppEnabled ? $"Disable watcher" : $"Enable watcher";
                _item.Button.Image = _isAppEnabled ? NSImage.ImageNamed("status_enabled") : NSImage.ImageNamed("status_disabled");

                if (_isAppEnabled)
                {
                    StartTimer();
                }
                else
                {
                    StopTimer();
                }
            };


            var aboutItem = new NSMenuItem("About");

            aboutItem.Activated += (sender, e) => {
                if (_controller?.Window?.IsVisible == false)
                {
                    _controller.ShowWindow(this);
                }
            };

            var exitItem = new NSMenuItem("Exit");

            exitItem.Activated += (sender, e) => {
                NSApplication.SharedApplication.Terminate(this);
            };

            _item.Menu.AddItem(watcherItem);
            _item.Menu.AddItem(aboutItem);
            _item.Menu.AddItem(NSMenuItem.SeparatorItem);
            _item.Menu.AddItem(exitItem);

            StartTimer();
        }
Example #36
0
        private void makeStatusBarMenu()
        {
            var statusBar = NSStatusBar.SystemStatusBar;

            var item = statusBar.CreateStatusItem(NSStatusItemLength.Variable);

            item.Title = "BeeMouser";

            item.Button.Activated += (sender, args) =>
            {
                showPreferences();
            };

            StatusItem = item;
        }
Example #37
0
        private void SetupMenu()
        {
            _inactiveIcon  = NSImage.ImageNamed("statusIconInactive");
            _activeIcon    = NSImage.ImageNamed("statusIconActive");
            _noArduinoIcon = NSImage.ImageNamed("statusIconNoArduino");

            _statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusItemLength.Variable);
            SetSystemIcon();
            _statusItem.Menu          = StatusMenu;
            _statusItem.HighlightMode = true;

            _stopItem = _statusItem.Menu.ItemArray().FirstOrDefault(x => x.Title == "Stop");

            InvokeOnMainThread(() => _stopItem.Enabled = false);
        }
Example #38
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            NSImage statusImage = NSImage.ImageNamed("StatusBarButtonImage");

            statusImage.Size = new CoreGraphics.CGSize(16.0, 16.0);

            this.statusItem               = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusItemLength.Square);
            this.statusItem.Image         = statusImage;
            this.statusItem.HighlightMode = true;
            this.statusItem.Enabled       = true;
            //this.statusItem.Menu = this.statusMenu;
            this.statusItem.Action = new ObjCRuntime.Selector("togglePopover:");

            //statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusItemLength.Square);
            //var button = statusItem.Button;
            //if (button != null) {
            //    button.Image = NSImage.ImageNamed("StatusBarButtonImage");
            //    button.Image.Size = new CoreGraphics.CGSize(16.0, 16.0);
            //    statusItem.HighlightMode = true;
            //    button.Image.Template = true;
            //    button.Action = new ObjCRuntime.Selector("togglePopover:");
            //}

            //NSImage* statusImage = [NSImage imageNamed: NSImageNameActionTemplate];
            //statusImage.size = NSMakeSize(18.0, 18.0);
            //self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength: NSSquareStatusItemLength];
            //self.statusItem.image = statusImage;
            //self.statusItem.highlightMode = YES;
            //self.statusItem.enabled = YES;
            //self.statusItem.menu = self.statusMenu;

            popover.ContentViewController = ConduitViewController.freshController();
            this.showPopover(this);

            //TODO: Event monitor not yet working


            //GlobalEventHandler eventHandler = new GlobalEventHandler((theEvent) =>
            //{
            //    var strongSelf = this;
            //    if (strongSelf.popover.Shown)
            //    {
            //        strongSelf.closePopover(theEvent);
            //    }
            //});
            //NSEventMask[] masks = { NSEventMask.LeftMouseDown, NSEventMask.RightMouseDown };
            //eventMonitor = new EventMonitor(masks, eventHandler);
        }
Example #39
0
        private void CreateNsMenu()
        {
            var menu = new NSMenu();

            statusItem               = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
            statusItem.Menu          = menu;
            statusItem.Image         = NSImage.ImageNamed("statusicon");
            statusItem.HighlightMode = true;

            menu.RemoveAllItems();

            browseMenuItem = new NSMenuItem("Browse Media Library", "b", delegate {
                Browse(NSApplication.SharedApplication);
            });
            menu.AddItem(browseMenuItem);

            configureMenuItem = new NSMenuItem("Configure Media Browser", "c", delegate {
                Configure(NSApplication.SharedApplication);
            });
            menu.AddItem(configureMenuItem);

            developerMenuItem = new NSMenuItem("Developer Resources");
            menu.AddItem(developerMenuItem);

            var developerMenu = new NSMenu();

            developerMenuItem.Submenu = developerMenu;

            apiMenuItem = new NSMenuItem("Api Documentation", "a", delegate {
                ApiDocs(NSApplication.SharedApplication);
            });
            developerMenu.AddItem(apiMenuItem);

            githubMenuItem = new NSMenuItem("Github", "g", delegate {
                Github(NSApplication.SharedApplication);
            });
            developerMenu.AddItem(githubMenuItem);

            communityMenuItem = new NSMenuItem("Visit Community", "v", delegate {
                Community(NSApplication.SharedApplication);
            });
            menu.AddItem(communityMenuItem);

            quitMenuItem = new NSMenuItem("Quit", "q", delegate {
                Quit(NSApplication.SharedApplication);
            });
            menu.AddItem(quitMenuItem);
        }
Example #40
0
		private void CreateNsMenu() {

			var menu = new NSMenu ();

			statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
			statusItem.Menu = menu;
			statusItem.Image = NSImage.ImageNamed("statusicon");
			statusItem.HighlightMode = true;

			menu.RemoveAllItems ();

			browseMenuItem = new NSMenuItem ("Browse Media Library", "b", delegate {
				Browse (NSApplication.SharedApplication);
			});
			menu.AddItem (browseMenuItem);

			configureMenuItem = new NSMenuItem ("Configure Media Browser", "c", delegate {
				Configure (NSApplication.SharedApplication);
			});
			menu.AddItem (configureMenuItem);

			developerMenuItem = new NSMenuItem ("Developer Resources");
			menu.AddItem (developerMenuItem);

			var developerMenu = new NSMenu ();
			developerMenuItem.Submenu = developerMenu;

			apiMenuItem = new NSMenuItem ("Api Documentation", "a", delegate {
				ApiDocs (NSApplication.SharedApplication);
			});
			developerMenu.AddItem (apiMenuItem);

			githubMenuItem = new NSMenuItem ("Github", "g", delegate {
				Github (NSApplication.SharedApplication);
			});
			developerMenu.AddItem (githubMenuItem);

			communityMenuItem = new NSMenuItem ("Visit Community", "v", delegate {
				Community (NSApplication.SharedApplication);
			});
			menu.AddItem (communityMenuItem);

			quitMenuItem = new NSMenuItem ("Quit", "q", delegate {
				Quit (NSApplication.SharedApplication);
			});
			menu.AddItem (quitMenuItem);
		}
Example #41
0
        public override void FinishedLaunching(NSObject notification)
        {
            // load image for the status item
            string imageFile = NSBundle.MainBundle.PathForImageResource("SysTrayIcon.png");
            NSImage image = new NSImage(imageFile);

            // creating the status item with a length of -2 is equivalent to the call
            // [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]
            iStatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(-2);
            iStatusItem.HighlightMode = true;
            iStatusItem.Menu = StatusMenu;
            iStatusItem.Image = image;

            // create the main configuration window
            iWindow = new ConfigurationWindowController();
            iWindow.LoadWindow();

            // create the controller for the application
            iController = new Controller(this);
        }
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
                return;

            if (disposing)
            {
                // Clear managed resources here
            }

            if (_statusItem != null)
            {
                NSStatusBar.SystemStatusBar.RemoveStatusItem(_statusItem);
                _statusItem = null;
            }

            _disposed = true;
        }
        public SparkleStatusIcon()
            : base()
        {
            using (var a = new NSAutoreleasePool ())
            {
                ErrorImage        = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/sparkleshare-syncing-error-mac.png");
                ErrorImageActive  = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/sparkleshare-syncing-error-mac-active.png");
                FolderImage       = NSImage.ImageNamed ("NSFolder");
                CautionImage      = NSImage.ImageNamed ("NSCaution");
                SparkleShareImage = NSImage.ImageNamed ("sparkleshare-mac");

                Animation = CreateAnimation ();

                StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
                StatusItem.HighlightMode = true;

                if (Controller.Folders.Length == 0)
                    StateText = _("Welcome to SparkleShare!");
                else
                    StateText = _("Up to date") + Controller.FolderSize;

                CreateMenu ();

                Menu.Delegate = new SparkleStatusIconMenuDelegate ();
            }

            Controller.UpdateQuitItemEvent += delegate (bool quit_item_enabled) {
                InvokeOnMainThread (delegate {
                    if (QuitMenuItem != null) {
                        QuitMenuItem.Enabled = quit_item_enabled;
                        StatusItem.Menu.Update ();
                    }
                });
            };

            Controller.UpdateMenuEvent += delegate (IconState state) {
                InvokeOnMainThread (delegate {
                    using (var a = new NSAutoreleasePool ()) {
                        switch (state) {
                        case IconState.Idle:

                            Animation.Stop ();

                            if (Controller.Folders.Length == 0)
                                StateText = _("Welcome to SparkleShare!");
                            else
                                StateText = _("Up to date") + Controller.FolderSize;

                            StateMenuItem.Title = StateText;
                            CreateMenu ();

                            break;

                        case IconState.Syncing:

                            StateText = _("Syncing… ") +
                                        Controller.ProgressPercentage + "%  " +
                                        Controller.ProgressSpeed;

                            StateMenuItem.Title = StateText;

                            if (!Animation.Enabled)
                                Animation.Start ();

                            break;

                        case IconState.Error:

                            Animation.Stop ();

                            StateText = _("Not everything is synced");
                            StateMenuItem.Title = StateText;
                            CreateMenu ();

                            StatusItem.Image               = ErrorImage;
                            StatusItem.AlternateImage      = ErrorImageActive;
                            StatusItem.Image.Size          = new SizeF (16, 16);
                            StatusItem.AlternateImage.Size = new SizeF (16, 16);

                            break;
                        }

                        StatusItem.Menu.Update ();
                    }
                });
            };
        }
 public StatusItemView(NSStatusItem statusItem)
     : base(new RectangleF(0f, 0f, statusItem.Length, NSStatusBar.SystemStatusBar.Thickness))
 {
     _statusItem = statusItem;
     _statusItem.View = this;
 }
Example #45
0
 protected override void Run(string[] args)
 {
     try
     {
         m_app.Run();
     }
     finally
     {
         if (m_statusItem != null)
         {
             NSStatusBar.SystemStatusBar.RemoveStatusItem(m_statusItem);
             m_statusItem = null;
             m_keeper.Clear();
             m_images.Clear();
         }
         m_app = null;
     }
 }
Example #46
0
        public StatusIcon () : base ()
        {
            using (var a = new NSAutoreleasePool ())
            {
                CreateAnimationFrames ();

                this.status_item = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
                this.status_item.HighlightMode = true;
                this.status_item.Image = this.animation_frames [0];

                this.status_item.Image               = this.animation_frames [0];
                this.status_item.Image.Size          = new SizeF (16, 16);

                CreateMenu ();
            }
            

            Controller.UpdateIconEvent += delegate (int icon_frame) {
                using (var a = new NSAutoreleasePool ())
                {
                    BeginInvokeOnMainThread (delegate {
                        if (icon_frame > -1) {
                            this.status_item.Image               = this.animation_frames [icon_frame];
                            this.status_item.Image.Size          = new SizeF (16, 16);

                        } else {
                            this.status_item.Image               = this.error_image;
                            this.status_item.Image.Size          = new SizeF (16, 16);
                        }
                    });
                }
            };

            Controller.UpdateStatusItemEvent += delegate (string state_text) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.state_item.Title = state_text;
                    });
                }
            };

            Controller.UpdateMenuEvent += delegate {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (() => CreateMenu ());
                }
            };

            Controller.UpdateSuspendSyncFolderEvent += delegate(string reponame)
            {
                using (var a = new NSAutoreleasePool()){
                    InvokeOnMainThread(delegate {
                        NSMenuItem PauseItem;
                        if(FolderItems.TryGetValue(reponame,out PauseItem)){
                            setSyncItemState(PauseItem, getSyncStatus(reponame));
                        }
                    });
                }
            };

            // TODO Need to implement this method like the COCOA way to do it
            Controller.UpdateTransmissionMenuEvent += delegate
            {
                using (var a = new NSAutoreleasePool()) {
                    InvokeOnMainThread(delegate {
                        List<FileTransmissionEvent> transmissions =    Program.Controller.ActiveTransmissions();
                        NSMenu transmissionmenu = new NSMenu();
                        foreach(FileTransmissionEvent transmission in transmissions) {
                            NSMenuItem transmissionItem = new TransmissionMenuItem(transmission);
                            transmissionmenu.AddItem(transmissionItem);
                        }
                        if(transmissions.Count > 0) {
                            state_item.Submenu = transmissionmenu;
                            state_item.Enabled = true;
                        }else{
                            state_item.Enabled = false;
                        }
                    });
                }
            };
        }
Example #47
0
        public SparkleStatusIcon()
            : base()
        {
            using (var a = new NSAutoreleasePool ())
            {
                this.status_item = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
                this.status_item.HighlightMode = true;

                this.syncing_idle_image  = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-idle.png"));
                this.syncing_up_image    = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-up.png"));
                this.syncing_down_image  = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-down.png"));
                this.syncing_image  = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing.png"));
                this.syncing_error_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-error.png"));

                this.syncing_idle_image_active  = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-idle-active.png"));
                this.syncing_up_image_active    = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-up-active.png"));
                this.syncing_down_image_active  = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-down-active.png"));
                this.syncing_image_active  = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-active.png"));
                this.syncing_error_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-error-active.png"));

                this.status_item.Image      = this.syncing_idle_image;
                this.status_item.Image.Size = new SizeF (16, 16);

                this.status_item.AlternateImage      = this.syncing_idle_image_active;
                this.status_item.AlternateImage.Size = new SizeF (16, 16);

                this.folder_image       = NSImage.ImageNamed ("NSFolder");
                this.caution_image      = NSImage.ImageNamed ("NSCaution");
                this.sparkleshare_image = NSImage.ImageNamed ("sparkleshare-folder");

                CreateMenu ();
            }

            Controller.UpdateIconEvent += delegate (IconState state) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        switch (state) {
                        case IconState.Idle: {
                            this.status_item.Image          = this.syncing_idle_image;
                            this.status_item.AlternateImage = this.syncing_idle_image_active;
                            break;
                        }
                        case IconState.SyncingUp: {
                            this.status_item.Image          = this.syncing_up_image;
                            this.status_item.AlternateImage = this.syncing_up_image_active;
                            break;
                        }
                        case IconState.SyncingDown: {
                            this.status_item.Image          = this.syncing_down_image;
                            this.status_item.AlternateImage = this.syncing_down_image_active;
                            break;
                        }
                        case IconState.Syncing: {
                            this.status_item.Image          = this.syncing_image;
                            this.status_item.AlternateImage = this.syncing_image_active;
                            break;
                        }
                        case IconState.Error: {
                            this.status_item.Image          = this.syncing_error_image;
                            this.status_item.AlternateImage = this.syncing_error_image_active;
                            break;
                        }
                        }

                        this.status_item.Image.Size = new SizeF (16, 16);
                        this.status_item.AlternateImage.Size = new SizeF (16, 16);
                    });
                }
            };

            Controller.UpdateStatusItemEvent += delegate (string state_text) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.state_item.Title = state_text;
                    });
                }
            };

            Controller.UpdateMenuEvent += delegate {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (() => CreateMenu ());
                }
            };

            Controller.UpdateQuitItemEvent += delegate (bool quit_item_enabled) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.quit_item.Enabled = quit_item_enabled;
                    });
                }
            };

            Controller.UpdateRecentEventsItemEvent += delegate (bool events_item_enabled) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.recent_events_item.Enabled = events_item_enabled;
                    });
                }
            };
        }
Example #48
0
        public StatusIcon () : base ()
        {
            using (var a = new NSAutoreleasePool ())
            {
                CreateAnimationFrames ();

                this.status_item = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
                this.status_item.HighlightMode = true;
                this.status_item.Image = this.animation_frames [0];

                this.status_item.Image               = this.animation_frames [0];
                this.status_item.Image.Size          = new SizeF (16, 16);
                this.status_item.AlternateImage      = this.animation_frames_active [0];
                this.status_item.AlternateImage.Size = new SizeF (16, 16);

                this.folder_image       = NSImage.ImageNamed ("NSFolder");
                this.caution_image      = NSImage.ImageNamed ("NSCaution");
                this.cmissync_image = NSImage.ImageNamed ("cmissync-folder");

                CreateMenu ();
            }
			

            Controller.UpdateIconEvent += delegate (int icon_frame) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        if (icon_frame > -1) {
                            this.status_item.Image               = this.animation_frames [icon_frame];
                            this.status_item.Image.Size          = new SizeF (16, 16);
                            this.status_item.AlternateImage      = this.animation_frames_active [icon_frame];
                            this.status_item.AlternateImage.Size = new SizeF (16, 16);

                        } else {
                            this.status_item.Image               = this.error_image;
                            this.status_item.AlternateImage      = this.error_image_active;
                            this.status_item.Image.Size          = new SizeF (16, 16);
                            this.status_item.AlternateImage.Size = new SizeF (16, 16);
                        }
                    });
                }
            };

            Controller.UpdateStatusItemEvent += delegate (string state_text) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.state_item.Title = state_text;
                    });
                }
            };

            Controller.UpdateMenuEvent += delegate {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (() => CreateMenu ());
                }
            };

            Controller.UpdateQuitItemEvent += delegate (bool quit_item_enabled) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.quit_item.Enabled = quit_item_enabled;
                    });
                }
            };

            Controller.UpdateOpenRecentEventsItemEvent += delegate (bool events_item_enabled) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.recent_events_item.Enabled = events_item_enabled;
                    });
                }
            };
        }
 private void InstantiateStatusItem()
 {
     this.si = NSStatusBar.SystemStatusBar.CreateStatusItem(28);
     this.si.HighlightMode = true;
     this.si.Menu = this.menu;
 }
 public void CreateMenuBarIcon()
 {
     StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusItemLength.Variable);
     //StatusItem.Menu = notifyMenu;
     StatusItem.Menu = MnuTray;
     StatusItem.Image = NSImage.ImageNamed ("menubar_light_red.png");
     StatusItem.HighlightMode = true;
 }
Example #51
0
 private void SetStatusItem()
 {
     if(_statusItem == null)
         _statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
     _statusItem.Menu = statusMenu;
     _statusItem.Image = NSImage.FromStream(System.IO.File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/icon.icns"));
     _statusItem.HighlightMode = true;
 }
        public override void FinishedLaunching(NSObject notification)
        {
            // Configure logger
            string path = Path.Combine (Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "log4net.config");
            XmlConfigurator.ConfigureAndWatch (new FileInfo(path));
            logger.Info ("Ventriliquest 1.0 Starting up...");

            // Get list of available audio out devices
            xamspeech ham = new xamspeech ();
            OutputDevices = ham.GetDevices ();

            // Setup UI
            statusMenu = new NSMenu ();
            statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (30);

            var outputItem = new NSMenuItem ("Output Device",
                (a, b) => {

                });

            var deviceList = new NSMenu ();
            outputItem.Submenu = deviceList;

            OutputDeviceUID = "Built-in Output";

            foreach(var entry in OutputDevices) {
                var test = new NSMenuItem (entry.Key.ToString(),
                    (a, b) => {
                        foreach(NSMenuItem item in deviceList.ItemArray()) {
                            item.State = NSCellStateValue.Off;
                        }
                        NSMenuItem theItem = (NSMenuItem)a;
                        theItem.State = NSCellStateValue.On;
                        config.OutputDevice = theItem.Title;
                        foreach(var e in OutputDevices) {
                            if(e.Key.ToString().Equals(theItem.Title)) {
                                OutputDeviceUID = e.Value.ToString();
                            }
                        }
                    });
                if(entry.Key.ToString().Equals(config.OutputDevice)) {
                    test.State = NSCellStateValue.On;
                    OutputDeviceUID = entry.Value.ToString ();
                }
                deviceList.AddItem (test);
            }

            var daItem = new NSMenuItem ("Local Connections Only",
                (a, b) => {
                    NSMenuItem theItem = (NSMenuItem)a;
                    if(theItem.State == NSCellStateValue.On) {
                        config.LocalOnly = false;
                        theItem.State = NSCellStateValue.Off;
                    } else {
                        config.LocalOnly = true;
                        theItem.State = NSCellStateValue.On;
                    }
                });

            if(config.LocalOnly) {
                daItem.State = NSCellStateValue.On;
            }

            var quitItem = new NSMenuItem("Quit",
                (a, b) => Shutdown ());

            var voiceconfigItem = new NSMenuItem("Voice Configuration",
                (a, b) => Process.Start("http://127.0.0.1:7888/config"));

            statusMenu.AddItem (outputItem);
            statusMenu.AddItem (daItem);
            statusMenu.AddItem (voiceconfigItem);
            statusMenu.AddItem (quitItem);
            statusItem.Menu = statusMenu;
            statusItem.Image = NSImage.ImageNamed("tts-1.png");
            statusItem.AlternateImage = NSImage.ImageNamed ("tts-2.png");
            statusItem.HighlightMode = true;

            speechdelegate.DidComplete += delegate {
                synthesis.Set();
            };
            sounddelegate.DidComplete += delegate {
                playback.Set ();
                IsSounding = false;
                IsSpeaking = false;
                sound.Dispose();
            };

            speech.Delegate = speechdelegate;

            queuetimer = new System.Timers.Timer (250);
            queuetimer.Elapsed += (object sender, ElapsedEventArgs e) => {
                TTSRequest r;
                if(Queue.TryDequeue(out r)) {
                    if(r.Interrupt) {
                        // stop current TTS
                        NSApplication.SharedApplication.InvokeOnMainThread( delegate {
                            if(IsSpeaking) {
                                speech.StopSpeaking();
                            }
                            if(IsSounding) {
                                sound.Stop();
                            }
                        });
                        // clear queue
                        SpeechQueue.Clear();
                    }
                    SpeechQueue.Enqueue(r);
                    RequestCount++;

                }
                var eventdata = new Hashtable();
                eventdata.Add("ProcessedRequests", RequestCount);
                eventdata.Add("QueuedRequests", SpeechQueue.Count);
                eventdata.Add("IsSpeaking", IsSpeaking);
                InstrumentationEvent ev = new InstrumentationEvent();
                ev.EventName = "status";
                ev.Data = eventdata;
                NotifyGui(ev.EventMessage());
            };

            // when this timer fires, it will pull off of the speech queue and speak it
            // the 1000ms delay also adds a little pause between tts requests.
            speechtimer = new System.Timers.Timer (1000);
            speechtimer.Elapsed += (object sender, ElapsedEventArgs e) => {
                if(IsSpeaking.Equals(false)) {
                    if(SpeechQueue.Count > 0) {
                        TTSRequest r = SpeechQueue.Dequeue();
                        IsSpeaking = true;
                        speechtimer.Enabled = false;
                        var oink = Path.Combine(audiopath, "temp.aiff");
                        NSApplication.SharedApplication.InvokeOnMainThread( delegate {
                            ConfigureSpeechEngine(r);
                            speech.StartSpeakingStringtoURL(r.Text, new NSUrl(oink, false));
                        });
                        synthesis.WaitOne();
                        NSApplication.SharedApplication.InvokeOnMainThread( delegate {
                            IsSounding = true;
                            sound = new NSSound(Path.Combine(audiopath, "temp.aiff"), false);
                            sound.Delegate = sounddelegate;
                            //if(OutputDeviceUID != "Default") {
                                sound.PlaybackDeviceID = OutputDeviceUID;
                            //}
                            sound.Play();
                        });
                        playback.WaitOne();
                        IsSounding = false;
                        speechtimer.Enabled = true;
                    }
                }
            };

            queuetimer.Enabled = true;
            queuetimer.Start ();
            speechtimer.Enabled = true;
            speechtimer.Start ();

            InitHTTPServer ();
        }
Example #53
0
 public void InitializeBackend(object frontend)
 {
     statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (NSVariableStatusItemLength);
 }
Example #54
0
        public StatusIcon () : base ()
        {
            using (var a = new NSAutoreleasePool ())
            {
                CreateAnimationFrames ();

                this.status_item = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
                this.status_item.HighlightMode = true;
                this.status_item.Image = this.animation_frames [0];

                this.status_item.Image               = this.animation_frames [0];
                this.status_item.Image.Size          = new SizeF (16, 16);

                CreateMenu ();
            }
            

            Controller.UpdateIconEvent += delegate (int icon_frame) {
                Logger.Debug("StatusIcon UpdateIconEvent " + icon_frame);

                using (var a = new NSAutoreleasePool ())
                {
                    BeginInvokeOnMainThread (delegate {
                        if (icon_frame > -1) {
                            this.status_item.Image               = this.animation_frames [icon_frame];
                            this.status_item.Image.Size          = new SizeF (16, 16);

                        } else {
                            this.status_item.Image               = this.error_image;
                            this.status_item.Image.Size          = new SizeF (16, 16);
                        }
                    });
                }
            };

            Controller.UpdateStatusItemEvent += delegate (string state_text) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.state_item.Title = state_text;
                    });
                }
            };

            Controller.UpdateMenuEvent += delegate {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (() => CreateMenu ());
                }
            };

            Controller.UpdateSuspendSyncFolderEvent += delegate(string reponame)
            {
                using (var a = new NSAutoreleasePool()){
                    InvokeOnMainThread(delegate {
                        NSMenuItem PauseItem;
                        if(FolderItems.TryGetValue(reponame,out PauseItem)){
                            setSyncItemState(PauseItem, getSyncStatus(reponame));
                        }
                    });
                }
            };
        }
Example #55
0
 public void Dispose()
 {
     statusItem.Dispose ();
     statusItem = null;
 }
        public SparkleStatusIcon()
            : base()
        {
            using (var a = new NSAutoreleasePool ()) {
                Animation = CreateAnimation ();

                StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
                StatusItem.HighlightMode = true;

                StateText = _("Up to date") + " (" + Controller.FolderSize + ")";
                CreateMenu ();

                Menu.Delegate = new SparkleStatusIconMenuDelegate ();
            }

            Controller.UpdateMenuEvent += delegate (IconState state) {
                InvokeOnMainThread (delegate {
                    using (var a = new NSAutoreleasePool ()) {
                        switch (state) {
                        case IconState.Idle:

                            Animation.Stop ();

                            if (Controller.Folders.Length == 0)
                                StateText = _("Welcome to SparkleShare!");
                            else
                                StateText = _("Up to date") + " (" + Controller.FolderSize + ")";

                            StateMenuItem.Title = StateText;
                            CreateMenu ();

                            break;

                        case IconState.Syncing:

                            StateText = _("Syncing…");
                            StateMenuItem.Title = StateText;

                            if (!Animation.Enabled)
                                Animation.Start ();

                            break;

                        case IconState.Error:

                            StateText = _("Not everything is synced");
                            StateMenuItem.Title = StateText;
                            CreateMenu ();

                            InvokeOnMainThread (delegate {
                                StatusItem.Image               = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/error.png");
                                StatusItem.AlternateImage      = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/error-active.png");
                                StatusItem.Image.Size          = new SizeF (16, 16);
                                StatusItem.AlternateImage.Size = new SizeF (16, 16);
                            });
                            break;
                        }
                    }
                });
            };
        }
Example #57
0
        public IconController () : base ()
        {
            recentChanges = new List<NSMenuItem> ();
            using (var a = new NSAutoreleasePool ()) {
                this.status_item = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
                this.status_item.HighlightMode = true;


                this.syncing_working = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-working.png"));
                this.syncing_idle_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-idle.png"));
                this.syncing_up_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-up.png"));
                this.syncing_down_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-down.png"));
                this.syncing_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing.png"));
                this.syncing_error_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-error.png"));
                this.disconnected_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-active_new.png"));

                this.syncing_idle_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-idle-active.png"));
                this.syncing_up_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-up-active.png"));
                this.syncing_down_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-down-active.png"));
                this.syncing_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-active.png"));
                this.syncing_error_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-error-active.png"));
                this.sync_pause_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-paused.png"));
    
                this.status_item.Image = this.syncing_working;
                this.status_item.Image.Size = new SizeF (16, 16);

                //this.status_item.AlternateImage      = this.syncing_idle_image_active;
                //this.status_item.AlternateImage.Size = new SizeF (16, 16);
                this.folder_image = NSImage.ImageNamed ("NSFolder");
                this.caution_image = NSImage.ImageNamed ("NSCaution");
                this.sparkleshare_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "qloudsync-folder.icns"));

                this.share_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "share.png"));
                this.docs_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "folder-docs.png"));
                this.docs_image.Size = new SizeF (16, 16);
                this.movies_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "folder-movies.png"));
                this.movies_image.Size = new SizeF (16, 16);
                this.music_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "folder-music.png"));
                this.music_image.Size = new SizeF (16, 16);
                this.pics_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "folder-pics.png"));
                this.pics_image.Size = new SizeF (16, 16);
                this.default_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "file-3.png"));
                this.default_image.Size = new SizeF (16, 16);

                CreateMenu ();
            }


            Program.Controller.OnIdle += delegate {
                    CurrentState = IconState.Idle;
                    StateText = "✓  Up to date ";
                    UpdateQuitItemEvent (QuitItemEnabled);
                    UpdateStatusItemEvent (StateText, this.up_to_date);
                    UpdateIconEvent (CurrentState);
                    CreateMenu();
            };

            Program.Controller.OnPaused += delegate {
                    CurrentState = IconState.Paused;
                    StateText = "Sync Paused ";
                    isPaused = true;
                    UpdateQuitItemEvent (QuitItemEnabled);
                    UpdateStatusItemEvent (StateText, this.up_to_date);
                    UpdateIconEvent (CurrentState);
                    CreateMenu();
            }; 

            Program.Controller.OnSyncing += delegate {
           
                    isPaused = false;

                    bool syncDown = SynchronizerUnit.AnyDownloading (); 
                    bool syncUp = SynchronizerUnit.AnyUploading (); 

                    if (syncDown && syncUp) {
                        CurrentState = IconState.Syncing;
                        StateText = "⟳ Syncing changes…";
                        
                    } else if (syncUp) {
                        CurrentState = IconState.SyncingUp;
                        StateText = "⟳ Sending changes…";
                        
                    } else if (syncDown) {
                        CurrentState = IconState.SyncingDown;
                        StateText = "⟳ Receiving changes…";
                    } else {
                        CurrentState = IconState.Idle;
                        StateText = "✓  Up to date ";
                    }

                    UpdateIconEvent (CurrentState);
                    UpdateStatusItemEvent (StateText, this.syncing_working);
                    UpdateQuitItemEvent (QuitItemEnabled);
                    CreateMenu();

            };
            
            Program.Controller.OnError += delegate {
             
                    isPaused = false;
                    CurrentState = IconState.Error;
                    switch (Program.Controller.ErrorType) {
                    case Controller.ERROR_TYPE.DISCONNECTION:
                        StateText = "✗   Lost network connection";
                        break;
                    case Controller.ERROR_TYPE.ACCESS_DENIED:
                        StateText = "✗   Access Denied. Login again!";
                        this.preferences_item.Enabled = true;
                        break;
                    default:
                        StateText = "✗   Failed to send some changes";
                        break;
                    }
                    UpdateQuitItemEvent (QuitItemEnabled);
                    UpdateStatusItemEvent (StateText, this.error_in_sync);
                    UpdateIconEvent (CurrentState);
                    CreateMenu();
                
            };			

            UpdateIconEvent += delegate (IconState state) {
                using (var a = new NSAutoreleasePool ()) {
                    NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                        switch (state) {
                        case IconState.Idle:
                            {
                                this.status_item.Image = this.syncing_idle_image;
                                break;
                            }
                        case IconState.SyncingUp:
                            {
                                this.status_item.Image = this.syncing_up_image;
                                break;
                            }
                        case IconState.SyncingDown:
                            {
                                this.status_item.Image = this.syncing_down_image;
                                break;
                            }
                        case IconState.Syncing:
                            {
                                this.status_item.Image = this.syncing_image;
                                break;
                            }
                        case IconState.Error:
                            {
                                if (Program.Controller.ErrorType == Controller.ERROR_TYPE.DISCONNECTION) {
                                    this.status_item.Image = this.disconnected_image;
                                } else {
                                    this.status_item.Image = this.syncing_error_image;
                                }
                                break;
                            }
                        case IconState.Paused:
                            {
                                this.status_item.Image = this.sync_pause_active;
                                break;
                            }
                        }

                        this.status_item.Image.Size = new SizeF (16, 16);
                    });
                }
            };

            UpdateStatusItemEvent += delegate (string state_text, NSImage image) {
                using (var a = new NSAutoreleasePool ()) {
                    NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                        StateText = state_text;
                    });
                }
            };

            UpdateQuitItemEvent += delegate (bool quit_item_enabled) {
                using (var a = new NSAutoreleasePool ()) {
                    NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                        this.quit_item.Enabled = quit_item_enabled;
                    });
                }
            };
        }