static public void StartStopService(bool start)
        {
            lock (instanceContext)
            {
                try
                {
                    //if(!WindowsUserRoutines.CurrentUserHasElevatedPrivileges())
                    if (!ProcessRoutines.ProcessHasElevatedPrivileges() && !ProcessRoutines.ProcessIsSystem() /*used for configuration during installing*/)
                    {
                        if (Message.YesNo("This action requires elevated privileges. Would you like to restart this application 'As Administrator'?"))
                        {
                            ProcessRoutines.Restart(true);
                        }
                        return;
                    }

                    double timeoutSecs = 20;
                    using (ServiceController serviceController = new ServiceController(Cliver.CisteraScreenCaptureService.Program.SERVICE_NAME))
                    {
                        if (start)
                        {
                            serviceController.Start();
                            serviceController.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(timeoutSecs));
                            if (serviceController.Status != ServiceControllerStatus.Running)
                            {
                                Message.Error("Could not start service '" + Cliver.CisteraScreenCaptureService.Program.SERVICE_NAME + "' within " + timeoutSecs + " secs.");
                            }
                        }
                        else
                        {
                            serviceController.Stop();
                            serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(timeoutSecs));
                            if (serviceController.Status != ServiceControllerStatus.Stopped)
                            {
                                Message.Error("Could not stop service '" + Cliver.CisteraScreenCaptureService.Program.SERVICE_NAME + "' within " + timeoutSecs + " secs.");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogMessage.Error(ex);
                }
                finally
                {
                }
            }
        }
        SettingsWindow()
        {
            InitializeComponent();
            System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(this);

            Icon = AssemblyRoutines.GetAppIconImageSource();

            ContentRendered += delegate
            {
                //this.MinHeight = this.ActualHeight;
                //this.MaxHeight = this.ActualHeight;
                //this.MinWidth = this.ActualWidth;
            };

            WpfRoutines.AddFadeEffect(this, 300);

            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            //WindowStartupLocation = WindowStartupLocation.CenterScreen;
            //DefaultServerIp.ValueDataType = typeof(IPAddress);

            general = UiApiClient.GetServiceSettings();
            if (general == null)
            {
                ok.IsEnabled    = false;
                reset.IsEnabled = false;
                Message.Error("The service is unavailable.");
                return;
            }
            set();

            if (!ProcessRoutines.ProcessHasElevatedPrivileges() && !ProcessRoutines.ProcessIsSystem() /*used for configuration during installing*/)
            {
                ok.IsEnabled    = false;
                reset.IsEnabled = false;
                if (Message.YesNo("Settings modification requires elevated privileges. Would you like to restart this application 'As Administrator'?"))
                {
                    ProcessRoutines.Restart(true);
                }
            }
        }