コード例 #1
0
        public int UxThemeGetThemeTextMetrics(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, out TextMetrics result)
        {
            XplatUIWin32.TEXTMETRIC metrics;

            int hresult = UXTheme.GetThemeTextMetrics(hTheme, dc.GetHdc(), iPartId, iStateId, out metrics);

            dc.ReleaseHdc();

            TextMetrics retval = new TextMetrics();

            retval.Ascent           = metrics.tmAscent;
            retval.AverageCharWidth = metrics.tmAveCharWidth;
            retval.BreakChar        = (char)metrics.tmBreakChar;
            retval.CharSet          = (TextMetricsCharacterSet)metrics.tmCharSet;
            retval.DefaultChar      = (char)metrics.tmDefaultChar;
            retval.Descent          = metrics.tmDescent;
            retval.DigitizedAspectX = metrics.tmDigitizedAspectX;
            retval.DigitizedAspectY = metrics.tmDigitizedAspectY;
            retval.ExternalLeading  = metrics.tmExternalLeading;
            retval.FirstChar        = (char)metrics.tmFirstChar;
            retval.Height           = metrics.tmHeight;
            retval.InternalLeading  = metrics.tmInternalLeading;
            retval.Italic           = metrics.tmItalic == 0 ? false : true;
            retval.LastChar         = (char)metrics.tmLastChar;
            retval.MaxCharWidth     = metrics.tmMaxCharWidth;
            retval.Overhang         = metrics.tmOverhang;
            retval.PitchAndFamily   = (TextMetricsPitchAndFamilyValues)metrics.tmPitchAndFamily;
            retval.StruckOut        = metrics.tmStruckOut == 0 ? false : true;
            retval.Underlined       = metrics.tmUnderlined == 0 ? false : true;
            retval.Weight           = metrics.tmWeight;

            result = retval;
            return(hresult);
        }
コード例 #2
0
        public TextMetrics GetTextMetrics(IDeviceContext dc)
        {
            if (dc == null)
            {
                throw new ArgumentNullException("dc");
            }
            TextMetrics ptm = new TextMetrics();

            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.GetThemeTextMetrics(new HandleRef(this, this.Handle), hdc, this.part, this.state, ref ptm);
            }
            return(ptm);
        }
コード例 #3
0
        /// <summary>
        ///    <para>
        ///       [See win32 equivalent.]
        ///    </para>
        /// </summary>
        public TextMetrics GetTextMetrics(IDeviceContext dc)
        {
            if (dc == null)
            {
                throw new ArgumentNullException(nameof(dc));
            }

            TextMetrics tm = new TextMetrics();

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

            return(tm);
        }
コード例 #4
0
 public static extern int GetThemeTextMetrics(HandleRef hTheme, HandleRef hdc, int iPartId, int iStateId, ref VisualStyles.TextMetrics ptm);
コード例 #5
0
        /// <include file='doc\VisualStyleRenderer.uex' path='docs/doc[@for="VisualStyleRenderer.GetTextMetric"]/*' />
        /// <devdoc>
        ///    <para>
        ///       [See win32 equivalent.]
        ///    </para>
        /// </devdoc>
        public TextMetrics GetTextMetrics(IDeviceContext dc) {
            if( dc == null ){
                throw new ArgumentNullException("dc");
            }
            
            TextMetrics tm = new TextMetrics();

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

            return tm;
        }
 public TextMetrics GetTextMetrics(IDeviceContext dc)
 {
     if (dc == null)
     {
         throw new ArgumentNullException("dc");
     }
     TextMetrics ptm = new TextMetrics();
     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.GetThemeTextMetrics(new HandleRef(this, this.Handle), hdc, this.part, this.state, ref ptm);
     }
     return ptm;
 }
コード例 #7
0
 public int UxThemeGetThemeTextMetrics(IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, out TextMetrics result) => throw new InvalidOperationException();
コード例 #8
0
		public int UxThemeGetThemeTextMetrics (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, out TextMetrics result)
		{
			XplatUIWin32.TEXTMETRIC metrics;
			
			int hresult = UXTheme.GetThemeTextMetrics (hTheme, dc.GetHdc (), iPartId, iStateId, out metrics);
			dc.ReleaseHdc ();

			TextMetrics retval = new TextMetrics ();
			retval.Ascent = metrics.tmAscent;
			retval.AverageCharWidth = metrics.tmAveCharWidth;
			retval.BreakChar =(char)metrics.tmBreakChar;
			retval.CharSet = (TextMetricsCharacterSet)metrics.tmCharSet;
			retval.DefaultChar = (char)metrics.tmDefaultChar;
			retval.Descent = metrics.tmDescent;
			retval.DigitizedAspectX = metrics.tmDigitizedAspectX;
			retval.DigitizedAspectY = metrics.tmDigitizedAspectY;
			retval.ExternalLeading = metrics.tmExternalLeading;
			retval.FirstChar = (char)metrics.tmFirstChar;
			retval.Height = metrics.tmHeight;
			retval.InternalLeading = metrics.tmInternalLeading;
			retval.Italic = metrics.tmItalic == 0 ? false : true;
			retval.LastChar = (char)metrics.tmLastChar;
			retval.MaxCharWidth = metrics.tmMaxCharWidth;
			retval.Overhang = metrics.tmOverhang;
			retval.PitchAndFamily = (TextMetricsPitchAndFamilyValues)metrics.tmPitchAndFamily;
			retval.StruckOut = metrics.tmStruckOut == 0 ? false : true;
			retval.Underlined = metrics.tmUnderlined == 0 ? false : true;
			retval.Weight = metrics.tmWeight;

			result = retval;
			return hresult;
		}
コード例 #9
0
		public int UxThemeGetThemeTextMetrics (IntPtr hTheme, IDeviceContext dc, int iPartId, int iStateId, out TextMetrics result)
		{
			result = new TextMetrics ();
			return (int)S.S_FALSE;
		}
コード例 #10
0
ファイル: SafeNativeMethodsR.cs プロジェクト: rkbrth/rkbrth-1
 public static extern int GetThemeTextMetrics(HandleRef hTheme, HandleRef hdc, int iPartId, int iStateId, ref TextMetrics ptm);