private void thread_DoWork(object sender, DoWorkEventArgs e)
        {
            if (isDemoProject)
            {
                string demoZipPath = System.Windows.Forms.Application.StartupPath + @"\APIDemo.lmg";
                if (File.Exists(demoZipPath))
                {
                    ZipFile zip = new ZipFile(demoZipPath);
                    if (Directory.Exists(dstPath + @"\APIDemo"))
                    {
                        createResult = false;
                        return;
                    }
                    IEnumerator<ZipEntry> entries = zip.GetEnumerator();

                    maxFileCount = 0;
                    while (entries.MoveNext())
                    {
                        ZipEntry entry = entries.Current;
                        maxFileCount++;
                    }

                    entries = zip.GetEnumerator();
                    currentFileCount = 0;
                    while (entries.MoveNext())
                    {
                        ZipEntry entry = entries.Current;
                        entry.Extract(dstPath, ExtractExistingFileAction.OverwriteSilently);
                        pd.UpdateProgress((double)(++currentFileCount) / (double)maxFileCount);
                        pd.UpdateStatus(entry.FileName);
                    }
                }
                else
                {
                    createResult = false;
                }
            }
            else
            {
                maxFileCount = fileCount(srcPath);
                currentFileCount = 0;
                Thread.Sleep(100);
                //dstPath += @"\" + projectName;
                if (Directory.Exists(dstPath))
                {
                    createResult = false;
                    return;
                }
                copyAll(srcPath, dstPath);

                if (isLandscape)
                    File.Delete(dstPath + @"\assets\main_portrait.lua");
                else
                {
                    File.Delete(dstPath + @"\assets\main.lua");
                    File.Move(dstPath + @"\assets\main_portrait.lua", dstPath + @"\assets\main.lua");
                }

                createProjectInformationFile();
            }
        }
Example #2
0
 private void Initialise(Stream zipStream)
 {
     try
     {
         zipFile = ZipFile.Read(zipStream);
     }
     catch (ZipException e)
     {
         throw new ArgumentException("Cannot read input as a ZipFile", "zipStream", e);
     }
     
     enumerator = zipFile.GetEnumerator();
     zipFile.ExtractProgress += zipFile_ExtractProgress;
 }