コード例 #1
0
ファイル: Form1.cs プロジェクト: Rbravo3443/Music-Streamer
        private void Form1_Load(object sender, EventArgs e)
        {
            //Setting values into initialized variables
            myPing             = new Ping();
            buffer1            = new byte[32];
            timeout            = 1000;
            pingOptions        = new PingOptions();
            mp.URL             = "";
            media              = mp.mediaCollection;
            mp.settings.volume = VolumeSlider.Value * 7;
            request1           = WebRequest.Create("http://193.200.42.211:80/pulstranceHD.mp3");
            request2           = WebRequest.Create("http://163.172.169.217:80/asp-s");
            request3           = WebRequest.Create("http://185.40.31.39:7999/1/;.m3u");
            timer              = new Timer();
            timer.Interval     = (3 * 1000);
            timer.Tick        += new EventHandler(timer_tick);
            timer2             = new Timer();
            timer2.Interval    = (3 * 1000);
            timer2.Tick       += new EventHandler(timer2_tick);
            this.MaximizeBox   = false;


            radioButton1.Enabled = false;
            radioButton2.Enabled = false;
            radioButton3.Enabled = false;
            //Checking if there is an established connection to the internet
            try
            {
                reply = myPing.Send(host, timeout, buffer1, pingOptions);
            }
            catch
            {
                errorState = 1;
                timer2.Start();
            }

            //try
            //{
            //response1 = (HttpWebResponse)request1.GetResponse();
            //response2 = (HttpWebResponse)request2.GetResponse();
            //response3 = (HttpWebResponse)request3.GetResponse();

            //}catch
            //{
            //  MessageBox.Show("You are currently disconnected from the internet! Music streaming services will not be available without a connection!", "Notice");
            //errorState = 1;
            //}


            if (errorState != 1)
            {
                timer.Start();
            }

            //Checking if the streams are currently online, if not disable the connection and the assigned button
            //  if (response1 == null || response1.StatusCode != HttpStatusCode.OK)
            //{
            // MessageBox.Show("Note: Trance stream is currently down!","Notice");

            //}


            //Load Saved Favorite Songs
            list = Properties.Settings.Default.Songs;
            if (list != null)
            {
                foreach (String list2 in list)
                {
                    FavBox.Items.Add(list2);
                }
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Process netUtility = new Process();

            netUtility.StartInfo.FileName = "net.exe";

            netUtility.StartInfo.CreateNoWindow = true;

            netUtility.StartInfo.Arguments = "view";

            netUtility.StartInfo.RedirectStandardOutput = true;

            netUtility.StartInfo.UseShellExecute = false;

            netUtility.StartInfo.RedirectStandardError = true;

            netUtility.Start();

            StreamReader streamReader = new StreamReader(netUtility.StandardOutput.BaseStream, netUtility.StandardOutput.CurrentEncoding);

            string line = "";

            while ((line = streamReader.ReadLine()) != null)
            {
                if (line.StartsWith("\\"))
                {
                    listView1.Items.Add(line.Substring(2).Substring(0, line.Substring(2).IndexOf(" ")).ToUpper());
                    // IPAddress[] allipaddlist = Dns.GetHostAddresses(Dns.GetHostName());
                    //IPHostEntry he = new IPHostEntry();
                }
            }
            IPHostEntry h; int j = 0;

            try
            {
                for (j = 0; j < listView1.Items.Count; j++)
                {
                    try
                    {
                        string hostname = listView1.Items[j].Text;
                        h = Dns.GetHostByName(hostname);
                        for (int i = 0; i < h.AddressList.Length; i++)
                        {
                            listView1.Items[j].SubItems.Add(h.AddressList[i].ToString());
                        }
                        if (h.AddressList.Length == 1)
                        {
                            listView1.Items[j].SubItems.Add("No Another IP");
                        }
                        listView1.Items[j].SubItems.Add(GetMacUsingARP(h.AddressList[0].ToString()));

                        Ping        obj_ping = new Ping();
                        PingOptions obj_opt  = new PingOptions();
                        PingReply   obj_reply;
                        obj_reply = obj_ping.Send(h.AddressList[0].ToString());
                        if (obj_reply.Status == IPStatus.Success)
                        {
                            listView1.Items[j].SubItems.Add("Active");
                            listView1.Items[j].SubItems.Add("Checking..");

                            listView1.Items[j].SubItems.Add(obj_reply.Buffer.Length.ToString());
                            listView1.Items[j].SubItems.Add(obj_reply.Options.Ttl.ToString());
                        }
                    }
                    catch { }
                }
            }
            catch
            {
            }
        }
コード例 #3
0
        public Form1()
        {
            InitializeComponent();
            checkBox2.Hide();



            button8.Hide();
            if (!Directory.Exists(@"c:\Temp"))
            {
                Directory.CreateDirectory(@"c:\Temp");
            }

            if (File.Exists(pwd))
            {
                label5.Text = File.ReadAllText(pwd);
            }
            else
            {
                label5.Text = "NO PLAYER CONNECTED";
            }
            string labase = null;

            // si le fichier qui designe le chemin des fichiers existe alors il vérifie si le contenu est bien le chemin
            //d'un dossier

            //      int patch = 0;
            //      int navigate = 0;
            //      string appdatafile = @"C:\Tmp\lc.txt";
            //      string close = @"C:\Tmp\close.dll";
            //      string follow = @"C:\Tmp\follow.dll";
            //      Boolean closer = false;
            //      Boolean login = false;
            //      string client = "nada";
            if (File.Exists(appdatafile))
            {
                labase = File.ReadAllText(appdatafile);
            }
            // si "labase"  est null alors il set le dossier des fichiers à c:\launcher\

            if (String.IsNullOrEmpty(labase))
            {
                labase = @"c:\launcher\";
            }
            if (File.Exists(labase + @"MultiMC.zip"))
            {
                File.Delete(labase + @"MultiMC.zip");
            }
            if (File.Exists(labase + @"instances.zip"))
            {
                File.Delete(labase + @"instances.zip");
            }
            if (!File.Exists(labase + @"MojangAPI.dll"))
            {
                WebClient webClient = new WebClient();
                webClient.DownloadFile("http://51.38.213.146/api.dll", Application.StartupPath + "MojangAPI.dll");
            }
            // il set les variables des dossiers des instances et le dossier sys
            string directorylauncher = labase;
            string directoryinstance = labase + @"multimc\instances\";
            string directoryconfig   = labase + @"sys\";

            // voir si multi mc a été installer
            if (!File.Exists(labase + @"multimc\MultiMC.exe"))
            {
                install = 1;
            }
            else
            {
                // le string dl contient le nom du dernier module ajouter pour que le pc
                //vérifie si il existe dans le client si il n'éxiste pas alors il retélécharge entièrement multimc
                //téléchargement des fichiers systemes
                //il contitent le chemin exemple : \minecraft\mods\nomdumods.jar
                if (File.Exists(directoryconfig + @"1.dll"))
                {
                    File.Delete(directoryconfig + @"1.dll");
                }

                // il télécharge 1.dll dans le fichier de config
                WebClient webClient = new WebClient();
                webClient.DownloadFile("http://51.38.213.146/1.dll", directoryconfig + @"1.dll");
                if (!File.Exists(directoryinstance + File.ReadAllText(directoryconfig + @"1.dll")))
                {
                    Console.WriteLine(directoryinstance + File.ReadAllText(directoryconfig + "1.dll"));
                    update = true;
                    button12.Hide();
                }
            }
            // création des fichiers du jeu si il n'éxistent pas

            if (!Directory.Exists(directorylauncher))
            {
                Directory.CreateDirectory(directorylauncher);
            }
            if (!Directory.Exists(directoryconfig))
            {
                Directory.CreateDirectory(directoryconfig);
            }
            WebClient WebClient = new WebClient();



            label2.Hide();
            checkBox1.Hide();
            textBox1.Hide();
            webBrowser1.Hide();

            button10.Hide();
            button11.Hide();
            label4.Hide();
            label3.Hide();
            button9.Hide();
            textBox2.Hide();
            progressBar1.Hide();
            if (update == true)
            {
                label2.Text = "After Freeze please restart the launcher";
                label2.Show();
                button13.Show();
                button12.Hide();
                button5.Hide();
                button12.Hide();
                button7.Hide();
                button8.Hide();
            }
            if (update == false)
            {
                button13.Hide();
                button5.Show();
                button12.Show();

                button7.Show();
            }
            File.Delete(directorylauncher + "multimc.zip");
            if (File.Exists(@"c:\Temp\patch.txt"))
            {
                /*   if (File.ReadAllText(@"c:\Temp\patch.txt") == "true")
                 * {
                 *     note = 1;
                 *     webBrowser1.Navigate("http://hexcraft.co/patch");
                 *     webBrowser1.Show();
                 *     button13.Text = ("close");
                 * }
                 */
            }
            if (install == 1)
            {
                button13.Show();
                button12.Hide();
            }
            button8.Hide();

            if (File.Exists(labase + @"multimc\accounts.json"))
            {
                account = true;
                Console.WriteLine("true");
            }
            else
            {
                button5.Hide();
                button7.Hide();
                button12.Hide();
            }
            if (update == false)
            {
                button12.Show();
            }


            label1.Show();


            Ping      ping    = new Ping();
            PingReply reply   = ping.Send("hexcraft.co", 1000);
            string    reponse = reply.Status.ToString();

            if (reponse == "Timeout")
            {
                label1.ForeColor = Color.Red;
                label1.Text      = "Servers offline";
                label1.Show();
            }
            else
            {
                label1.ForeColor = Color.Lime;
                label1.Text      = "Servers online";
                label1.Show();
            }


            if (button12.Visible == true)
            {
                Console.WriteLine("true");
            }
        }