Advertisement
Seregamil

Launcher

Oct 20th, 2013
3,353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using System.Net;
  12. using System.Diagnostics;
  13. using Microsoft.Win32;
  14. using Microsoft.VisualBasic;
  15.  
  16.  
  17. namespace _launcher
  18. {
  19.     public partial class Form1 : Form
  20.     {
  21.         string _mainPage = "http://pawno.ru/";
  22.         string _imgURL = "http://add0n.hol.es/_launcher/logo.png";
  23.         string _newsURL = "http://add0n.hol.es/_launcher/_testNews.txt";
  24.         string _ip = "127.0.0.1:7777";
  25.  
  26.         public Form1()
  27.         {
  28.             InitializeComponent();
  29.         }
  30.  
  31.         private void Form1_Load(object sender, EventArgs e)
  32.         {//loading          
  33.             pictureBox1.Load(_imgURL);
  34.             richTextBox1.Clear();
  35.             siteNews();
  36.         }
  37.  
  38.         private void button1_Click(object sender, EventArgs e)
  39.         {//connect
  40.             if (textBox1.Text.Length < 3 || textBox1.Text.Length > 22) return;
  41.             using (var key = Registry.ClassesRoot.OpenSubKey(@"samp\shell\open\command\"))
  42.             {
  43.                 string value = (string)key.GetValue(null);
  44.  
  45.                 value = value.Remove(0, 1);
  46.                 value = value.Remove(value.Length - 14);
  47.                 key.Close();
  48.                 Registry.CurrentUser.OpenSubKey(@"Software\SAMP", true).SetValue("PlayerName", textBox1.Text);
  49.                 Process.Start(value+"samp", _ip);
  50.             }
  51.         }
  52.  
  53.         private void pictureBox1_DoubleClick(object sender, EventArgs e) { Process.Start(_mainPage); }
  54.         private void button2_Click(object sender, EventArgs e) { Process.Start(_mainPage); }
  55.  
  56.         public void siteNews()
  57.         {
  58.             WebRequest request = WebRequest.Create(_newsURL);
  59.             request.Credentials = CredentialCache.DefaultCredentials;
  60.             HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  61.             Console.WriteLine(response.StatusDescription);
  62.             Stream dataStream = response.GetResponseStream();
  63.             StreamReader reader = new StreamReader(dataStream);
  64.             string responseFromServer = reader.ReadToEnd();
  65.             reader.Close();
  66.             dataStream.Close();
  67.             response.Close();
  68.             richTextBox1.Text = "Новости проекта:\n" + responseFromServer;
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement