private void guna2Button4_Click(object sender, EventArgs e) { this.Hide(); ServerPage f2 = new ServerPage(); f2.Show(); }
public override void LoadPanels(MainForm mainForm, ServiceContainer serviceContainer, List <ModuleProvider> moduleProviders) { if (readOnly) { MessageBox.Show("Elevation is required. Please run Jexus Manager as administrator."); return; } if (ServerManager == null && _status != NodeStatus.Loaded) { return; } serviceContainer.RemoveService(typeof(IConfigurationService)); serviceContainer.RemoveService(typeof(IControlPanel)); var server = (ServerManager)Tag; var panel = new ServerPage(server); var scope = ManagementScope.Server; serviceContainer.AddService(typeof(IControlPanel), new ControlPanel()); serviceContainer.AddService(typeof(IConfigurationService), new ConfigurationService(mainForm, server.GetApplicationHostConfiguration(), scope, server, null, null, null, null, null)); var moduleDefinitions = new List <ModuleDefinition>(); var modules = new List <Module>(); foreach (var provider in moduleProviders) { if (!provider.SupportsScope(scope)) { continue; } var definition = provider.GetModuleDefinition(null); moduleDefinitions.Add(definition); var type = Type.GetType(definition.ClientModuleTypeName); if (type == null) { continue; } if (!typeof(Module).IsAssignableFrom(type)) { continue; } var module = (Module)Activator.CreateInstance(type); module.Initialize(serviceContainer, null); modules.Add(module); } IModulePage page = panel; var mainModule = new MainModule(); mainModule.Initialize(serviceContainer, null); page.Initialize(mainModule, null, null); mainForm.LoadPage(page); }
public ServerViewModel(Server server) : base(server) { if (Server == null) { throw new Exception(); } DateTime start = DateTime.Now; Console.WriteLine("Starting initialization of ViewModel for Server " + Server.Name); if (Server.Version.Type == ServerVersion.VersionType.Vanilla) { Versions = VersionManager.Instance.VanillaVersions; } else if (Server.Version.Type == ServerVersion.VersionType.Paper) { Versions = VersionManager.Instance.PaperVersions; } else if (Server.Version.Type == ServerVersion.VersionType.Spigot) { Versions = VersionManager.Instance.SpigotVersions; } Application.Current.Dispatcher.Invoke(new Action(() => EntityPage = new ServerPage(this))); Application.Current.Dispatcher.Invoke(new Action(() => ConsolePage = new ConsolePage(this))); Application.Current.Dispatcher.Invoke(new Action(() => WorldsPage = new WorldsPage(this))); Application.Current.Dispatcher.Invoke(new Action(() => PluginsPage = new PluginsPage(new PluginViewModel(this)))); Application.Current.Dispatcher.Invoke(new Action(() => SettingsViewModel = new SettingsViewModel(this))); PlayerList.CollectionChanged += PlayerListChanged; WhiteList.CollectionChanged += WhiteListChanged; BanList.CollectionChanged += BanListChanged; OPList.CollectionChanged += OPListChanged; Worlds = new ObservableCollection <World>(); Worlds.CollectionChanged += WorldsChanged; InitializeLists(Server); if (!ApplicationManager.Initialized) { ApplicationManager.ApplicationInitialized += () => Application.Current.Dispatcher?.Invoke(StartSettingsReader); } else { Application.Current.Dispatcher?.Invoke(StartSettingsReader); } TimeSpan t = DateTime.Now - start; Console.WriteLine("Server ViewModel for " + Server.Name + " initialized in " + t.Seconds + "." + t.Milliseconds + "s"); }
private async void VersionChange_Click(object sender, RoutedEventArgs e) { if (viewModel.EntityViewModel is ServerViewModel serverViewModel) { ServerPage serverPage = viewModel.EntityViewModel.EntityPage as ServerPage; serverPage?.OpenTerminal(); bool success = await ServerManager.Instance.ChangeServerVersionAsync((ServerVersion)versionComboBox.SelectedValue, serverViewModel); if (!success) { //TODO: Display error return; } } }