示例#1
0
        public void ScaleTransform(float sx, float sy, MatrixOrder order)
        {
            Status status = GDIPlus.GdipScalePenTransform(nativeObject, sx, sy, order);

            GDIPlus.CheckStatus(status);
        }
示例#2
0
        public void TranslateTransform(float dx, float dy, MatrixOrder order)
        {
            Status status = GDIPlus.GdipTranslatePenTransform(nativeObject, dx, dy, order);

            GDIPlus.CheckStatus(status);
        }
示例#3
0
        public void RotateFlip(RotateFlipType rotateFlipType)
        {
            Status status = GDIPlus.GdipImageRotateFlip(nativeObject, rotateFlipType);

            GDIPlus.CheckStatus(status);
        }
示例#4
0
        public void RotateTransform(float angle, MatrixOrder order)
        {
            Status status = GDIPlus.GdipRotatePenTransform(nativeObject, angle, order);

            GDIPlus.CheckStatus(status);
        }
示例#5
0
        public Region()
        {
            Status status = GDIPlus.GdipCreateRegion(out nativeRegion);

            GDIPlus.CheckStatus(status);
        }
示例#6
0
        public void MakeInfinite()
        {
            Status status = GDIPlus.GdipSetInfinite(nativeRegion);

            GDIPlus.CheckStatus(status);
        }
示例#7
0
        public void ToLogFont(object logFont, Graphics graphics)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            if (logFont == null)
            {
#if NET_2_0
                throw new AccessViolationException("logFont");
#else
                throw new NullReferenceException("logFont");
#endif
            }

            Type st = logFont.GetType();
            if (!st.GetTypeInfo().IsLayoutSequential)
            {
                throw new ArgumentException("logFont", Locale.GetText("Layout must be sequential."));
            }

            // note: there is no exception if 'logFont' isn't big enough
            Type lf   = typeof(LOGFONT);
            int  size = Marshal.SizeOf(logFont);
            if (size >= Marshal.SizeOf(lf))
            {
                Status status;
                IntPtr copy = Marshal.AllocHGlobal(size);
                try {
                    Marshal.StructureToPtr(logFont, copy, false);

                    status = GDIPlus.GdipGetLogFont(NativeObject, graphics.NativeObject, logFont);
                    if (status != Status.Ok)
                    {
                        // reset to original values
                        Marshal.PtrToStructure(copy, logFont);
                    }
                }
                finally {
                    Marshal.FreeHGlobal(copy);
                }

                if (CharSetOffset == -1)
                {
                    // not sure why this methods returns an IntPtr since it's an offset
                    // anyway there's no issue in downcasting the result into an int32
                    CharSetOffset = (int)Marshal.OffsetOf(lf, "lfCharSet");
                }

                // note: Marshal.WriteByte(object,*) methods are unimplemented on Mono
                GCHandle gch = GCHandle.Alloc(logFont, GCHandleType.Pinned);
                try {
                    IntPtr ptr = gch.AddrOfPinnedObject();
                    // if GDI+ lfCharSet is 0, then we return (S.D.) 1, otherwise the value is unchanged
                    if (Marshal.ReadByte(ptr, CharSetOffset) == 0)
                    {
                        // set lfCharSet to 1
                        Marshal.WriteByte(ptr, CharSetOffset, 1);
                    }
                }
                finally {
                    gch.Free();
                }

                // now we can throw, if required
                GDIPlus.CheckStatus(status);
            }
        }
示例#8
0
        public void Xor(RectangleF rect)
        {
            Status status = GDIPlus.GdipCombineRegionRect(nativeRegion, ref rect, CombineMode.Xor);

            GDIPlus.CheckStatus(status);
        }
示例#9
0
        public StringFormat(StringFormatFlags options)
        {
            Status status = GDIPlus.GdipCreateStringFormat(options, GDIPlus.LANG_NEUTRAL, out nativeStrFmt);

            GDIPlus.CheckStatus(status);
        }
示例#10
0
        public static Font FromHfont(IntPtr hfont)
        {
            IntPtr    newObject;
            IntPtr    hdc;
            FontStyle newStyle = FontStyle.Regular;
            float     newSize;
            LOGFONT   lf = new LOGFONT();

            // Sanity. Should we throw an exception?
            if (hfont == IntPtr.Zero)
            {
                Font result = new Font("Arial", (float)10.0, FontStyle.Regular);
                return(result);
            }

            if (GDIPlus.RunningOnUnix())
            {
                // If we're on Unix we use our private gdiplus API to avoid Wine
                // dependencies in S.D
                Status s = GDIPlus.GdipCreateFontFromHfont(hfont, out newObject, ref lf);
                GDIPlus.CheckStatus(s);
            }
            else
            {
                // This needs testing
                // GetDC, SelectObject, ReleaseDC GetTextMetric and
                // GetFontFace are not really GDIPlus, see gdipFunctions.cs

                newStyle = FontStyle.Regular;

                hdc = GDIPlus.GetDC(IntPtr.Zero);
                try {
                    return(FromLogFont(lf, hdc));
                }
                finally {
                    GDIPlus.ReleaseDC(IntPtr.Zero, hdc);
                }
            }

            if (lf.lfItalic != 0)
            {
                newStyle |= FontStyle.Italic;
            }

            if (lf.lfUnderline != 0)
            {
                newStyle |= FontStyle.Underline;
            }

            if (lf.lfStrikeOut != 0)
            {
                newStyle |= FontStyle.Strikeout;
            }

            if (lf.lfWeight > 400)
            {
                newStyle |= FontStyle.Bold;
            }

            if (lf.lfHeight < 0)
            {
                newSize = lf.lfHeight * -1;
            }
            else
            {
                newSize = lf.lfHeight;
            }

            string lfFaceName = String.Concat(
                lf.lfFaceName1,
                lf.lfFaceName2,
                lf.lfFaceName3,
                lf.lfFaceName4,
                lf.lfFaceName5,
                lf.lfFaceName6,
                lf.lfFaceName7,
                lf.lfFaceName8,
                lf.lfFaceName9,
                lf.lfFaceName10,
                lf.lfFaceName11,
                lf.lfFaceName12,
                lf.lfFaceName13,
                lf.lfFaceName14,
                lf.lfFaceName15,
                lf.lfFaceName16,
                lf.lfFaceName17,
                lf.lfFaceName18,
                lf.lfFaceName19,
                lf.lfFaceName20,
                lf.lfFaceName21,
                lf.lfFaceName22,
                lf.lfFaceName23,
                lf.lfFaceName24,
                lf.lfFaceName25,
                lf.lfFaceName26,
                lf.lfFaceName27,
                lf.lfFaceName28,
                lf.lfFaceName29,
                lf.lfFaceName30,
                lf.lfFaceName31,
                lf.lfFaceName32);

            return(new Font(newObject, lfFaceName, newStyle, newSize));
        }
示例#11
0
        public StringFormat(StringFormatFlags options, int language)
        {
            Status status = GDIPlus.GdipCreateStringFormat(options, language, out nativeStrFmt);

            GDIPlus.CheckStatus(status);
        }
示例#12
0
        public void SetDigitSubstitution(int language, StringDigitSubstitute substitute)
        {
            Status status = GDIPlus.GdipSetStringFormatDigitSubstitution(nativeStrFmt, this.language, substitute);

            GDIPlus.CheckStatus(status);
        }
示例#13
0
        public void SetTabStops(float firstTabOffset, float[] tabStops)
        {
            Status status = GDIPlus.GdipSetStringFormatTabStops(nativeStrFmt, firstTabOffset, tabStops.Length, tabStops);

            GDIPlus.CheckStatus(status);
        }
示例#14
0
        public void Complement(Rectangle rect)
        {
            Status status = GDIPlus.GdipCombineRegionRectI(nativeRegion, ref rect, CombineMode.Complement);

            GDIPlus.CheckStatus(status);
        }
示例#15
0
        public void SetResolution(float xDpi, float yDpi)
        {
            Status status = GDIPlus.GdipBitmapSetResolution(nativeObject, xDpi, yDpi);

            GDIPlus.CheckStatus(status);
        }
示例#16
0
        public void Exclude(Rectangle rect)
        {
            Status status = GDIPlus.GdipCombineRegionRectI(nativeRegion, ref rect, CombineMode.Exclude);

            GDIPlus.CheckStatus(status);
        }
示例#17
0
        public void UnlockBits(BitmapData bitmapdata)
        {
            Status status = GDIPlus.GdipBitmapUnlockBits(nativeObject, bitmapdata);

            GDIPlus.CheckStatus(status);
        }
示例#18
0
        public void Translate(float dx, float dy)
        {
            Status status = GDIPlus.GdipTranslateRegion(nativeRegion, dx, dy);

            GDIPlus.CheckStatus(status);
        }
示例#19
0
        public void MultiplyTransform(Matrix matrix, MatrixOrder order)
        {
            Status status = GDIPlus.GdipMultiplyPenTransform(nativeObject, matrix.nativeMatrix, order);

            GDIPlus.CheckStatus(status);
        }
示例#20
0
        public void MakeEmpty()
        {
            Status status = GDIPlus.GdipSetEmpty(nativeRegion);

            GDIPlus.CheckStatus(status);
        }
示例#21
0
        public void ResetTransform()
        {
            Status status = GDIPlus.GdipResetPenTransform(nativeObject);

            GDIPlus.CheckStatus(status);
        }
示例#22
0
        public Region(RectangleF rect)
        {
            Status status = GDIPlus.GdipCreateRegionRect(ref rect, out nativeRegion);

            GDIPlus.CheckStatus(status);
        }
示例#23
0
        public void RemovePropertyItem(int propid)
        {
            Status status = GDIPlus.GdipRemovePropertyItem(nativeObject, propid);

            GDIPlus.CheckStatus(status);
        }