private void ControlButton_Click(object sender, RoutedEventArgs e)
 {
     if (!Working)
     {
         try
         {
             NetworkOperator.ServerPort = int.Parse(ServerAddress.Text);
         }
         catch
         {
             MessageBox.Show("Некорректный адрес");
         }
         Receiver = new CommandReceiver(NetworkOperator.ServerPort);
         Receiver.Start();
         ServerAddress.IsEnabled = false;
         Working               = true;
         PowerIndicator.Fill   = Brushes.Green;
         ControlButton.Content = "Остановить";
     }
     else
     {
         Receiver.Stop();
         ServerAddress.IsEnabled = true;
         Working               = false;
         PowerIndicator.Fill   = Brushes.Red;
         ControlButton.Content = "Запустить";
     }
 }
Beispiel #2
0
        public static void Clean()
        {
            _cmmdReceiver.Stop();
            _cmmdReceiver.Dispose();

            var cmmdFiles = Directory.EnumerateFiles(CommandFile.SharedFolder, $"*{CommandFile.FileExtension}").ToArray();

            Parallel.ForEach(cmmdFiles, (f) => File.Delete(f));

            File.Delete(_localDbFilePath);
            File.Delete(_sharedFolderDbFilePath);
        }