Exemplo n.º 1
0
        public override object ConvertManagedToNative(object managedValue, Com2PropertyDescriptor pd, ref bool cancelSet)
        {
            // we default to black.
            if (managedValue == null)
            {
                managedValue = Control.DefaultFont;
            }

            cancelSet = true;

            if (_lastFont != null && _lastFont.Equals(managedValue))
            {
                // don't do anything here.
                return(null);
            }

            _lastFont = (Font)managedValue;
            Ole32.IFont nativeFont = (Ole32.IFont)pd.GetNativeValue(pd.TargetObject);

            // now, push all the values into the native side
            if (nativeFont != null)
            {
                bool changed = ControlPaint.FontToIFont(_lastFont, nativeFont);

                if (changed)
                {
                    // here, we want to pick up a new font from the handle
                    _lastFont = null;
                    ConvertNativeToManaged(nativeFont, pd);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        public override object ConvertManagedToNative(object managedValue, Com2PropertyDescriptor pd, ref bool cancelSet) {

            // we default to black.
            //
            if (managedValue == null) {
                managedValue = Control.DefaultFont;
            }

            cancelSet = true;

            if (lastFont != null && lastFont.Equals(managedValue)) {
                // don't do anything here.
                return null;
            }


            lastFont = (Font)managedValue;
            UnsafeNativeMethods.IFont nativeFont = (UnsafeNativeMethods.IFont)pd.GetNativeValue(pd.TargetObject);

            // now, push all the values into the native side
            if (nativeFont != null) {
                bool changed = ControlPaint.FontToIFont(lastFont, nativeFont);

                if (changed) {
                    // here, we want to pick up a new font from the handle
                    lastFont = null;
                    ConvertNativeToManaged(nativeFont, pd);

                }
            }
            return null;
        }
Exemplo n.º 3
0
 public override object ConvertManagedToNative(object managedValue, Com2PropertyDescriptor pd, ref bool cancelSet)
 {
     if (managedValue == null)
     {
         managedValue = Control.DefaultFont;
     }
     cancelSet = true;
     if ((this.lastFont == null) || !this.lastFont.Equals(managedValue))
     {
         this.lastFont = (Font)managedValue;
         System.Windows.Forms.UnsafeNativeMethods.IFont nativeValue = (System.Windows.Forms.UnsafeNativeMethods.IFont)pd.GetNativeValue(pd.TargetObject);
         if ((nativeValue != null) && ControlPaint.FontToIFont(this.lastFont, nativeValue))
         {
             this.lastFont = null;
             this.ConvertNativeToManaged(nativeValue, pd);
         }
     }
     return(null);
 }