/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); _applicationObject = (EnvDTE80.DTE2)this.GetService(typeof(EnvDTE.DTE)); // Add our command handlers for menu (commands must exist in the .vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the menu item. CommandID menuCommandID = new CommandID(GuidList.guidAttachToW3WPCmdSet, (int)PkgCmdIDList.cmdidAttachToW3WP); MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID); mcs.AddCommand(menuItem); } }
public ListFileDlg(EnvDTE80.DTE2 dte,RecordHandler rec) { InitializeComponent(); //�����ļ���ַ txt_FilePath.Text = RecordHandler.GetValueFromRegistry(); _manuallySettingSelection = false; _dte = dte; _fileNames = new System.Collections.Generic.List<ProjectItemInfo>(); foreach (EnvDTE.Project project in _dte.Solution.Projects) { WalkProject(project.ProjectItems); } LogTimer.Interval = 2000; LogTimer.Tick += new EventHandler(LogTimer_Tick); RecordTable = initRecordTable(); initProjectSelector(); btn_ReadRecordCurProject_Click(null, null); de_begin.DateTime = DateTime.Today; de_end.DateTime = DateTime.Today; recHandler = rec; }
/// <summary> /// Constructor /// </summary> /// <param name="dte">Instance of DTE to get the Output Window and Status Bar from</param> /// public CompilerStatus(EventBus eventBus) { _EventBus = eventBus; _DTE = _EventBus.DTE; _OutputWindow = _DTE.ToolWindows.OutputWindow.OutputWindowPanes.Item("Build"); _StatusBar = _DTE.StatusBar; }
public static void ClassInit(TestContext context) { _msgFilter = new MessageFilter(); var dteType = Type.GetTypeFromProgID("VisualStudio.DTE.12.0", true); _dte = (EnvDTE80.DTE2)Activator.CreateInstance(dteType, true); _testEnv = new TestEnv(); _dte.Solution.Open(_testEnv.SolutionFile); }
public static void ClassCleanup() { if (_dte != null) { _dte.Quit(); _dte = null; } if (_msgFilter != null) { _msgFilter.Dispose(); _msgFilter = null; } }
private void InitializeDTE() { Microsoft.VisualStudio.Shell.Interop.IVsShell shellService; this.dte2 = this.iServiceProvider.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SDTE)) as EnvDTE80.DTE2; if (this.dte2 == null) // The IDE is not yet fully initialized { shellService = this.iServiceProvider.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SVsShell)) as Microsoft.VisualStudio.Shell.Interop.IVsShell; this.dteInitializer = new DteInitializer(shellService, this.InitializeDTE); } else { this.dteInitializer = null; this.InitializeSolutionMonitor(); } }
/// <summary> /// Standard constructor for the tool window. /// </summary> public MyToolWindow() : base(null) { // Set the window title reading it from the resources. this.Caption = Resources.ToolWindowTitle; // Set the image that will appear on the tab of the window frame // when docked with an other window // The resource ID correspond to the one defined in the resx file // while the Index is the offset in the bitmap strip. Each image in // the strip being 16x16. this.BitmapResourceID = 301; this.BitmapIndex = 1; dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.12.0"); IServiceProvider sp; ServiceProvider serviceProvider = new ServiceProvider(dte2 as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on // the object returned by the Content property. base.Content = new MyControl(serviceProvider); }
/// <summary> /// Класс для заполнения словаря ключевых слов. /// </summary> public ReplacementDictionaryHelper(EnvDTE80.DTE2 dte, Dictionary <string, string> replacementDictionary) { Dte = dte ?? throw new ArgumentNullException(nameof(dte)); ReplacementDictionary = replacementDictionary ?? throw new ArgumentNullException(nameof(replacementDictionary)); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentReport(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, Tuple <string, string[]> schemas, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusOpenedDocumentsXml(applicationObject, menuCommand); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { var myCommand = sender as OleMenuCommand; EnvDTE80.DTE2 applicationObject = this.ServiceProvider.GetService(typeof(DTE)) as EnvDTE80.DTE2; object[] selectedItems = (object[])applicationObject.ToolWindows.SolutionExplorer.SelectedItems; var processArray = new List <ShaderCompileData>(); FindHLSLCompiler(out string fxc, "fxc.exe"); FindHLSLCompiler(out string dxc, "dxc.exe"); foreach (EnvDTE.UIHierarchyItem selectedUIHierarchyItem in selectedItems) { if (selectedUIHierarchyItem.Object is EnvDTE.ProjectItem) { EnvDTE.ProjectItem item = selectedUIHierarchyItem.Object as EnvDTE.ProjectItem; int size = item.FileCount; string fileName = item.FileNames[0]; if (IsShaderFile(fileName, out ShaderType shaderType)) { StreamReader reader = new StreamReader(fileName); if (reader != null) { string content = reader.ReadToEnd(); DetermineShaderLanguage(content, out ShaderLanguage language); ProcessStartInfo info = null; FindShaderMacros(content, language, out string[] macros); String outFile = Path.GetFileName(fileName) + ".bin"; String inFileFolder = Path.GetDirectoryName(fileName); String outFileFullPath = String.Format("{0}\\{1}", inFileFolder, outFile); switch (language) { case ShaderLanguage.HLSL: { DetermineShaderTarget(shaderType, fxc, dxc, out string shaderTarget, out string compiler); if (compiler == "") { WriteToOutputWindow("Cannot find HLSL Compiler. Make sure your Windows SDK has fxc.exe (dxc.exe for raytracing shader)"); continue; } GenerateHLSLArguments(shaderType, fileName, outFile, shaderTarget, out string compilerArguments); info = new ProcessStartInfo { UseShellExecute = false, FileName = String.Format("\"{0}\"", compiler), Arguments = compilerArguments, RedirectStandardError = true, RedirectStandardOutput = true, CreateNoWindow = true, }; break; } case ShaderLanguage.VULKAN_GLSL: { String configFileName = "config.conf"; String vulkanSDK = Environment.GetEnvironmentVariable("VULKAN_SDK"); String glslangValidator = vulkanSDK + "\\Bin\\glslangValidator.exe"; bool useConfigFile = File.Exists(fileName + "\\..\\" + configFileName); configFileName = String.Format("\"{0}\"", Path.Combine(fileName + "\\..\\", configFileName)); info = new ProcessStartInfo { UseShellExecute = false, FileName = glslangValidator, Arguments = String.Format("{0} -V \"{1}\" -o \"{2}\"", useConfigFile ? configFileName : " ", fileName, outFileFullPath), RedirectStandardError = true, RedirectStandardOutput = true, CreateNoWindow = true, }; break; } } for (int i = 0; i < macros.Length; ++i) { String prevArgs = info.Arguments; String macroFormat = String.Format("_{0}_{1}", processArray.Count, outFile); info.Arguments += macros[i]; info.Arguments = info.Arguments.Replace(outFile, macroFormat); WriteToOutputWindow(String.Format("Compiling {0}:\n\t {1} {2}\n", fileName, info.FileName, info.Arguments)); processArray.Add(new ShaderCompileData { fileName = fileName, outFileName = outFileFullPath.Replace(outFile, macroFormat), language = language, macros = macros[i].TrimStart().TrimEnd().Replace("-D", "").Replace("\"", ""), process = System.Diagnostics.Process.Start(info), }); info.Arguments = prevArgs; } } } else { WriteToOutputWindow(String.Format("Not supported : {0} Supported extensions are {1}\n", Path.GetFileName(fileName), String.Join(", ", shaderExtensions))); } } } for (int i = 0; i < processArray.Count; ++i) { // glslangValidator error message format /* * ERROR: C:\Users\agent47\Documents\Experimental\VisualStudio\ConsoleApp1\ConsoleApp1\skybox.frag:24: '' : syntax error, unexpected IDENTIFIER */ String errorLog = processArray[i].language == ShaderLanguage.VULKAN_GLSL ? processArray[i].process.StandardOutput.ReadToEnd() : processArray[i].process.StandardError.ReadToEnd(); processArray[i].process.WaitForExit(); if (processArray[i].process.ExitCode != 0) { // For Vulkan format the error message so user can double click on it in output window to get to exact line with error if (processArray[i].language == ShaderLanguage.VULKAN_GLSL) { errorLog = errorLog.Replace("ERROR: ", ""); String pattern = "([A-Za-z.0-9]+):(\\d+):"; Regex regex = new Regex(pattern); String replacement = String.Format("$1($2):"); String formattedError = regex.Replace(errorLog, replacement); errorLog = formattedError; } WriteToOutputWindow(String.Format("Failure : Shader {0} {1}\n{2}", Path.GetFileName(processArray[i].fileName), processArray[i].macros, errorLog)); } else { WriteToOutputWindow(String.Format("Success : Shader {0} {1} compiled successfully\n", Path.GetFileName(processArray[i].fileName), processArray[i].macros)); } // Cleanup if (processArray[i].language == ShaderLanguage.VULKAN_GLSL) { File.Delete(String.Format("SPIRV_OUTPUT_{0}.bin", i)); } File.Delete(processArray[i].outFileName); } }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusSolutionExplorerXmlAny(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { CommonHandlers.ActiveSolutionExplorerFolderSingle(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusOpenedDocumentsWebResourceText(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, string solutionUniqueName, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusOpenedDocumentsCSharp(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusSolutionExplorerCSharpSingle(applicationObject, menuCommand); CommonHandlers.ActionBeforeQueryStatusSolutionExplorerSingleItemContainsProject(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentJavaScript(applicationObject, menuCommand); CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, Properties.CommandNames.CodeJavaScriptUpdateEntityMetadataFileWithSelectCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentXml(applicationObject, menuCommand); CommonHandlers.ActionBeforeQueryStatusClipboardIsText(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusConnectionIsNotReadOnly(applicationObject, menuCommand); CommonHandlers.ActionBeforeQueryStatusFilesToAdd(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, string solutionUniqueName, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusSolutionExplorerItemContainsProjectAny(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusSolutionExplorerWebResourceSingle(applicationObject, menuCommand); CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, Properties.CommandNames.FileWebResourceExplorerCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusSolutionExplorerCSharpRecursive(applicationObject, menuCommand); }
public ProjectSystemClient(EnvDTE80.DTE2 dte) { _dte = dte; }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, string selectedSiteMap, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentIsXmlWithRoot(applicationObject, menuCommand, out _, AbstractDynamicCommandXsdSchemas.SiteMapXmlRoot); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusSolutionExplorerJavaScriptSingle(applicationObject, menuCommand); CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, Properties.CommandNames.FileJavaScriptUpdateGlobalOptionSetSingleFileWithSelectCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusSolutionExplorerWebResourceTextRecursive(applicationObject, menuCommand); }
protected virtual void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { }
public BreakpointsManager(EnvDTE80.DTE2 dte2) { m_dte2 = dte2; }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentJavaScriptHasLinkedSystemForm(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { _sourceSelectedFiles.CommandBeforeQueryStatus(applicationObject, menuCommand, SelectedFileType.CSharp); CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, Properties.CommandNames.CSharpEntityMetadataFileGenerationOptionsCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { _sourceSelectedFiles.CommandBeforeQueryStatus(applicationObject, menuCommand, SelectedFileType.WebResource); CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, this._commandNameForCorrection); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, Properties.CommandNames.CommonCrmConnectionCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentWebResourceText(applicationObject, menuCommand); CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, Properties.CommandNames.CodeWebResourceShowDifferenceCustomCommand); }
private void InitializeDte() { m_dte = this.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SDTE)) as EnvDTE80.DTE2; m_dteInitializer = null; }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.CorrectCommandNameForConnectionName(applicationObject, menuCommand, Properties.CommandNames.CommonEntityRelationshipOneToManyExplorerCommand); }
public ShortcutViewModel(EnvDTE80.DTE2 dte) { _applicationObject = dte; }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); applicationObject = (EnvDTE80.DTE2)GetService(typeof(EnvDTE.DTE)); // Add our command handlers for menu (commands must exist in the .vsct file) var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the menu item. mcs.AddCommand(new MenuCommand(MenuItemCallbackAuto, new CommandID(GuidList.guidNodeVsDebugger_PackageCmdSet, (int)PkgCmdIDList.cmdidNodeStartAuto))); mcs.AddCommand(new MenuCommand(MenuItemCallbackProject, new CommandID(GuidList.guidNodeVsDebugger_PackageCmdSet, (int)PkgCmdIDList.cmdidNodeStartProject))); mcs.AddCommand(new MenuCommand(MenuItemCallbackDocument, new CommandID(GuidList.guidNodeVsDebugger_PackageCmdSet, (int)PkgCmdIDList.cmdidNodeStartDocument))); mcs.AddCommand(new MenuCommand(MenuItemCallbackConfigure, new CommandID(GuidList.guidNodeVsDebugger_PackageCmdSet, (int)PkgCmdIDList.cmdidNodeConfigure))); } }
// TODO behaviour opening .cs files and .sln private void HandleOpenFile(ExplorerTreeViewItem explorerTreeViewItem) { if (explorerTreeViewItem.CanDrag == false) return; // Optional: implement open file behaviour string extension = System.IO.Path.GetExtension(explorerTreeViewItem.Text).ToLower().Trim(); // is directory? if (extension.Equals(string.Empty)) return; if (!AcceptedExtensions.Contains(extension)) return; switch (extension) { case ".gibbo": //EditorHandler.ChangeSelectedObject(SceneManager.GameProject); break; case ".scene": //System.Threading.ThreadPool.QueueUserWorkItem(o => Gibbo.Library.SceneManager.LoadScene(node.FullPath)); if (SceneManager.ActiveScene != null && MessageBox.Show("Do you want to save the current scene?", "Warning", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { SceneManager.SaveActiveScene(); } Gibbo.Library.SceneManager.LoadScene(explorerTreeViewItem.FullPath, true); EditorHandler.ChangeSelectedObject(Gibbo.Library.SceneManager.ActiveScene); EditorHandler.SelectedGameObjects = new List<GameObject>(); EditorHandler.SceneTreeView.CreateView(); //EditorHandler.EditorSplitterContainer.Panel2Collapsed = true; EditorHandler.ChangeSelectedObjects(); break; case ".cs": // TODO: add behaviour for opening .cs files string projectPath = SceneManager.GameProject.ProjectPath; #region SharpDevelop and Xamarin tries // MessageBox.Show(@"C:\Program Files (x86)\SharpDevelop\4.3\bin\SharpDevelop.exe :" + SceneManager.GameProject.ProjectPath + "\\Scripts.sln" + " : " + explorerTreeViewItem.FullPath); //C:\Program Files (x86)\SharpDevelop\4.3\bin\SharpDevelop.exe // C:\Program Files (x86)\Xamarin Studio\bin\XamarinStudio.exe // if (sharpDevelop == null || sharpDevelop.HasExited) // { // ProcessStartInfo pinfo = new ProcessStartInfo(); // pinfo.FileName = @"C:\Program Files (x86)\Xamarin Studio\bin\XamarinStudio.exe"; // pinfo.Arguments = "-nologo " + "Scripts.sln " + GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, explorerTreeViewItem.FullPath); // pinfo.WorkingDirectory = SceneManager.GameProject.ProjectPath; // //pinfo.RedirectStandardInput = true; // //pinfo.UseShellExecute = false; // sharpDevelop = Process.Start(pinfo); // } // else // { // SetForegroundWindow(sharpDevelop.MainWindowHandle); // //sharpDevelop. // //sharpDevelop.StandardInput.WriteLine(GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, explorerTreeViewItem.FullPath)); // //ProcessStartInfo pinfo = new ProcessStartInfo(); // //pinfo.FileName = @"C:\Program Files (x86)\SharpDevelop\4.3\bin\SharpDevelop.exe"; // //pinfo.Arguments = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, explorerTreeViewItem.FullPath); // //sharpDevelop.StartInfo = pinfo; // //sharpDevelop.Start(); // //using (StreamWriter sw = new StreamWriter(sharpDevelop.StandardInput)) // //{ // // if (sw.BaseStream.CanWrite) // // { // // sw.WriteLine(GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, explorerTreeViewItem.FullPath)); // // } // //} //} //break; // Process.Start(@"C:\Program Files (x86)\SharpDevelop\4.3\bin\SharpDevelop.exe " + SceneManager.GameProject.ProjectPath + "\\Scripts.sln"); #endregion // check if default editor is lime if (Properties.Settings.Default.DefaultScriptEditor.ToLower().Equals("lime")) { LimeScriptEditor.OpenScript(explorerTreeViewItem.FullPath); } // else, try visual studio else if (EditorUtils.CheckVisualStudioExistance(Properties.Settings.Default.DefaultScriptEditor)) { try { string rf = string.Empty; string editor = Properties.Settings.Default.DefaultScriptEditor; switch (editor) { case "VisualStudio2015": rf = "VisualStudio.DTE.14.0"; break; case "VisualStudio2013": rf = "VisualStudio.DTE.12.0"; break; case "VisualStudio2012": rf = "VisualStudio.DTE.11.0"; break; case "VisualStudio2010": rf = "VisualStudio.DTE.10.0"; break; //case "CSExpress2010": // rf = "VCSExpress.DTE.10.0"; // break; } // attempts to find a solution EnvDTE.DTE tmp2DTE; if (EditorCommands.TryToRestoreSolution(out tmp2DTE)) { // assign dte if a solution was found dte = tmp2DTE as EnvDTE80.DTE2; } /* // if instance exists, try to make it visible if (dte != null) { try { // attempts to access main window and make it visible dte.MainWindow.Visible = true; } catch (Exception) { // if unable, set instance to null in order to create one. dte = null; } }*/ // if there's no instance, create one if (dte == null) { // store the specified type visual studio instance (2015, 2013, 2012, 2010...) Type type = Type.GetTypeFromProgID(rf); // create that type of instance dte = (EnvDTE80.DTE2)Activator.CreateInstance(type); // create an unique guid and set it to dte main window caption, so we can search for it later on string uniqueGuid = Guid.NewGuid().ToString(); // change main window title using user32.dll SetWindowText. Unable to change it directly using 'set' » dte.MainWindow.Caption = "x" SetWindowText(new System.IntPtr(dte.MainWindow.HWnd), uniqueGuid); // make the window visible dte.MainWindow.Visible = true; // get every visual studio process (devenv.exe) Process[] pVSList = Process.GetProcessesByName("DEVENV"); // reset visual studio instance PID EditorCommands.VisualStudioInstancePID = 0; // iterate through every process and check its title foreach (Process pVS in pVSList) { // if the title is the Guid we stored previously, then store it if (uniqueGuid != string.Empty && pVS.MainWindowTitle.Equals(uniqueGuid)) { // store the visual studio instance PID EditorCommands.VisualStudioInstancePID = pVS.Id; break; } } // open solution dte.Solution.Open(UserPreferences.Instance.ProjectSlnFilePath); } // open document, which changes the title (which we had set to a Guid) to its name dte.Documents.Open(explorerTreeViewItem.FullPath); } catch (Exception e) { Properties.Settings.Default.DefaultScriptEditor = "None"; Properties.Settings.Default.Save(); MessageBox.Show("You don't have selected a default scripting editor!\nEither select one on the Settings Window or open the scripts solution (.sln file) with other IDE to manage the scripts", "Error!"); } } else { MessageBox.Show("You don't have selected a default scripting editor.\nEither select one on the Settings Window or open the scripts solution (.sln file) with other IDE to manage the scripts", "Error!"); } break; case ".sln": // checks if the file is a valid solution file (e.g. one could place a dummy file with .sln extension and try to open it. In that case, there's // no need to continue) bool validSolution = UserPreferences.Instance.ProjectSlnFilePath.Equals(explorerTreeViewItem.FullPath); // if it's a valid solution file, check if solution is already opened in order to avoid duplicate instances EnvDTE.DTE tmpDTE; if (validSolution && !EditorCommands.TryToRestoreSolution(out tmpDTE)) { // dte is null, since no visual studion solution instance was found // start solution process Process vsProcess = Process.Start(UserPreferences.Instance.ProjectSlnFilePath); // store its Id EditorCommands.VisualStudioInstancePID = vsProcess.Id; } // if it's not a valid solution, pop a message warning the user else if (!validSolution) { MessageBox.Show("Invalid solution file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } break; default: // Default behaviour, tries to use the default user opening for this type of file: try { Process.Start(explorerTreeViewItem.FullPath); } catch (Exception ex) { MessageBox.Show(ex.Message); } break; } }
public void SetDTE(_DTE applicationObject) { if (_applicationObject == null) { _applicationObject = applicationObject as EnvDTE80.DTE2; _solutionEvents = (EnvDTE.SolutionEvents)_applicationObject.Events.SolutionEvents; TextManagerEvents.Setup(); } }
/// <summary> /// Initialization of the package; this method is called right after the /// package is sited, so this is the place /// where you can put all the initialization code that rely on services /// provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); dte = Package.GetGlobalService(typeof(DTE)) as EnvDTE80.DTE2; var shellSettingsManager = new ShellSettingsManager(this); var writableSettingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); var settings = new SettingsHelper (CollectionPath, writableSettingsStore); clangStyle = new ClangFormatStyle(); styleDb = new StyleDatabase(settings); dte.Events.SolutionEvents.Opened += onSolutionOpened; dte.Events.SolutionEvents.AfterClosing += onSolutionClosed; dte.Events.SolutionEvents.Renamed += onSolutionRenamed; appEvents = dte.Events; solutionEvents = appEvents.SolutionEvents; rdt = new RunningDocumentTable (this); rdt.Advise(new RunningDocTableEvents(this)); // Add our command handlers for menu (commands must exist in the .vsct // file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the menu item. CommandID menuCommandID = new CommandID( GuidList.GuidCmdSet, (int)PkgCmdIDList.cmdIdOptions); OleMenuCommand menuItem = new OleMenuCommand(optionsDialogCallback, menuCommandID); mcs.AddCommand(menuItem); menuCommandID = new CommandID( GuidList.GuidCmdSet, (int)PkgCmdIDList.cmdIdFormatDocument); menuItem = new OleMenuCommand(formatDocumentCallback, menuCommandID); menuItem.BeforeQueryStatus += onBeforeQueryStatus; mcs.AddCommand(menuItem); menuCommandID = new CommandID( GuidList.GuidCmdSet, (int)PkgCmdIDList.cmdIdFormatFunction); menuItem = new OleMenuCommand(formatFunctionCallback, menuCommandID); menuItem.BeforeQueryStatus += onBeforeQueryStatus; mcs.AddCommand(menuItem); menuCommandID = new CommandID( GuidList.GuidCmdSet, (int)PkgCmdIDList.cmdIdFormatSelection); menuItem = new OleMenuCommand(formatSelectionCallback, menuCommandID); menuItem.BeforeQueryStatus += onBeforeQueryStatus; mcs.AddCommand(menuItem); } }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusConnectionIsNotReadOnly(applicationObject, menuCommand); CommonHandlers.ActionBeforeQueryStatusOpenedDocumentsWebResource(applicationObject, menuCommand); }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, ConnectionData connectionData, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentIsXmlWithRoot(applicationObject, menuCommand, out var doc, AbstractDynamicCommandXsdSchemas.RootSiteMap); }
// TODO behaviour opening .cs files and .sln private void HandleOpenFile(ExplorerTreeViewItem explorerTreeViewItem) { if (explorerTreeViewItem.CanDrag == false) return; // Optional: implement open file behaviour string extension = System.IO.Path.GetExtension(explorerTreeViewItem.Text).ToLower().Trim(); // is directory? if (extension.Equals(string.Empty)) return; if (!AcceptedExtensions.Contains(extension)) return; switch (extension) { case ".gibbo": //EditorHandler.ChangeSelectedObject(SceneManager.GameProject); break; case ".scene": //System.Threading.ThreadPool.QueueUserWorkItem(o => Gibbo.Library.SceneManager.LoadScene(node.FullPath)); if (SceneManager.ActiveScene != null && MessageBox.Show("Do you want to save the current scene?", "Warning", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { SceneManager.SaveActiveScene(); } Gibbo.Library.SceneManager.LoadScene(explorerTreeViewItem.FullPath, true); EditorHandler.ChangeSelectedObject(Gibbo.Library.SceneManager.ActiveScene); EditorHandler.SelectedGameObjects = new List<GameObject>(); EditorHandler.SceneTreeView.CreateView(); //EditorHandler.EditorSplitterContainer.Panel2Collapsed = true; EditorHandler.ChangeSelectedObjects(); break; case ".cs": // TODO: add behaviour for opening .cs files string projectPath = SceneManager.GameProject.ProjectPath; // se o programa que, por defeito abre os ficheiros .cs n for o ddeexec abre com notepad ou algo do género : má solução //var si = new System.Diagnostics.ProcessStartInfo { UseShellExecute = true, FileName = projectPath + @"\samples\SampleController.cs", Verb = "Open" }; //System.Diagnostics.Process.Start(si); // funciona bastante bem da 1ª vez; pode ser complicado encontrar o caminho do startinfo.filename //if (p == null || p.HasExited) // p = new Process(); //p.StartInfo.FileName = @"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.com"; //p.StartInfo.Arguments = projectPath + @"\Scripts.sln /command ""of " + explorerTreeViewItem.FullPath; //p.Start(); //dte = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.11.0"); // MessageBox.Show(@"C:\Program Files (x86)\SharpDevelop\4.3\bin\SharpDevelop.exe :" + SceneManager.GameProject.ProjectPath + "\\Scripts.sln" + " : " + explorerTreeViewItem.FullPath); //C:\Program Files (x86)\SharpDevelop\4.3\bin\SharpDevelop.exe // C:\Program Files (x86)\Xamarin Studio\bin\XamarinStudio.exe // if (sharpDevelop == null || sharpDevelop.HasExited) // { // ProcessStartInfo pinfo = new ProcessStartInfo(); // pinfo.FileName = @"C:\Program Files (x86)\Xamarin Studio\bin\XamarinStudio.exe"; // pinfo.Arguments = "-nologo " + "Scripts.sln " + GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, explorerTreeViewItem.FullPath); // pinfo.WorkingDirectory = SceneManager.GameProject.ProjectPath; // //pinfo.RedirectStandardInput = true; // //pinfo.UseShellExecute = false; // sharpDevelop = Process.Start(pinfo); // } // else // { // SetForegroundWindow(sharpDevelop.MainWindowHandle); // //sharpDevelop. // //sharpDevelop.StandardInput.WriteLine(GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, explorerTreeViewItem.FullPath)); // //ProcessStartInfo pinfo = new ProcessStartInfo(); // //pinfo.FileName = @"C:\Program Files (x86)\SharpDevelop\4.3\bin\SharpDevelop.exe"; // //pinfo.Arguments = GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, explorerTreeViewItem.FullPath); // //sharpDevelop.StartInfo = pinfo; // //sharpDevelop.Start(); // //using (StreamWriter sw = new StreamWriter(sharpDevelop.StandardInput)) // //{ // // if (sw.BaseStream.CanWrite) // // { // // sw.WriteLine(GibboHelper.MakeExclusiveRelativePath(SceneManager.GameProject.ProjectPath, explorerTreeViewItem.FullPath)); // // } // //} //} //break; // Process.Start(@"C:\Program Files (x86)\SharpDevelop\4.3\bin\SharpDevelop.exe " + SceneManager.GameProject.ProjectPath + "\\Scripts.sln"); if (Properties.Settings.Default.DefaultScriptEditor.ToLower().Equals("lime")) { LimeScriptEditor.OpenScript(explorerTreeViewItem.FullPath); } else if (EditorUtils.CheckVisualStudioExistance(Properties.Settings.Default.DefaultScriptEditor)) { try { string rf = string.Empty; string editor = Properties.Settings.Default.DefaultScriptEditor; switch (editor) { case "VisualStudio2013": rf = "VisualStudio.DTE.12.0"; break; case "VisualStudio2012": rf = "VisualStudio.DTE.11.0"; break; case "VisualStudio2010": rf = "VisualStudio.DTE.10.0"; break; //case "CSExpress2010": // rf = "VCSExpress.DTE.10.0"; // break; } if (dte == null || !dte.MainWindow.Visible) { Type type = Type.GetTypeFromProgID(rf); dte = (EnvDTE80.DTE2)Activator.CreateInstance(type); dte.MainWindow.Visible = true; dte.Solution.Open(UserPreferences.Instance.ProjectSlnFilePath); } dte.Documents.Open(explorerTreeViewItem.FullPath); } catch (Exception) { Properties.Settings.Default.DefaultScriptEditor = "None"; Properties.Settings.Default.Save(); MessageBox.Show("You don't have selected a default scripting editor!\nEither select one on the Settings Window or open the scripts solution (.sln file) with other IDE to manage the scripts", "Error!"); } } else { MessageBox.Show("You don't have selected a default scripting editor.\nEither select one on the Settings Window or open the scripts solution (.sln file) with other IDE to manage the scripts", "Error!"); } break; default: // Default behaviour, tries to use the default user opening for this type of file: try { Process.Start(explorerTreeViewItem.FullPath); } catch (Exception ex) { MessageBox.Show(ex.Message); } break; } }
public DocumentsMakerSingle(EnvDTE80.DTE2 dte2, Options settings) { this.m_logger = new Logger(dte2, settings); m_dte2 = dte2; m_settings = settings; }
public HostProjectWindow(EnvDTE80.DTE2 dte) { InitializeComponent(); this.dte = dte; }
protected override void CommandBeforeQueryStatus(EnvDTE80.DTE2 applicationObject, OleMenuCommand menuCommand) { CommonHandlers.ActionBeforeQueryStatusActiveDocumentCSharp(applicationObject, menuCommand); CommonHandlers.ActionBeforeQueryStatusActiveDocumentContainingProject(applicationObject, menuCommand); }