QuitClicked() публичный Метод

Quit CmisSync.
public QuitClicked ( ) : void
Результат void
Пример #1
0
        public void CreateMenu()
        {
            using (NSAutoreleasePool a = new NSAutoreleasePool())
            {
                this.menu = new NSMenu();
                this.menu.AutoEnablesItems = false;

                this.FolderItems = new Dictionary <String, NSMenuItem>();

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

                this.log_item = new NSMenuItem()
                {
                    Title = CmisSync.Properties_Resources.ViewLog
                };

                this.log_item.Activated += delegate
                {
                    Controller.LogClicked();
                };

                this.add_item = new NSMenuItem()
                {
                    Title   = CmisSync.Properties_Resources.AddARemoteFolder,
                    Enabled = true
                };

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

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

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

                this.quit_item = new NSMenuItem()
                {
                    Title   = CmisSync.Properties_Resources.Exit,
                    Enabled = true
                };

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

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

                if (Controller.Folders.Length > 0)
                {
                    foreach (string folder_name in Controller.Folders)
                    {
                        this.menu.AddItem(CreateFolderMenuItem(folder_name));
                    }
                    ;
                    if (Controller.OverflowFolders.Length > 0)
                    {
                        NSMenuItem moreitem = new NSMenuItem();
                        moreitem.Title = "More Folder";
                        NSMenu moreitemsmenu = new NSMenu();
                        foreach (string folder_name in Controller.OverflowFolders)
                        {
                            moreitemsmenu.AddItem(CreateFolderMenuItem(folder_name));
                        }
                        ;
                        moreitem.Submenu = moreitemsmenu;
                        this.menu.AddItem(moreitem);
                    }
                    this.menu.AddItem(NSMenuItem.SeparatorItem);
                }

                this.menu.AddItem(this.add_item);
                this.menu.AddItem(NSMenuItem.SeparatorItem);
                this.menu.AddItem(this.log_item);
                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;
            }
        }
Пример #2
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);
        }
Пример #3
0
        /// <summary>
        /// Create the UI elements of the menu.
        /// </summary>
        private void CreateMenu()
        {
            // Reset existing items.
            this.traymenu.Items.Clear();

            // Create the state menu item.
            this.stateItem = new ToolStripMenuItem()
            {
                Text    = Utils.Ellipsis(Controller.StateText, 32),
                Enabled = false
            };

            if (Controller.StateText.Length > 32)
            {
                this.stateItem.ToolTipText = Utils.WordWrap(Controller.StateText, 63);
            }

            this.traymenu.Items.Add(stateItem);
            this.trayicon.Text = Utils.Ellipsis(Properties_Resources.Oris4Sync + "\n" + Controller.StateText, 63);

            // Create a menu item per synchronized folder.
            if (Controller.Folders.Length > 0)
            {
                foreach (string folderName in Controller.Folders)
                {
                    // Main item.
                    ToolStripMenuItem subfolderItem = new ToolStripMenuItem()
                    {
                        Text  = folderName,
                        Name  = "tsmi" + folderName,
                        Image = UIHelpers.GetBitmap("folder"),
                    };

                    // Sub-item: open locally.
                    ToolStripMenuItem openLocalFolderItem = new ToolStripMenuItem()
                    {
                        Text  = CmisSync.Properties_Resources.OpenLocalFolder,
                        Name  = "openLocal",
                        Image = UIHelpers.GetBitmap("folder"),
                    };
                    openLocalFolderItem.Click += OpenLocalFolderDelegate(folderName);

                    // Sub-item: open remotely.
                    ToolStripMenuItem openRemoteFolderItem = new ToolStripMenuItem()
                    {
                        Text  = CmisSync.Properties_Resources.BrowseRemoteFolder,
                        Name  = "openRemote",
                        Image = UIHelpers.GetBitmap("classic_folder_web"),
                    };
                    openRemoteFolderItem.Click += OpenRemoteFolderDelegate(folderName);

                    // Sub-item: suspend sync.
                    ToolStripMenuItem suspendFolderItem = new ToolStripMenuItem()
                    {
                        Name = "pause",
                    };
                    suspendFolderItem.Click += SuspendSyncFolderDelegate(folderName);

                    // Sub-item: remove folder from sync
                    ToolStripMenuItem removeFolderFromSyncItem = new ToolStripMenuItem()
                    {
                        Text  = Properties_Resources.RemoveFolderFromSync,
                        Name  = "remove",
                        Image = UIHelpers.GetBitmap("disconnect"),
                    };
                    removeFolderFromSyncItem.Click += RemoveFolderFromSyncDelegate(folderName);

                    // Sub-item: manual sync
                    ToolStripMenuItem manualSyncItem = new ToolStripMenuItem()
                    {
                        Text  = Properties_Resources.ManualSync,
                        Name  = "sync",
                        Image = UIHelpers.GetBitmap("media_playback_refresh"),
                    };
                    manualSyncItem.Click += ManualSyncDelegate(folderName);

                    // Sub-item: settings dialog
                    ToolStripMenuItem settingsItem = new ToolStripMenuItem()
                    {
                        Text = Properties_Resources.Settings,
                        Name = "settings",
                    };
                    settingsItem.Click += SettingsDelegate(folderName);


                    setSyncItemState(suspendFolderItem, manualSyncItem, SyncStatus.Idle);
                    foreach (RepoBase aRepo in Program.Controller.Repositories)
                    {
                        if (aRepo.Name.Equals(folderName))
                        {
                            setSyncItemState(suspendFolderItem, manualSyncItem, aRepo.Status);
                            break;
                        }
                    }

                    // Add the sub-items.
                    subfolderItem.DropDownItems.Add(openLocalFolderItem);
                    subfolderItem.DropDownItems.Add(openRemoteFolderItem);
                    subfolderItem.DropDownItems.Add(new ToolStripSeparator());
                    subfolderItem.DropDownItems.Add(suspendFolderItem);
                    subfolderItem.DropDownItems.Add(manualSyncItem);
                    subfolderItem.DropDownItems.Add(new ToolStripSeparator());
                    subfolderItem.DropDownItems.Add(removeFolderFromSyncItem);
                    subfolderItem.DropDownItems.Add(new ToolStripSeparator());
                    subfolderItem.DropDownItems.Add(settingsItem);

                    // Add the main item.
                    this.traymenu.Items.Add(subfolderItem);
                }
            }
            this.traymenu.Items.Add(new ToolStripSeparator());

            // Create the menu item that lets the user add a new synchronized folder.
            ToolStripMenuItem addFolderItem = new ToolStripMenuItem()
            {
                Text  = CmisSync.Properties_Resources.AddARemoteFolder,
                Name  = "add",
                Image = UIHelpers.GetBitmap("connect"),
            };

            if (ConfigManager.CurrentConfig.SingleRepository && ConfigManager.CurrentConfig.Folder.Count > 0)
            {
                //Configured for single repository and repository count 1 or more so disable menu item.
                addFolderItem.Enabled = false;
            }

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

            // Create the menu item that lets the user view the log.
            ToolStripMenuItem log_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.ViewLog,
                Name = "log",
            };

            log_item.Click += delegate
            {
                Controller.LogClicked();
            };
            //Removed for Oris4
            //this.traymenu.Items.Add(log_item);

            // Create the About menu.
            ToolStripMenuItem about_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.About,
                Name = "about",
            };

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

            // Create the exit menu.
            this.exitItem = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.Exit,
                Name = "exit",
            };
            this.exitItem.Click += delegate
            {
                this.trayicon.Dispose();
                Controller.QuitClicked();
            };
            this.traymenu.Items.Add(this.exitItem);
        }
Пример #4
0
        public void CreateMenu()
        {
            this.menu = new Menu();

            // State Menu
            this.state_item = new MenuItem(Controller.StateText)
            {
                Sensitive = false
            };
            this.menu.Add(this.state_item);
            this.menu.Add(new SeparatorMenuItem());

            // Folders Menu
            if (Controller.Folders.Length > 0)
            {
                foreach (string folder_name in Controller.Folders)
                {
                    Menu          submenu        = new Menu();
                    ImageMenuItem subfolder_item = new CmisSyncMenuItem(folder_name)
                    {
                        Image    = new Image(UIHelpers.GetIcon("dataspacesync-folder", 16)),
                        Submenu  = submenu,
                        RepoName = folder_name
                    };

                    ImageMenuItem open_localfolder_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.OpenLocalFolder)
                    {
                        Image = new Image(UIHelpers.GetIcon("dataspacesync-folder", 16))
                    };
                    open_localfolder_item.Activated += OpenFolderDelegate(folder_name);

                    ImageMenuItem edit_folder_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.EditTitle);
                    edit_folder_item.Activated += EditFolderDelegate(folder_name);

                    ImageMenuItem suspend_folder_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.PauseSync)
                    {
                        RepoName = folder_name
                    };
                    foreach (Repository aRepo in Program.Controller.Repositories)
                    {
                        if (aRepo.Name.Equals(folder_name))
                        {
                            setSyncItemState(suspend_folder_item, aRepo.Status);
                            break;
                        }
                    }
                    suspend_folder_item.Activated += SuspendSyncFolderDelegate(folder_name);

                    ImageMenuItem remove_folder_from_sync_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.RemoveFolderFromSync)
                    {
                        Image = new Image(UIHelpers.GetIcon("dataspacesync-deleted", 12))
                    };
                    remove_folder_from_sync_item.Activated += RemoveFolderFromSyncDelegate(folder_name);

                    submenu.Add(open_localfolder_item);
                    submenu.Add(suspend_folder_item);
                    //  GUI workaround to remove ignore folder {{
                    //submenu.Add(edit_folder_item);
                    //  GUI workaround to remove ignore folder }}
                    submenu.Add(new SeparatorMenuItem());
                    submenu.Add(remove_folder_from_sync_item);

                    this.menu.Add(subfolder_item);
                }

                this.menu.Add(new SeparatorMenuItem());
            }

            // Add Menu
            MenuItem add_item = new MenuItem(
                CmisSync.Properties_Resources.AddARemoteFolder);

            add_item.Activated += delegate {
                Controller.AddRemoteFolderClicked();
            };
            this.menu.Add(add_item);

            this.menu.Add(new SeparatorMenuItem());

            // Log Menu
            MenuItem log_item = new MenuItem(
                CmisSync.Properties_Resources.ViewLog);

            log_item.Activated += delegate
            {
                Controller.LogClicked();
            };
            this.menu.Add(log_item);

            // About Menu
            MenuItem about_item = new MenuItem(
                String.Format(CmisSync.Properties_Resources.About, Properties_Resources.ApplicationName));

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

            this.quit_item = new MenuItem(
                CmisSync.Properties_Resources.Exit)
            {
                Sensitive = true
            };

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

            this.menu.Add(this.quit_item);
            this.menu.ShowAll();

#if HAVE_APP_INDICATOR
            this.indicator.Menu = this.menu;
#endif
            this.IsHandleCreated = true;
        }
Пример #5
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;
            }
        }
Пример #6
0
        /// <summary>
        /// Create the UI elements of the menu.
        /// </summary>
        private void CreateMenu()
        {
            // Reset existing items.
            this.traymenu.Items.Clear();
            this.repoItems = new List <RepositoryMenuItem>();

            this.trayicon.Text = string.Format("{0}\n{1}", Properties_Resources.ApplicationName, Controller.StateText);

            // Create a menu item per synchronized folder.
            if (Controller.Folders.Length > 0)
            {
                foreach (var repo in Program.Controller.Repositories)
                {
                    var repoItem = new RepositoryMenuItem(repo, this.Controller, this);
                    this.repoItems.Add(repoItem);
                    this.traymenu.Items.Add(repoItem);
                }

                this.traymenu.Items.Add(new ToolStripSeparator());
            }

            // Create the menu item that lets the user add a new synchronized folder.
            ToolStripMenuItem addFolderItem = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.AddARemoteFolder
            };

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

            // Create the menu item that lets the user view setting.
            ToolStripMenuItem setting_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.Settings
            };

            setting_item.Click += delegate {
                Controller.SettingClicked();
            };
            this.traymenu.Items.Add(setting_item);

            // Create the menu item that lets the uer view transmission.
            ToolStripMenuItem transmission_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.Transmission
            };

            transmission_item.Click += delegate {
                Controller.TransmissionClicked();
            };
            this.traymenu.Items.Add(transmission_item);

            // Create the menu item that lets the user view the log.
            ToolStripMenuItem log_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.ViewLog
            };

            log_item.Click += delegate {
                Controller.LogClicked();
            };
            this.traymenu.Items.Add(log_item);

            // Create the About menu.
            ToolStripMenuItem about_item = new ToolStripMenuItem()
            {
                Text = String.Format(Properties_Resources.About, Properties_Resources.ApplicationName)
            };

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

            // Create the exit menu.
            this.exitItem = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.Exit
            };
            this.exitItem.Click += delegate {
                this.trayicon.Dispose();
                Controller.QuitClicked();
            };
            this.traymenu.Items.Add(this.exitItem);
        }
Пример #7
0
        public void CreateMenu()
        {
            this.menu = new Menu();

            // State Menu
            this.state_item = new MenuItem(Controller.StateText)
            {
                Sensitive = false
            };
            this.menu.Add(this.state_item);

            this.menu.Add(new SeparatorMenuItem());

            // Folders Menu
            if (Controller.Folders.Length > 0)
            {
                foreach (string folder_name in Controller.Folders)
                {
                    Menu          submenu        = new Menu();
                    ImageMenuItem subfolder_item = new CmisSyncMenuItem(folder_name)
                    {
                        Image   = new Image(UIHelpers.GetIcon("folder-cmissync", 16)),
                        Submenu = submenu
                    };

                    ImageMenuItem open_localfolder_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.ResourceManager.GetString("OpenLocalFolder", CultureInfo.CurrentCulture))
                    {
                        Image = new Image(UIHelpers.GetIcon("folder-cmissync", 16))
                    };
                    open_localfolder_item.Activated += OpenFolderDelegate(folder_name);

                    ImageMenuItem browse_remotefolder_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.ResourceManager.GetString("BrowseRemoteFolder", CultureInfo.CurrentCulture))
                    {
                        Image = new Image(UIHelpers.GetIcon("folder-cmissync", 16))
                    };
                    browse_remotefolder_item.Activated += OpenRemoteFolderDelegate(folder_name);

                    ImageMenuItem suspend_folder_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.ResourceManager.GetString("PauseSync", CultureInfo.CurrentCulture))
                    {
                        Image = new Image(UIHelpers.GetIcon("media_playback_pause", 16))
                    };
                    suspend_folder_item.Activated += SuspendSyncFolderDelegate(folder_name);

                    submenu.Add(open_localfolder_item);
                    submenu.Add(browse_remotefolder_item);
                    submenu.Add(suspend_folder_item);

                    this.menu.Add(subfolder_item);
                }

                this.menu.Add(new SeparatorMenuItem());
            }

            // Add Menu
            MenuItem add_item = new MenuItem(
                CmisSync.Properties_Resources.ResourceManager.GetString("AddARemoteFolder", CultureInfo.CurrentCulture));

            add_item.Activated += delegate {
                Controller.AddRemoteFolderClicked();
            };
            this.menu.Add(add_item);

            this.menu.Add(new SeparatorMenuItem());

            // Log Menu
            MenuItem log_item = new MenuItem(
                CmisSync.Properties_Resources.ResourceManager.GetString("ViewLog", CultureInfo.CurrentCulture));

            log_item.Activated += delegate
            {
                Controller.LogClicked();
            };
            this.menu.Add(log_item);

            // About Menu
            MenuItem about_item = new MenuItem(
                CmisSync.Properties_Resources.ResourceManager.GetString("About", CultureInfo.CurrentCulture));

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

            this.quit_item = new MenuItem(
                CmisSync.Properties_Resources.ResourceManager.GetString("Exit", CultureInfo.CurrentCulture))
            {
                Sensitive = true
            };

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

            this.menu.Add(this.quit_item);
            this.menu.ShowAll();

#if HAVE_APP_INDICATOR
            this.indicator.Menu = this.menu;
#endif
        }
Пример #8
0
        /// <summary>
        /// Create the GUI elements of the menu.
        /// </summary>
        public void CreateMenu()
        {
            this.menu = new Menu();

            // State Menu
            this.state_item = new MenuItem(Controller.StateText)
            {
                Sensitive = false
            };
            this.menu.Add(this.state_item);

            this.menu.Add(new SeparatorMenuItem());

            // Folders Menu
            if (Controller.Folders.Length > 0)
            {
                foreach (string folder_name in Controller.Folders)
                {
                    Menu          submenu        = new Menu();
                    ImageMenuItem subfolder_item = new CmisSyncMenuItem(folder_name)
                    {
                        Image    = new Image(UIHelpers.GetIcon("folder-cmissync", 16)),
                        Submenu  = submenu,
                        RepoName = folder_name
                    };

                    // Sub-item: open locally.
                    ImageMenuItem open_localfolder_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.OpenLocalFolder)
                    {
                        Image = new Image(UIHelpers.GetIcon("folder-cmissync", 16))
                    };
                    open_localfolder_item.Activated += OpenFolderDelegate(folder_name);

/*
 *                  // Sub-item: open remotely.
 *                  ImageMenuItem browse_remotefolder_item = new CmisSyncMenuItem(
 *                          CmisSync.Properties_Resources.BrowseRemoteFolder) {
 *                      Image = new Image (UIHelpers.GetIcon ("folder-cmissync", 16))
 *                  };
 *                  browse_remotefolder_item.Activated += OpenRemoteFolderDelegate(folder_name);
 */

                    ImageMenuItem edit_folder_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.EditTitle);
                    edit_folder_item.Activated += EditFolderDelegate(folder_name);

                    // Sub-item: suspend sync.
                    ImageMenuItem suspend_folder_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.PauseSync)
                    {
                        RepoName = folder_name
                    };
                    foreach (RepoBase aRepo in Program.Controller.Repositories)
                    {
                        if (aRepo.Name.Equals(folder_name))
                        {
                            setSyncItemState(suspend_folder_item, aRepo.Status);
                            break;
                        }
                    }
                    suspend_folder_item.Activated += SuspendSyncFolderDelegate(folder_name);

                    // Sub-item: remove folder from sync
                    ImageMenuItem remove_folder_from_sync_item = new CmisSyncMenuItem(
                        CmisSync.Properties_Resources.RemoveFolderFromSync)
                    {
                        Image = new Image(UIHelpers.GetIcon("document-deleted", 12))
                    };
                    remove_folder_from_sync_item.Activated += RemoveFolderFromSyncDelegate(folder_name);

                    // Add the sub-items.
                    submenu.Add(open_localfolder_item);
                    //submenu.Add(browse_remotefolder_item);
                    submenu.Add(suspend_folder_item);
                    submenu.Add(edit_folder_item);
                    submenu.Add(new SeparatorMenuItem());
                    submenu.Add(remove_folder_from_sync_item);

                    // Add the main item.
                    this.menu.Add(subfolder_item);
                }

                this.menu.Add(new SeparatorMenuItem());
            }

            // Add Menu
            MenuItem add_item = new MenuItem(
                CmisSync.Properties_Resources.AddARemoteFolder);

            add_item.Activated += delegate {
                Controller.AddRemoteFolderClicked();
            };
            this.menu.Add(add_item);

            this.menu.Add(new SeparatorMenuItem());

            // Log Menu
            MenuItem log_item = new MenuItem(
                CmisSync.Properties_Resources.ViewLog);

            log_item.Activated += delegate
            {
                Controller.LogClicked();
            };
            this.menu.Add(log_item);

            // About Menu
            MenuItem about_item = new MenuItem(
                CmisSync.Properties_Resources.About);

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

            this.quit_item = new MenuItem(
                CmisSync.Properties_Resources.Exit)
            {
                Sensitive = true
            };

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

            this.menu.Add(this.quit_item);
            this.menu.ShowAll();

#if HAVE_APP_INDICATOR
            this.indicator.Menu = this.menu;
#endif
            this.IsHandleCreated = true;
        }
Пример #9
0
        /// <summary>
        /// Create the UI elements of the menu.
        /// </summary>
        private void CreateMenu()
        {
            // Reset existing items.
            this.traymenu.Items.Clear();

            // Create the state menu item.
            this.stateItem = new ToolStripMenuItem()
            {
                Text    = Controller.StateText,
                Enabled = false
            };
            this.traymenu.Items.Add(stateItem);
            this.trayicon.Text = String.Format("{0}\n{1}", Properties_Resources.ApplicationName, Controller.StateText);
            this.traymenu.Items.Add(new ToolStripSeparator());

            /*this.transmissionItem = new ToolStripMenuItem()
             * {
             *  Text = "No active transmissions",
             *  Enabled = false
             * };
             * this.traymenu.Items.Add(transmissionItem); */


            // Create a menu item per synchronized folder.
            if (Controller.Folders.Length > 0)
            {
                foreach (string folderName in Controller.Folders)
                {
                    // Main item.
                    ToolStripMenuItem subfolderItem = new ToolStripMenuItem()
                    {
                        Text  = folderName,
                        Name  = "tsmi" + folderName,
                        Image = UIHelpers.GetBitmap("folder")
                    };

                    // Sub-item: open locally.
                    ToolStripMenuItem openLocalFolderItem = new ToolStripMenuItem()
                    {
                        Text  = CmisSync.Properties_Resources.OpenLocalFolder,
                        Image = UIHelpers.GetBitmap("folder")
                    };
                    openLocalFolderItem.Click += OpenLocalFolderDelegate(folderName);

                    // Sub-item: edit ignore folder.
                    ToolStripMenuItem editFolderItem = new ToolStripMenuItem()
                    {
                        Text = CmisSync.Properties_Resources.Settings
                    };
                    editFolderItem.Click += EditFolderDelegate(folderName);


                    // Sub-item: suspend sync.
                    ToolStripMenuItem suspendFolderItem = new ToolStripMenuItem();
                    setSyncItemState(suspendFolderItem, SyncStatus.Idle);
                    foreach (Repository aRepo in Program.Controller.Repositories)
                    {
                        if (aRepo.Name.Equals(folderName))
                        {
                            setSyncItemState(suspendFolderItem, aRepo.Status);
                            break;
                        }
                    }
                    suspendFolderItem.Click += SuspendSyncFolderDelegate(folderName);

                    // Sub-item: remove folder from sync
                    ToolStripMenuItem removeFolderFromSyncItem = new ToolStripMenuItem()
                    {
                        Text = Properties_Resources.RemoveFolderFromSync,
                        Tag  = "remove",
                    };
                    removeFolderFromSyncItem.Click += RemoveFolderFromSyncDelegate(folderName);

                    // Add the sub-items.
                    subfolderItem.DropDownItems.Add(openLocalFolderItem);
                    //subfolderItem.DropDownItems.Add(openRemoteFolderItem);
                    subfolderItem.DropDownItems.Add(new ToolStripSeparator());
                    subfolderItem.DropDownItems.Add(suspendFolderItem);
                    subfolderItem.DropDownItems.Add(new ToolStripSeparator());
                    subfolderItem.DropDownItems.Add(editFolderItem);
                    subfolderItem.DropDownItems.Add(new ToolStripSeparator());
                    subfolderItem.DropDownItems.Add(removeFolderFromSyncItem);
                    // Add the main item.
                    this.traymenu.Items.Add(subfolderItem);
                }
                this.traymenu.Items.Add(new ToolStripSeparator());
            }

            // Create the menu item that lets the user add a new synchronized folder.
            ToolStripMenuItem addFolderItem = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.AddARemoteFolder
            };

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

            // Create the menu item that lets the user view setting.
            ToolStripMenuItem setting_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.Settings
            };

            setting_item.Click += delegate
            {
                Controller.SettingClicked();
            };
            this.traymenu.Items.Add(setting_item);

            // Create the menu item that lets the user view the log.
            ToolStripMenuItem log_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.ViewLog
            };

            log_item.Click += delegate
            {
                Controller.LogClicked();
            };
            this.traymenu.Items.Add(log_item);

            // Create the About menu.
            ToolStripMenuItem about_item = new ToolStripMenuItem()
            {
                Text = String.Format(Properties_Resources.About, Properties_Resources.ApplicationName)
            };

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

            // Create the exit menu.
            this.exitItem = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.Exit
            };
            this.exitItem.Click += delegate
            {
                this.trayicon.Dispose();
                Controller.QuitClicked();
            };
            this.traymenu.Items.Add(this.exitItem);
        }
Пример #10
0
        /// <summary>
        /// Create the UI elements of the menu.
        /// </summary>
        private void CreateMenu()
        {
            // Reset existing items.
            this.traymenu.Items.Clear();

            // Create the state menu item.
            this.stateItem = new ToolStripMenuItem()
            {
                Text    = Controller.StateText,
                Enabled = false
            };
            this.traymenu.Items.Add(stateItem);
            this.trayicon.Text = "CmisSync\n" + Controller.StateText;

            // Create a menu item per synchronized folder.
            if (Controller.Folders.Length > 0)
            {
                foreach (string folderName in Controller.Folders)
                {
                    // Main item.
                    ToolStripMenuItem subfolderItem = new ToolStripMenuItem()
                    {
                        Text  = folderName,
                        Name  = "tsmi" + folderName,
                        Image = UIHelpers.GetBitmap("folder")
                    };

                    // Sub-item: open locally.
                    ToolStripMenuItem openLocalFolderItem = new ToolStripMenuItem()
                    {
                        Text  = CmisSync.Properties_Resources.ResourceManager.GetString("OpenLocalFolder", CultureInfo.CurrentCulture),
                        Image = UIHelpers.GetBitmap("folder")
                    };
                    openLocalFolderItem.Click += OpenLocalFolderDelegate(folderName);

                    // Sub-item: open remotely.
                    ToolStripMenuItem openRemoteFolderItem = new ToolStripMenuItem()
                    {
                        Text  = CmisSync.Properties_Resources.ResourceManager.GetString("BrowseRemoteFolder", CultureInfo.CurrentCulture),
                        Image = UIHelpers.GetBitmap("classic_folder_web")
                    };
                    openRemoteFolderItem.Click += OpenRemoteFolderDelegate(folderName);

                    // Sub-item: suspend sync.
                    ToolStripMenuItem suspendFolderItem = new ToolStripMenuItem()
                    {
                        Text  = CmisSync.Properties_Resources.ResourceManager.GetString("PauseSync", CultureInfo.CurrentCulture),
                        Tag   = "pause",
                        Image = UIHelpers.GetBitmap("media_playback_pause")
                    };
                    suspendFolderItem.Click += SuspendSyncFolderDelegate(folderName);

                    // Add the sub-items.
                    subfolderItem.DropDownItems.Add(openLocalFolderItem);
                    subfolderItem.DropDownItems.Add(openRemoteFolderItem);
                    subfolderItem.DropDownItems.Add(new ToolStripSeparator());
                    subfolderItem.DropDownItems.Add(suspendFolderItem);

                    // Add the main item.
                    this.traymenu.Items.Add(subfolderItem);
                }
            }
            this.traymenu.Items.Add(new ToolStripSeparator());

            // Create the menu item that lets the user add a new synchronized folder.
            ToolStripMenuItem addFolderItem = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.ResourceManager.GetString("AddARemoteFolder", CultureInfo.CurrentCulture)
            };

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

            // Create the menu item that lets the user view the log.
            ToolStripMenuItem log_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.ResourceManager.GetString("ViewLog", CultureInfo.CurrentCulture)
            };

            log_item.Click += delegate
            {
                Controller.LogClicked();
            };
            this.traymenu.Items.Add(log_item);

            // Create the About menu.
            ToolStripMenuItem about_item = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.ResourceManager.GetString("About", CultureInfo.CurrentCulture)
            };

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

            // Create the exit menu.
            this.exitItem = new ToolStripMenuItem()
            {
                Text = CmisSync.Properties_Resources.ResourceManager.GetString("Exit", CultureInfo.CurrentCulture)
            };
            this.exitItem.Click += delegate
            {
                this.trayicon.Dispose();
                Controller.QuitClicked();
            };
            this.traymenu.Items.Add(this.exitItem);
        }
Пример #11
0
        public void CreateMenu()
        {
            using (NSAutoreleasePool a = new NSAutoreleasePool()) {
                this.repoItems             = new List <RepositoryMenuItem>();
                this.menu                  = new NSMenu();
                this.menu.AutoEnablesItems = false;

                this.general_settings_item = new NSMenuItem()
                {
                    Title = Properties_Resources.EditTitle
                };

                this.general_settings_item.Activated += delegate {
                    this.Controller.SettingClicked();
                };

                this.transmission_item = new NSMenuItem()
                {
                    Title = Properties_Resources.Transmission
                };

                this.transmission_item.Activated += delegate {
                    this.Controller.TransmissionClicked();
                };

                this.log_item = new NSMenuItem()
                {
                    Title = Properties_Resources.ViewLog
                };

                this.log_item.Activated += delegate {
                    this.Controller.LogClicked();
                };

                this.add_item = new NSMenuItem()
                {
                    Title   = Properties_Resources.AddARemoteFolder,
                    Enabled = true
                };

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

                this.about_item = new NSMenuItem()
                {
                    Title   = string.Format(Properties_Resources.About, Properties_Resources.ApplicationName),
                    Enabled = true
                };

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

                this.quit_item = new NSMenuItem()
                {
                    Title   = Properties_Resources.Exit,
                    Enabled = true
                };

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

                var repos = Program.Controller.Repositories;
                if (repos.Length > 0)
                {
                    foreach (var repo in repos)
                    {
                        var repoItem = new RepositoryMenuItem(repo, this.Controller);
                        this.repoItems.Add(repoItem);
                        this.menu.AddItem(repoItem);
                    }
                    ;
                    this.menu.AddItem(NSMenuItem.SeparatorItem);
                }

                this.menu.AddItem(this.add_item);
                this.menu.AddItem(NSMenuItem.SeparatorItem);
                this.menu.AddItem(this.general_settings_item);
                this.menu.AddItem(this.transmission_item);
                this.menu.AddItem(this.log_item);
                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;
            }
        }