Пример #1
0
        private void ThemeBtn_Click(object sender, RoutedEventArgs e)
        {
            ThemeWindow thwin = new ThemeWindow();

            thwin.Owner = this;
            thwin.ShowDialog();
        }
Пример #2
0
        /// <summary>
        /// Fired when a user selects the create a new theme menu option
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void ThemeCallback(object sender, EventArgs e)
        {
            var ssol     = dte.Solution;
            var projects = ssol.Projects;
            //if we need to use codegen or can use our extended theme generator
            bool extended = CheckFramework(projects);

            var vm = new ThemeViewModel();

            vm.Codegen = !extended;
            var window  = new ThemeWindow(vm);
            var success = window.ShowDialog();

            if (String.IsNullOrWhiteSpace(vm.ThemeName))
            {
                FireError("Please specify a name for your theme!");
                return;
            }

            vm.ThemeName = vm.ThemeName.Replace(" ", String.Empty);

            if (success.GetValueOrDefault() == false)
            {
                return;
            }

            var solution = GetGlobalService(typeof(SVsSolution)) as IVsSolution;

            if (!extended)
            //if(true)
            {
                var path = GetOrchardExe(solution);
                if (!File.Exists(path))
                {
                    FireError("Cannot find Orchard.exe, try building the solution and then creating your theme again");
                    return;
                }

                var basedon = String.IsNullOrEmpty(vm.BasedOn) ? String.Empty : "/BasedOn:" + vm.BasedOn.Trim();
                var cproj   = vm.CreateProject ? "/CreateProject:true" : String.Empty;

                var args = String.Format("codegen theme {0} {1} {2} /IncludeInSolution:true",
                                         Regex.Replace(vm.ThemeName, @"\s+", ""), cproj, basedon);

                ProcessStartInfo start = new ProcessStartInfo
                {
                    FileName  = path,
                    Arguments = "feature enable Orchard.CodeGeneration"
                };
                Process.Start(start).WaitForExit();

                ProcessStartInfo start2 = new ProcessStartInfo {
                    FileName = path, Arguments = args
                };
                Process.Start(start2);
                return;
            }

            if (vm.Type == null)
            {
                vm.Type = "Blank";
            }

            // get the Themes folder in the solution
            Project themesFolderProject = (from Project p in projects where p.Name == "Themes" select p).FirstOrDefault();

            if (themesFolderProject == null)
            {
                FireError("There appears to be no Themes folder");
            }
            SolutionFolder themesFolder = themesFolderProject.Object as SolutionFolder;

            // Orchard templates
            var     templates = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "OrchardTemplates");
            Project theme     = (from ProjectItem item in themesFolderProject.ProjectItems where item.Name == "Themes" select item.Object as Project).FirstOrDefault();

            if (vm.Type.Contains("Bootstrap"))
            {
                FireError("I haven't created the bootstrap theme... but I will! Maybe. Probably not. I'm lazy");
            }

            if (vm.Type.Contains("Blank"))
            {
                if (vm.CreateProject)
                {
                    BuildThemeWithProject(themesFolder, vm, templates, "__BlankThemeProject");
                    return;
                }

                BuildThemeFromTemplate(theme, vm, templates, "__BlankTheme");
                return;
            }

            if (vm.Type.Contains("Theme Machine"))
            {
                if (vm.CreateProject)
                {
                    var themeType = vm.Responsive ? "__TMRP" : "__TMP";
                    BuildThemeWithProject(themesFolder, vm, templates, themeType);
                    return;
                }
                else
                {
                    var themeType = vm.Responsive ? "__TMR" : "__TM";
                    BuildThemeFromTemplate(theme, vm, templates, themeType);
                    return;
                }
            }

            //// get the themes project
            //if (theme == null)
            //    FireError("Could not find themes folder!");

            //var projItems = theme.ProjectItems;
            //var themePath = theme.FileName.Replace("Themes.csproj", vm.ThemeName);

            //var newproj = projItems.AddFromDirectory(templates + "\\BlankTheme");
            //newproj.Name = vm.ThemeName;
            //Insert(themePath + "\\Theme.txt", new[]
            //{
            //    new KeyValuePair<string, string>("$ThemeName$", vm.ThemeName),
            //    new KeyValuePair<string, string>("$Author$", vm.Author ?? "Hazzamanic"),
            //    new KeyValuePair<string, string>("$Description$", vm.Description ?? "Theme created by Orchardizer"),
            //    new KeyValuePair<string, string>("$BasedOn$", vm.BasedOn ?? "")
            //});

            //if (vm.IncludeHelpFile)
            //    newproj.ProjectItems.AddFromFile(templates + "\\ThemeHelp.md");
        }
Пример #3
0
        /// <summary>
        /// Fired when a user selects the create a new theme menu option
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void ThemeCallback(object sender, EventArgs e)
        {
            var ssol = dte.Solution;
            var projects = ssol.Projects;
            //if we need to use codegen or can use our extended theme generator
            bool extended = CheckFramework(projects);

            var vm = new ThemeViewModel();
            vm.Codegen = !extended;
            var window = new ThemeWindow(vm);
            var success = window.ShowDialog();

            if (String.IsNullOrWhiteSpace(vm.ThemeName))
            {
                FireError("Please specify a name for your theme!");
                return;
            }

            vm.ThemeName = vm.ThemeName.Replace(" ", String.Empty);
            vm.Version = vm.Version ?? vm.Versions[0];

            if (success.GetValueOrDefault() == false)
                return;

            var solution = GetGlobalService(typeof(SVsSolution)) as IVsSolution;

            //if (!extended)
            if(false)
            {
                var path = GetOrchardExe(solution);
                if (!File.Exists(path))
                {
                    FireError("Cannot find Orchard.exe, try building the solution and then creating your theme again");
                    return;
                }

                var basedon = String.IsNullOrEmpty(vm.BasedOn) ? String.Empty : "/BasedOn:" + vm.BasedOn.Trim();
                var cproj = vm.CreateProject ? "/CreateProject:true" : String.Empty;

                var args = String.Format("codegen theme {0} {1} {2} /IncludeInSolution:true",
                    Regex.Replace(vm.ThemeName, @"\s+", ""), cproj, basedon);

                ProcessStartInfo start = new ProcessStartInfo
                {
                    FileName = path,
                    Arguments = "feature enable Orchard.CodeGeneration"
                };
                Process.Start(start).WaitForExit();

                ProcessStartInfo start2 = new ProcessStartInfo { FileName = path, Arguments = args };
                Process.Start(start2);
                return;
            }

            if (vm.Type == null) vm.Type = "Blank";

            // get the Themes folder in the solution
            Project themesFolderProject = (from Project p in projects where p.Name == "Themes" select p).FirstOrDefault();
            if (themesFolderProject == null)
            {
                FireError("There appears to be no Themes folder");
                return;
            }
            SolutionFolder themesFolder = themesFolderProject.Object as SolutionFolder;

            // Orchard templates
            var templates = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "OrchardTemplates");
            Project theme = (from ProjectItem item in themesFolderProject.ProjectItems where item.Name == "Themes" select item.Object as Project).FirstOrDefault();

            //if (vm.Type.Contains("Bootstrap"))
            //{
            //    FireError("I haven't created the bootstrap theme... but I will! Maybe. Probably not. I'm lazy");
            //    return;
            //}

                if (vm.CreateProject)
                {
                    BuildThemeWithProject(themesFolder, vm, templates, "__BlankThemeProject");
                    return;
                }

                BuildThemeFromTemplate(theme, vm, templates, "__BlankTheme");
                return;

            //if (vm.Type.Contains("Theme Machine"))
            //{
            //    if (vm.CreateProject)
            //    {
            //        var themeType = vm.Responsive ? "__TMRP" : "__TMP";
            //        BuildThemeWithProject(themesFolder, vm, templates, themeType);
            //        return;
            //    }
            //    else
            //    {
            //        var themeType = vm.Responsive ? "__TMR" : "__TM";
            //        BuildThemeFromTemplate(theme, vm, templates, themeType);
            //        return;
            //    }
            //}

            //// get the themes project
            //if (theme == null)
            //    FireError("Could not find themes folder!");

            //var projItems = theme.ProjectItems;
            //var themePath = theme.FileName.Replace("Themes.csproj", vm.ThemeName);

            //var newproj = projItems.AddFromDirectory(templates + "\\BlankTheme");
            //newproj.Name = vm.ThemeName;
            //Insert(themePath + "\\Theme.txt", new[]
            //{
            //    new KeyValuePair<string, string>("$ThemeName$", vm.ThemeName),
            //    new KeyValuePair<string, string>("$Author$", vm.Author ?? "Hazzamanic"),
            //    new KeyValuePair<string, string>("$Description$", vm.Description ?? "Theme created by Orchardizer"),
            //    new KeyValuePair<string, string>("$BasedOn$", vm.BasedOn ?? "")
            //});

            //if (vm.IncludeHelpFile)
            //    newproj.ProjectItems.AddFromFile(templates + "\\ThemeHelp.md");
        }