public static System.Windows.Forms.Padding GetMargins2(this VisualStyleRenderer rnd, IDeviceContext dc, MarginProperty prop)
 {
     NativeMethods.RECT rc;
     using (SafeGDIHandle hdc = new SafeGDIHandle(dc))
         NativeMethods.GetThemeMargins(rnd.Handle, hdc, rnd.Part, rnd.State, (int)prop, IntPtr.Zero, out rc);
     return new System.Windows.Forms.Padding(rc.Left, rc.Top, rc.Right, rc.Bottom);
 }
Ejemplo n.º 2
0
		public StyleBase()
		{
			Width = new WidthProperty();
			Height= new HeightProperty();
			Padding = new PaddingProperty();
			Margin = new MarginProperty();
			FontSize = new FontSizeProperty();

			Color=string.Empty;
			BackgroundColor=string.Empty;
			Hidden=false;
		}
Ejemplo n.º 3
0
        /// <summary>
        ///  [See win32 equivalent.]
        /// </summary>
        public unsafe Padding GetMargins(IDeviceContext dc, MarginProperty prop)
        {
            if (dc == null)
            {
                throw new ArgumentNullException(nameof(dc));
            }

            //valid values are 0xe11 to 0xe13
            if (!ClientUtils.IsEnumValid(prop, (int)prop, (int)MarginProperty.SizingMargins, (int)MarginProperty.CaptionMargins))
            {
                throw new InvalidEnumArgumentException(nameof(prop), (int)prop, typeof(MarginProperty));
            }

            using var wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties);
            var hdc = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc);

            lastHResult = GetThemeMargins(this, hdc, part, state, (int)prop, null, out MARGINS margins);

            return(new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight));
        }
Ejemplo n.º 4
0
        public Padding GetMargins(IDeviceContext dc, MarginProperty prop)
        {
            if (dc == null)
            {
                throw new ArgumentNullException(nameof(dc));
            }

            //valid values are 0xe11 to 0xe13
            if (!ClientUtils.IsEnumValid(prop, (int)prop, (int)MarginProperty.SizingMargins, (int)MarginProperty.CaptionMargins))
            {
                throw new InvalidEnumArgumentException(nameof(prop), (int)prop, typeof(MarginProperty));
            }

            UxTheme.MARGINS margins = default;

            using (WindowsGraphicsWrapper wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties))
            {
                HandleRef hdc = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc);
                lastHResult = SafeNativeMethods.GetThemeMargins(new HandleRef(this, Handle), hdc, part, state, (int)prop, prc: null, ref margins);
            }

            return(new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight));
        }
Ejemplo n.º 5
0
 public int UxThemeGetThemeMargins(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, MarginProperty prop, out Padding result) => throw new InvalidOperationException();
Ejemplo n.º 6
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Static ctor.  Initializes property metadata.
        /// </summary>
        static Table()
        {
            MarginProperty.OverrideMetadata(typeof(Table), new FrameworkPropertyMetadata(new Thickness(Double.NaN)));
        }
Ejemplo n.º 7
0
        public int UxThemeGetThemeMargins(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, MarginProperty prop, out Padding result)
        {
            UXTheme.MARGINS   retval = new UXTheme.MARGINS();
            XplatUIWin32.RECT BoundsRect;

            int hresult = UXTheme.GetThemeMargins(hTheme, dc.GetHdc(), iPartId, iStateId, (int)prop, out BoundsRect, out retval);

            dc.ReleaseHdc();

            result = retval.ToPadding();
            return(hresult);
        }
 public static System.Windows.Forms.Padding GetMargins2(this VisualStyleRenderer rnd, IDeviceContext dc, MarginProperty prop)
 {
     NativeMethods.RECT rc;
     using (SafeGDIHandle hdc = new SafeGDIHandle(dc))
         NativeMethods.GetThemeMargins(rnd.Handle, hdc, rnd.Part, rnd.State, (int)prop, IntPtr.Zero, out rc);
     return(new System.Windows.Forms.Padding(rc.Left, rc.Top, rc.Right, rc.Bottom));
 }
        /// <include file='doc\VisualStyleRenderer.uex' path='docs/doc[@for="VisualStyleRenderer.GetMargins"]/*' />
        /// <devdoc>
        ///    <para>
        ///       [See win32 equivalent.]
        ///    </para>
        /// </devdoc>
        public Padding GetMargins(IDeviceContext dc, MarginProperty prop) {
            if( dc == null ){
                throw new ArgumentNullException("dc");
            }
            
            //valid values are 0xe11 to 0xe13
            if (!ClientUtils.IsEnumValid(prop, (int)prop, (int)MarginProperty.SizingMargins, (int)MarginProperty.CaptionMargins))
            {
                throw new InvalidEnumArgumentException("prop", (int)prop, typeof(MarginProperty));
            }

            NativeMethods.MARGINS margins = new NativeMethods.MARGINS();

            using( WindowsGraphicsWrapper wgr = new WindowsGraphicsWrapper( dc, AllGraphicsProperties ) ) {
                HandleRef hdc = new HandleRef( wgr, wgr.WindowsGraphics.DeviceContext.Hdc );
                lastHResult = SafeNativeMethods.GetThemeMargins( new HandleRef( this, Handle ), hdc, part, state, (int) prop, ref margins );
            }

            return new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
        }
Ejemplo n.º 10
0
 private Padding GetMargins(IDeviceContext ctxt, MarginProperty type, VisualStyleRenderer renderer)
 {
     return(GetMargins(ctxt, type, renderer.Handle, renderer.Part, renderer.State));
 }
		public int UxThemeGetThemeMargins (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, MarginProperty prop, out Padding result)
		{
			result = Padding.Empty;
			return (int)S.S_FALSE;
		}
Ejemplo n.º 12
0
 set => SetValue(MarginProperty, value);
 public System.Windows.Forms.Padding GetMargins(System.Drawing.IDeviceContext dc, MarginProperty prop)
 {
 }
Ejemplo n.º 14
0
 static LayoutItem()
 {
     ToolTipProperty.OverrideMetadata(typeof(LayoutItem), new FrameworkPropertyMetadata(null, (s, e) => OnToolTipChanged(s, e)));
     VisibilityProperty.OverrideMetadata(typeof(LayoutItem), new FrameworkPropertyMetadata(Visibility.Visible, (s, e) => OnVisibilityChanged(s, e)));
     MarginProperty.OverrideMetadata(typeof(LayoutItem), new FrameworkPropertyMetadata(new Thickness(0), (s, e) => OnMarginChanged(s, e)));
 }
Ejemplo n.º 15
0
 static OptionPanel()
 {
     MarginProperty.OverrideMetadata(typeof(OptionPanel),
                                     new FrameworkPropertyMetadata(new Thickness(2, 0, 4, 0)));
 }
 public Padding GetMargins(IDeviceContext dc, MarginProperty prop)
 {
     if (dc == null)
     {
         throw new ArgumentNullException("dc");
     }
     if (!System.Windows.Forms.ClientUtils.IsEnumValid(prop, (int) prop, 0xe11, 0xe13))
     {
         throw new InvalidEnumArgumentException("prop", (int) prop, typeof(MarginProperty));
     }
     System.Windows.Forms.NativeMethods.MARGINS margins = new System.Windows.Forms.NativeMethods.MARGINS();
     using (WindowsGraphicsWrapper wrapper = new WindowsGraphicsWrapper(dc, TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.PreserveGraphicsClipping))
     {
         HandleRef hDC = new HandleRef(wrapper, wrapper.WindowsGraphics.DeviceContext.Hdc);
         this.lastHResult = System.Windows.Forms.SafeNativeMethods.GetThemeMargins(new HandleRef(this, this.Handle), hDC, this.part, this.state, (int) prop, ref margins);
     }
     return new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
 }
 private Padding GetThemeMargins(IDeviceContext dc,
                                 MarginProperty marginType)
 {
   NativeMethods.MARGINS margins;
   try {
     var hDC = dc.GetHdc();
     var rv = NativeMethods.GetThemeMargins(
       renderer.Handle,
       hDC,
       renderer.Part,
       renderer.State,
       (int)marginType,
       IntPtr.Zero,
       out margins);
     if (rv == 0) {
       return new Padding(
         margins.cxLeftWidth,
         margins.cyTopHeight,
         margins.cxRightWidth,
         margins.cyBottomHeight);
     }
     return new Padding(0);
   }
   catch (Exception) {
     return renderer.GetMargins(dc, marginType);
   }
   finally {
     dc.ReleaseHdc();
   }
 }
Ejemplo n.º 18
0
 public System.Windows.Forms.Padding GetMargins(System.Drawing.IDeviceContext dc, MarginProperty prop)
 {
 }
Ejemplo n.º 19
0
 public Padding GetMargins(IDeviceContext dc, MarginProperty prop)
 {
     throw null;
 }
Ejemplo n.º 20
0
 /// <summary>Retrieves the value of a <c>MARGINS</c> property.</summary>
 /// <param name="rnd">The visual style to query.</param>
 /// <param name="dc">A device context for any font selection. This value can be <see langword="null"/>.</param>
 /// <param name="prop">The property to retrieve.</param>
 /// <returns>The margins defined for the property.</returns>
 public static Padding GetMargins2(this VisualStyleRenderer rnd, IDeviceContext dc = null, MarginProperty prop = MarginProperty.ContentMargins)
 {
     using (var hdc = new SafeHDC(dc))
     {
         GetThemeMargins(rnd.GetSafeHandle(), hdc, rnd.Part, rnd.State, (int)prop, null, out MARGINS m);
         return(new Padding(m.cxLeftWidth, m.cyTopHeight, m.cxRightWidth, m.cyBottomHeight));
     }
 }
		public Padding GetMargins (IDeviceContext dc, MarginProperty prop)
		{
			if (dc == null)
				throw new ArgumentNullException ("dc");
			if (!Enum.IsDefined (typeof (MarginProperty), prop))
				throw new System.ComponentModel.InvalidEnumArgumentException ("prop", (int)prop, typeof (MarginProperty));

			Padding result;
			last_hresult = VisualStyles.UxThemeGetThemeMargins (theme, dc, this.part, this.state, prop, out result);
			return result;
		}
 public static Padding GetMargins2(this VisualStyleRenderer rnd, IDeviceContext dc = null, MarginProperty prop = MarginProperty.ContentMargins)
 {
     NativeMethods.RECT rc;
     using (var hdc = new NativeMethods.SafeDCHandle(dc))
         NativeMethods.GetThemeMargins(rnd, hdc, rnd.Part, rnd.State, (int)prop, IntPtr.Zero, out rc);
     return(new Padding(rc.Left, rc.Top, rc.Right, rc.Bottom));
 }
Ejemplo n.º 23
0
		public int UxThemeGetThemeMargins (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, MarginProperty prop, out Padding result)
		{
			UXTheme.MARGINS retval = new UXTheme.MARGINS ();
			XplatUIWin32.RECT BoundsRect;

			int hresult = UXTheme.GetThemeMargins (hTheme, dc.GetHdc (), iPartId, iStateId, (int)prop, out BoundsRect, out retval);
			dc.ReleaseHdc ();

			result = retval.ToPadding();
			return hresult;
		}
Ejemplo n.º 24
0
 // *** Constructors ***
 static ShadowChrome()
 {
     MarginProperty.OverrideMetadata(typeof(ShadowChrome), new FrameworkPropertyMetadata(new Thickness(0, 0, 4, 4)));
     CreateBrushes();
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Initialises static members of the <see cref="Window"/> class.
        /// </summary>
        static Window()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata(typeof(Window)));

            MarginProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata(new PropertyChangedCallback(OnMarginPropertyChanged)));
        }