Beispiel #1
0
        private async void SolutionEvents_Opened()
        {
            foreach (Project project in ProjectHelpers.GetAllProjects())
            {
                if (project.ProjectItems.Count == 0)
                {
                    continue;
                }

                string folder = ProjectHelpers.GetRootFolder(project);
                Func <string, bool, Task> bundleFunc = new BundleFilesMenu().UpdateBundleAsync;
                Func <string, bool, Task> spriteFunc = new SpriteImageMenu().UpdateSpriteAsync;

                foreach (string file in Directory.EnumerateFiles(folder, "*.*", SearchOption.AllDirectories)
                         .Where(s => s.EndsWith(".bundle") || s.EndsWith(".sprite")))
                {
                    if (ProjectHelpers.GetProjectItem(file) == null)
                    {
                        continue;
                    }

                    if (file.EndsWith(".bundle", StringComparison.OrdinalIgnoreCase))
                    {
                        await BundleGenerator.WatchFiles(await BundleDocument.FromFile(file), bundleFunc);
                    }
                    else
                    {
                        await SpriteGenerator.WatchFiles(await SpriteDocument.FromFile(file), spriteFunc);
                    }
                }
            }
        }
 private async Task UpdateSpriteAsync()
 {
     try
     {
         await Task.WhenAll(_sprites.Select(async file =>
         {
             SpriteDocument doc = SpriteDocument.FromFile(file);
             await GenerateAsync(doc);
         }));
     }
     catch (FileNotFoundException ex)
     {
         Logger.Log(ex.Message);
         MessageBox.Show("The file '" + Path.GetFileName(ex.Message) + "' does not exist");
         _dte.StatusBar.Text = "Sprite was not created";
     }
     catch (Exception ex)
     {
         Logger.Log(ex);
         MessageBox.Show("Error generating the sprite. See output window for details");
     }
 }