/CPML/DslPackage/GeneratedCode/CommandSet.cs

http://mddpm.codeplex.com · C# · 268 lines · 149 code · 31 blank · 88 comment · 6 complexity · fde86a05d02bf49cc55a46ade0ff4a37 MD5 · raw file

  1. //------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // This code was generated by a tool.
  4. //
  5. // Changes to this file may cause incorrect behavior and will be lost if
  6. // the code is regenerated.
  7. // </auto-generated>
  8. //------------------------------------------------------------------------------
  9. using DslShell = global::Microsoft.VisualStudio.Modeling.Shell;
  10. using VSShell = global::Microsoft.VisualStudio.Shell;
  11. using DslModeling = global::Microsoft.VisualStudio.Modeling;
  12. using DslDiagrams = global::Microsoft.VisualStudio.Modeling.Diagrams;
  13. using DslValidation = global::Microsoft.VisualStudio.Modeling.Validation;
  14. namespace ITU.MDD.CPML
  15. {
  16. /// <summary>
  17. /// Double-derived class to allow easier code customization.
  18. /// </summary>
  19. internal partial class CPMLCommandSet : CPMLCommandSetBase
  20. {
  21. /// <summary>
  22. /// Constructs a new CPMLCommandSet.
  23. /// </summary>
  24. public CPMLCommandSet(global::System.IServiceProvider serviceProvider)
  25. : base(serviceProvider)
  26. {
  27. }
  28. }
  29. /// <summary>
  30. /// Class containing handlers for commands supported by this DSL.
  31. /// </summary>
  32. internal abstract class CPMLCommandSetBase : DslShell::CommandSet
  33. {
  34. /// <summary>
  35. /// Constructs a new CPMLCommandSetBase.
  36. /// </summary>
  37. protected CPMLCommandSetBase(global::System.IServiceProvider serviceProvider) : base(serviceProvider)
  38. {
  39. }
  40. /// <summary>
  41. /// Provide the menu commands that this command set handles
  42. /// </summary>
  43. protected override global::System.Collections.Generic.IList<global::System.ComponentModel.Design.MenuCommand> GetMenuCommands()
  44. {
  45. // Get the standard commands
  46. global::System.Collections.Generic.IList<global::System.ComponentModel.Design.MenuCommand> commands = base.GetMenuCommands();
  47. global::System.ComponentModel.Design.MenuCommand menuCommand;
  48. // Add command handler for the "view explorer" command in the top-level menu.
  49. // We use a ContextBoundMenuCommand because the visibility of this command is
  50. // based on whether or not the command context of our DSL editor is active.
  51. menuCommand = new DslShell::CommandContextBoundMenuCommand(this.ServiceProvider,
  52. new global::System.EventHandler(OnMenuViewModelExplorer),
  53. Constants.ViewCPMLExplorerCommand,
  54. typeof(CPMLEditorFactory).GUID);
  55. commands.Add(menuCommand);
  56. return commands;
  57. }
  58. /// <summary>
  59. /// Command handler that shows the explorer tool window.
  60. /// </summary>
  61. internal virtual void OnMenuViewModelExplorer(object sender, global::System.EventArgs e)
  62. {
  63. CPMLExplorerToolWindow explorer = this.CPMLExplorerToolWindow;
  64. if (explorer != null)
  65. {
  66. explorer.Show();
  67. }
  68. }
  69. /// <summary>
  70. /// Returns the currently focused document.
  71. /// </summary>
  72. [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
  73. protected CPMLDocData CurrentCPMLDocData
  74. {
  75. get
  76. {
  77. return this.MonitorSelection.CurrentDocument as CPMLDocData;
  78. }
  79. }
  80. /// <summary>
  81. /// Returns the currently focused document view.
  82. /// </summary>
  83. [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
  84. protected CPMLDocView CurrentCPMLDocView
  85. {
  86. get
  87. {
  88. return this.MonitorSelection.CurrentDocumentView as CPMLDocView;
  89. }
  90. }
  91. /// <summary>
  92. /// Returns the explorer tool window.
  93. /// </summary>
  94. protected CPMLExplorerToolWindow CPMLExplorerToolWindow
  95. {
  96. get
  97. {
  98. CPMLExplorerToolWindow explorerWindow = null;
  99. DslShell::ModelingPackage package = this.ServiceProvider.GetService(typeof(VSShell::Package)) as DslShell::ModelingPackage;
  100. if (package != null)
  101. {
  102. explorerWindow = package.GetToolWindow(typeof(CPMLExplorerToolWindow), true) as CPMLExplorerToolWindow;
  103. }
  104. return explorerWindow;
  105. }
  106. }
  107. /// <summary>
  108. /// Returns the currently selected object in the model explorer.
  109. /// </summary>
  110. [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
  111. protected object ExplorerSelection
  112. {
  113. get
  114. {
  115. object selection = null;
  116. CPMLExplorerToolWindow explorerWindow = this.CPMLExplorerToolWindow;
  117. if(explorerWindow != null)
  118. {
  119. foreach (object o in explorerWindow.GetSelectedComponents())
  120. {
  121. selection = o;
  122. break;
  123. }
  124. }
  125. return selection;
  126. }
  127. }
  128. }
  129. /// <summary>
  130. /// Double-derived class to allow easier code customization.
  131. /// </summary>
  132. internal partial class CPMLClipboardCommandSet : CPMLClipboardCommandSetBase
  133. {
  134. /// <summary>
  135. /// Constructs a new CPMLClipboardCommandSet.
  136. /// </summary>
  137. public CPMLClipboardCommandSet(global::System.IServiceProvider serviceProvider)
  138. : base(serviceProvider)
  139. {
  140. }
  141. }
  142. /// <summary>
  143. /// Class containing handlers for cut/copy/paste commands supported by this DSL.
  144. /// </summary>
  145. internal abstract partial class CPMLClipboardCommandSetBase : DslShell::ClipboardCommandSet
  146. {
  147. /// <summary>
  148. /// Constructs a new CPMLClipboardCommandSetBase.
  149. /// </summary>
  150. protected CPMLClipboardCommandSetBase(global::System.IServiceProvider serviceProvider)
  151. : base(serviceProvider)
  152. {
  153. }
  154. /// <summary>
  155. /// Provide the menu commands that this command set handles
  156. /// </summary>
  157. protected override global::System.Collections.Generic.IList<global::System.ComponentModel.Design.MenuCommand> GetMenuCommands()
  158. {
  159. // Get the standard commands
  160. var commands = new global::System.Collections.Generic.List<global::System.ComponentModel.Design.MenuCommand>(3);
  161. global::System.ComponentModel.Design.MenuCommand menuCommand;
  162. menuCommand = new DslShell::DynamicStatusMenuCommand(
  163. new global::System.EventHandler(this.OnStatusCut),
  164. new global::System.EventHandler(this.OnMenuCut),
  165. global::System.ComponentModel.Design.StandardCommands.Cut);
  166. commands.Add(menuCommand);
  167. menuCommand = new DslShell::DynamicStatusMenuCommand(
  168. new global::System.EventHandler(this.OnStatusCopy),
  169. new global::System.EventHandler(this.OnMenuCopy),
  170. global::System.ComponentModel.Design.StandardCommands.Copy);
  171. commands.Add(menuCommand);
  172. menuCommand = new DslShell::DynamicStatusMenuCommand(
  173. new global::System.EventHandler(this.OnStatusPaste),
  174. new global::System.EventHandler(this.OnMenuPaste),
  175. global::System.ComponentModel.Design.StandardCommands.Paste);
  176. commands.Add(menuCommand);
  177. return commands;
  178. }
  179. /// <summary>
  180. /// Determines whether Cut menu item should be visible and if so, enabled.
  181. /// </summary>
  182. /// <param name="sender">The sender of the message</param>
  183. /// <param name="args">empty</param>
  184. private void OnStatusCut(object sender, global::System.EventArgs args)
  185. {
  186. System.ComponentModel.Design.MenuCommand cmd = sender as System.ComponentModel.Design.MenuCommand;
  187. this.ProcessOnStatusCutCommand(cmd);
  188. }
  189. /// <summary>
  190. /// Determines whether Copy menu item should be visible and if so, enabled.
  191. /// </summary>
  192. /// <param name="sender">The sender of the message</param>
  193. /// <param name="args">empty</param>
  194. private void OnStatusCopy(object sender, global::System.EventArgs args)
  195. {
  196. System.ComponentModel.Design.MenuCommand cmd = sender as System.ComponentModel.Design.MenuCommand;
  197. this.ProcessOnStatusCopyCommand(cmd);
  198. }
  199. /// <summary>
  200. /// Updates the UI for the Paste command
  201. /// </summary>
  202. /// <param name="sender">The sender of the message</param>
  203. /// <param name="args">Message parameters</param>
  204. private void OnStatusPaste(object sender, global::System.EventArgs args)
  205. {
  206. System.ComponentModel.Design.MenuCommand cmd = sender as System.ComponentModel.Design.MenuCommand;
  207. this.ProcessOnStatusPasteCommand(cmd);
  208. }
  209. /// <summary>
  210. /// Event handler to cut the selected objects to the clipboard then delete the original.
  211. /// </summary>
  212. /// <param name="sender">The MenuCommand selected.</param>
  213. /// <param name="args">not used</param>
  214. private void OnMenuCut(object sender, global::System.EventArgs args)
  215. {
  216. this.ProcessOnMenuCutCommand();
  217. }
  218. /// <summary>
  219. /// Event handler to copy the selected objects to the clipboard.
  220. /// </summary>
  221. /// <param name="sender">The MenuCommand selected.</param>
  222. /// <param name="args">not used</param>
  223. private void OnMenuCopy(object sender, global::System.EventArgs args)
  224. {
  225. this.ProcessOnMenuCopyCommand();
  226. }
  227. /// <summary>
  228. /// Event handler to paste a copy of the object on the clipboard.
  229. /// </summary>
  230. /// <param name="sender">The MenuCommand selected.</param>
  231. /// <param name="args">not used</param>
  232. private void OnMenuPaste(object sender, global::System.EventArgs args)
  233. {
  234. this.ProcessOnMenuPasteCommand();
  235. }
  236. }
  237. }