Example #1
0
        public override bool ShouldSerializeValue(object component)
        {
            GetBoolValueEvent gvbe = new GetBoolValueEvent(false);

            this.OnShouldSerializeValue(gvbe);
            return(gvbe.Value);
        }
 private void OnGetIsReadOnly(Com2PropertyDescriptor sender, GetBoolValueEvent gbvevent)
 {
     if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing)
     {
         NativeMethods.IVsPerPropertyBrowsing targetObject = (NativeMethods.IVsPerPropertyBrowsing)sender.TargetObject;
         if (targetObject.IsPropertyReadOnly(sender.DISPID, false) == 0)
         {
             gbvevent.Value = fReadOnly;
         }
     }
 }
 private void OnGetIsReadOnly(Com2PropertyDescriptor sender, GetBoolValueEvent gbvevent)
 {
     if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing)
     {
         NativeMethods.IVsPerPropertyBrowsing targetObject = (NativeMethods.IVsPerPropertyBrowsing) sender.TargetObject;
         if (targetObject.IsPropertyReadOnly(sender.DISPID, false) == 0)
         {
             gbvevent.Value = fReadOnly;
         }
     }
 }
 private void OnCanResetPropertyValue(Com2PropertyDescriptor sender, GetBoolValueEvent boolEvent)
 {
     if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing)
     {
         NativeMethods.IVsPerPropertyBrowsing targetObject = (NativeMethods.IVsPerPropertyBrowsing)sender.TargetObject;
         bool pfCanReset = boolEvent.Value;
         if (NativeMethods.Succeeded(targetObject.CanResetPropertyValue(sender.DISPID, ref pfCanReset)))
         {
             boolEvent.Value = pfCanReset;
         }
     }
 }
 private void OnCanResetPropertyValue(Com2PropertyDescriptor sender, GetBoolValueEvent boolEvent)
 {
     if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing)
     {
         NativeMethods.IVsPerPropertyBrowsing targetObject = (NativeMethods.IVsPerPropertyBrowsing) sender.TargetObject;
         bool pfCanReset = boolEvent.Value;
         if (NativeMethods.Succeeded(targetObject.CanResetPropertyValue(sender.DISPID, ref pfCanReset)))
         {
             boolEvent.Value = pfCanReset;
         }
     }
 }
 private void OnShouldSerializeValue(Com2PropertyDescriptor sender, GetBoolValueEvent gbvevent)
 {
     if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing)
     {
         NativeMethods.IVsPerPropertyBrowsing targetObject = (NativeMethods.IVsPerPropertyBrowsing)sender.TargetObject;
         bool fDefault = true;
         if ((targetObject.HasDefaultValue(sender.DISPID, ref fDefault) == 0) && !fDefault)
         {
             gbvevent.Value = true;
         }
     }
 }
Example #7
0
 /// <summary>
 ///  Here is where we handle IVsPerPropertyBrowsing.IsPropertyReadOnly
 /// </summary>
 private unsafe void OnGetIsReadOnly(Com2PropertyDescriptor sender, GetBoolValueEvent gbvevent)
 {
     if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing vsObj)
     {
         // should we make this read only?
         BOOL    pfResult = BOOL.FALSE;
         HRESULT hr       = vsObj.IsPropertyReadOnly(sender.DISPID, &pfResult);
         if (hr == HRESULT.S_OK)
         {
             gbvevent.Value = pfResult != BOOL.FALSE;
         }
     }
 }
Example #8
0
        private unsafe void OnCanResetPropertyValue(Com2PropertyDescriptor sender, GetBoolValueEvent boolEvent)
        {
            if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing target)
            {
                BOOL    canReset = boolEvent.Value ? BOOL.TRUE : BOOL.FALSE;
                HRESULT hr       = target.CanResetPropertyValue(sender.DISPID, &canReset);
                if (hr.Succeeded())
                {
                    boolEvent.Value = canReset != BOOL.FALSE;
                }
            }

            Debug.Assert(sender.TargetObject == null || sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing, "Object is not " + Interface.Name + "!");
        }
Example #9
0
        private void OnCanResetPropertyValue(Com2PropertyDescriptor sender, GetBoolValueEvent boolEvent)
        {
            if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing target)
            {
                bool canReset = boolEvent.Value;
                int  hr       = target.CanResetPropertyValue(sender.DISPID, ref canReset);

                if (NativeMethods.Succeeded(hr))
                {
                    boolEvent.Value = canReset;
                }
            }
            Debug.Assert(sender.TargetObject == null || sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing, "Object is not " + Interface.Name + "!");
        }
Example #10
0
 public override bool CanResetValue(object component)
 {
     if (component is ICustomTypeDescriptor)
     {
         component = ((ICustomTypeDescriptor)component).GetPropertyOwner(this);
     }
     if (component == this.TargetObject)
     {
         GetBoolValueEvent gvbe = new GetBoolValueEvent(false);
         this.OnCanResetValue(gvbe);
         return(gvbe.Value);
     }
     return(false);
 }
Example #11
0
        /// <summary>
        /// Here is where we handle IVsPerPropertyBrowsing.IsPropertyReadOnly
        /// </summary>
        private void OnGetIsReadOnly(Com2PropertyDescriptor sender, GetBoolValueEvent gbvevent)
        {
            if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing vsObj)
            {
                // should we make this read only?
                bool pfResult = false;
                int  hr       = vsObj.IsPropertyReadOnly(sender.DISPID, ref pfResult);

                if (hr == NativeMethods.S_OK)
                {
                    gbvevent.Value = pfResult;
                }
            }
        }
Example #12
0
        private void OnShouldSerializeValue(Com2PropertyDescriptor sender, GetBoolValueEvent gbvevent)
        {
            if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing vsObj)
            {
                // by default we say it's default
                bool pfResult = true;
                int  hr       = vsObj.HasDefaultValue(sender.DISPID, ref pfResult);

                if (hr == NativeMethods.S_OK && !pfResult)
                {
                    // specify a default value editor
                    gbvevent.Value = true;
                }
            }
            Debug.Assert(sender.TargetObject == null || sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing, "Object is not " + Interface.Name + "!");
        }
Example #13
0
 private void RaiseGetBoolValueEvent(object key, GetBoolValueEvent e)
 {
     try
     {
         this.com2props.AlwaysValid = this.com2props.CheckValid();
         GetBoolValueEventHandler handler = (GetBoolValueEventHandler)this.Events[key];
         if (handler != null)
         {
             handler(this, e);
         }
     }
     finally
     {
         this.com2props.AlwaysValid = false;
     }
 }
Example #14
0
        private unsafe void OnShouldSerializeValue(Com2PropertyDescriptor sender, GetBoolValueEvent gbvevent)
        {
            if (sender.TargetObject is VSSDK.IVsPerPropertyBrowsing vsObj)
            {
                // by default we say it's default
                BOOL    pfResult = BOOL.TRUE;
                HRESULT hr       = vsObj.HasDefaultValue(sender.DISPID, &pfResult);
                if (hr == HRESULT.S_OK && pfResult.IsFalse())
                {
                    // specify a default value editor
                    gbvevent.Value = true;
                }
            }

            Debug.Assert(sender.TargetObject is null || sender.TargetObject is VSSDK.IVsPerPropertyBrowsing, "Object is not " + Interface.Name + "!");
        }
Example #15
0
 protected void OnShouldSerializeValue(GetBoolValueEvent gvbe)
 {
     this.RaiseGetBoolValueEvent(EventShouldSerializeValue, gvbe);
 }
Example #16
0
 protected void OnGetIsReadOnly(GetBoolValueEvent gvbe)
 {
     this.RaiseGetBoolValueEvent(EventGetIsReadOnly, gvbe);
 }
Example #17
0
 protected void OnCanResetValue(GetBoolValueEvent gvbe)
 {
     this.RaiseGetBoolValueEvent(EventCanResetValue, gvbe);
 }
Example #18
0
        /// <include file='doc\COM2PropertyDescriptor.uex' path='docs/doc[@for="Com2PropertyDescriptor.CanResetValue"]/*' />
        /// <devdoc>
        ///     Indicates whether reset will change the value of the component.  If there
        ///     is a DefaultValueAttribute, then this will return true if getValue returns
        ///     something different than the default value.  If there is a reset method and
        ///     a shouldPersist method, this will return what shouldPersist returns.
        ///     If there is just a reset method, this always returns true.  If none of these
        ///     cases apply, this returns false.
        /// </devdoc>
        public override bool CanResetValue(Object component) {

            if (component is ICustomTypeDescriptor) {
                component = ((ICustomTypeDescriptor)component).GetPropertyOwner(this);
            }
        
            if (component == this.TargetObject) {
                GetBoolValueEvent gbv = new GetBoolValueEvent(false);
                OnCanResetValue(gbv);
                return gbv.Value;
            }
            return false;
        }
         private void OnShouldSerializeValue(Com2PropertyDescriptor sender, GetBoolValueEvent gbvevent){
               if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing){
                     NativeMethods.IVsPerPropertyBrowsing vsObj = (NativeMethods.IVsPerPropertyBrowsing)sender.TargetObject;

                     // by default we say it's default
                     bool pfResult = true;
                     int hr = vsObj.HasDefaultValue(sender.DISPID,ref pfResult);

                     if (hr == NativeMethods.S_OK && !pfResult){
                        // specify a default value editor
                        gbvevent.Value = true;
                     }
               }
               Debug.Assert(sender.TargetObject == null || sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing, "Object is not " + Interface.Name + "!");
         }
         /// <include file='doc\COM2IVsPerPropertyBrowsingHandler.uex' path='docs/doc[@for="Com2IVsPerPropertyBrowsingHandler.OnGetIsReadOnly"]/*' />
         /// <devdoc>
         /// Here is where we handle IVsPerPropertyBrowsing.IsPropertyReadOnly
         /// </devdoc>
         private void OnGetIsReadOnly(Com2PropertyDescriptor sender, GetBoolValueEvent gbvevent){
               if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing){
                  NativeMethods.IVsPerPropertyBrowsing vsObj = (NativeMethods.IVsPerPropertyBrowsing)sender.TargetObject;

                  // should we make this read only?
                  bool pfResult = false;
                  int hr = vsObj.IsPropertyReadOnly(sender.DISPID, ref pfResult);

                  if (hr == NativeMethods.S_OK){
                     gbvevent.Value = pfResult;
                  }
               }
         }
         private void OnCanResetPropertyValue(Com2PropertyDescriptor sender, GetBoolValueEvent boolEvent) {
               if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing) {
                    NativeMethods.IVsPerPropertyBrowsing target = (NativeMethods.IVsPerPropertyBrowsing)sender.TargetObject;
                    bool canReset = boolEvent.Value;
                    int hr = target.CanResetPropertyValue(sender.DISPID, ref canReset);

                    if (NativeMethods.Succeeded(hr)){
                        boolEvent.Value = canReset;
                    }
               }
               Debug.Assert(sender.TargetObject == null || sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing, "Object is not " + Interface.Name + "!");
         }
Example #22
0
 /// <include file='doc\COM2PropertyDescriptor.uex' path='docs/doc[@for="Com2PropertyDescriptor.ShouldSerializeValue"]/*' />
 /// <devdoc>
 ///     Indicates whether the value of this property needs to be persisted. In
 ///     other words, it indicates whether the state of the property is distinct
 ///     from when the component is first instantiated. If there is a default
 ///     value specified in this PropertyDescriptor, it will be compared against the
 ///     property's current value to determine this.  If there is't, the
 ///     shouldPersistXXX method is looked for and invoked if found.  If both
 ///     these routes fail, true will be returned.
 ///
 ///     If this returns false, a tool should not persist this property's value.
 /// </devdoc>
 public override bool ShouldSerializeValue(Object component) {
     GetBoolValueEvent gbv = new GetBoolValueEvent(false);
     OnShouldSerializeValue(gbv);
     return gbv.Value;
 }
Example #23
0
 /// <include file='doc\COM2PropertyDescriptor.uex' path='docs/doc[@for="Com2PropertyDescriptor.OnShouldSerializeValue"]/*' />
 /// <devdoc>
 ///     Raises the appropriate event
 /// </devdoc>
 protected void OnShouldSerializeValue(GetBoolValueEvent gvbe) {
     RaiseGetBoolValueEvent(EventShouldSerializeValue, gvbe);
 }
 public override bool ShouldSerializeValue(object component)
 {
     GetBoolValueEvent gvbe = new GetBoolValueEvent(false);
     this.OnShouldSerializeValue(gvbe);
     return gvbe.Value;
 }
Example #25
0
 /// <include file='doc\COM2PropertyDescriptor.uex' path='docs/doc[@for="Com2PropertyDescriptor.OnCanResetValue"]/*' />
 /// <devdoc>
 ///     Raises the appropriate event
 /// </devdoc>
 protected void OnCanResetValue(GetBoolValueEvent gvbe) {
     RaiseGetBoolValueEvent(EventCanResetValue, gvbe);
 }
Example #26
0
 /// <include file='doc\COM2PropertyDescriptor.uex' path='docs/doc[@for="Com2PropertyDescriptor.OnGetIsReadOnly"]/*' />
 /// <devdoc>
 ///     Raises the appropriate event
 /// </devdoc>
 protected void OnGetIsReadOnly(GetBoolValueEvent gvbe) {
     RaiseGetBoolValueEvent(EventGetIsReadOnly, gvbe);
 }
 private void OnShouldSerializeValue(Com2PropertyDescriptor sender, GetBoolValueEvent gbvevent)
 {
     if (sender.TargetObject is NativeMethods.IVsPerPropertyBrowsing)
     {
         NativeMethods.IVsPerPropertyBrowsing targetObject = (NativeMethods.IVsPerPropertyBrowsing) sender.TargetObject;
         bool fDefault = true;
         if ((targetObject.HasDefaultValue(sender.DISPID, ref fDefault) == 0) && !fDefault)
         {
             gbvevent.Value = true;
         }
     }
 }
Example #28
0
 /// <include file='doc\COM2PropertyDescriptor.uex' path='docs/doc[@for="Com2PropertyDescriptor.RaiseGetBoolValueEvent"]/*' />
 /// <devdoc>
 ///     Raises the appropriate event
 /// </devdoc>
 private void RaiseGetBoolValueEvent(Object key, GetBoolValueEvent e) {
     try {
         com2props.AlwaysValid = com2props.CheckValid();
         GetBoolValueEventHandler handler = (GetBoolValueEventHandler)Events[key];
         if (handler != null) handler(this, e);
     }
     finally {
         com2props.AlwaysValid = false;
     }
 }