コード例 #1
0
ファイル: SysTrayMenu.cs プロジェクト: wilson0x4d/Mubox
        private MenuItem QuickLaunchMenu_CreateClientItem(string clientName, Mubox.Configuration.ProfileSettings profile)
        {
            RoutedEventHandler clientStartEventHandler = (sender, e) =>
            {
                var clientSettings = profile.Clients.GetExisting(clientName);
                if (clientSettings != null)
                {
                    Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile = profile;
                    Mubox.Configuration.MuboxConfigSection.Save();
                    ClientState clientState = new ClientState(clientSettings, profile);
                    Mubox.View.Client.ClientWindow clientWindow = new Mubox.View.Client.ClientWindow(clientState);
                    clientWindow.Show();
                }
            };

            RoutedEventHandler clientDeleteEventHandler = (sender, e) =>
            {
                // TODO: add confirmation dialog to avoid accidental deletions
                if (profile.Clients.Remove(clientName))
                {
                    // TODO: we need to clean up the sandbox account as well
                    Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile = profile;
                    Mubox.Configuration.MuboxConfigSection.Save();
                }
            };

            MenuItem clientMenuItem = new MenuItem();
            clientMenuItem.Header = clientName;
            // clientMenuItem.Click += clientLaunchEventHandler;

            MenuItem clientLaunchMenuItem = new MenuItem();
            clientLaunchMenuItem.Header = "_Start";
            clientLaunchMenuItem.Click += clientStartEventHandler;

            MenuItem clientDeleteMenuItem = new MenuItem();
            clientDeleteMenuItem.Header = "_Remove From List";
            clientDeleteMenuItem.Click += clientDeleteEventHandler;

            clientMenuItem.ItemsSource = new object[] {
                clientLaunchMenuItem,
                clientDeleteMenuItem
            };

            return clientMenuItem;
        }
コード例 #2
0
ファイル: SysTrayMenu.cs プロジェクト: wilson0x4d/Mubox
        private MenuItem CreateProfileShortcutMenu(Configuration.ProfileSettings profile)
        {
            var menuItem = default(MenuItem);

            // Shortcuts Menu Item
            List<object> quickLaunchClientShortcuts = new List<object>();
            Mubox.Configuration.ClientSettingsCollection clients = profile.Clients;

            menuItem = new MenuItem();
            menuItem.Header = "Start All";
            menuItem.Click += (sender, e) =>
            {
                LaunchProfileClients(profile);
            };
            quickLaunchClientShortcuts.Add(menuItem);

            // "Auto-Launch Game on Client Start"
            menuItem = new MenuItem();
            menuItem.IsCheckable = true;
            menuItem.IsChecked = Mubox.Configuration.MuboxConfigSection.Default.AutoLaunchGame;
            menuItem.Click += (sender, e) =>
            {
                Mubox.Configuration.MuboxConfigSection.Default.AutoLaunchGame = !Mubox.Configuration.MuboxConfigSection.Default.AutoLaunchGame;
                Mubox.Configuration.MuboxConfigSection.Save();
            };
            menuItem.Header = "Auto-Launch Game on Client Start";
            menuItem.ToolTip =
                "Enable this option to Automatically Launch your Game when a Client started via the Quick Launch Menu." + Environment.NewLine +
                "Note, the game will not run until the client successfully connects to the Server, once a Server Connection is established the Launch will continue.";
            quickLaunchClientShortcuts.Add(menuItem);

            // "Enable Mouse Panning Fix"
            menuItem = new MenuItem();
            menuItem.IsCheckable = true;
            menuItem.IsChecked = profile.EnableMousePanningFix;
            menuItem.Click += (sender, e) =>
            {
                profile.EnableMousePanningFix = !profile.EnableMousePanningFix;
                Mubox.Configuration.MuboxConfigSection.Save();
            };
            menuItem.Header = "Enable Mouse Panning Fix";
            menuItem.ToolTip = "Only enable this option if you experience 'erratic' behavior when panning with the mouse. Properly written games do not have this problem.";
            quickLaunchClientShortcuts.Add(menuItem);

            // "Enable CAS Fix"
            menuItem = new MenuItem();
            menuItem.IsCheckable = true;
            menuItem.IsChecked = profile.EnableCASFix;
            menuItem.Click += (sender, e) =>
            {
                profile.EnableCASFix = !profile.EnableCASFix;
                Mubox.Configuration.MuboxConfigSection.Save();
            };
            menuItem.Header = "Enable Control-Alt-Shift Fix";
            menuItem.ToolTip = "Only enable this option if you have problems with the Control, Alt and Shift keys in your game.";
            quickLaunchClientShortcuts.Add(menuItem);

            // New Mubox Client
            menuItem = new MenuItem();
            menuItem.Click += (sender, e) =>
            {
                try
                {
                    // ensure client name is unique for current profile
                    var clientName = default(string);
                    while (true)
                    {
                        clientName = Mubox.View.PromptForClientNameDialog.PromptForClientName();
                        if (string.IsNullOrEmpty(clientName))
                        {
                            return;
                        }
                        //foreach (var L_profile in Mubox.Configuration.MuboxConfigSection.Default.Profiles.Cast<Mubox.Configuration.ProfileSettings>())
                        {
                            if (profile.Clients.GetExisting(clientName) != null)
                            {
                                MessageBox.Show("Name '" + clientName + "' is already in use, choose another.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                                continue;
                            }
                        }
                        break;
                    }

                    var clientSettings = profile.Clients.CreateNew(clientName);
                    clientSettings.CanLaunch = true;
                    Mubox.Configuration.MuboxConfigSection.Save();

                    ClientState clientState = new ClientState(clientSettings, profile);
                    Mubox.View.Client.ClientWindow clientWindow = new Mubox.View.Client.ClientWindow(clientState);
                    clientWindow.Show();
                }
                catch (Exception ex)
                {
                    ex.Log();
                }
            };
            menuItem.Header = "_Configure New Client...";
            menuItem.Icon = Resources["imageSettingsIcon"];
            quickLaunchClientShortcuts.Add(menuItem);

            quickLaunchClientShortcuts.Add(new Separator());
            foreach (var client in clients.Cast<Mubox.Configuration.ClientSettings>())
            {
                // NOTE: a !CanLaunch client is one we know about, but likely exists on a remote computer. we do not (yet) support remote launch, and so these entries are hidden even though they may appear in the config file.
                if (!client.CanLaunch || (Mubox.View.Client.ClientWindowCollection.Instance.Count((dlg) => dlg.ClientState.Settings.Name.ToUpper() == client.Name.ToUpper()) != 0))
                {
                    continue;
                }

                client.PerformConnectOnLoad = true;
                quickLaunchClientShortcuts.Add(
                    QuickLaunchMenu_CreateClientItem(client.Name, profile)
                    );
            }

            menuItem = new MenuItem();
            menuItem.Header = profile.Name;
            menuItem.ItemsSource = quickLaunchClientShortcuts;

            var lMenuItem = new MenuItem();
            lMenuItem.IsCheckable = true;
            lMenuItem.IsChecked = (Mubox.Configuration.MuboxConfigSection.Default.Profiles.Default.Equals(profile.Name));
            lMenuItem.Header = "Active Profile";
            lMenuItem.Click += (s, e) =>
                {
                    Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile = profile;
                    Mubox.Configuration.MuboxConfigSection.Save();
                };
            quickLaunchClientShortcuts.Insert(0, lMenuItem);

            return menuItem;
        }