Esempio n. 1
0
        public static int GetTextExtentPoint32(HandleRef hDC, string text, [In, Out] IntNativeMethods.SIZE size)
        {
            int length = text.Length;

            if (Marshal.SystemDefaultCharSize == 1)
            {
                byte[] pOutBytes = new byte[WideCharToMultiByte(0, 0, text, text.Length, null, 0, IntPtr.Zero, IntPtr.Zero)];
                WideCharToMultiByte(0, 0, text, text.Length, pOutBytes, pOutBytes.Length, IntPtr.Zero, IntPtr.Zero);
                length = Math.Min(text.Length, 0x2000);
                return(GetTextExtentPoint32A(hDC, pOutBytes, length, size));
            }
            return(GetTextExtentPoint32W(hDC, text, text.Length, size));
        }
        public Size GetTextExtent(string text, WindowsFont font)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(Size.Empty);
            }
            IntNativeMethods.SIZE size = new IntNativeMethods.SIZE();
            HandleRef             hDC  = new HandleRef(null, this.dc.Hdc);

            if (font != null)
            {
                this.dc.SelectFont(font);
            }
            IntUnsafeNativeMethods.GetTextExtentPoint32(hDC, text, size);
            if ((font != null) && !MeasurementDCInfo.IsMeasurementDC(this.dc))
            {
                this.dc.ResetFont();
            }
            return(new Size(size.cx, size.cy));
        }
Esempio n. 3
0
 public static bool SetViewportExtEx(HandleRef hDC, int x, int y, [In, Out] IntNativeMethods.SIZE size)
 {
     return(IntSetViewportExtEx(hDC, x, y, size));
 }
Esempio n. 4
0
 public static extern bool IntSetViewportExtEx(HandleRef hDC, int x, int y, [In, Out] IntNativeMethods.SIZE size);
Esempio n. 5
0
 public static extern bool IntGetViewportExtEx(HandleRef hdc, [In, Out] IntNativeMethods.SIZE lpSize);
Esempio n. 6
0
 public static bool GetViewportExtEx(HandleRef hdc, [In, Out] IntNativeMethods.SIZE lpSize)
 {
     return(IntGetViewportExtEx(hdc, lpSize));
 }
Esempio n. 7
0
 public static extern int GetTextExtentPoint32W(HandleRef hDC, string text, int len, [In, Out] IntNativeMethods.SIZE size);
Esempio n. 8
0
 public static extern int GetTextExtentPoint32A(HandleRef hDC, byte[] lpszString, int byteCount, [In, Out] IntNativeMethods.SIZE size);
Esempio n. 9
0
 public Size SetViewportExtent(Size newExtent)
 {
     IntNativeMethods.SIZE size = new IntNativeMethods.SIZE();
     IntUnsafeNativeMethods.SetViewportExtEx(new HandleRef(this, this.Hdc), newExtent.Width, newExtent.Height, size);
     return(size.ToSize());
 }