Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Status_Check
- {
- public partial class Form1 : Form
- {
- string[] ServerName = { "Playstation Network", "XBOX Live" };
- string[] ServerURL = { "https://support.us.playstation.com/app/answers/detail/a_id/237/~/psn-status%3A-on", "https://support.xbox.com/en-US/xbox-live-status" };
- string[] Element = { "rn_AnswerText", "XboxLiveCoreServices" };
- char[] ElementChar = { '!', 'L' };
- int[] ElementNum = { 1, 189 };
- int Retry_Time = 60;
- int tick = 60;
- public Form1()
- {
- InitializeComponent();
- }
- private void MessageBox_Popup_Show(string Name)
- {
- MessageBox_Popup Mp = new MessageBox_Popup();
- if (!Mp.IsShown)
- {
- Mp.Show();
- Mp.Message = Name;
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- this.Width = 239;
- this.Height = 216;
- nsComboBox1.SelectedIndex = 0;
- }
- private void nsButton1_Click(object sender, EventArgs e)
- {
- if (nsButton1.Text == "Start Checking")
- {
- if (nsRadioButton1.Checked)
- webBrowser1.Url = new Uri(ServerURL[nsComboBox1.SelectedIndex]);
- else
- webBrowser1.Url = new Uri(nsTextBox1.Text);
- nsButton1.Text = "Stop Checking";
- this.Height = 272;
- Refresh_Timer.Enabled = true;
- nsComboBox1.Enabled = false;
- nsTextBox1.Enabled = false;
- nsRadioButton1.Enabled = false;
- nsRadioButton2.Enabled = false;
- }
- else
- {
- nsButton1.Text = "Start Checking";
- this.Height = 216;
- Refresh_Timer.Enabled = false;
- nsComboBox1.Enabled = true;
- nsTextBox1.Enabled = true;
- nsRadioButton1.Enabled = true;
- nsRadioButton2.Enabled = true;
- tick = Retry_Time;
- nsLabel2.Visible = false;
- nsLabel3.Value2 = "Connecting...";
- }
- }
- private void nsRadioButton1_CheckedChanged(object sender)
- {
- nsComboBox1.Enabled = nsRadioButton1.Checked;
- nsTextBox1.Enabled = !nsRadioButton1.Checked;
- }
- private void Refresh_Timer_Tick(object sender, EventArgs e)
- {
- nsLabel2.Value1 = "Retrying In";
- nsLabel2.Value2 = tick.ToString() + " Seconds";
- tick--;
- if (tick == 0)
- {
- nsLabel2.Value1 = "Refreshing";
- nsLabel2.Value2 = "...";
- webBrowser1.Refresh();
- tick = Retry_Time;
- }
- }
- private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
- {
- nsLabel2.Visible = true;
- if (nsRadioButton1.Checked)//Server
- {
- try
- {
- string Text = webBrowser1.Document.GetElementById(Element[nsComboBox1.SelectedIndex]).InnerHtml;
- if (Text[ElementNum[nsComboBox1.SelectedIndex]] == ElementChar[nsComboBox1.SelectedIndex])
- {
- nsLabel3.Value2 = " Offline";
- }
- else
- {
- nsLabel3.Value2 = " Online";
- MessageBox_Popup_Show(ServerName[nsComboBox1.SelectedIndex]);
- }
- }
- catch
- {
- nsLabel3.Value2 = "Error";
- }
- }
- else//Website
- {
- try
- {
- string Text = webBrowser1.Document.GetElementById("mainTitle").InnerText;
- if (Text == "This page can’t be displayed")
- {
- nsLabel3.Value2 = " Offline";
- }
- else
- {
- nsLabel3.Value2 = " Online";
- MessageBox_Popup_Show(nsTextBox1.Text);
- }
- }
- catch
- {
- nsLabel3.Value2 = " Online";
- MessageBox_Popup_Show(nsTextBox1.Text);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement