示例#1
0
        public static void installForge()
        {
            if (ManifestManager.newForgeVersionJson != null)
            {
                HomeUserControl.ChangeDownLoadDescriptor("Installation de forge...");
                /* Create new Process and assign parameters */
                javaProcess.StartInfo = new ProcessStartInfo("javaw");
                javaProcess.StartInfo.CreateNoWindow = true;

                javaProcess.StartInfo.WorkingDirectory = CommonData.minecraftFolder;

                if (!File.Exists(CommonData.libraryFolder + "de/oceanlabs/mcp/mcp_config/1.15.2-20200307.202953/mcp_config-1.15.2-20200307.202953-mappings.txt"))
                {
                    PrepareMCPConfig();
                }
                if (!File.Exists(CommonData.libraryFolder + "net/minecraft/client/1.15.2/client-1.15.2-slim.jar") || !File.Exists(CommonData.libraryFolder + "net/minecraft/client/1.15.2/client-1.15.2-extra.jar"))
                {
                    PrepareClient();
                }
                if (!File.Exists(CommonData.libraryFolder + "net/minecraft/client/1.15.2-20200307.202953/client-1.15.2-20200307.202953-srg.jar"))
                {
                    PrepareClientSRG();
                }
                if (!File.Exists(CommonData.libraryFolder + "net/minecraftforge/forge/1.15.2-31.1.44/forge-1.15.2-31.1.44-client.jar"))
                {
                    InstallPatch();
                }
            }
            else if (ManifestManager.forgeV31InstallationProfile != null)
            {
            }
        }
示例#2
0
        private void Login(object sender, RoutedEventArgs e)
        {
            HomeUserControl _homeUserControl = new HomeUserControl();
            MainWindow      mainWindow       = new MainWindow();

            DatabaseConnection.SetConnection();
            DatabaseConnection.querySystemDetail();

            loginModel.login_username = usernameTextblock.Text;
            loginModel.Login_password = passwordTextblock.Password;

            loginMessage = LoginController.Login(loginModel);
            GlobalFunctions.ShowDebug(loginMessage.returnStatusModel.error_message);


            if (loginMessage.returnStatusModel.status == true)
            {
                //test solution store in GlobalVar but not recommend
                //GlobalVariables._mainWindow.ListViewItemHome_Selected(sender, e);
                //Change to Open Windows
                mainWindow.Show();
                this.Close();
            }
            else
            {
                passwordTextblock.Clear();
            }
        }
示例#3
0
        private static void downloadForgeMods()
        {
            HomeUserControl.ChangeDownLoadDescriptor("Étape 9/12 : Vérification des mods forge...");
            HomeUserControl.ChangeProgressBarValue(0);
            foreach (InstalledAddon addon in ManifestManager.packageJson.InstalledAddons)
            {
                FileDownloadInformation fileDownloadInformation = new FileDownloadInformation();

                string filePath = CommonData.modsFolder + addon.InstalledFile.FileName;
                fileDownloadInformation.outputPath = filePath;
                fileDownloadInformation.url        = addon.InstalledFile.DownloadUrl.AbsoluteUri;

                if (System.IO.File.Exists(filePath))
                {
                    /* Compare size */
                    if (new FileInfo(filePath).Length != addon.InstalledFile.FileLength)
                    {
                        /* Size is incorrect, add to download list */
                        fileToDownload.Add(fileDownloadInformation);
                    }
                }
                else
                {
                    /* add to download list */
                    fileToDownload.Add(fileDownloadInformation);
                }
            }

            HomeUserControl.ChangeDownLoadDescriptor("Étape 10/12 : Téléchargement des mods forge...");
            DownloadFiles();
        }
示例#4
0
        private void Init()
        {
            //實體化usercontrol的物件
            communicationStatusUserControl = new CommunicationStatusUserControl();
            recordUserControl        = new RecordUserControl();
            homeUserControl          = new HomeUserControl();
            buildingTableUserControl = new BuildingTableUserControl();

            //賦予dictionary key跟value
            pagesDictionary.Add(Page.Communication, communicationStatusUserControl);
            pagesDictionary.Add(Page.Record, recordUserControl);
            pagesDictionary.Add(Page.Home, homeUserControl);
            //pagesDictionary.Add(Page.BuildTable, buildingTableUserControl);

            //在contentPanel上加上三塊usercontrol
            contentPanel.Controls.Add(pagesDictionary[Page.Communication]);
            contentPanel.Controls.Add(pagesDictionary[Page.Record]);
            contentPanel.Controls.Add(pagesDictionary[Page.Home]);

            //最大塊的panel,用來加建表UI
            this.buildingTablePanel.Controls.Add(buildingTableUserControl);
            this.buildingTablePanel.Visible = false;

            //tree的event
            menuTreeView.AfterSelect += MenuTreeView_AfterSelect;
        }
示例#5
0
        private static void downloadConfigs()
        {
            fileToDownload.Clear();
            HomeUserControl.ChangeDownLoadDescriptor("Étape 11/12 : Vérification des configurations...");
            HomeUserControl.ChangeProgressBarValue(0);
            if (ManifestManager.packageConfigurationJson != null)
            {
                foreach (FileProperty file in ManifestManager.packageConfigurationJson.FileProperties)
                {
                    FileDownloadInformation fileDownloadInformation = new FileDownloadInformation();

                    string filePath = CommonData.scriptFolder + file.FileName;
                    fileDownloadInformation.outputPath = filePath;
                    fileDownloadInformation.url        = CommonData.packageInfoBaseURL + CommonData.packageName + "/scripts/" + file.FileName;

                    if (System.IO.File.Exists(filePath))
                    {
                        /* Compare size */
                        if (new FileInfo(filePath).Length != file.FileSize)
                        {
                            /* Size is incorrect, add to download list */
                            fileToDownload.Add(fileDownloadInformation);
                        }
                    }
                    else
                    {
                        /* add to download list */
                        fileToDownload.Add(fileDownloadInformation);
                    }
                }

                HomeUserControl.ChangeDownLoadDescriptor("Étape 12/12 : Téléchargement des configurations...");
                HomeUserControl.ChangeProgressBarValue(0);
                int currentConfig = 0;
                fileToDownload.ForEach(delegate(FileDownloadInformation libFile)
                {
                    /* Create dir if not exist */
                    if (!Directory.Exists(Path.GetDirectoryName(libFile.outputPath)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(libFile.outputPath));
                    }

                    /* Download file asset */
                    webClient.DownloadFile(libFile.url, libFile.outputPath);

                    HomeUserControl.ChangeProgressBarValue(++currentConfig * 100.0 / fileToDownload.Count);
                });
            }

            InsalledPackage newInstalledPackage = new InsalledPackage();

            newInstalledPackage.packageName    = CommonData.packageName;
            newInstalledPackage.packageVersion = CommonData.packageVersion;

            CommonData.launcherProfileJson.installedPackageVersion.Add(newInstalledPackage);
            CommonData.saveLauncherProfile();
        }
示例#6
0
 public NewReservation(HomeUserControl homeUserControl, DataBase context, Emplacement emplacement, Mode mode = Mode.Add, int resCode = -1) :
     this(homeUserControl, context, mode, resCode)
 {
     locationsListBox.Items.Add(new LocationItem
     {
         Location = _db.Emplacement.First(a => a.Code_Emplacement == emplacement.Code_Emplacement),
         Lodgers  = new HashSet <Lodger>()
     });
 }
示例#7
0
        public NewReservation(HomeUserControl homeUserControl, DataBase context, Mode mode = Mode.Add, int resCode = -1)
        {
            InitializeComponent();
            _homeUserControl = homeUserControl;
            if (context == null)
            {
                _db = new DataBase();
            }
            else
            {
                _db = context;
            }

            foreach (Client person in _db.Client)
            {
                reservationHolderComboBox.Items.Add(person.Personne.Nom_Personne + " " + person.Personne.Prenom_Personne);
                reservationHolderComboBox.AutoCompleteCustomSource.Add(person.Personne.Nom_Personne + " " + person.Personne.Prenom_Personne);
            }
            locationsListBox.DisplayMember = "LocationName";
            lodgersListBox.DisplayMember   = "ClientFullName";
            _mode = mode;
            Text  = Resources.add_a_reservation;

            _resToEditCode = resCode;
            if (_mode == Mode.Edit)
            {
                reservationHolderComboBox.Enabled = false;
                addReservationButton.Text         = Resources.edit;
                Text = Resources.edit_a_reservation;
                Reservation reservation = _db.Reservation.FirstOrDefault(a => a.Code_Reservation == resCode);
                if (reservation != null)
                {
                    beginDateTimePicker.Value = reservation.Date_Debut;
                    endDateTimePicker.Value   = reservation.Date_Fin;
                    PayedCheckBox.Checked     = reservation.Est_Paye;
                }
                foreach (Emplacement location in _db.Loge.Where(a => a.Code_Reservation == resCode).Select(a => a.Emplacement).Distinct())
                {
                    LocationItem locationItem = new LocationItem
                    {
                        Lodgers  = new HashSet <Lodger>(),
                        Location = location
                    };
                    locationsListBox.Items.Add(locationItem);
                    foreach (Personne lodger in _db.Loge.Where(a => a.Code_Emplacement == location.Code_Emplacement).Select(a => a.Personne).Distinct())
                    {
                        if (lodger.Client != null)
                        {
                            locationItem.Lodgers.Add(new Lodger
                            {
                                Client = lodger.Client
                            });
                        }
                    }
                }
            }
        }
示例#8
0
        public NewReservation(HomeUserControl homeUserControl, DataBase context, int codePerson, Mode mode = Mode.Add, int resCode = -1)
            : this(homeUserControl, context, mode, resCode)
        {
            Personne client = _db.Personne.Find(codePerson);

            if (client != null)
            {
                reservationHolderComboBox.Text = client.Nom_Personne + Resources.one_space + client.Prenom_Personne;
            }
        }
示例#9
0
        public NewShortcutDialog(NewMainWindow mw, HomeUserControl myBlogDialog, BlogContentModel blogContentModel, Shortcut shortcut)
        {
            InitializeComponent();

            this.mw               = mw;
            this.myBlogDialog     = myBlogDialog;
            this.blogContentModel = blogContentModel;
            this.shortcut         = shortcut;
            tbUrl.Text            = shortcut.url;
        }
示例#10
0
 private static void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e)
 {
     HomeUserControl.ChangeProgressBarValue(e.ProgressPercentage);
     // Displays the operation identifier, and the transfer progress.
     //System.Console.WriteLine("{0}    downloaded {1} of {2} bytes. {3} % complete...",
     //    (string)e.UserState,
     //    e.BytesReceived,
     //    e.TotalBytesToReceive,
     //    e.ProgressPercentage);
 }
示例#11
0
        private static void downloadForgeLibrairies()
        {
            HomeUserControl.ChangeDownLoadDescriptor("Étape 3/12 : Vérification des fichiers forge...");
            HomeUserControl.ChangeProgressBarValue(0);
            int currentAsset = 0;

            foreach (ForgeLibrary library in ManifestManager.forgeVersionJson.Libraries)
            {
                FileDownloadInformation fileDownloadInformation = new FileDownloadInformation();

                string[] tempSplitted = library.Name.Split(':');
                if (tempSplitted.Length == 3)
                {
                    string completedFilePath = tempSplitted[0].Replace('.', '/') + "/" + tempSplitted[1] + "/" + tempSplitted[2] + "/" + tempSplitted[1] + "-" + tempSplitted[2] + ".jar";

                    if (library.Url != null)
                    {
                        fileDownloadInformation.url = library.Url.AbsoluteUri + completedFilePath;
                    }
                    else
                    {
                        int result = ManifestManager.minecraftVersionJson.Id.CompareTo("1.13.0");
                        if (result >= 0)
                        {
                            if (library.Name.Contains("net.minecraftforge:forge"))
                            {
                                fileDownloadInformation.url = ManifestManager.packageJson.BaseModLoader.DownloadUrl.ToString();
                            }
                            else
                            {
                                fileDownloadInformation.url = "https://files.minecraftforge.net/maven/" + completedFilePath;
                            }
                        }
                        else
                        {
                            fileDownloadInformation.url = "https://libraries.minecraft.net/" + completedFilePath;
                        }
                    }
                    fileDownloadInformation.outputPath = CommonData.libraryFolder + completedFilePath;
                    classPathList.Add(fileDownloadInformation.outputPath);

                    if (File.Exists(fileDownloadInformation.outputPath))
                    {
                        File.Delete(fileDownloadInformation.outputPath);
                    }

                    fileToDownload.Add(fileDownloadInformation);
                }

                HomeUserControl.ChangeProgressBarValue(++currentAsset * 100.0 / ManifestManager.forgeVersionJson.Libraries.Length);
            }

            HomeUserControl.ChangeDownLoadDescriptor("Étape 4/12 : Téléchargement des fichiers forge...");
            DownloadFiles();
        }
示例#12
0
        private async Task _fillVideosToHomeArea(IReadOnlyList <Video> videos)
        {
            HomeUserControl home = this.MenuItems.First(x => x.MenuItemType == MenuItemType.OnlineVideos).Content as HomeUserControl;

            home.ClearVideos();
            foreach (var video in videos)
            {
                OnlineVideoCard card = new OnlineVideoCard(await Common.ToYoutubeVideo(video));
                home.AddVideo(card);
            }
        }
示例#13
0
 private static void Process_Exited(object sender, EventArgs e)
 {
     try
     {
         Directory.Delete(CommonData.nativeFolder, true);
     }
     catch (Exception)
     {
     }
     HomeUserControl.ChangeDownLoadDescriptor("Minecraft n'est pas lancé...");
     HomeUserControl.ChangeDownloadButtonVisibility(System.Windows.Visibility.Visible);
 }
示例#14
0
        void HomeUserControl_Disposed(object sender, EventArgs e)
        {
            homeUserControl.NewButtonClicked  -= homeUserControl_NewButtonClicked;
            homeUserControl.OpenButtonClicked -= homeUserControl_OpenButtonClicked;
            homeUserControl.Disposed          -= HomeUserControl_Disposed;
            homeUserControl = null;

            if (Controls.Count == 0)
            {
                ShowHomeUserControl();
            }
        }
示例#15
0
 public Reservations(HomeUserControl homeUserControl, int codeClient)
 {
     InitializeComponent();
     _homeUserControl = homeUserControl;
     _db = new DataBase();
     if (_db.Client.Any(c => c.Code_Personne == codeClient))
     {
         Personne person = _db.Client.First(a => a.Code_Personne == codeClient).Personne;
         titleLabel.Text = Resources.reservationTitleLabel + person.Nom_Personne + Resources.one_space + person.Prenom_Personne;
         _codePerson     = codeClient;
         RefreshReservations();
     }
 }
示例#16
0
        public MainForm()
        {
            synchronizationContext = (WindowsFormsSynchronizationContext)SynchronizationContext.Current;

            homeUserControl       = new HomeUserControl();
            webBrowserUserControl = new WebBrowserUserControl();
            wifiSetupUserControl  = new WifiSetupUserControl();

            InitializeComponent();

            MessageBus.Bus.Instance.Subscribe <UIEvent>(this, OnUIEvent);

            this.Width    = (int)(Screen.PrimaryScreen.Bounds.Width);
            this.Height   = (int)(Screen.PrimaryScreen.Bounds.Height);
            this.Location = new Point(0, 0);
        }
示例#17
0
 void ShowHomeUserControl()
 {
     if (homeUserControl == null)
     {
         homeUserControl = new HomeUserControl(this)
         {
             Dock = DockStyle.Fill
         };
         homeUserControl.NewButtonClicked  += homeUserControl_NewButtonClicked;
         homeUserControl.OpenButtonClicked += homeUserControl_OpenButtonClicked;
         homeUserControl.Disposed          += HomeUserControl_Disposed;
         Controls.Add(homeUserControl);
     }
     homeUserControl.Visible = true;
     closeableControl        = null;
 }
示例#18
0
        private static void downloadAssets()
        {
            int currentAsset = 0;

            /* Create directories */
            if (!Directory.Exists(CommonData.assetsIndexFolder))
            {
                Directory.CreateDirectory(CommonData.assetsIndexFolder);
            }

            System.IO.File.WriteAllText(CommonData.assetsIndexFolder + ManifestManager.minecraftVersionJson.Assets + ".json", ManifestManager.minecrafetVersionAssetsData);

            HomeUserControl.ChangeDownLoadDescriptor("Étape 1/12 : Vérification des assets...");
            HomeUserControl.ChangeProgressBarValue(0);
            fileToDownload.Clear();
            ManifestManager.assetsInformation.ForEach(delegate(AssetInformation assetInformation)
            {
                FileDownloadInformation fileDownloadInformation = new FileDownloadInformation();
                string assetPath = CommonData.assetsObjectFolder + assetInformation.GetFolder() + "/" + assetInformation.Hash;
                /* Check if object were already download */
                if (System.IO.File.Exists(assetPath))
                {
                    /* Check sha of file */
                    if (assetInformation.Hash != Metadata.GetSha1(assetPath))
                    {
                        /* File sha is incorrect */
                        fileDownloadInformation.url        = "http://resources.download.minecraft.net/" + assetInformation.GetFolder() + "/" + assetInformation.Hash;
                        fileDownloadInformation.outputPath = assetPath;
                        fileToDownload.Add(fileDownloadInformation);
                    }
                }
                else
                {
                    fileDownloadInformation.url        = "http://resources.download.minecraft.net/" + assetInformation.GetFolder() + "/" + assetInformation.Hash;
                    fileDownloadInformation.outputPath = assetPath;
                    fileToDownload.Add(fileDownloadInformation);
                }

                HomeUserControl.ChangeProgressBarValue(++currentAsset * 100.0 / ManifestManager.assetsInformation.Count);
            });

            /* download assets */
            HomeUserControl.ChangeDownLoadDescriptor("Étape 2/12 : Téléchargement des assets...");
            DownloadFiles();
        }
示例#19
0
        public ExpenseLoggerAppForm()
        {
            InitializeComponent();

            // Showing a label with user's firstName when they logged in.
            labelUserName.Text = "Hi, " + UserIdentity.Instance.FirstName;

            // Load Home User Control
            HomeUserControl homeUserControl = new HomeUserControl();

            SwitchView(homeUserControl, buttonHome);

            // Register events.
            buttonHome.Click       += ButtonHome_Click;
            buttonReport.Click     += ButtonReport_Click;
            buttonStatistics.Click += ButtonStatistics_Click;
            buttonSettings.Click   += ButtonSettings_Click;
            linkLabelSignOut.Click += LinkLabelSignOut_Click;
        }
示例#20
0
        private static void DownloadFiles()
        {
            HomeUserControl.ChangeProgressBarValue(0);
            int currentFile = 0;

            fileToDownload.ForEach(delegate(FileDownloadInformation libFile)
            {
                /* Create dir if not exist */
                if (!Directory.Exists(Path.GetDirectoryName(libFile.outputPath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(libFile.outputPath));
                }

                /* Download file asset */
                webClient.DownloadFile(libFile.url, libFile.outputPath);

                HomeUserControl.ChangeProgressBarValue(++currentFile * 100.0 / fileToDownload.Count);
            });

            fileToDownload.Clear();
        }
示例#21
0
        public static void StartMinecraft()
        {
            HomeUserControl.ChangeDownLoadDescriptor("Démarrage de minecraft...");
            CreateNatives();
            /* Create new Process and assign parameters */
            minecraftGame.StartInfo = new ProcessStartInfo("javaw");
            minecraftGame.StartInfo.CreateNoWindow = true;

            minecraftGame.EnableRaisingEvents = true;
            minecraftGame.Exited += Process_Exited;
            minecraftGame.StartInfo.WorkingDirectory = CommonData.minecraftFolder;
            if (ManifestManager.forgeVersionJson != null)
            {
                minecraftGame.StartInfo.Arguments = CreateCommand();
            }
            else
            {
                minecraftGame.StartInfo.Arguments = ParseArguments();
            }
            minecraftGame.Start();
            HomeUserControl.ChangeDownLoadDescriptor("Minecraft est lancé...");
        }
示例#22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //HomeUserControl userControl = new HomeUserControl();
        //userControl.getDropDownList().SelectedIndex = Convert.ToInt32(Session["disease"].ToString());
        //access the values from session

        HomeUserControl userControl = new HomeUserControl();

         if (Session["disease"] != null &&(int)Session["choice"] == 1)
        {
            string str = Session["disease"].ToString();
            getQueryByDisease(str);
        }
        if(Session["Medicine"]!=null && (int)Session["choice"]==2)
        {
            string str = Session["Medicine"].ToString();
            getQueryByMedicine(str);
        }
        if (Session["Doctor"] != null && (int)Session["choice"] == 3)
        {
            string docId = Session["Doctor"].ToString();
            getQueryByDoctor(docId);
        }
        if (Session["Symptoms"] != null && (int)Session["choice"] == 4)
        {
            string symptoms = Session["Symptoms"].ToString();
            getQueryBySymptoms(symptoms);

        }

        //HomeUserControl1.DDLIndex =Convert.ToInt32(Session["disease"]);
        if (!Page.IsPostBack)
        {

        }
    }
示例#23
0
        private static void downloadForgeV31Librairies()
        {
            HomeUserControl.ChangeDownLoadDescriptor("Étape 3/12 : Vérification des fichiers forge...");
            HomeUserControl.ChangeProgressBarValue(0);
            int currentAsset = 0;

            List <Library> toDelete = new List <Library>();

            foreach (Library library in ManifestManager.forgeV31InstallationProfile.Libraries)
            {
                if (library.Downloads.Artifact.Url == null)
                {
                    /* search for an other item with same name */
                    Library searchLib = ManifestManager.forgeV31InstallationProfile.Libraries.Find(lib => lib.Name == library.Name && lib.Downloads.Artifact.Url != null);
                    if (searchLib != null)
                    {
                        library.Downloads.Artifact.Url = searchLib.Downloads.Artifact.Url;
                        toDelete.Add(searchLib);
                    }
                }
            }

            foreach (Library libraryToDelete in toDelete)
            {
                ManifestManager.forgeV31InstallationProfile.Libraries.Remove(libraryToDelete);
            }

            foreach (Library library in ManifestManager.forgeV31InstallationProfile.Libraries)
            {
                FileDownloadInformation fileDownloadInformation = new FileDownloadInformation();

                string filePath = CommonData.libraryFolder + library.Downloads.Artifact.Path;
                string sha      = library.Downloads.Artifact.Sha1;
                fileDownloadInformation.outputPath = filePath;
                fileDownloadInformation.url        = library.Downloads.Artifact.Url.AbsoluteUri;

                classPathList.Add(fileDownloadInformation.outputPath);

                if (File.Exists(filePath))
                {
                    /* Compare size */
                    if (new FileInfo(filePath).Length != library.Downloads.Artifact.Size)
                    {
                        /* Size is incorrect, add to download list */
                        fileToDownload.Add(fileDownloadInformation);
                    }
                    else
                    {
                        /* Check sha of file */
                        if (sha != Metadata.GetSha1(filePath))
                        {
                            /* File sha is incorrect, download again */
                            fileToDownload.Add(fileDownloadInformation);
                        }
                    }
                }
                else
                {
                    /* add to download list */
                    fileToDownload.Add(fileDownloadInformation);
                }

                HomeUserControl.ChangeProgressBarValue(++currentAsset * 100.0 / ManifestManager.forgeV31InstallationProfile.Libraries.Count);
            }

            foreach (Library library in ManifestManager.forgeV31InstallationProfile.Libraries)
            {
                FileDownloadInformation fileDownloadInformation = new FileDownloadInformation();

                string filePath = CommonData.libraryFolder + library.Downloads.Artifact.Path;
                string sha      = library.Downloads.Artifact.Sha1;
                fileDownloadInformation.outputPath = filePath;
                if (library.Downloads.Artifact.Url != null)
                {
                    fileDownloadInformation.url = library.Downloads.Artifact.Url.AbsoluteUri;
                }

                if (File.Exists(filePath))
                {
                    /* Compare size */
                    if (library.Downloads.Artifact.Size != 0 && new FileInfo(filePath).Length != library.Downloads.Artifact.Size)
                    {
                        /* Size is incorrect, add to download list */
                        fileToDownload.Add(fileDownloadInformation);
                    }
                    else
                    {
                        /* Check sha of file */
                        if (sha != null && sha != Metadata.GetSha1(filePath))
                        {
                            /* File sha is incorrect, download again */
                            fileToDownload.Add(fileDownloadInformation);
                        }
                    }
                }
                else
                {
                    /* add to download list */
                    fileToDownload.Add(fileDownloadInformation);
                }

                HomeUserControl.ChangeProgressBarValue(++currentAsset * 100.0 / (ManifestManager.forgeV31InstallationProfile.Libraries.Count));
            }

            HomeUserControl.ChangeDownLoadDescriptor("Étape 4/12 : Téléchargement des fichiers forge...");
            DownloadFiles();
        }
示例#24
0
        /// <summary>
        /// Switch to the home screen.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonHome_Click(object sender, EventArgs e)
        {
            HomeUserControl homeUserControl = new HomeUserControl();

            SwitchView(homeUserControl, ((Button)sender));
        }
示例#25
0
        private static void downloadLibraries()
        {
            int currentAsset = 0;

            /* Create directories if needed */
            if (!Directory.Exists(CommonData.libraryFolder))
            {
                Directory.CreateDirectory(CommonData.libraryFolder);
            }

            HomeUserControl.ChangeDownLoadDescriptor("Étape 5/12 : Vérification des Librairies...");
            HomeUserControl.ChangeProgressBarValue(0);
            currentAsset = 0;
            foreach (MinecraftLibrary library in ManifestManager.minecraftVersionJson.Libraries)
            {
                bool libraryNeeded = false;

                /* first check if this lib is needed */
                if (library.Rules != null)
                {
                    foreach (LibraryRule libraryRule in library.Rules)
                    {
                        if (libraryRule.Action == Manifest.Action.Allow)
                        {
                            if (libraryRule.Os == null)
                            {
                                libraryNeeded = true;
                            }
                        }
                    }
                }
                else
                {
                    libraryNeeded = true;
                }

                if (libraryNeeded)
                {
                    System.Uri libraryUrl = null;
                    string     filePath   = "";
                    string     sha        = "";

                    /* check if file is native or not */
                    if (library.Downloads.Classifiers != null)
                    {
                        /* File is native */
                        if (library.Downloads.Classifiers.NativesWindows != null)
                        {
                            /* File is windows native */
                            libraryUrl = library.Downloads.Classifiers.NativesWindows.Url;
                            filePath   = CommonData.libraryFolder + library.Downloads.Classifiers.NativesWindows.Path;
                            sha        = library.Downloads.Classifiers.NativesWindows.Sha1;
                            nativesToExtract.Add(filePath);
                        }
                    }
                    else
                    {
                        /* File is library */
                        libraryUrl = library.Downloads.Artifact.Url;
                        filePath   = CommonData.libraryFolder + library.Downloads.Artifact.Path;
                        sha        = library.Downloads.Artifact.Sha1;
                        classPathList.Add(filePath);
                    }

                    if (libraryUrl != null)
                    {
                        FileDownloadInformation fileDownloadInformation = new FileDownloadInformation();
                        /* Check if version were already download */
                        if (System.IO.File.Exists(filePath))
                        {
                            /* Check sha of file */
                            if (sha != Metadata.GetSha1(filePath))
                            {
                                /* File sha is incorrect, download again */
                                fileDownloadInformation.url        = libraryUrl.AbsoluteUri;
                                fileDownloadInformation.outputPath = filePath;
                                fileToDownload.Add(fileDownloadInformation);
                            }
                        }
                        else
                        {
                            fileDownloadInformation.url        = libraryUrl.AbsoluteUri;
                            fileDownloadInformation.outputPath = filePath;
                            fileToDownload.Add(fileDownloadInformation);
                        }
                    }
                }
                HomeUserControl.ChangeProgressBarValue(++currentAsset * 100.0 / ManifestManager.minecraftVersionJson.Libraries.Length);
            }

            HomeUserControl.ChangeDownLoadDescriptor("Étape 6/12 : Téléchargement des Librairies...");
            DownloadFiles();
        }
示例#26
0
        private static void downloadNewForgeLibrairies()
        {
            HomeUserControl.ChangeDownLoadDescriptor("Étape 3/12 : Vérification des fichiers forge...");
            HomeUserControl.ChangeProgressBarValue(0);
            int currentAsset = 0;

            foreach (NewForgeLibrary library in ManifestManager.newForgeVersionJson.Libraries)
            {
                FileDownloadInformation fileDownloadInformation = new FileDownloadInformation();

                string filePath = CommonData.libraryFolder + library.Downloads.Artifact.Path;
                string sha      = library.Downloads.Artifact.Sha1;
                fileDownloadInformation.outputPath = filePath;
                fileDownloadInformation.url        = library.Downloads.Artifact.Url.AbsoluteUri;

                classPathList.Add(fileDownloadInformation.outputPath);

                if (File.Exists(filePath))
                {
                    /* Compare size */
                    if (new FileInfo(filePath).Length != library.Downloads.Artifact.Size)
                    {
                        /* Size is incorrect, add to download list */
                        fileToDownload.Add(fileDownloadInformation);
                    }
                    else
                    {
                        /* Check sha of file */
                        if (sha != Metadata.GetSha1(filePath))
                        {
                            /* File sha is incorrect, download again */
                            fileToDownload.Add(fileDownloadInformation);
                        }
                    }
                }
                else
                {
                    /* add to download list */
                    fileToDownload.Add(fileDownloadInformation);
                }

                HomeUserControl.ChangeProgressBarValue(++currentAsset * 100.0 / (ManifestManager.newForgeVersionJson.Libraries.Length + ManifestManager.forgeInstallationProfile.Libraries.Length));
            }

            foreach (NewForgeLibrary library in ManifestManager.forgeInstallationProfile.Libraries)
            {
                FileDownloadInformation fileDownloadInformation = new FileDownloadInformation();

                string filePath = CommonData.libraryFolder + library.Downloads.Artifact.Path;
                string sha      = library.Downloads.Artifact.Sha1;
                fileDownloadInformation.outputPath = filePath;
                if (library.Downloads.Artifact.Url != null)
                {
                    fileDownloadInformation.url = library.Downloads.Artifact.Url.AbsoluteUri;
                }
                else
                {
                    fileDownloadInformation.url = "https://files.minecraftforge.net/maven/" + library.Downloads.Artifact.Path;
                }

                if (File.Exists(filePath))
                {
                    /* Compare size */
                    if (library.Downloads.Artifact.Size != 0 && new FileInfo(filePath).Length != library.Downloads.Artifact.Size)
                    {
                        /* Size is incorrect, add to download list */
                        fileToDownload.Add(fileDownloadInformation);
                    }
                    else
                    {
                        /* Check sha of file */
                        if (sha != null && sha != Metadata.GetSha1(filePath))
                        {
                            /* File sha is incorrect, download again */
                            fileToDownload.Add(fileDownloadInformation);
                        }
                    }
                }
                else
                {
                    /* add to download list */
                    fileToDownload.Add(fileDownloadInformation);
                }

                HomeUserControl.ChangeProgressBarValue(++currentAsset * 100.0 / (ManifestManager.newForgeVersionJson.Libraries.Length + ManifestManager.forgeInstallationProfile.Libraries.Length));
            }

            HomeUserControl.ChangeDownLoadDescriptor("Étape 4/12 : Téléchargement des fichiers forge...");
            DownloadFiles();
        }
示例#27
0
        private static void downloadMinecraft()
        {
            FileDownloadInformation gameDownloadInformation      = new FileDownloadInformation();
            FileDownloadInformation logconfigDownloadInformation = new FileDownloadInformation();

            if (!Directory.Exists(CommonData.versionFolder + ManifestManager.minecraftVersionJson.Id))
            {
                Directory.CreateDirectory(CommonData.versionFolder + ManifestManager.minecraftVersionJson.Id);
            }

            HomeUserControl.ChangeDownLoadDescriptor("Étape 7/12 : Vérification des fichiers du jeu...");
            string gameFilePath = CommonData.versionFolder + ManifestManager.minecraftVersionJson.Id + "/" + ManifestManager.minecraftVersionJson.Id + ".jar";

            gameDownloadInformation.url        = ManifestManager.minecraftVersionJson.Downloads.Client.Url.AbsoluteUri;
            gameDownloadInformation.outputPath = gameFilePath;

            /* Check if version were already download */
            if (System.IO.File.Exists(gameFilePath))
            {
                /* Check sha of file */
                if (ManifestManager.minecraftVersionJson.Downloads.Client.Sha1 != Metadata.GetSha1(gameFilePath))
                {
                    /* File sha is incorrect */
                    fileToDownload.Add(gameDownloadInformation);
                }
            }
            else
            {
                fileToDownload.Add(gameDownloadInformation);
            }

            if (ManifestManager.minecraftVersionJson.Logging.Client.File != null)
            {
                if (!Directory.Exists(CommonData.assetsLogConfigFolder))
                {
                    Directory.CreateDirectory(CommonData.assetsLogConfigFolder);
                }

                logconfigDownloadInformation.url        = ManifestManager.minecraftVersionJson.Logging.Client.File.Url.AbsoluteUri;
                logconfigDownloadInformation.outputPath = CommonData.assetsLogConfigFolder + ManifestManager.minecraftVersionJson.Logging.Client.File.Id;

                if (System.IO.File.Exists(logconfigDownloadInformation.outputPath))
                {
                    /* Check sha of file */
                    if (ManifestManager.minecraftVersionJson.Logging.Client.File.Sha1 != Metadata.GetSha1(logconfigDownloadInformation.outputPath))
                    {
                        fileToDownload.Add(logconfigDownloadInformation);
                    }
                }
                else
                {
                    fileToDownload.Add(logconfigDownloadInformation);
                }
            }

            HomeUserControl.ChangeDownLoadDescriptor("Étape 8/12 : Téléchargement des fichiers du jeu...");
            /* record json into this same path if not exist */
            string gameJSONFilePath = CommonData.versionFolder + ManifestManager.minecraftVersionJson.Id + "/" + ManifestManager.minecraftVersionJson.Id + ".json";

            if (!System.IO.File.Exists(gameJSONFilePath))
            {
                /* record the json file */
                System.IO.File.WriteAllText(gameJSONFilePath, ManifestManager.manifestVersionData);
            }

            DownloadProgressChangedEventHandler eventHandler = new DownloadProgressChangedEventHandler(DownloadProgressCallback);

            fileToDownload.ForEach(delegate(FileDownloadInformation libFile)
            {
                /* Create dir if not exist */
                if (!Directory.Exists(Path.GetDirectoryName(libFile.outputPath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(libFile.outputPath));
                }

                /* Download file asset */
                webClient.DownloadProgressChanged += eventHandler;
                webClient.DownloadFileAsync(new System.Uri(libFile.url), libFile.outputPath);
                while (webClient.IsBusy)
                {
                }
            });

            webClient.DownloadProgressChanged -= eventHandler;
        }
示例#28
0
 internal void Login()
 {
     _homeUserControl = new HomeUserControl(this);
     WindowPanel.Controls.Add(_homeUserControl);
     WindowPanel.Controls.Remove(_connectionUserControl);
 }