Esempio n. 1
0
        private void BtnClose_Click(object sender, RoutedEventArgs e)
        {
            Formdata f = new Formdata();

            using (FileStream fs = new FileStream(System.Reflection.Assembly.GetEntryAssembly().Location.Replace(@"\FesToolPCForm.exe", "") + "/Files/Metadata/Formdata.frd", FileMode.Open, FileAccess.Read))
            {
                using (StreamReader sr = new StreamReader(fs))
                {
                    f = JsonConvert.DeserializeObject <Formdata>((string)new Encryption().DecryptFile(sr.ReadToEnd(), Properties.Resources.Key));
                }
            }
            f.FirstBoot = false;
            using (FileStream fs = new FileStream(System.Reflection.Assembly.GetEntryAssembly().Location.Replace(@"\FesToolPCForm.exe", "") + "/Files/Metadata/Formdata.frd", FileMode.Open, FileAccess.Write))
            {
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.Write((string)new Encryption().EncryptFile(JsonConvert.SerializeObject(f), Properties.Resources.Key));
                }
            }
            if (mnw == null)
            {
                try
                {
                    MainWindow main = new MainWindow();
                    main.m = m;
                    main.Show();
                    this.Close();
                }
                catch
                {
                    SubWindow sub = new SubWindow();
                    sub.m = m;
                    sub.Show();
                    this.Close();
                }
            }
            else
            {
                this.Close();
            }
        }
Esempio n. 2
0
        private async void Boot()
        {
            lblTask.Content = "Creating directories";
            CreateDirectories();
            lblTask.Content = "Connecting to the internet";
            //var ping = new System.Net.NetworkInformation.Ping();
            //var result = ping.Send("www.google.com");
            if (!File.Exists(System.Reflection.Assembly.GetEntryAssembly().Location.Replace(@"\FesToolPCForm.exe", "") + "/Files/Metadata/Formdata.frd"))
            {
                using (FileStream fs = new FileStream(System.Reflection.Assembly.GetEntryAssembly().Location.Replace(@"\FesToolPCForm.exe", "") + "/Files/Metadata/Formdata.frd", FileMode.Create, FileAccess.Write))
                {
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        f.FirstBoot = true;
                        sw.Write((string)new Encryption().EncryptFile(JsonConvert.SerializeObject(f), Properties.Resources.Key));
                    }
                }
            }
            else
            {
                using (FileStream fs = new FileStream(System.Reflection.Assembly.GetEntryAssembly().Location.Replace(@"\FesToolPCForm.exe", "") + "/Files/Metadata/Formdata.frd", FileMode.Open, FileAccess.Read))
                {
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        f = JsonConvert.DeserializeObject <Formdata>((string)new Encryption().DecryptFile(sr.ReadToEnd(), Properties.Resources.Key));
                    }
                }
            }
            //if (result.Status == System.Net.NetworkInformation.IPStatus.Success)
            //{
            lblTask.Content = "Downloading metadata";
            try
            {
                await GetFile(System.Reflection.Assembly.GetEntryAssembly().Location.Replace(@"\FesToolPCForm.exe", "") + "/Files/Metadata/Metadata.mtd", "/Splatfest/Metadata/Metadata.mtd");

                using (FileStream fs = new FileStream(System.Reflection.Assembly.GetEntryAssembly().Location.Replace(@"\FesToolPCForm.exe", "") + "/Files/Metadata/Metadata.mtd", FileMode.Open, FileAccess.Read))
                {
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        m = JsonConvert.DeserializeObject <Metadata>((string)new Encryption().DecryptFile(sr.ReadToEnd(), Properties.Resources.Key));

                        if (m.Announce > DateTime.UtcNow || m.End < DateTime.UtcNow)
                        {
                            MessageBox.Show("There is currently no Splatfest going on. Injecting files will not be possible.");
                        }
                        if (m.HasCustomStage == true)
                        {
                            MessageBox.Show("Note: This Splatfest will have a custom stage! However, the files for this stage will not be distributed until the Splatfest starts! Please use this tool to safely install and deinstall these files!");
                        }
                        lblTask.Content = "Downloading original files";
                        try
                        {
                            await DownloadFiles();

                            lblTask.Content = "Loading FesTool";
                            try
                            {
                                if (f.FirstBoot == false)
                                {
                                    MainWindow a = new MainWindow();
                                    a.m = m;
                                    if (f.Address != "" && f.Address != null)
                                    {
                                        a.SavedAddress = f.Address;
                                    }
                                    a.Show();
                                    this.Close();
                                }
                                else
                                {
                                    Tutorial t = new Tutorial();
                                    t.m = m;
                                    t.Show();
                                    this.Close();
                                }
                            }
                            catch
                            {
                                if (f.FirstBoot == false)
                                {
                                    SubWindow a = new SubWindow();
                                    a.m = m;
                                    if (f.Address != "" && f.Address != null)
                                    {
                                        a.SavedAddress = f.Address;
                                    }
                                    a.Show();
                                    this.Close();
                                }
                                else
                                {
                                    Tutorial t = new Tutorial();
                                    t.m = m;
                                    t.Show();
                                    this.Close();
                                }
                            }
                        }
                        catch
                        {
                            MessageBox.Show("Could not retrieve original Splatfest files. Please try again later.");
                            this.Close();
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("Could not get the metadata file. Please try again later.");
                this.Close();
            }
            //}
            //else
            //{
            //    MessageBox.Show("Could not connect to the internet. Please make sure you have a working internet connection and try again.");
            //    this.Close();
            //}
        }