Example #1
0
        private void CreateMenu()
        {
            this.traymenu.Items.Clear();

            // State Menu
            this.state_item = new ToolStripMenuItem()
            {
                Text    = Controller.StateText,
                Enabled = false
            };
            this.traymenu.Items.Add(state_item);

            this.trayicon.Text = "CmisSync\n" + Controller.StateText;

            // Folders Menu
            if (Controller.Folders.Length > 0)
            {
                foreach (string folder_name in Controller.Folders)
                {
                    ToolStripMenuItem subfolder_item = new ToolStripMenuItem()
                    {
                        Text  = folder_name,
                        Name  = "tsmi" + folder_name,
                        Image = UIHelpers.GetBitmap("folder")
                    };

                    ToolStripMenuItem open_localfolder_item = new ToolStripMenuItem()
                    {
                        Text  = CmisSync.Properties.Resources.ResourceManager.GetString("OpenLocalFolder", CultureInfo.CurrentCulture),
                        Image = UIHelpers.GetBitmap("folder")
                    };
                    open_localfolder_item.Click += OpenFolderDelegate(folder_name);

                    ToolStripMenuItem open_remotefolder_item = new ToolStripMenuItem()
                    {
                        Text  = CmisSync.Properties.Resources.ResourceManager.GetString("BrowseRemoteFolder", CultureInfo.CurrentCulture),
                        Image = UIHelpers.GetBitmap("classic_folder_web")
                    };
                    open_remotefolder_item.Click += OpenRemoteFolderDelegate(folder_name);

                    ToolStripMenuItem suspend_folder_item = new ToolStripMenuItem()
                    {
                        Text  = CmisSync.Properties.Resources.ResourceManager.GetString("PauseSync", CultureInfo.CurrentCulture),
                        Tag   = "pause",
                        Image = UIHelpers.GetBitmap("media_playback_pause")
                    };
                    suspend_folder_item.Click += SuspendSyncFolderDelegate(folder_name);

                    subfolder_item.DropDownItems.Add(open_localfolder_item);
                    subfolder_item.DropDownItems.Add(open_remotefolder_item);
                    subfolder_item.DropDownItems.Add(new ToolStripSeparator());
                    subfolder_item.DropDownItems.Add(suspend_folder_item);
                    this.traymenu.Items.Add(subfolder_item);
                }
            }
            this.traymenu.Items.Add(new ToolStripSeparator());

            // Add Menu
            ToolStripMenuItem add_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties.Resources.ResourceManager.GetString("AddARemoteFolder", CultureInfo.CurrentCulture)
            };

            add_item.Click += delegate
            {
                Controller.AddHostedProjectClicked();
            };
            this.traymenu.Items.Add(add_item);
            this.traymenu.Items.Add(new ToolStripSeparator());

            // About Menu
            ToolStripMenuItem about_item = new ToolStripMenuItem()
            {
                Text = "About CmisSync"
            };

            about_item.Click += delegate
            {
                Controller.AboutClicked();
            };
            this.traymenu.Items.Add(about_item);

            // Exit Menu
            this.exit_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties.Resources.ResourceManager.GetString("Exit", CultureInfo.CurrentCulture)
            };

            this.exit_item.Click += delegate
            {
                this.trayicon.Dispose();
                Controller.QuitClicked();
            };
            this.traymenu.Items.Add(this.exit_item);
        }
Example #2
0
        public void CreateMenu()
        {
            using (NSAutoreleasePool a = new NSAutoreleasePool())
            {
                this.menu = new NSMenu();
                this.menu.AutoEnablesItems = false;

                this.state_item = new NSMenuItem()
                {
                    Title   = Controller.StateText,
                    Enabled = false
                };

                this.folder_item = new NSMenuItem()
                {
                    Title = "CmisSync"
                };

                this.folder_item.Activated += delegate {
                    Controller.CmisSyncClicked();
                };

                this.folder_item.Image      = this.cmissync_image;
                this.folder_item.Image.Size = new SizeF(16, 16);
                this.folder_item.Enabled    = true;

                this.add_item = new NSMenuItem()
                {
                    Title   = "Add Hosted Project…",
                    Enabled = true
                };

                this.add_item.Activated += delegate {
                    Controller.AddHostedProjectClicked();
                };

                this.recent_events_item = new NSMenuItem()
                {
                    Title   = "Recent Changes…",
                    Enabled = Controller.OpenRecentEventsItemEnabled
                };

                if (Controller.Folders.Length > 0)
                {
                    this.recent_events_item.Activated += delegate {
                        Controller.OpenRecentEventsClicked();
                    };
                }

                this.notify_item = new NSMenuItem()
                {
                    Enabled = (Controller.Folders.Length > 0)
                };

                if (Program.Controller.NotificationsEnabled)
                {
                    this.notify_item.Title = "Turn Notifications Off";
                }
                else
                {
                    this.notify_item.Title = "Turn Notifications On";
                }

                this.notify_item.Activated += delegate {
                    Program.Controller.ToggleNotifications();

                    InvokeOnMainThread(delegate {
                        if (Program.Controller.NotificationsEnabled)
                        {
                            this.notify_item.Title = "Turn Notifications Off";
                        }
                        else
                        {
                            this.notify_item.Title = "Turn Notifications On";
                        }
                    });
                };

                this.about_item = new NSMenuItem()
                {
                    Title   = "About CmisSync",
                    Enabled = true
                };

                this.about_item.Activated += delegate {
                    Controller.AboutClicked();
                };

                this.quit_item = new NSMenuItem()
                {
                    Title   = "Quit",
                    Enabled = Controller.QuitItemEnabled
                };

                this.quit_item.Activated += delegate {
                    Controller.QuitClicked();
                };


                this.menu.AddItem(this.state_item);
                this.menu.AddItem(NSMenuItem.SeparatorItem);
                this.menu.AddItem(this.folder_item);

                this.folder_menu_items = new NSMenuItem [Controller.Folders.Length];
                this.submenu_items     = new NSMenuItem [Controller.OverflowFolders.Length];

                if (Controller.Folders.Length > 0)
                {
                    this.folder_tasks   = new EventHandler [Controller.Folders.Length];
                    this.overflow_tasks = new EventHandler [Controller.OverflowFolders.Length];

                    int i = 0;
                    foreach (string folder_name in Controller.Folders)
                    {
                        NSMenuItem item = new NSMenuItem();
                        item.Title = folder_name;

                        if (Program.Controller.UnsyncedFolders.Contains(folder_name))
                        {
                            item.Image = this.caution_image;
                        }
                        else
                        {
                            item.Image = this.folder_image;
                        }

                        item.Image.Size       = new SizeF(16, 16);
                        this.folder_tasks [i] = OpenFolderDelegate(folder_name);

                        this.folder_menu_items [i]            = item;
                        this.folder_menu_items [i].Activated += this.folder_tasks [i];

                        i++;
                    }
                    ;

                    i = 0;
                    foreach (string folder_name in Controller.OverflowFolders)
                    {
                        NSMenuItem item = new NSMenuItem();
                        item.Title = folder_name;

                        if (Program.Controller.UnsyncedFolders.Contains(folder_name))
                        {
                            item.Image = this.caution_image;
                        }
                        else
                        {
                            item.Image = this.folder_image;
                        }

                        item.Image.Size         = new SizeF(16, 16);
                        this.overflow_tasks [i] = OpenFolderDelegate(folder_name);

                        this.submenu_items [i]            = item;
                        this.submenu_items [i].Activated += this.overflow_tasks [i];

                        i++;
                    }
                    ;
                }


                foreach (NSMenuItem item in this.folder_menu_items)
                {
                    this.menu.AddItem(item);
                }

                if (this.submenu_items.Length > 0)
                {
                    this.submenu = new NSMenu();

                    foreach (NSMenuItem item in this.submenu_items)
                    {
                        this.submenu.AddItem(item);
                    }

                    this.more_item = new NSMenuItem()
                    {
                        Title   = "More Projects",
                        Submenu = this.submenu
                    };

                    this.menu.AddItem(NSMenuItem.SeparatorItem);
                    this.menu.AddItem(this.more_item);
                }

                this.menu.AddItem(NSMenuItem.SeparatorItem);
                this.menu.AddItem(this.add_item);
                this.menu.AddItem(this.recent_events_item);
                this.menu.AddItem(NSMenuItem.SeparatorItem);
                this.menu.AddItem(this.notify_item);
                this.menu.AddItem(NSMenuItem.SeparatorItem);
                this.menu.AddItem(this.about_item);
                this.menu.AddItem(NSMenuItem.SeparatorItem);
                this.menu.AddItem(this.quit_item);

                this.menu.Delegate    = new StatusIconMenuDelegate();
                this.status_item.Menu = this.menu;
            }
        }