Exemplo n.º 1
0
        public Settings(Server server)
        {
            this.server = server;
            config = server.getConfiguration();
            InitializeComponent();

            module_network_enable.Checked = config.networkConfig.enabled;
            module_cpu_enable.Checked = config.cpuConfig.enabled;
            module_memory_enable.Checked = config.memoryConfig.enabled;
            module_teamspeak_enable.Checked = config.tsconfig.enabled;
            module_clock_enable.Checked = config.clockConfig.enabled;

            foreach (string networkInterface in server.systemInfoService.getNetworkInterfaces())
            {
                networkDropdown.Items.Add(networkInterface);
            }
            if (config.networkConfig.interfaceName == "")
            {
                config.networkConfig.interfaceName = networkDropdown.Items[0].ToString();
            }
            networkDropdown.SelectedIndex = networkDropdown.FindString(config.networkConfig.interfaceName);

            foreach (string s in Directory.GetFiles(wallpaperpath, "*").Select(Path.GetFileName))
            {
                style_wallpapers.Items.Add(s);
            }

            style_wallpapers.SelectedIndex = style_wallpapers.FindString(config.styleconig.wallpaper);
            style_Preview.Image = Image.FromFile("Style/Wallpapers/" + config.styleconig.wallpaper);

            Color color = Color.FromArgb(config.styleconig.color_r, config.styleconig.color_g, config.styleconig.color_b);
            style_color.BackColor = color;

            Color bcolor = Color.FromArgb(config.styleconig.b_color_r, config.styleconig.b_color_g, config.styleconig.b_color_b);
            style_back_color.BackColor = bcolor;

            style_opacity.Value = (int)(config.styleconig.b_opacity * 100);

            if (!fwh.IsFirewallEnabled)
            {
                fw_addRule.Enabled = false;
                fw_removeRule.Enabled = false;
            }
            else
            {
                if (fwh.IsPortOpen(port))
                {
                    fw_addRule.Enabled = false;
                    fw_removeRule.Enabled = true;
                }
                else
                {
                    fw_addRule.Enabled = true;
                    fw_removeRule.Enabled = false;
                }
            }
        }
Exemplo n.º 2
0
 public static Configuration CreateConfig()
 {
     Configuration config = new Configuration();
     NetworkConfiguration networkcon = new NetworkConfiguration();
     ClockConfiguration clockcon = new ClockConfiguration();
     CPUConfiguration cpuconfig = new CPUConfiguration();
     MemoryConfiguration memoryconfig = new MemoryConfiguration();
     TeamSpeakConfiguration teamspeakconfig=new TeamSpeakConfiguration();
     StyleConfiguration styleconfig = new StyleConfiguration();
     config.networkConfig = networkcon;
     config.clockConfig = clockcon;
     config.cpuConfig = cpuconfig;
     config.memoryConfig = memoryconfig;
     config.tsconfig = teamspeakconfig;
     config.styleconig = styleconfig;
     return config;
 }
Exemplo n.º 3
0
        public void startServer()
        {
            settingsService = new ConfigurationService();
            serverConfig = settingsService.getConfig();
            //TODO disable deactivated modules

            systemInfoService = new SystemInfoService();
            teamspeakInfoService = new TeamSpeakInfoService();

            var fileSystem = new PhysicalFileSystem(".");
            var options = new FileServerOptions
            {
                EnableDirectoryBrowsing = true,
                FileSystem = fileSystem
            };

            var container = new UnityContainer();
            container.RegisterType<ISystemInfoService, SystemInfoService>(new HierarchicalLifetimeManager());
            container.RegisterType<ITeamSpeakInfoService, TeamSpeakInfoService>(new HierarchicalLifetimeManager());
            container.RegisterType<IConfigurationService, ConfigurationService>(new HierarchicalLifetimeManager());

            container.RegisterInstance<SystemInfoService>(systemInfoService);
            container.RegisterInstance<TeamSpeakInfoService>(teamspeakInfoService);
            container.RegisterInstance<ConfigurationService>(settingsService);

            HttpConfiguration config = new HttpConfiguration();
            config.DependencyResolver = new UnityResolver(container);
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            StartOptions urls = new StartOptions();

            urls.Urls.Add("http://*:13337");

            WebApp.Start(urls, builder => builder.UseFileServer(options).UseWebApi(config));
        }