コード例 #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);
                    }
                }
            }
        }
コード例 #2
0
        private async Task GenerateAsync(BundleDocument bundle, string extension, bool hasUpdated = false)
        {
            _dte.StatusBar.Text = "Generating bundle...";

            if (ProjectHelpers.GetProjectItem(bundle.FileName) == null)
            {
                ProjectHelpers.AddFileToActiveProject(bundle.FileName);
            }

            string bundleFile = Path.Combine(Path.GetDirectoryName(bundle.FileName), Path.GetFileNameWithoutExtension(bundle.FileName));

            if (!string.IsNullOrEmpty(bundle.OutputDirectory))
            {
                bundleFile = ProjectHelpers.GetAbsolutePathFromSettings(bundle.OutputDirectory, Path.Combine(Path.GetDirectoryName(bundle.FileName), Path.GetFileNameWithoutExtension(bundle.FileName)));
            }

            ProjectHelpers.CreateDirectoryInProject(bundleFile);

            bool hasChanged = await BundleGenerator.MakeBundle(bundle, bundleFile, UpdateBundleAsync);

            ProjectHelpers.AddFileToProject(bundle.FileName, bundleFile);

            if (!hasUpdated)
            {
                WebEssentialsPackage.DTE.ItemOperations.OpenFile(bundle.FileName);
            }

            if (bundle.Minified)
            {
                await BundleGenerator.MakeMinFile(bundleFile, extension, hasChanged);
            }

            _dte.StatusBar.Text = "Bundle generated";
        }
コード例 #3
0
        private async Task GenerateAsync(BundleDocument bundle, string extension, bool hasUpdated = false)
        {
            _dte.StatusBar.Text = "Generating bundle...";

            if (!hasUpdated)
            {
                ProjectHelpers.AddFileToActiveProject(bundle.FileName);
            }

            string bundleFile = Path.Combine(Path.GetDirectoryName(bundle.FileName), Path.GetFileNameWithoutExtension(bundle.FileName));
            bool   hasChanged = await BundleGenerator.MakeBundle(bundle, bundleFile, UpdateBundleAsync);

            if (!hasUpdated)
            {
                ProjectHelpers.AddFileToProject(bundle.FileName, bundleFile);
                EditorExtensionsPackage.DTE.ItemOperations.OpenFile(bundle.FileName);
            }

            if (bundle.Minified)
            {
                await BundleGenerator.MakeMinFile(bundleFile, extension, hasChanged);
            }

            _dte.StatusBar.Text = "Bundle generated";
        }