public MainWindow() { const string WINDOWS_FIREWALL_SERVICE = "MpsSvc"; using (var sc = new ServiceController(WINDOWS_FIREWALL_SERVICE)) { if ((sc.Status == ServiceControllerStatus.Running)) { Log.Instance.W(this, "Found working Windows Firewall Service"); MessageBoxResult result = MessageBox.Show(ClientUIPresenter.GetString("FoundworkingWindowsFirewallServiceWouldyouliketostopit") , ClientUIPresenter.GetString("Question") , MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: if (ClientMaintaining.IsRunningAsLocalAdmin()) { Log.Instance.W(this, ClientUIPresenter.GetString("Tryingtostop") ); try { sc.Stop(); ServiceHelper.ChangeStartMode(sc, ServiceStartMode.Disabled); System.Windows.MessageBox.Show( ClientUIPresenter.GetString("WindowsFirewallServicehasbeenstopped") , ClientUIPresenter.GetString("Success") , MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception e) { Log.Instance.W(this, ClientUIPresenter.GetString("Errorwhilestoptrying") + e.Message); System.Windows.MessageBox.Show( "Error while stop trying: " + e.Message, "Attention", MessageBoxButton.OK, MessageBoxImage.Warning); } //sc.sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(30)); if (sc.Status == ServiceControllerStatus.Stopped) { Console.WriteLine("Service '{0}' has been stopped", sc.DisplayName); } } else { System.Windows.MessageBox.Show( ClientUIPresenter.GetString("TostoptheWindowsFirewallServiceyoumustRunthisappasAdministrator") , ClientUIPresenter.GetString("Insufficientrightstostoptheservice") , MessageBoxButton.OK, MessageBoxImage.Warning); } break; case MessageBoxResult.No: System.Windows.MessageBox.Show( ClientUIPresenter.GetString("Youmayencountersomeproblemswhensearchingforotherpeoplesservers") , ClientUIPresenter.GetString("Attention") , MessageBoxButton.OK, MessageBoxImage.Warning); break; } } } settings.LocaleChanged += ChangeFormLocale; ClientMaintaining.ClientStateChanged += ClientEventsHandler; InitializeComponent(); cbLanguage.ItemsSource = new List <string> { "ru-RU", "en-US", "ms-MY" }; FillUpTextFields(); ChatGrid.Width = 0; SetDefaultValues(); ChatClientHandler.ChatMessageCame += (string s) => { Dispatcher.BeginInvoke(new ThreadStart(delegate { lbChatMessages.ItemsSource = new List <string>(); lbChatMessages.ItemsSource = ChatClientHandler.ChatBoxContainment; lbChatMessages.ScrollIntoView(lbChatMessages.Items[lbChatMessages.Items.Count - 1]); })); }; void SetDefaultValues() { tbLeaderName.Text = ClientMaintaining.IsRunningAsLocalAdmin() ? Miscelanious.GetComputerName() : string.Empty; tbPort.Text = ClientMaintaining.IsRunningAsLocalAdmin() ? "666" : string.Empty; tbYourName.Text = Miscelanious.GetComputerName(); } void ChangeFormLocale(string locale) { FillUpTextFields(); } void FillUpTextFields() { ClientUIPresenter presenter = new ClientUIPresenter(this); presenter.FillUpTextFields(); } StartupManual manual = new StartupManual(); if (!File.Exists(Path.Combine(Assembly.GetExecutingAssembly().Location .Replace(Assembly.GetExecutingAssembly().ManifestModule.Name, "") + "firstrun"))) { manual.ShowDialog(); File.Create(Path.Combine(Assembly.GetExecutingAssembly().Location .Replace(Assembly.GetExecutingAssembly().ManifestModule.Name, "") + "firstrun")); } // Create a timer with a two second interval. aTimer = new System.Timers.Timer(2000); // Hook up the Elapsed event for the timer. aTimer.Elapsed += MonitoringStringAutoUpdating; aTimer.AutoReset = true; aTimer.Enabled = true; }