private void ThemeBtn_Click(object sender, RoutedEventArgs e) { ThemeWindow thwin = new ThemeWindow(); thwin.Owner = this; thwin.ShowDialog(); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); // Tool windows RunnerWindow.Initialize(this); ThemeWindow.Initialize(this); MultiInstanceWindow.Initialize(this); // Commands await TestCommand.InitializeAsync(this); await RunnerWindowCommand.InitializeAsync(this); await ThemeWindowCommand.InitializeAsync(this); await MultiInstanceWindowCommand.InitializeAsync(this); }
bool VSThemeWindow(IntPtr hwnd, bool forDialog) { if (_twd == null) { object uiShell = GetService(typeof(SVsUIShell)); _twd = GetInterfaceDelegate <ThemeWindow>(VSAssemblies.VSShellInterop11.GetType("Microsoft.VisualStudio.Shell.Interop.IVsUIShell5"), uiShell); if (_twd == null) { _twd = delegate(IntPtr h) { return(false); } } ; if (VSVersion.VS2013OrLater) { _sftc = GetInterfaceDelegate <SetFixedThemeColors>(VSAssemblies.VSShellInterop12.GetType("Microsoft.VisualStudio.Shell.Interop.IVsUIShell6"), uiShell); } if (_sftc == null) { _sftc = delegate(IntPtr h) {} } ; } bool r = _twd(hwnd); if (r && forDialog) { _sftc(hwnd); } return(r); } delegate IVsUIObject GetIconForFile(string filename, __VSUIDATAFORMAT desiredFormat); GetIconForFile _giff; delegate IVsUIObject GetIconForFileEx(string filename, __VSUIDATAFORMAT desiredFormat, out uint iconSource); GetIconForFileEx _giffEx;
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // Tool windows RunnerWindow.Initialize(this); ThemeWindow.Initialize(this); MultiInstanceWindow.Initialize(this); await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); // Commands await RunnerWindowCommand.InitializeAsync(this); await ThemeWindowCommand.InitializeAsync(this); await MultiInstanceWindowCommand.InitializeAsync(this); await BuildActiveProjectAsyncCommand.InitializeAsync(this); await BuildSolutionAsyncCommand.InitializeAsync(this); VS.Events.DocumentEvents.AfterDocumentWindowHide += DocumentEvents_AfterDocumentWindowHide; VS.Events.DocumentEvents.BeforeDocumentWindowShow += DocumentEvents_BeforeDocumentWindowShow; }
/// <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"); }
/// <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"); }