The Labs \ Source Viewer \ SSCLI \ System.ComponentModel \ DesignTimeVisibleAttribute

  1. //------------------------------------------------------------------------------
  2. // <copyright file="DesignTimeVisibleAttribute.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
  18. {
  19.    
  20.     using System;
  21.     using System.Security.Permissions;
  22.    
  23.     /// <devdoc>
  24.     /// <para>
  25.     /// DesignTimeVisibileAttribute marks a component's visibility. If
  26.     /// DesignTimeVisibileAttribute.Yes is present, a visual designer can show
  27.     /// this component on a designer.
  28.     /// </para>
  29.     /// </devdoc>
  30.     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
  31.     public sealed class DesignTimeVisibleAttribute : Attribute
  32.     {
  33.         private bool visible;
  34.        
  35.         /// <devdoc>
  36.         /// Creates a new DesignTimeVisibleAttribute with the visible
  37.         /// property set to the given value.
  38.         /// </devdoc>
  39.         public DesignTimeVisibleAttribute(bool visible)
  40.         {
  41.             this.visible = visible;
  42.         }
  43.        
  44.         /// <devdoc>
  45.         /// Creates a new DesignTimeVisibleAttribute set to the default
  46.         /// value of true.
  47.         /// </devdoc>
  48.         public DesignTimeVisibleAttribute()
  49.         {
  50.         }
  51.        
  52.         /// <devdoc>
  53.         /// True if this component should be shown at design time, or false
  54.         /// if it shouldn't.
  55.         /// </devdoc>
  56.         public bool Visible {
  57.             get { return visible; }
  58.         }
  59.        
  60.         /// <devdoc>
  61.         /// Marks a component as visible in a visual designer.
  62.         /// </devdoc>
  63.         public static readonly DesignTimeVisibleAttribute Yes = new DesignTimeVisibleAttribute(true);
  64.        
  65.         /// <devdoc>
  66.         /// Marks a component as not visible in a visual designer.
  67.         /// </devdoc>
  68.         public static readonly DesignTimeVisibleAttribute No = new DesignTimeVisibleAttribute(false);
  69.        
  70.         /// <devdoc>
  71.         /// The default visiblity. (equal to Yes.)
  72.         /// </devdoc>
  73.         public static readonly DesignTimeVisibleAttribute Default = Yes;
  74.        
  75.         /// <devdoc>
  76.         /// <para>[To be supplied.]</para>
  77.         /// </devdoc>
  78.         public override bool Equals(object obj)
  79.         {
  80.             if (obj == this) {
  81.                 return true;
  82.             }
  83.            
  84.             DesignTimeVisibleAttribute other = obj as DesignTimeVisibleAttribute;
  85.             return other != null && other.Visible == visible;
  86.         }
  87.        
  88.         /// <devdoc>
  89.         /// <para>[To be supplied.]</para>
  90.         /// </devdoc>
  91.         public override int GetHashCode()
  92.         {
  93.             return typeof(DesignTimeVisibleAttribute).GetHashCode() ^ (visible ? -1 : 0);
  94.         }
  95.        
  96.         /// <devdoc>
  97.         /// <para>[To be supplied.]</para>
  98.         /// </devdoc>
  99.         public override bool IsDefaultAttribute()
  100.         {
  101.             return (this.Visible == Default.Visible);
  102.         }
  103.     }
  104. }

Developer Fusion