The Labs \ Source Viewer \ SSCLI \ System.ComponentModel.Design \ DesignerVerb

  1. //------------------------------------------------------------------------------
  2. // <copyright file="DesignerVerb.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. /*
  16. */
  17. namespace System.ComponentModel.Design
  18. {
  19.     using Microsoft.Win32;
  20.     using System;
  21.     using System.ComponentModel;
  22.     using System.Diagnostics;
  23.     using System.Security.Permissions;
  24.     using System.Text.RegularExpressions;
  25.    
  26.     /// <devdoc>
  27.     /// <para> Represents a verb that can be executed by a component's designer.</para>
  28.     /// </devdoc>
  29.     [HostProtection(SharedState = true)]
  30.     [System.Runtime.InteropServices.ComVisible(true)]
  31.     [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name = "FullTrust")]
  32.     [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Name = "FullTrust")]
  33.     public class DesignerVerb : MenuCommand
  34.     {
  35.        
  36.         /// <devdoc>
  37.         /// <para>
  38.         /// Initializes a new instance of the <see cref='System.ComponentModel.Design.DesignerVerb'/> class.
  39.         /// </para>
  40.         /// </devdoc>
  41.         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
  42.         public DesignerVerb(string text, EventHandler handler) : base(handler, StandardCommands.VerbFirst)
  43.         {
  44.             Properties["Text"] = text == null ? null : Regex.Replace(text, "\\(\\&.\\)", "");
  45.         }
  46.        
  47.         /// <devdoc>
  48.         /// <para>
  49.         /// Initializes a new instance of the <see cref='System.ComponentModel.Design.DesignerVerb'/>
  50.         /// class.
  51.         /// </para>
  52.         /// </devdoc>
  53.         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
  54.         public DesignerVerb(string text, EventHandler handler, CommandID startCommandID) : base(handler, startCommandID)
  55.         {
  56.             Properties["Text"] = text == null ? null : Regex.Replace(text, "\\(\\&.\\)", "");
  57.         }
  58.        
  59.         /// <devdoc>
  60.         /// Gets or sets the description of the menu item for the verb.
  61.         /// </devdoc>
  62.         public string Description {
  63.             get {
  64.                 object result = Properties["Description"];
  65.                 if (result == null) {
  66.                     return String.Empty;
  67.                 }
  68.                 return (string)result;
  69.             }
  70.             set { Properties["Description"] = value; }
  71.         }
  72.        
  73.         /// <devdoc>
  74.         /// <para>
  75.         /// Gets or sets the text to show on the menu item for the verb.
  76.         /// </para>
  77.         /// </devdoc>
  78.         public string Text {
  79.             get {
  80.                 object result = Properties["Text"];
  81.                 if (result == null) {
  82.                     return String.Empty;
  83.                 }
  84.                 return (string)result;
  85.             }
  86.         }
  87.        
  88.        
  89.         /// <devdoc>
  90.         /// <para>
  91.         /// Overrides object's ToString().
  92.         /// </para>
  93.         /// </devdoc>
  94.         public override string ToString()
  95.         {
  96.             return Text + " : " + base.ToString();
  97.         }
  98.     }
  99. }

Developer Fusion