Beispiel #1
0
        public bool Getting_WindowsInfo(string path)
        {
            ManagedWimLib.Wim.GlobalInit("libwim-15.dll");
            try
            {
                ManagedWimLib.Wim     wim  = ManagedWimLib.Wim.OpenWim(path, ManagedWimLib.OpenFlags.DEFAULT);
                ManagedWimLib.WimInfo info = wim.GetWimInfo();
                string[] index             = new string[info.ImageCount];
                ManagedWimLib.CompressionType compression = info.CompressionType;

                for (int i = 0; i < info.ImageCount; i++)
                {
                    switch (info.CompressionType)
                    {
                    case ManagedWimLib.CompressionType.LZMS:
                        Windows_Editions_List.Rows.Add(wim.GetImageDescription(i + 1), (info.TotalBytes / (1024 * 1024)).ToString() + " MB", "LZMS");
                        break;

                    case ManagedWimLib.CompressionType.LZX:
                        Windows_Editions_List.Rows.Add(wim.GetImageDescription(i + 1), (info.TotalBytes / (1024 * 1024)).ToString() + " MB", "LZX");
                        break;

                    case ManagedWimLib.CompressionType.NONE:
                        Windows_Editions_List.Rows.Add(wim.GetImageDescription(i + 1), (info.TotalBytes / (1024 * 1024)).ToString() + " MB", "NONE");
                        break;

                    case ManagedWimLib.CompressionType.XPRESS:
                        Windows_Editions_List.Rows.Add(wim.GetImageDescription(i + 1), (info.TotalBytes / (1024 * 1024)).ToString() + " MB", "XPRESS");
                        break;
                    }
                }
                ManagedWimLib.Wim.GlobalCleanup();
                return(true);
            }
            catch
            {
                MessageBox.Show("Error loading the selected file: " + path);
                ManagedWimLib.Wim.GlobalCleanup();
                return(false);
            }
        }
        private void Timer1_Tick(object sender, EventArgs e)
        {
            Progress_Bar.Minimum = 0;
            Progress_Bar.Maximum = 100;
            string ss = IntegrateOS.Temporary_I.locatie;

            Percentage_Label.Text = string.Format("{0} %", Progress_Bar.Value);
            Percentage_Label.Refresh();

            if (Progress_Bar.Value == 0)
            {
                Progress_Bar.Value = Progress_Bar.Value + 20;
                ManagedWimLib.Wim.GlobalInit("libwim-15.dll");
                Thread t1 = new Thread(() => {
                    ManagedWimLib.Wim x = ManagedWimLib.Wim.OpenWim(IntegrateOS.Temporary_I.locatie, 0);
                    x.ExtractImage(Int32.Parse(IntegrateOS.Temporary_I.fix), IntegrateOS.Temporary_I.format + "\\", ManagedWimLib.ExtractFlags.ALL_CASE_CONFLICTS);
                })
                {
                    IsBackground = true
                };
                t1.Start();
                while (t1.IsAlive)
                {
                    Application.DoEvents();
                }
                Progress_Bar.Value    = 60;
                Percentage_Label.Text = Progress_Bar.Value.ToString() + " %";
                Percentage_Label.Refresh();
                Done_1.Visible = true;
            }
            if (Progress_Bar.Value == 60)
            {
                Extracting_windows_label.Font = new Font("Segoe UI Semilight", 14, FontStyle.Regular);
                Installing_Boot_Label.Font    = new Font("Segoe UI Semibold", 14, FontStyle.Italic);
                Extracting_windows_label.Refresh(); Installing_Boot_Label.Refresh();
                string[] epsilon = IntegrateOS.Temporary_I.format.Split('\\');
                IntegrateOS.Temporary_I.format = epsilon[0];
                Thread bootsect = new Thread(() => { Complete(); })
                {
                    IsBackground = true
                };
                bootsect.Start();
                bootsect.Join();
                Done_2.Visible        = true;
                Progress_Bar.Value    = 100;
                Percentage_Label.Text = Progress_Bar.Value.ToString() + "%";
                Percentage_Label.Refresh();
            }

            if (Progress_Bar.Value == 100)
            {
                Timer_Installation.Enabled = false;
                Progress_Bar.Enabled       = false;
                var result = MetroMessageBox.Show(this, "Do you want to restart the Windows to complete the installation?", "Succes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information, IntegrateOS.IntegrateOS_var.color_t);
                if (result == DialogResult.Yes)
                {
                    IntegrateOS.CMD_Process_Class.Process_CMD("shutdown -r -t 0", "cmd.exe");
                }
                else
                {
                    Environment.Exit(0);
                }
            }
        }