/// <summary> /// Updates <see cref="CurrentSettings"/>, making changes to other services (like forwarding ports) as necessary. /// </summary> /// <param name="newSettings">The settings to apply.</param> public void ChangeSettings(IMSSettings newSettings) { lock (CurrentSettings) { if (CurrentSettings.ManagementPort.AttemptUPnPForwarding) { PortManager.RemovePort(CurrentSettings.ManagementPort.Port); } if (newSettings.ManagementPort.AttemptUPnPForwarding) { PortManager.ForwardPort(newSettings.ManagementPort.Port); } if (CurrentSettings.ManagementPort.Port != newSettings.ManagementPort.Port) { WebServer.Stop(); WebServer.Port = newSettings.ManagementPort; WebServer.Start(); } if (CurrentSettings.RunIMSOnStartup != newSettings.RunIMSOnStartup) { if (newSettings.RunIMSOnStartup) { Process.Start("cmd.exe", "/C sc config IMS start=auto"); } else { Process.Start("cmd.exe", "/C sc config IMS start=demand"); } } CurrentSettings = newSettings; CurrentSettings.SaveConfiguration(); } }