Datei: NDOPackage/Commands/OpenMappingTool.cs
Last Commit (946ad0e)
1 | namespace NDOVsPackage.Commands |
2 | { |
3 | ····[Command(PackageGuids.guidNDOPackageCmdSetString, PackageIds.cmdidOpenMappingTool)] |
4 | ····internal sealed class OpenMappingTool : BaseCommand<OpenMappingTool> |
5 | ····{ |
6 | ········protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) |
7 | ········{ |
8 | await VS. MessageBox. ShowWarningAsync( "OpenMappingTool", "Button clicked") ; |
9 | ········} |
10 | ····} |
11 | } |
12 |
New Commit (33e9857)
1 | // |
2 | // Copyright (c) 2002-2022 Mirko Matytschak |
3 | // (www.netdataobjects.de) |
4 | // |
5 | // Author: Mirko Matytschak |
6 | // |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
11 | // conditions: |
12 | |
13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
14 | // of the Software. |
15 | // |
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. |
21 | |
22 | |
23 | using EnvDTE; |
24 | using System.Diagnostics; |
25 | using System.IO; |
26 | using System.Linq; |
27 | using System.Text; |
28 | using System.Threading.Tasks; |
29 | using MessageBox = System.Windows.Forms.MessageBox; |
30 | using Project = EnvDTE.Project; |
31 | |
32 | |
33 | namespace NDOVsPackage.Commands |
34 | { |
35 | ····[Command(PackageGuids.guidNDOPackageCmdSetString, PackageIds.cmdidOpenMappingTool)] |
36 | ····internal sealed class OpenMappingTool : BaseCommand<OpenMappingTool> |
37 | ····{ |
38 | ········protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) |
39 | ········{ |
40 | ············try |
41 | ············{ |
42 | await ThreadHelper. JoinableTaskFactory. SwitchToMainThreadAsync( ) ; |
43 | ················System.Array solObjects = (Array) ApplicationObject.VisualStudioApplication.ActiveSolutionProjects; |
44 | ················if (solObjects.Length < 1) |
45 | ····················return; |
46 | |
47 | ················Project project = (Project) solObjects.GetValue( 0 ); |
48 | ················//················string s = ""; |
49 | ················//················foreach(EnvDTE.Property p in project.ConfigurationManager.ActiveConfiguration.Properties) |
50 | ················//····················s += p.Name + " "; |
51 | ················//················MessageBox.Show(s); |
52 | |
53 | ················string exeFile = Path.Combine( ApplicationObject.AssemblyPath, "Mapping.exe" ); |
54 | ················string mappingFile = project.MappingFilePath(); |
55 | ················mappingFile = "\"" + mappingFile + '"'; |
56 | ················string s = "-m:" + mappingFile; |
57 | ················ProcessStartInfo psi = new ProcessStartInfo( exeFile, s ); |
58 | ················psi.CreateNoWindow = false; |
59 | ················psi.UseShellExecute = false; |
60 | ················psi.RedirectStandardError = false; |
61 | ················psi.RedirectStandardOutput = false; |
62 | |
63 | ················System.Diagnostics.Process proc = System.Diagnostics.Process.Start( psi ); |
64 | ············} |
65 | ············catch (Exception ex) |
66 | ············{ |
67 | ················Debug.WriteLine( ex.ToString() ); |
68 | ················MessageBox.Show( ex.Message, "Open Mapping Tool" ); |
69 | ············} |
70 | ········} |
71 | |
72 | ········protected override void BeforeQueryStatus( EventArgs e ) |
73 | ········{ |
74 | ············ThreadHelper.JoinableTaskFactory.Run( async () => |
75 | ············{ |
76 | ················var activeProj = await VS.Solutions.GetActiveProjectAsync(); |
77 | ················await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); |
78 | ················Command.Enabled = activeProj.MappingFileExists(); |
79 | ············} ); |
80 | ········} |
81 | ····} |
82 | } |
83 |