Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace WierszPolecen1
- {
- /// <summary>
- /// Program do uzywania polecenia Ping zaimplementowanego w systemie Windows
- /// </summary>
- public partial class MainWindow : Window
- {
- static String polecenie;
- public MainWindow()
- {
- InitializeComponent();
- }
- private void btnPolecenie_Click(object sender, RoutedEventArgs e)
- {
- MessageBox.Show(polecenie);
- try
- {
- System.Diagnostics.ProcessStartInfo procStartInfo =
- new System.Diagnostics.ProcessStartInfo("cmd", "/c " + polecenie);
- procStartInfo.UseShellExecute = true;
- System.Diagnostics.Process proc = new System.Diagnostics.Process();
- proc.StartInfo = procStartInfo;
- proc.Start();
- }
- catch (Exception e1)
- {
- MessageBox.Show(e1.Message);
- }
- }
- private void rbPing_Checked(object sender, RoutedEventArgs e)
- {
- polecenie = "ping " + txtIPDomain.Text;
- }
- private void rbTracert_Checked(object sender, RoutedEventArgs e)
- {
- polecenie = "tracert " + txtIPDomain.Text;
- }
- private void txtIPDomain_TextChanged(object sender, TextChangedEventArgs e)
- {
- if (!txtIPDomain.Text.Equals(""))
- {
- rbPing.IsEnabled = true;
- rbTracert.IsEnabled = true;
- btnPolecenie.IsEnabled = true;
- }
- else
- {
- rbPing.IsEnabled = false;
- rbTracert.IsEnabled = false;
- btnPolecenie.IsEnabled = false;
- }
- }
- private void btnZamknij_Click(object sender, RoutedEventArgs e)
- {
- this.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement