Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/System.Drawing')
-rwxr-xr-xmcs/class/System.Drawing/Assembly/Application.icobin0 -> 3262 bytes
-rw-r--r--mcs/class/System.Drawing/Assembly/AssemblyInfo.cs74
-rwxr-xr-xmcs/class/System.Drawing/Assembly/Asterisk.icobin0 -> 3262 bytes
-rw-r--r--mcs/class/System.Drawing/Assembly/ChangeLog20
-rwxr-xr-xmcs/class/System.Drawing/Assembly/Error.icobin0 -> 3262 bytes
-rwxr-xr-xmcs/class/System.Drawing/Assembly/Exclamation.icobin0 -> 3262 bytes
-rwxr-xr-xmcs/class/System.Drawing/Assembly/Hand.icobin0 -> 3262 bytes
-rwxr-xr-xmcs/class/System.Drawing/Assembly/Information.icobin0 -> 3262 bytes
-rwxr-xr-xmcs/class/System.Drawing/Assembly/Question.icobin0 -> 3262 bytes
-rwxr-xr-xmcs/class/System.Drawing/Assembly/Warning.icobin0 -> 3262 bytes
-rwxr-xr-xmcs/class/System.Drawing/Assembly/WinLogo.icobin0 -> 3262 bytes
-rw-r--r--mcs/class/System.Drawing/ChangeLog318
-rw-r--r--mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfiguration.cs76
-rw-r--r--mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfigurationCollection.cs93
-rw-r--r--mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfigurationHandler.cs140
-rw-r--r--mcs/class/System.Drawing/Makefile21
-rw-r--r--mcs/class/System.Drawing/README40
-rw-r--r--mcs/class/System.Drawing/SD.csproj974
-rw-r--r--mcs/class/System.Drawing/Samples/ChangeLog22
-rw-r--r--mcs/class/System.Drawing/Samples/General/ChangeLog10
-rw-r--r--mcs/class/System.Drawing/Samples/General/hering.cs80
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Drawing2D/ChangeLog4
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ChangeLog13
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ColorMatrix.cs259
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ImageAttributes.cs124
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ImageCodecs.cs74
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Printing/ChangeLog13
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Printing/EnumPrinters.cs42
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintMe.txt196
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintingMargins.cs62
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintingTextFile.cs54
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing.Text/ChangeLog4
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/BmpPaint.cs91
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/ChangeLog69
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/CopyFromScreen.cs23
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/FontDrawing.cs148
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/FontDrawingAdv.cs359
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/GraphicsUnits.cs133
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/ImageRotateFlip.cs91
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/ImageStream.cs53
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/RegionsGraphicsPath.cs160
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/RegionsRectangle.cs428
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/SystemFonts.cs29
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/TextureWrapModes.cs121
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/bitmaps/ChangeLog5
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/bitmaps/horse.bmpbin0 -> 17526 bytes
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/bmpsave.cs50
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/clip.cs52
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/clipping.cs103
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/drawimage.cs82
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/font.cs63
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/fontsizes.cs52
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/graphicsUi.cs134
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/imagecompose.cs68
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/pie.cs94
-rw-r--r--mcs/class/System.Drawing/Samples/System.Drawing/region.cs31
-rwxr-xr-xmcs/class/System.Drawing/Samples/run-samples.sh148
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/CategoryNameCollection.cs79
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/ChangeLog91
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/IPropertyValueUIService.cs54
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/IToolboxItemProvider.cs40
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/IToolboxService.cs103
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/IToolboxUser.cs40
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/PaintValueEventArgs.cs85
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/PropertyValueItem.cs89
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIHandler.cs42
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIItemInvokeHandler.cs42
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventArgs.cs54
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventHandler.cs37
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventArgs.cs57
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventHandler.cs36
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/ToolboxItem.cs351
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCollection.cs73
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCreatorCallback.cs38
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/UITypeEditor.cs89
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Design/UITypeEditorEditStyle.cs38
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.cs122
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.jvm.cs102
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs81
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog553
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs78
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/CombineMode.cs48
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingMode.cs44
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingQuality.cs48
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/CoordinateSpace.cs45
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs183
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.jvm.cs129
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/DashCap.cs45
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/DashStyle.cs48
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/ExtendedGeneralPath.jvm.cs700
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/FillMode.cs45
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/FlushIntention.cs44
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/GeneralPathIterator.jvm.cs105
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.cs59
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.jvm.cs54
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs883
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.jvm.cs1082
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.cs202
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.jvm.cs220
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.cs51
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.jvm.cs150
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.cs97
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.jvm.cs60
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchStyle.cs101
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs51
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/LineCap.cs53
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/LineJoin.cs46
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs348
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.jvm.cs346
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientMode.cs46
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.cs308
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.jvm.cs295
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/MatrixOrder.cs44
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs53
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.cs357
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.jvm.cs286
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/PathPointType.cs50
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/PenAlignment.cs45
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/PenType.cs46
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/PixelOffsetMode.cs49
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs46
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs52
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/SmoothingMode.cs48
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/WarpMode.cs44
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Drawing2D/WrapMode.cs49
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/BitmapData.cs120
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog412
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ColorAdjustType.cs43
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ColorChannelFlag.cs41
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs64
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ColorMapType.cs38
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs372
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrixFlag.cs39
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ColorMode.cs38
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs116
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs289
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/EmfType.cs39
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/Encoder.cs79
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.cs358
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.jvm.cs189
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameterValueType.cs44
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameters.cs115
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/EncoderValue.cs60
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/FrameDimension.cs93
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs433
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.jvm.cs298
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodec.jvm.cs700
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs46
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs217
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.jvm.cs181
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs51
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageFormat.cs187
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/ImageLockMode.cs40
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs94
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/Metafile.cs328
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/Metafile.jvm.cs362
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/MetafileFrameUnit.cs42
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/MetafileHeader.cs144
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/MetafileType.cs46
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/PaletteFlags.cs39
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/PixelFormat.cs63
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/PlayRecordCallback.cs42
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs77
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Imaging/WmfPlaceableFileHeader.cs103
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/ChangeLog54
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/Duplex.cs42
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs64
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/Margins.cs151
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/MarginsConverter.cs137
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PageSettings.cs216
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PaperKind.cs157
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PaperSize.cs115
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PaperSource.cs95
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PaperSourceKind.cs52
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PreviewPageInfo.cs57
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PreviewPrintController.cs87
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintAction.cs45
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintController.cs65
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintDocument.cs209
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintEventArgs.cs60
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintEventHandler.cs40
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventArgs.cs103
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventHandler.cs40
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintRange.cs44
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolution.cs106
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolutionKind.cs43
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrinterSettings.cs541
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnit.cs39
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnitConvert.cs139
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermission.cs259
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionAttribute.cs69
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionLevel.cs41
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintingServices.cs102
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesUnix.cs354
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesWin32.cs339
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventArgs.cs57
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventHandler.cs40
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Printing/StandardPrintController.cs68
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs100
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/FontCollection.jvm.cs89
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/GenericFontFamilies.cs39
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/HotkeyPrefix.cs39
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.cs49
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.jvm.cs57
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Text/LineLayout.jvm.cs187
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.cs86
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.jvm.cs58
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.Text/TextLineIterator.jvm.cs242
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/TextRenderingHint.cs42
-rw-r--r--mcs/class/System.Drawing/System.Drawing.Text/changelog91
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing.dll.sources192
-rw-r--r--mcs/class/System.Drawing/System.Drawing.sln21
-rw-r--r--mcs/class/System.Drawing/System.Drawing.vmwcsproj170
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/AdvancedStroke.jvm.cs550
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/BasicShape.jvm.cs85
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Bitmap.cs324
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Bitmap.jvm.cs420
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Brush.cs115
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/Brush.jvm.cs104
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Brushes.cs1459
-rw-r--r--mcs/class/System.Drawing/System.Drawing/BufferedGraphics.cs118
-rw-r--r--mcs/class/System.Drawing/System.Drawing/BufferedGraphicsContext.cs89
-rw-r--r--mcs/class/System.Drawing/System.Drawing/BufferedGraphicsManager.cs52
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ChangeLog2471
-rw-r--r--mcs/class/System.Drawing/System.Drawing/CharacterRange.cs91
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Color.cs1577
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ColorConverter.cs245
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs200
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ComIStreamMarshaler.cs681
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ComIStreamWrapper.cs210
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ContentAlignment.cs49
-rw-r--r--mcs/class/System.Drawing/System.Drawing/CopyPixelOperation.cs59
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Font.cs717
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Font.jvm.cs295
-rw-r--r--mcs/class/System.Drawing/System.Drawing/FontConverter.cs310
-rw-r--r--mcs/class/System.Drawing/System.Drawing/FontFamily.cs313
-rw-r--r--mcs/class/System.Drawing/System.Drawing/FontFamily.jvm.cs232
-rw-r--r--mcs/class/System.Drawing/System.Drawing/FontStyle.cs44
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Graphics.cs2448
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/Graphics.jvm.cs2564
-rw-r--r--mcs/class/System.Drawing/System.Drawing/GraphicsUnit.cs42
-rw-r--r--mcs/class/System.Drawing/System.Drawing/IDeviceContext.cs43
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Icon.cs572
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/Icon.jvm.cs198
-rw-r--r--mcs/class/System.Drawing/System.Drawing/IconConverter.cs90
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Image.cs795
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Image.jvm.cs571
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs218
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ImageConverter.cs101
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ImageFormatConverter.cs153
-rw-r--r--mcs/class/System.Drawing/System.Drawing/KnownColor.cs215
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Pen.cs521
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/Pen.jvm.cs577
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Pens.cs1597
-rw-r--r--mcs/class/System.Drawing/System.Drawing/PlainImage.jvm.cs137
-rw-r--r--mcs/class/System.Drawing/System.Drawing/PlainImageCollection.jvm.cs101
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Point.cs387
-rw-r--r--mcs/class/System.Drawing/System.Drawing/PointConverter.cs144
-rw-r--r--mcs/class/System.Drawing/System.Drawing/PointF.cs257
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Rectangle.cs638
-rw-r--r--mcs/class/System.Drawing/System.Drawing/RectangleConverter.cs164
-rw-r--r--mcs/class/System.Drawing/System.Drawing/RectangleF.cs580
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Region.cs640
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Region.jvm.cs384
-rw-r--r--mcs/class/System.Drawing/System.Drawing/RotateFlipType.cs53
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SRDescriptionAttribute.cs58
-rw-r--r--mcs/class/System.Drawing/System.Drawing/Size.cs356
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SizeConverter.cs148
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SizeF.cs312
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SizeFConverter.cs134
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SolidBrush.cs98
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SolidBrush.jvm.cs77
-rw-r--r--mcs/class/System.Drawing/System.Drawing/StringAligment.cs41
-rw-r--r--mcs/class/System.Drawing/System.Drawing/StringDigitSubstitute.cs42
-rw-r--r--mcs/class/System.Drawing/System.Drawing/StringFormat.cs291
-rw-r--r--mcs/class/System.Drawing/System.Drawing/StringFormat.jvm.cs270
-rw-r--r--mcs/class/System.Drawing/System.Drawing/StringFormatFlags.cs48
-rw-r--r--mcs/class/System.Drawing/System.Drawing/StringTrimming.cs44
-rw-r--r--mcs/class/System.Drawing/System.Drawing/StringUnit.cs46
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/StrokeFactory.jvm.cs67
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs462
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SystemColors.cs498
-rwxr-xr-xmcs/class/System.Drawing/System.Drawing/SystemColors.jvm.cs296
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SystemFonts.cs170
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SystemIcons.cs61
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SystemIcons.jvm.cs73
-rw-r--r--mcs/class/System.Drawing/System.Drawing/SystemPens.cs456
-rw-r--r--mcs/class/System.Drawing/System.Drawing/TextureBrush.cs214
-rw-r--r--mcs/class/System.Drawing/System.Drawing/TextureBrush.jvm.cs226
-rw-r--r--mcs/class/System.Drawing/System.Drawing/ToolboxBitmapAttribute.cs139
-rw-r--r--mcs/class/System.Drawing/System.Drawing/carbonFunctions.cs149
-rw-r--r--mcs/class/System.Drawing/System.Drawing/gdipEnums.cs87
-rw-r--r--mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs1795
-rw-r--r--mcs/class/System.Drawing/System.Drawing/gdipStructs.cs226
-rw-r--r--mcs/class/System.Drawing/System.Drawing_test.dll.sources56
-rw-r--r--mcs/class/System.Drawing/Test/ChangeLog28
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/ChangeLog20
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/AssemblyInfo.cs58
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/ChangeLog29
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTest.cs652
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper.csproj117
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper_java.vmwcsproj29
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/Makefile10
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/PDComparer.cs109
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/Makefile10
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/doc/Exocortex.DSP.xml1124
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/AssemblyInfo.cs58
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Complex.cs527
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexArray.cs682
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexF.cs520
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexMath.cs158
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexStats.cs306
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Exocortex.DSP.v1.J2EE.vmwcsproj31
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Exocortex.DSP.v1.csproj135
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Fourier.cs1346
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/FourierDirection.cs55
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.dotnet.sln51
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.sln44
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/AssemblyInfo.cs58
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap.cs53
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap1.bmpbin0 -> 12342 bytes
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap1.pngbin0 -> 397 bytes
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Brush.cs139
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Brushes.cs367
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/ChangeLog76
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Colors.cs361
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Enums.cs454
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Graphics.cs2740
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPath.cs5729
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPathIterator.cs749
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Image.cs293
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Makefile17
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Pen.cs892
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Pens.cs350
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/Region.cs238
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/SampIcon.icobin0 -> 1406 bytes
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap25.pngbin0 -> 34088 bytes
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap50.pngbin0 -> 433 bytes
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap_gh.pngbin0 -> 23443 bytes
-rw-r--r--mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap_net.pngbin0 -> 27876 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Design/CategoryNameCollectionCas.cs83
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Design/ChangeLog22
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Design/PaintValueEventArgsCas.cs85
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Design/PropertyValueUIItemCas.cs89
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Design/TestToolboxItem.cs120
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxComponentsCreatedEventArgsCas.cs83
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxComponentsCreatingEventArgsCas.cs83
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxItemCas.cs82
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxItemCollectionCas.cs83
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Design/UITypeEditorCas.cs82
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/ChangeLog55
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/GraphicsPathTest.cs1136
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/PathDataTest.cs87
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestBlend.cs83
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestColorBlend.cs83
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestHatchBrush.cs621
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestMatrix.cs308
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog48
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestBmpCodec.cs159
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestColorMatrix.cs172
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageAttributes.cs103
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageCodecInfo.cs183
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageFormat.cs87
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestJpegCodec.cs133
-rwxr-xr-xmcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh28
-rwxr-xr-xmcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh29
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Printing/ChangeLog28
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Printing/PrinterUnitConvertTest.cs139
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Printing/PrintingPermissionAttributeTest.cs134
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Printing/PrintingPermissionTest.cs482
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing.Text/ChangeLog3
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/BitmapCas.cs133
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/ChangeLog357
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/ColorConverter.cs401
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/ColorTranslator.cs128
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/GraphicsCas.cs150
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/README12
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/RegionCas.cs97
-rwxr-xr-xmcs/class/System.Drawing/Test/System.Drawing/RegionDataTest.cs101
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/RegionNonRectTest.cs160
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestBitmap.cs551
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestBrushes.cs1074
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestColor.cs1161
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs113
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs310
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs112
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestIconConverter.cs424
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestImage.cs55
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestImageConverter.cs459
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestImageFormatConverter.cs305
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestPens.cs2197
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestPoint.cs230
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestPointConverter.cs455
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestPointF.cs201
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestRectangle.cs212
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestRectangleConverter.cs533
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestRectangleF.cs190
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestRegion.cs1294
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestSize.cs218
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestSizeConverter.cs462
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestSizeF.cs229
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestSizeFConverter.cs468
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestStringFormat.cs116
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestSystemBrushes.cs718
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/TestSystemPens.cs364
-rwxr-xr-xmcs/class/System.Drawing/Test/System.Drawing/bitmaps/1bit.pngbin0 -> 12336 bytes
-rwxr-xr-xmcs/class/System.Drawing/Test/System.Drawing/bitmaps/4bit.pngbin0 -> 30960 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/VisualPng.icobin0 -> 766 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/VisualPng1.icobin0 -> 766 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver-os2.bmpbin0 -> 95186 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver1bit.bmpbin0 -> 16222 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver24bits.bmpbin0 -> 95214 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver24bits1.bmpbin0 -> 95214 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver32bits.bmpbin0 -> 126690 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver8bits.bmpbin0 -> 33286 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/maketransparent.bmpbin0 -> 24534 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/nature24bits.gifbin0 -> 10292 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/nature24bits.jpgbin0 -> 2372 bytes
-rw-r--r--mcs/class/System.Drawing/Test/System.Drawing/bitmaps/smiley.icobin0 -> 2734 bytes
-rwxr-xr-xmcs/class/System.Drawing/Test/System.Drawing/tests-ms.sh28
-rwxr-xr-xmcs/class/System.Drawing/Test/System.Drawing/tests.sh29
-rw-r--r--mcs/class/System.Drawing/Test/Test.dotnet.csproj543
-rw-r--r--mcs/class/System.Drawing/Test/Test.vmwcsproj70
-rw-r--r--mcs/class/System.Drawing/Test/resources/indexed.pngbin0 -> 238 bytes
-rw-r--r--mcs/class/System.Drawing/cdeclRedirector/cdeclCallback.dllbin0 -> 3072 bytes
-rw-r--r--mcs/class/System.Drawing/cdeclRedirector/cdeclCallback.il204
-rw-r--r--mcs/class/System.Drawing/net_1_1_java_System.Drawing.dll.exclude.sources82
-rw-r--r--mcs/class/System.Drawing/net_1_1_java_System.Drawing.dll.sources49
428 files changed, 96776 insertions, 0 deletions
diff --git a/mcs/class/System.Drawing/Assembly/Application.ico b/mcs/class/System.Drawing/Assembly/Application.ico
new file mode 100755
index 00000000000..7a7840be1fd
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/Application.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Assembly/AssemblyInfo.cs b/mcs/class/System.Drawing/Assembly/AssemblyInfo.cs
new file mode 100644
index 00000000000..77b0cbf04ed
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/AssemblyInfo.cs
@@ -0,0 +1,74 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the system assembly
+
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+
+#if (ONLY_1_1)
+[assembly: ComCompatibleVersion (1, 0, 3300, 0)]
+[assembly: TypeLibVersion (1, 10)]
+#endif
+
+[assembly: AssemblyTitle("System.Drawing.dll")]
+[assembly: AssemblyDescription("System.Drawing.dll")]
+[assembly: AssemblyConfiguration("Development version")]
+[assembly: AssemblyCompany("MONO development team")]
+[assembly: AssemblyProduct("MONO CLI")]
+[assembly: AssemblyCopyright("(c) 2003 Various Authors")]
+[assembly: AssemblyTrademark("")]
+
+#if !TARGET_JVM
+[assembly: CLSCompliant(true)]
+#endif
+[assembly: AssemblyDefaultAlias("System.Drawing.dll")]
+[assembly: AssemblyInformationalVersion("0.0.0.1")]
+[assembly: NeutralResourcesLanguage("en-US")]
+
+[assembly: ComVisible(false)]
+[assembly: AllowPartiallyTrustedCallers]
+
+#if TARGET_JVM
+[assembly: AssemblyDelaySign(false)]
+#else
+[assembly: AssemblyDelaySign(true)]
+[assembly: AssemblyKeyFile("../msfinal.pub")]
+#endif
+
diff --git a/mcs/class/System.Drawing/Assembly/Asterisk.ico b/mcs/class/System.Drawing/Assembly/Asterisk.ico
new file mode 100755
index 00000000000..3000fe3e845
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/Asterisk.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Assembly/ChangeLog b/mcs/class/System.Drawing/Assembly/ChangeLog
new file mode 100644
index 00000000000..f56a4ddb1d2
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/ChangeLog
@@ -0,0 +1,20 @@
+2005-11-28 Konstantin Triger <kostat@mainsoft.com>
+
+ * Added system icons.
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * AssemblyInfo.cs: add TARGET_JVM mode
+
+2004-02-07 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Locale.cs: Added
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Consts.cs: Added
+
+2003-07-17 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * AssemblyInfo.cs: Added
+ * ChangeLog: Added
diff --git a/mcs/class/System.Drawing/Assembly/Error.ico b/mcs/class/System.Drawing/Assembly/Error.ico
new file mode 100755
index 00000000000..324796a4acb
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/Error.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Assembly/Exclamation.ico b/mcs/class/System.Drawing/Assembly/Exclamation.ico
new file mode 100755
index 00000000000..b29ae3641af
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/Exclamation.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Assembly/Hand.ico b/mcs/class/System.Drawing/Assembly/Hand.ico
new file mode 100755
index 00000000000..324796a4acb
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/Hand.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Assembly/Information.ico b/mcs/class/System.Drawing/Assembly/Information.ico
new file mode 100755
index 00000000000..3000fe3e845
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/Information.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Assembly/Question.ico b/mcs/class/System.Drawing/Assembly/Question.ico
new file mode 100755
index 00000000000..b2f111ccf37
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/Question.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Assembly/Warning.ico b/mcs/class/System.Drawing/Assembly/Warning.ico
new file mode 100755
index 00000000000..b29ae3641af
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/Warning.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Assembly/WinLogo.ico b/mcs/class/System.Drawing/Assembly/WinLogo.ico
new file mode 100755
index 00000000000..7a7840be1fd
--- /dev/null
+++ b/mcs/class/System.Drawing/Assembly/WinLogo.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/ChangeLog b/mcs/class/System.Drawing/ChangeLog
new file mode 100644
index 00000000000..71cdde616f8
--- /dev/null
+++ b/mcs/class/System.Drawing/ChangeLog
@@ -0,0 +1,318 @@
+2006-01-18 Sebastien Pouliot <sebastien@ximian.com>
+
+ * System.Drawing_test.dll.sources: Added unit tests for RegionData and
+ non-rectangular Region.
+
+2006-01-12 Sebastien Pouliot <sebastien@ximian.com>
+
+ * System.Drawing_test.dll.sources: Added unit tests for GraphicsPath
+ and PathData.
+
+2006-01-11 Sebastien Pouliot <sebastien@ximian.com>
+
+ * System.Drawing_test.dll.sources: Added CAS unit tests for Region to
+ the build.
+
+2005-12-05 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * MetaHeader.cs: Classes need to specify StructLayout attribute
+ * EncoderParameter.cs: Classes need to specify StructLayout attribute
+ * ImageAttributes.cs: Classes need to specify StructLayout attribute
+ * WmfPlaceableFileHeader.cs: Classes need to specify StructLayout attribute
+ * MetafileHeader.cs: Classes need to specify StructLayout attribute
+
+2005-12-04 Konstantin Triger <kostat@mainsoft.com>
+
+ * net_1_1_java_System.Drawing.dll.exclude.sources,
+ net_1_1_java_System.Drawing.dll.sources:
+ correcting SystemIcons.cs reference.
+
+2005-11-28 Konstantin Triger <kostat@mainsoft.com>
+
+ * System.Drawing.vmwcsproj: Added System icons; changed to mono icon implementation.
+
+2005-11-14 Andrew Skiba <andrews@mainsoft.com>
+
+ * net_1_1_java_System.Drawing.dll.sources,
+ net_1_1_java_System.Drawing.dll.exclude.sources: added java profile
+ sources lists
+ * Makefile: add java profile section
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * System.Drawing.vmwcsproj: Added System.Drawing.Text/LineLayout.jvm.cs,
+ System.Drawing.Text/LineLayout.jvm.cs
+
+2005-09-27 Kornél Pál <kornelpal@hotmail.com>
+
+ * Makefile: Removed /codepage:28591 as it is the default.
+
+2005-09-19 Miguel de Icaza <miguel@novell.com>
+
+ * Makefile (EXTRA_DISTFILES): Distribute indexed.png, add resource
+ to build.
+
+2005-09-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * System.Drawing.vmwcsproj: Added PlainImage.jvm.cs, PlainImageCollection.jvm.cs
+
+2005-09-07 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * System.Drawing.vmwcsproj: ImageCodec.jvm.cs
+ Added Mainsoft.Drawing.Configuration.jvm folder with
+ ResolutionConfiguration.cs, ResolutionConfigurationCollection.cs,
+ ResolutionConfigurationHandler.cs
+
+2005-08-28 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * System.Drawing.vmwcsproj: Added GraphicsContainer.jvm.cs, GraphicsState.jvm.cs
+ Excluded: GraphicsContainer.cs, GraphicsState.cs
+ Fixed: const.cs.in
+
+2005-08-25 Atsushi Enomoto <atsushi@ximian.com>
+
+ * Makefile: build fix for some utf8-defaulted environment.
+
+2005-08-24 Marek Safar <marek.safar@seznam.cz>
+
+ * SD.csproj: Updated.
+
+2005-08-23 Eyal Alalyf <eyala@mainsoft.com>
+ * System.Drawing.vmwcsproj: Change it to be developer edition project file
+
+2005-08-23 Boris Kirzner <borisk@mainsoft.com>
+ * System.Drawing.vmwcsproj: Changed reference to Consts.cs.
+
+2005-08-16 Andrew Skiba <andrews@mainsoft.com>
+
+ * System.Drawing.vmwcsproj: use ImageFormat.cs instead of jvm.cs
+
+2005-08-14 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * System.Drawing.dll.sources: Removed TestColorConverter again, as
+ there was already a test class for ColorConverter.
+
+2005-08-14 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * System.Drawing.dll.sources: Added TestColorConverter.cs.
+
+2005-08-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * System.Drawing.vmwcsproj: Added SystemIcons.jvm.cs, excluded SystemIcons.cs
+
+2005-08-11 Konstantin Triger <kostat@mainsoft.com>
+
+ * System.Drawing.vmwcsproj: changing JAVA to TARGET_JVM in release builds
+
+2005-08-10 Boris Kirzner <borisk@mainsoft.com>
+ * System.Drawing.vmwcsproj: Added ExtendedGeneralPath.jvm.cs and GeneralPathIterator.jvm.cs.
+
+2005-08-09 Konstantin Triger <kostat@mainsoft.com>
+
+ * System.Drawing.vmwcsproj: Added AdvancedStoke.jvm.cs and StrokeFactory.jvm.cs
+
+2005-08-09 Andrew Skiba <andrews@mainsoft.com>
+
+ * System.Drawing_test.dll.sources: add ColorConverter.cs and ColorTranslator.cs
+
+2005-08-07 Konstantin Triger <kostat@mainsoft.com>
+
+ * System.Drawing.vmwcsproj: removed source control dependency
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * System.Drawing.vmwcsproj, System.Drawing.sln: add a project file and solution for building System.Drawing for Grasshopper
+
+2004-12-09 Geoff Norton <gnorton@customerdna.com>
+
+ * System.Drawing.dll.sources: Add System.Drawing/carbonFunctions.cs to the build
+
+2004-11-22 Ravindra <rkumar@novell.com>
+
+ * SD.csproj: Removed a wrong entry from files list.
+
+2004-09-16 Ravindra <rkumar@novell.com>
+
+ * SD.csproj: Added a VS.NET project file. It can be used to build
+ System.Drawing library on MS.
+
+2004-09-09 Sebastien Pouliot <sebastien@ximian.com>
+
+ * System.Drawing_test.dll.sources: Added unit tests for
+ PrintingPermission and it's attribute class.
+
+2004-06-10 Ravindra <rkumar@novell.com>
+
+ * Makefile: Suppress compiler warning cs:618 for test dll.
+
+2004-06-03 Ravindra <rkumar@novell.com>
+
+ * Makefile: Updated. We don't need to define the flag
+ DECLARE_CDECL_DELEGATES anymore. As we have moved all the
+ codecs to libgdiplus.
+
+2004-05-26 Ravindra <rkumar@novell.com>
+
+ * System.Drawing_test.dll.sources: Added TestColor.cs to the test sources list.
+
+2004-05-20 Sanjay Gupta <gsanjay@novell.com>
+
+ * System.Drawing_test.dll.sources: Added TestIcon.cs to the test sources list.
+
+2004-05-18 Ravindra <rkumar@novell.com>
+
+ * System.Drawing_test.dll.sources: Added TestHatchBrush.cs to the
+ test sources list.
+ * README: Added some guidelines for writing tests/samples.
+
+2004-05-17 Sanjay Gupta <gsanjay@novell.com>
+
+ * System.Drawing_test.dll.sources: Added TestIconConverter.cs to the test sources list.
+
+2004-05-14 Sanjay Gupta <gsanjay@novell.com>
+
+ * System.Drawing_test.dll.sources: Added TestImageConverter.cs and
+ TestImageFormatConverter.cs to the test sources list.
+
+2004-04-22 Ravindra <rkumar@novell.com>
+
+ * System.Drawing_test.dll.sources: Added TestPointConverter.cs,
+ TestRectangleConverter.cs and TestSizeConverter.cs to the test
+ sources list.
+
+2004-04-21 Ravindra <rkumar@novell.com>
+
+ * System.Drawing_test.dll.sources: Added TestPens.cs and
+ TestBrushes.cs to the test sources list.
+
+2004-04-16 Ravindra <rkumar@novell.com>
+
+ * System.Drawing_test.dll.sources: Added TestSystemPens.cs
+ to the test sources list.
+
+2004-04-12 Ravindra <rkumar@novell.com>
+
+ * System.Drawing_test.dll.sources: Added TestSystemBrushes.cs
+ to the test sources list.
+
+2004-03-18 Ravindra <rkumar@novell.com>
+ * System.Drawing_test.dll.sources: Added TestBitmap.cs,
+ TestBlend.cs and TestColorBlend.cs to test sources list.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Samples: Created directory for samples.
+ * README: Created README that tells about the directory
+ structure for samples and tests.
+
+2004-02-11 Ravindra <rkumar@novell.com>
+ * System.Drawing.dll.sources: Added EncoderParameter.cs
+ and EncoderParameters.cs.
+
+2004-02-07 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * System.Drawing.dll.sources:
+ SRDescriptionAttribute.cs, Locale.cs added
+
+2004-01-26 Ravindra <rkumar@novell.com>
+ * System.Drawing.dll.sources: Added TextureBrush.cs.
+
+2004-01-26 Ravindra <rkumar@novell.com>
+ * System.Drawing_test.dll.sources: Added to create
+ System.Drawing_test.dll.
+
+2004-01-23 Ravindra <rkumar@novell.com>
+ * System.Drawing.dll.sources: Removed TextureBrush.cs.
+ Was added by mistake during last check-in.
+
+2004-01-19 Ravindra <rkumar@novell.com>
+ * System.Drawing.dll.sources: Added Encoder.cs.
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+ * System.Drawing.dll.sources: MetafileHeader added (was missing), Consts.cs added
+
+2003-10-14 Bernie Solomon <bernard@ugsolutions.com>
+ * Makefile do not build gdiplus on Windows
+
+2003-10-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Makefile gdiplus added to subdirs
+
+2003-10-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * System.Drawing.dll.sources: Remove cairo,win32,gtk implementations
+ Add gdi+ implementation
+
+2003-09-21 Miguel de Icaza <miguel@ximian.com>
+ * System.Drawing.dll.sources: Remove xr implementation.
+
+2003-09-21 Alexandre Pigolkine <pigolkine@gmx.de>
+ * System.Drawing.dll.sources removed 2 files from Printing namespace
+
+2003-08-31 Jerome Laban <jlaban@wanadoo.fr>
+ * Graphics.cs:
+ * win32functions.cs: Added Win32 Ellipse implementation.
+
+2003-08-24 Duncan Mak <duncan@ximian.com>
+
+ * System.Drawing.dll.sources: Add Cairo implementation.
+
+2003-07-23 Peter Williams <peter@newton.cx>
+
+ * System.Drawing.dll.sources: Add Pens.cs
+
+2003-07-17 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * System.Drawing.dll.sources:
+ * list.unix: AssemblyInfo.cs added
+
+2003-06-27 Alexandre Pigolkine <pigolkine@gmx.de>
+ * list.unix
+ new file added
+
+2003-06-22 Alexandre Pigolkine <pigolkine@gmx.de>
+ * list.unix
+ reordered by folder names
+ few new files added
+ System.Drawing.Design/IDesignerHost.cs removed
+
+2003-06-18 Alexandre Pigolkine <pigolkine@gmx.de>
+ * list.unix changed
+
+2003-06-15 Alexandre Pigolkine <pigolkine@gmx.de>
+ * list.unix files added
+ * makefile.gnu --unsafe flag, cdecl delegates
+
+2003-06-06 Alexandre Pigolkine <pigolkine@gmx.de>
+ * list.unix changed
+
+2003-04-26 Alexandre Pigolkine <pigolkine@gmx.de>
+ * list.unix changed
+
+2003-03-31 Martin Willemoes Hansen <mwh@sysrq.dk>
+
+ * System.Drawing.Printing/PrinterUnitConvert.cs stubed
+
+2003-03-31 Martin Willemoes Hansen <mwh@sysrq.dk>
+
+ * System.Drawing.Design/ToolboxItemCollection.cs stubed
+
+2003-03-31 Alan Tam <Tam@SiuLung.com>
+
+ * list.unix: Added UITypeEditor.cs.
+
+2003-02-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * list.unix: added ImageAttributes.cs.
+
+2003-02-07 Alexandre Pigolkine <pigolkine@gmx.de>
+ * list.unix changed
+
+2002-12-1 Alejandro Sánchez Acosta <raciel@es.gnu.org>
+
+ * list.unix: Changed
+
+
+2002-06-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ChangeLog: new file.
+
+ * System.Drawing.build: added System.dll dependency
+
diff --git a/mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfiguration.cs b/mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfiguration.cs
new file mode 100644
index 00000000000..a62c270e935
--- /dev/null
+++ b/mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfiguration.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections;
+
+namespace Mainsoft.Drawing.Configuration
+{
+ /// <summary>
+ /// Summary description for ResolutionConfiguration.
+ /// </summary>
+ public class ResolutionConfiguration : IComparable
+ {
+ string _imageFormat = "";
+
+ string _xResPath = "";
+ string _yResPath = "";
+ string _unitsTypePath = "";
+
+ string _xResDefault = "";
+ string _yResDefault = "";
+ string _unitsTypeDefault = "";
+
+ Hashtable _unitScale;
+
+ public ResolutionConfiguration(
+ string imageFormat,
+ string xresPath, string yresPath, string unitsTypePath,
+ string xresDefault, string yresDefault, string unitsTypeDefault,
+ Hashtable unitScale)
+ {
+ _imageFormat = imageFormat;
+
+ _xResPath = xresPath;
+ _yResPath = yresPath;
+ _unitsTypePath = unitsTypePath;
+
+ _xResDefault = xresDefault;
+ _yResDefault = yresDefault;
+ _unitsTypeDefault = unitsTypeDefault;
+
+ _unitScale = unitScale;
+ }
+
+ public string XResPath {
+ get { return _xResPath; }
+ }
+ public string XResDefault {
+ get { return _xResDefault; }
+ }
+ public string YResPath {
+ get { return _yResPath; }
+ }
+ public string YResDefault {
+ get { return _yResDefault; }
+ }
+ public string UnitsTypePath {
+ get { return _unitsTypePath; }
+ }
+ public string UnitsTypeDefault {
+ get { return _unitsTypeDefault; }
+ }
+ public string ImageFormat {
+ get { return _imageFormat; }
+ }
+ public Hashtable UnitsScale {
+ get { return _unitScale; }
+ }
+
+ #region IComparable Members
+
+ public int CompareTo(object obj) {
+ return _imageFormat.CompareTo(((ResolutionConfiguration)obj).ImageFormat);
+ }
+
+ #endregion
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfigurationCollection.cs b/mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfigurationCollection.cs
new file mode 100644
index 00000000000..9dcbe40b8d3
--- /dev/null
+++ b/mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfigurationCollection.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections;
+
+namespace Mainsoft.Drawing.Configuration {
+ /// <summary>
+ /// Summary description for MetadataConfigurationCollection.
+ /// </summary>
+ public class ResolutionConfigurationCollection : IEnumerable, ICollection {
+
+ ArrayList _resolutionConfigurations;
+
+ #region ctors
+
+ internal ResolutionConfigurationCollection(ResolutionConfigurationCollection parent) {
+ _resolutionConfigurations = new ArrayList();
+
+ if (parent != null)
+ _resolutionConfigurations.AddRange(parent);
+ }
+
+ #endregion
+
+ #region methods
+
+ internal void Add(ResolutionConfiguration value) {
+ _resolutionConfigurations.Add(value);
+ }
+
+ internal void Sort() {
+ _resolutionConfigurations.Sort();
+ }
+
+ #endregion
+
+ #region props
+
+ public ResolutionConfiguration this[int index] {
+ get {
+ return (ResolutionConfiguration)_resolutionConfigurations[index];
+ }
+ }
+
+ public ResolutionConfiguration this[string ImageFormat] {
+ get {
+ for (int i=0; i < _resolutionConfigurations.Count; i++)
+ if ( ((ResolutionConfiguration)_resolutionConfigurations[i]).ImageFormat == ImageFormat )
+ return (ResolutionConfiguration)_resolutionConfigurations[i];
+ return null;
+ }
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ public IEnumerator GetEnumerator() {
+ // TODO: Add ResolutionConfigurationCollection.GetEnumerator implementation
+ return _resolutionConfigurations.GetEnumerator();
+ }
+
+ #endregion
+
+ #region ICollection Members
+
+ public bool IsSynchronized {
+ get {
+ // TODO: Add ResolutionConfigurationCollection.IsSynchronized getter implementation
+ return _resolutionConfigurations.IsSynchronized;
+ }
+ }
+
+ public int Count {
+ get {
+ // TODO: Add ResolutionConfigurationCollection.Count getter implementation
+ return _resolutionConfigurations.Count;
+ }
+ }
+
+ public void CopyTo(Array array, int index) {
+ // TODO: Add ResolutionConfigurationCollection.CopyTo implementation
+ _resolutionConfigurations.CopyTo(array, index);
+ }
+
+ public object SyncRoot {
+ get {
+ // TODO: Add ResolutionConfigurationCollection.SyncRoot getter implementation
+ return _resolutionConfigurations.SyncRoot;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfigurationHandler.cs b/mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfigurationHandler.cs
new file mode 100644
index 00000000000..18698ffcb85
--- /dev/null
+++ b/mcs/class/System.Drawing/Mainsoft.Drawing.Configuration.jvm/ResolutionConfigurationHandler.cs
@@ -0,0 +1,140 @@
+using System;
+using System.Collections;
+using System.Configuration;
+using System.Xml;
+
+
+namespace Mainsoft.Drawing.Configuration
+{
+ /// <summary>
+ /// Summary description for MetadataConfigurationHandler.
+ /// </summary>
+ public class ResolutionConfigurationHandler : IConfigurationSectionHandler
+ {
+ public ResolutionConfigurationHandler()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+
+ public virtual object Create (object parent, object configContext, XmlNode section) {
+
+ if (section.Attributes != null && section.Attributes.Count != 0)
+ HandlersUtil.ThrowException ("Unrecognized attribute", section);
+
+ ResolutionConfigurationCollection col =
+ new ResolutionConfigurationCollection(parent as ResolutionConfigurationCollection);
+
+ XmlNodeList imageFormats = section.ChildNodes;
+ foreach (XmlNode child in imageFormats) {
+
+ XmlNodeType ntype = child.NodeType;
+ if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment)
+ continue;
+
+ if (ntype != XmlNodeType.Element)
+ HandlersUtil.ThrowException ("Only elements allowed", child);
+
+ string imageFormatName = HandlersUtil.ExtractAttributeValue ("name", child, false, false);
+
+ string xResPath = HandlersUtil.ExtractNodeValue(child["xresolution"]);
+ string yResPath = HandlersUtil.ExtractNodeValue(child["yresolution"]);
+ string unitsType = HandlersUtil.ExtractNodeValue(child["unitstype"], false, true);
+
+ string xResDefault = HandlersUtil.ExtractAttributeValue ("default", child["xresolution"]);
+ string yResDefault = HandlersUtil.ExtractAttributeValue ("default", child["yresolution"]);
+ string unitsTypeDefault = HandlersUtil.ExtractAttributeValue ("default", child["unitstype"], true);
+
+ Hashtable unitScale = new Hashtable(3);
+
+ XmlNodeList unitScaleNodes = child.SelectNodes("unitscale");
+ foreach (XmlNode unitScaleNode in unitScaleNodes) {
+ unitScale.Add(
+ HandlersUtil.ExtractAttributeValue ("value", unitScaleNode),
+ HandlersUtil.ExtractNodeValue(unitScaleNode) );
+ }
+
+ ResolutionConfiguration resConf = new ResolutionConfiguration(
+ imageFormatName,
+ xResPath, yResPath, unitsType,
+ xResDefault, yResDefault, unitsTypeDefault,
+ unitScale);
+
+ col.Add(resConf);
+ }
+
+ col.Sort();
+ return col;
+ }
+ }
+
+ internal sealed class HandlersUtil {
+ private HandlersUtil () {
+ }
+
+ static internal string ExtractNodeValue(XmlNode node, bool optional, bool allowEmpty) {
+ if (node == null) {
+ if (optional)
+ return null;
+ ThrowException ("Required node not found", node);
+ }
+
+ string nodeValue = node.InnerText;
+
+ if (!allowEmpty && nodeValue == String.Empty) {
+ string opt = optional ? "Optional" : "Required";
+ ThrowException (opt + " node is empty", node);
+ }
+
+ return nodeValue;
+ }
+
+ static internal string ExtractNodeValue(XmlNode node, bool optional) {
+ return ExtractNodeValue(node, false, false);
+ }
+
+ static internal string ExtractNodeValue(XmlNode node) {
+ return ExtractNodeValue(node, false);
+ }
+
+ static internal string ExtractAttributeValue (string attKey, XmlNode node) {
+ return ExtractAttributeValue (attKey, node, false);
+ }
+
+ static internal string ExtractAttributeValue (string attKey, XmlNode node, bool optional) {
+ return ExtractAttributeValue (attKey, node, optional, false);
+ }
+
+ static internal string ExtractAttributeValue (string attKey, XmlNode node, bool optional,
+ bool allowEmpty) {
+ if (node.Attributes == null) {
+ if (optional)
+ return null;
+
+ ThrowException ("Required attribute not found: " + attKey, node);
+ }
+
+ XmlNode att = node.Attributes.RemoveNamedItem (attKey);
+ if (att == null) {
+ if (optional)
+ return null;
+ ThrowException ("Required attribute not found: " + attKey, node);
+ }
+
+ string value = att.Value;
+ if (!allowEmpty && value == String.Empty) {
+ string opt = optional ? "Optional" : "Required";
+ ThrowException (opt + " attribute is empty: " + attKey, node);
+ }
+
+ return value;
+ }
+
+ static internal void ThrowException (string msg, XmlNode node) {
+ if (node != null && node.Name != String.Empty)
+ msg = msg + " (node name: " + node.Name + ") ";
+ throw new ConfigurationException (msg, node);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Makefile b/mcs/class/System.Drawing/Makefile
new file mode 100644
index 00000000000..3f9d13e2ed5
--- /dev/null
+++ b/mcs/class/System.Drawing/Makefile
@@ -0,0 +1,21 @@
+thisdir = class/System.Drawing
+include ../../build/rules.make
+SUBDIRS =
+
+LIBRARY = System.Drawing.dll
+
+LIB_MCS_FLAGS = /unsafe /r:$(corlib) /r:System.dll /nowarn:649 /nowarn:169
+
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -resource:Test/resources/indexed.png,indexed.png \
+ /r:System.Drawing.dll -nowarn:0618 -nowarn:219 -nowarn:169 -nowarn:1595
+
+ifeq (net_1_1_java, $(PROFILE))
+LIB_MCS_FLAGS += \
+ -r:System.Xml.dll \
+ -r:rt.dll \
+ -r:J2SE.Helpers.dll
+endif
+
+include ../../build/library.make
+
+EXTRA_DISTFILES = Test/resources/indexed.png \ No newline at end of file
diff --git a/mcs/class/System.Drawing/README b/mcs/class/System.Drawing/README
new file mode 100644
index 00000000000..8105c140e8b
--- /dev/null
+++ b/mcs/class/System.Drawing/README
@@ -0,0 +1,40 @@
+
+ This README gives some details about Nunit tests and samples for
+ System.Drawing classes.
+
+ Following is the directory structure for the tests and samples:
+
+ Test/ (all the nunit test classes go here)
+ System.Drawing
+ System.Drawing.Drawing2D
+ System.Drawing.Imaging
+ System.Drawing.Printing
+ System.Drawing.Text
+
+ Samples/ (all the samples go here)
+ General (samples that affect more than a single area of SD)
+ System.Drawing
+ System.Drawing.Drawing2D
+ System.Drawing.Imaging
+ System.Drawing.Printing
+ System.Drawing.Text
+
+ Please note the directory structure given above is based on System.Drawing
+ namespaces.
+
+ Advice for writing System.Drawing tests/samples
+ ===============================================
+
+ Tests are Nunit test classes and follow general Nunit test guidelines. When
+ you write a new test class, you need to add it to System.Drawing_test.dll.sources
+ file. Please follow the alphabetical order while adding the name of your test
+ class.
+
+ Samples are independent C# programs with a Main method. Samples are supposed
+ to solve two purposes. First, samples expose the bugs that are not captured
+ by Nunit tests. To achieve this, it is advisable not to repeat the code in a
+ test and a sample for any class until unless required. Second, samples help
+ System.Drawing users in understanding System.Drawing components as well as in
+ writing System.Drawing applications. Writing too trivial samples for well known
+ classes might not be really helpful for the users. It is better to write a sample
+ to solve a particular problem.
diff --git a/mcs/class/System.Drawing/SD.csproj b/mcs/class/System.Drawing/SD.csproj
new file mode 100644
index 00000000000..4f9631adaaf
--- /dev/null
+++ b/mcs/class/System.Drawing/SD.csproj
@@ -0,0 +1,974 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{A6337986-B345-4C49-95F4-40D498C1927B}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "System.Drawing"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "System.Drawing"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "true"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "NET_1_1"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "Consts.cs"
+ Link = "..\..\build\common\Consts.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Locale.cs"
+ Link = "..\..\build\common\Locale.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "MonoTODOAttribute.cs"
+ Link = "..\..\build\common\MonoTODOAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <Folder RelPath = "Assembly\" />
+ <File
+ RelPath = "System.Drawing\Bitmap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Brush.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Brushes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\carbonFunctions.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\CharacterRange.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Color.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\ColorConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\ColorTranslator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\ComIStreamMarshaler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\ComIStreamWrapper.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\ContentAlignment.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Font.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\FontConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\FontFamily.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\FontStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\gdipEnums.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\gdipFunctions.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\gdipStructs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Graphics.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\GraphicsUnit.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Icon.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\IconConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Image.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\ImageAnimator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\ImageConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\ImageFormatConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\KnownColor.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Pen.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Pens.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Point.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\PointConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\PointF.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Rectangle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\RectangleConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\RectangleF.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Region.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\RotateFlipType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\Size.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\SizeConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\SizeF.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\SolidBrush.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\SRDescriptionAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\StringAligment.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\StringDigitSubstitute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\StringFormat.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\StringFormatFlags.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\StringTrimming.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\StringUnit.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\SystemBrushes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\SystemColors.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\SystemIcons.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\SystemPens.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TextureBrush.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\ToolboxBitmapAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\CategoryNameCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\IPropertyValueUIService.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\IToolboxService.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\IToolboxUser.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\PaintValueEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\PropertyValueItem.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\PropertyValueUIHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\PropertyValueUIItemInvokeHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\ToolboxComponentsCreatedEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\ToolboxComponentsCreatedEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\ToolboxComponentsCreatingEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\ToolboxComponentsCreatingEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\ToolboxItem.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\ToolboxItemCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\ToolboxItemCreatorCallback.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\UITypeEditor.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Design\UITypeEditorEditStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\AdjustableArrowCap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\Blend.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\ColorBlend.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\CombineMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\CompostingMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\CompostingQuality.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\CoordinateSpace.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\CustomLineCap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\DashCap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\DashStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\FillMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\FlushIntention.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\GraphicsContainer.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\GraphicsPath.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\GraphicsPathIterator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\GraphicsState.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\HatchBrush.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\HatchStyle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\InterpolationMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\LinearGradientBrush.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\LinearGradientMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\LineCap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\LineJoin.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\Matrix.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\MatrixOrder.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\PathData.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\PathGradientBrush.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\PathPointType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\PenAlignment.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\PenType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\PixelOffsetMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\QualityMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\RegionData.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\SmoothingMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\WarpMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\WrapMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\BitmapData.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ColorAdjustType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ColorChannelFlag.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ColorMap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ColorMapType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ColorMatrix.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ColorMatrixFlag.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ColorMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ColorPalette.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\EmfPlusRecordType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\EmfType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\Encoder.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\EncoderParameter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\EncoderParameters.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\EncoderParameterValueType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\EncoderValue.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\FrameDimension.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ImageAttributes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ImageCodecFlags.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ImageCodecInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ImageFlags.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ImageFormat.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\ImageLockMode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\Metafile.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\MetafileFrameUnit.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\MetafileHeader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\MetafileType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\MetaHeader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\PaletteFlags.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\PixelFormat.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\PlayRecordCallback.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\PropertyItem.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\WmfPlaceableFileHeader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\Duplex.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\InvalidPrinterException.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\Margins.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\MarginsConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PageSettings.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PaperKind.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PaperSize.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PaperSource.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PaperSourceKind.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PreviewPageInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PreviewPrintController.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrintController.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrintDocument.cs"
+ SubType = "Component"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrinterResolution.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrinterResolutionKind.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrinterSettings.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrinterUnit.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrinterUnitConvert.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrintEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrintEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrintingPermission.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrintingPermissionAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrintingPermissionLevel.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrintPageEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrintPageEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\PrintRange.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\QueryPageSettingsEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\QueryPageSettingsEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Printing\StandardPrintController.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Text\FontCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Text\GenericFontFamilies.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Text\HotkeyPrefix.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Text\InstalledFontCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Text\PrivateFontCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Text\TextRenderingHint.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/System.Drawing/Samples/ChangeLog b/mcs/class/System.Drawing/Samples/ChangeLog
new file mode 100644
index 00000000000..9bd8f76a772
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/ChangeLog
@@ -0,0 +1,22 @@
+2004-07-16 Ravindra <rkumar@novell.com>
+
+ * run-samples.sh: Some minor changes, mostly cosmetic.
+
+2004-06-11 Ravindra <rkumar@novell.com>
+
+ * run-samples.sh: Added a script to run the samples.
+ Thanks to Harinath and Sachin for the help.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * General: Created repository for samples that cover more than one
+ namespace.
+ * System.Drawing.Drawing2D: Created repository for samples of this
+ namespace.
+ * System.Drawing.Imaging: Created repository for samples of this
+ namespace.
+ * System.Drawing.Printing: Created repository for samples of this
+ namespace.
+ * System.Drawing.Text: Created repository for samples of this
+ namespace.
+ * System.Drawing: Created repository for samples of this namespace.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Samples/General/ChangeLog b/mcs/class/System.Drawing/Samples/General/ChangeLog
new file mode 100644
index 00000000000..a7e0c7d0609
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/General/ChangeLog
@@ -0,0 +1,10 @@
+2004-06-17 Ravindra <rkumar@novell.com>
+
+ * hering.cs: Formatted and moved here from Test/System.Drawing
+ directory.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+
+ * Created this repository for samples of SD that cover
+ more than one namespace.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Samples/General/hering.cs b/mcs/class/System.Drawing/Samples/General/hering.cs
new file mode 100644
index 00000000000..113ec5ae659
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/General/hering.cs
@@ -0,0 +1,80 @@
+//
+// hering.cs
+// Creates image for Hering illusion.
+// Converted to C# from Xr demo application.
+//
+// Author:
+// Alexandre Pigolkine(pigolkine@gmx.de)
+//
+//
+// Copyright (C) Ximian, Inc. http://www.ximian.com
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Drawing.Drawing2D;
+
+namespace MonoSamples.System.Drawing
+{
+ public class Hering
+ {
+ public static void Main (String[] args) {
+
+ float width = 400.0F;
+ float height = 800.0F;
+ Bitmap bmp = new Bitmap ((int) width, (int) height);
+ Graphics gr = Graphics.FromImage (bmp);
+ gr.Clear (Color.White);
+
+ int LINES = 32;
+ float MAX_THETA = (.80F * 90.0F);
+ float THETA = (2 * MAX_THETA / (LINES-1));
+
+ GraphicsState oldState = gr.Save ();
+
+ Pen blackPen = new Pen (Color.Black, 2.0F);
+ gr.TranslateTransform (width / 2.0F, height / 2.0F);
+ gr.RotateTransform (MAX_THETA);
+ for ( int i = 0; i < LINES; i++) {
+ gr.DrawLine (blackPen, -2.0F * width, 0.0F, 2.0F * width, 0.0F);
+ gr.RotateTransform (-THETA);
+ }
+
+ gr.Restore (oldState);
+
+ Pen redPen = new Pen (Color.Red, 6F);
+ gr.DrawLine (redPen, width / 4F, 0F, width / 4F, height);
+ gr.DrawLine (redPen, 3F * width / 4F, 0F, 3F * width / 4F, height);
+
+ /* save image in all the formats */
+ bmp.Save ("hering.png", ImageFormat.Png);
+ Console.WriteLine ("output file hering.png");
+ bmp.Save ("hering.jpg", ImageFormat.Jpeg);
+ Console.WriteLine ("output file hering.jpg");
+ bmp.Save ("hering.bmp", ImageFormat.Bmp);
+ Console.WriteLine ("output file hering.bmp");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Drawing2D/ChangeLog b/mcs/class/System.Drawing/Samples/System.Drawing.Drawing2D/ChangeLog
new file mode 100644
index 00000000000..d1d62e2f9f2
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Drawing2D/ChangeLog
@@ -0,0 +1,4 @@
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Created this repository for samples for
+ System.Drawing.Drawing2D namespace.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ChangeLog b/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ChangeLog
new file mode 100644
index 00000000000..ce4170136cc
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ChangeLog
@@ -0,0 +1,13 @@
+2004-05-25 Jordi Mas i Hernadez <jordi@ximian.com>
+ * ImageAttributes.cs Added WrapMode examples
+
+2004-05-22 Jordi Mas i Hernadez <jordi@ximian.com>
+ * ImageAttributes.cs Added
+
+2004-04-28 Jordi Mas i Hernadez <jordi@ximian.com>
+ * ImageCodecs.cs Added
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Created this repository for samples for
+ System.Drawing.Imaging namespace.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ColorMatrix.cs b/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ColorMatrix.cs
new file mode 100644
index 00000000000..445393bcb9d
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ColorMatrix.cs
@@ -0,0 +1,259 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2005 Novell, Inc.
+//
+// Author:
+//
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+// Tests color matrix processing
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+//
+public class SampleColorMatrix{
+
+ public static Color ProcessColorMatrix (Color color, ColorMatrix colorMatrix)
+ {
+ Bitmap bmp = new Bitmap (64, 64);
+ Graphics gr = Graphics.FromImage (bmp);
+ ImageAttributes imageAttr = new ImageAttributes ();
+
+ bmp.SetPixel (0,0, color);
+
+ imageAttr.SetColorMatrix (colorMatrix);
+ gr.DrawImage (bmp, new Rectangle (0, 0, 64,64), 0,0, 64,64, GraphicsUnit.Pixel, imageAttr);
+
+ Console.WriteLine ("{0} - > {1}", color, bmp.GetPixel (0,0));
+ return bmp.GetPixel (0,0);
+
+ }
+
+ public static void ProcessImageColorMatrix (string sin, string sout, ColorMatrix colorMatrix)
+ {
+ Bitmap bmp_in = new Bitmap (sin);
+ Bitmap bmp_out = new Bitmap (bmp_in.Width, bmp_in.Height, bmp_in.PixelFormat);
+
+ Graphics gr = Graphics.FromImage (bmp_out);
+ ImageAttributes imageAttr = new ImageAttributes ();
+
+ imageAttr.SetColorMatrix (colorMatrix);
+
+ gr.DrawImage (bmp_in, new Rectangle (0, 0, bmp_out.Width, bmp_out.Height),
+ 0,0, bmp_out.Width, bmp_out.Height, GraphicsUnit.Pixel, imageAttr);
+
+ imageAttr.Dispose ();
+ bmp_out.Save (sout);
+ bmp_in.Dispose ();
+ bmp_out.Dispose ();
+ Console.WriteLine ("Saving image file {0}", sout);
+ }
+
+ public static void Main(string[] args)
+ {
+ Color clr_src, clr_rslt;
+
+ Console.WriteLine ("Red");
+ /* Red */
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0},
+ new float[] {0, 1, 0, 0, 0},
+ new float[] {0, 0, 1, 0, 0},
+ new float[] {0, 0, 0, 1, 0},
+ new float[] {0, 0, 0, 0, 0},
+ });
+
+ clr_src = Color.FromArgb (255, 100, 20, 50);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {2, 0, 0, 0, 0}, //R
+ new float[] {0, 1, 0, 0, 0}, //G
+ new float[] {0, 0, 1, 0, 0}, //B
+ new float[] {0, 0, 0, 1, 0}, //A
+ new float[] {0.2f, 0, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 20, 50);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {0.5f, 0, 0, 0, 0}, //R
+ new float[] {0.5f, 1, 0, 0, 0}, //G
+ new float[] {0, 0, 1, 0, 0}, //B
+ new float[] {0, 0, 0, 1, 0}, //A
+ new float[] {0.2f, 0, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 20, 50);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ /* Green */
+ Console.WriteLine ("Green");
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0}, //R
+ new float[] {0, 2, 0, 0, 0}, //G
+ new float[] {0, 0, 1, 0, 0}, //B
+ new float[] {0, 0.5f, 0, 1, 0}, //A
+ new float[] {0, 0.1f, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 20, 50);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0}, //R
+ new float[] {0, 1, 0, 0, 0}, //G
+ new float[] {0, 0, 1, 0, 0}, //B
+ new float[] {0, 2, 0, 1, 0}, //A
+ new float[] {0, 0.5f, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 20, 50);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0}, //R
+ new float[] {0, 0, 0, 0, 0}, //G
+ new float[] {0, 0, 1, 0, 0}, //B
+ new float[] {0, 0.5f, 0, 1, 0}, //A
+ new float[] {0, 0f, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 20, 50);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ /* Blue */
+ Console.WriteLine ("Blue");
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0}, //R
+ new float[] {0, 1, 0, 0, 0}, //G
+ new float[] {0, 0, 1.5f, 0, 0}, //B
+ new float[] {0, 0, 0.5f, 1, 0}, //A
+ new float[] {0, 0, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 40, 25);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0}, //R
+ new float[] {0, 1, 1, 0, 0}, //G
+ new float[] {0, 0, 0, 0, 0}, //B
+ new float[] {0, 0, 0, 1, 0}, //A
+ new float[] {0, 0, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 100, 25);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0}, //R
+ new float[] {0, 0, 0, 0, 0}, //G
+ new float[] {0, 0, 1, 0, 0}, //B
+ new float[] {0, 0.5f, 0, 1, 0}, //A
+ new float[] {0, 0f, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 20, 50);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ /* Blue */
+ Console.WriteLine ("All");
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0}, //R
+ new float[] {0.5f, 1, 0, 0, 0}, //G
+ new float[] {0, 0.1f, 1.5f, 0, 0}, //B
+ new float[] {0.5f, 3, 0.5f, 1, 0}, //A
+ new float[] {0, 0, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 10, 20, 25);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ {
+ ColorMatrix colorMatrix = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0.5f, 0}, //R
+ new float[] {0, 1, 1, 0, 0}, //G
+ new float[] {0, 0, 0.8f, 0, 0}, //B
+ new float[] {0, 2, 0, 1, 0}, //A
+ new float[] {0, 0, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 100, 25);
+ clr_rslt = ProcessColorMatrix (clr_src, colorMatrix);
+ }
+
+ Console.WriteLine ("Images ---");
+
+ // Load an image and convert it to gray scale
+ ColorMatrix grayscale = new ColorMatrix();
+ grayscale.Matrix00 = 1/3f;
+ grayscale.Matrix01 = 1/3f;
+ grayscale.Matrix02 = 1/3f;
+ grayscale.Matrix10 = 1/3f;
+ grayscale.Matrix11 = 1/3f;
+ grayscale.Matrix12 = 1/3f;
+ grayscale.Matrix20 = 1/3f;
+ grayscale.Matrix21 = 1/3f;
+ grayscale.Matrix22 = 1/3f;
+ ProcessImageColorMatrix ("../System.Drawing/bitmaps/horse.bmp", "greyscale.bmp", grayscale);
+
+ // Load an image and convert it to sepia
+
+ ColorMatrix sepia = new ColorMatrix (new float[][] {
+ new float[] {0.393f, 0.349f, 0.272f, 0, 0},
+ new float[] {0.769f, 0.686f, 0.534f, 0, 0},
+ new float[] {0.189f, 0.168f, 0.131f, 0, 0},
+ new float[] { 0, 0, 0, 1, 0},
+ new float[] { 0, 0, 0, 0, 1}
+ });
+
+ ProcessImageColorMatrix ("../System.Drawing/bitmaps/horse.bmp", "sepia.bmp", sepia);
+
+ }
+
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ImageAttributes.cs b/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ImageAttributes.cs
new file mode 100644
index 00000000000..4d7d131a4a2
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ImageAttributes.cs
@@ -0,0 +1,124 @@
+//
+// Sample application for ImageAttributes
+//
+// Author:
+// Jordi Mas i Hernàndez, jordi@ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+//
+public class SampleDrawingImage
+{
+
+ /* DrawImageAbort callback method */
+ static private bool DrawImageCallback(IntPtr callBackData)
+ {
+ Console.WriteLine("DrawImageCallback");
+ return false;
+ }
+
+ public static void Main(string[] args)
+ {
+ Graphics.DrawImageAbort imageCallback;
+ Bitmap outbmp = new Bitmap (600, 600);
+ Bitmap bmp = new Bitmap("../../Test/System.Drawing/bitmaps/almogaver32bits.bmp");
+ Graphics dc = Graphics.FromImage (outbmp);
+ SolidBrush br = new SolidBrush(Color.White);
+ Bitmap img = bmp.Clone (new Rectangle (0,0, 60,60) , PixelFormat.Format32bppArgb);
+
+ ImageAttributes imageAttr = new ImageAttributes();
+
+ Bitmap bmpred = new Bitmap (100,100, PixelFormat.Format32bppArgb);
+ Graphics gr = Graphics.FromImage (bmpred);
+
+ /* Sample drawing*/
+ Pen cyan = new Pen(Color.Cyan, 0);
+ Pen green = new Pen(Color.Green, 0);
+ Pen pink = new Pen(Color.Pink, 0);
+ Pen blue = new Pen(Color.Blue, 0);
+ gr.DrawLine(cyan, 10.0F, 10.0F, 90.0F, 90.0F);
+ gr.DrawLine(pink, 10.0F, 30.0F, 90.0F, 30.0F);
+ gr.DrawLine(green, 10.0F, 50.0F, 90.0F, 50.0F);
+ gr.DrawRectangle (blue, 10.0F, 10.0F, 80.0F, 80.0F);
+
+ /* Draw image without any imageattributes*/
+ dc.DrawImage (bmpred, 0,0);
+ dc.DrawString ("Sample drawing", new Font ("Arial", 8), br, 10, 100);
+
+ /* Remmaping colours */
+ ColorMap[] clr = new ColorMap[1];
+ clr[0] = new ColorMap();
+ clr[0].OldColor = Color.Blue;
+ clr[0].NewColor = Color.Yellow;
+
+ imageAttr.SetRemapTable (clr, ColorAdjustType.Bitmap);
+ dc.DrawImage (bmpred, new Rectangle (100, 0, 100,100), 0,0, 100,100, GraphicsUnit.Pixel, imageAttr);
+ dc.DrawString ("Remapping colors", new Font ("Arial", 8), br, 110, 100);
+
+ /* Gamma correction on*/
+ imageAttr = new ImageAttributes();
+ imageAttr.SetGamma (2);
+ dc.DrawImage (bmpred, new Rectangle (200, 0, 100,100), 0,0,
+ 100,100, GraphicsUnit.Pixel, imageAttr);
+
+ dc.DrawString ("Gamma corrected", new Font ("Arial", 8), br, 210, 100);
+
+ /* WrapMode: TitleX */
+ imageAttr = new ImageAttributes();
+ imageAttr.SetWrapMode (WrapMode.TileFlipX);
+
+ dc.DrawImage (bmpred, new Rectangle (0, 120, 200, 200), 0,0,
+ 200, 200, GraphicsUnit.Pixel, imageAttr);
+
+ dc.DrawString ("WrapMode.TileFlipX", new Font ("Arial", 8), br, 10, 320);
+
+ /* WrapMode: TitleY */
+ imageAttr.SetWrapMode (WrapMode.TileFlipY);
+
+ dc.DrawImage (bmpred, new Rectangle (200, 120, 200, 200), 0,0,
+ 200, 200, GraphicsUnit.Pixel, imageAttr);
+
+ dc.DrawString ("WrapMode.TileFlipY", new Font ("Arial", 8), br, 210, 320);
+
+ /* WrapMode: TitleXY */
+ imageAttr.SetWrapMode (WrapMode.TileFlipXY);
+
+ dc.DrawImage (bmpred, new Rectangle (400, 120, 200, 200), 0,0,
+ 200, 200, GraphicsUnit.Pixel, imageAttr);
+
+ dc.DrawString ("WrapMode.TileFlipXY", new Font ("Arial", 8), br, 410, 320);
+
+ outbmp.Save("imageattributes.bmp", ImageFormat.Bmp);
+
+ }
+
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ImageCodecs.cs b/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ImageCodecs.cs
new file mode 100644
index 00000000000..e684cde85e1
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Imaging/ImageCodecs.cs
@@ -0,0 +1,74 @@
+//
+// Sample application for encoder/decoder
+//
+// Author:
+// Jordi Mas i Hernàndez, jordi@ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+//
+public class SampleImageCodecs
+{
+ public static void DumpCodeInfo (ImageCodecInfo codec)
+ {
+ Console.WriteLine ("Clsid:" + codec.Clsid);
+ Console.WriteLine ("FormatID:" + codec.FormatID);
+ Console.WriteLine ("Codec:" + codec.CodecName);
+ Console.WriteLine ("DllName:" + codec.DllName);
+ Console.WriteLine ("Extension:" + codec.FilenameExtension);
+ Console.WriteLine ("Format:" + codec.FormatDescription);
+ Console.WriteLine ("MimeType:" + codec.MimeType);
+ Console.WriteLine ("Flags:" + codec.Flags);
+ Console.WriteLine ("Version:" + codec.Version);
+ }
+
+ public static void Main(string[] args)
+ {
+ ImageCodecInfo[] decoders = ImageCodecInfo.GetImageDecoders();
+ ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders();
+
+ Console.WriteLine ("Encoders ********");
+
+ for (int i = 0; i < encoders.Length; i++) {
+ DumpCodeInfo (encoders[i]);
+ Console.WriteLine ("---");
+ }
+
+ Console.WriteLine ("Decoders ********");
+
+ for (int i = 0; i < decoders.Length; i++) {
+ DumpCodeInfo (decoders[i]);
+ Console.WriteLine ("---");
+ }
+ }
+
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Printing/ChangeLog b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/ChangeLog
new file mode 100644
index 00000000000..67ff343765f
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/ChangeLog
@@ -0,0 +1,13 @@
+2006-01-15 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * Adds PrintingMargins.cs
+
+2005-12-22 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * EnumPrinters.cs: Printer enumerator
+ * PrintingTextFile.cs: Prints a text file
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Created this repository for samples for
+ System.Drawing.Printing namespace.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Printing/EnumPrinters.cs b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/EnumPrinters.cs
new file mode 100644
index 00000000000..a674ab5e2d8
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/EnumPrinters.cs
@@ -0,0 +1,42 @@
+//
+// Enumerates printers installed in the system
+//
+
+using System;
+using System.Drawing.Printing;
+
+public class EnumPrinters
+{
+ public static void Main (string[] args)
+ {
+ PrinterSettings.StringCollection col = System.Drawing.Printing.PrinterSettings.InstalledPrinters;
+
+ for (int i = 0; i < col.Count; i++) {
+
+ Console.WriteLine ("--- {0}", col[i]);
+ PrinterSettings ps = new PrinterSettings ();
+ ps.PrinterName = col[i];
+ //Console.WriteLine (" Duplex: {0}", ps.Duplex);
+ Console.WriteLine (" FromPage: {0}", ps.FromPage);
+ Console.WriteLine (" ToPage: {0}", ps.ToPage);
+ Console.WriteLine (" MaximumCopies: {0}", ps.MaximumCopies);
+ Console.WriteLine (" IsDefaultPrinter: {0}", ps.IsDefaultPrinter);
+ Console.WriteLine (" SupportsColor: {0}", ps.SupportsColor);
+ Console.WriteLine (" MaximumPage {0}", ps.MaximumPage);
+ Console.WriteLine (" MinimumPage {0}", ps.MinimumPage);
+ Console.WriteLine (" LandscapeAngle {0}", ps.LandscapeAngle);
+ /*
+ for (int p = 0; p < ps.PrinterResolutions.Count; p++) {
+ Console.WriteLine (" PrinterResolutions {0}", ps.PrinterResolutions [p]);
+ }*/
+
+ for (int p = 0; p < ps.PaperSizes.Count; p++) {
+ Console.WriteLine (" PaperSize Name [{0}] Kind [{1}] Width {2} Height {3}",
+ ps.PaperSizes [p].PaperName, ps.PaperSizes [p].Kind,
+ ps.PaperSizes [p].Width, ps.PaperSizes [p].Height);
+ }
+ }
+ }
+
+}
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintMe.txt b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintMe.txt
new file mode 100644
index 00000000000..1fc6640a846
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintMe.txt
@@ -0,0 +1,196 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintingMargins.cs b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintingMargins.cs
new file mode 100644
index 00000000000..7050ddfd903
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintingMargins.cs
@@ -0,0 +1,62 @@
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//
+// Author:
+// Jordi Mas <jordimash@gmail.com>
+////
+// Draws a simple margin to be able to check if they are correct in different
+// paper sizes.
+//
+
+
+using System;
+using System.Drawing;
+using System.IO;
+using System.Drawing.Printing;
+using System.Drawing.Imaging;
+
+public class PrintingMargins
+{
+
+ static private void QueryPageSettings (object sender, QueryPageSettingsEventArgs e)
+ {
+
+ }
+
+ static private void PrintPageEvent (object sender, PrintPageEventArgs e)
+ {
+ e.Graphics.DrawRectangle (Pens.Red, e.MarginBounds);
+ e.Graphics.DrawRectangle (Pens.Green, e.PageBounds);
+ e.HasMorePages = false;
+ }
+
+
+ public static void Main (string[] args)
+ {
+ PrintDocument p = new PrintDocument ();
+ p.PrintPage += new PrintPageEventHandler (PrintPageEvent);
+ p.QueryPageSettings += new QueryPageSettingsEventHandler (QueryPageSettings);
+ p.Print ();
+
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintingTextFile.cs b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintingTextFile.cs
new file mode 100644
index 00000000000..bc1942a9f97
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintingTextFile.cs
@@ -0,0 +1,54 @@
+//
+// Simple text file printing sample
+//
+
+using System;
+using System.Drawing;
+using System.IO;
+using System.Drawing.Printing;
+
+public class PrintingTextFile
+{
+ private static StreamReader stream;
+
+ static private void PrintPageEvent (object sender, PrintPageEventArgs e)
+ {
+ float lines_page, y;
+ int count = 0;
+ float left = e.MarginBounds.Left;
+ float top = e.MarginBounds.Top;
+ String line = null;
+ Font font = new Font ("Arial", 10);
+ float font_height = font.GetHeight (e.Graphics);
+ lines_page = e.MarginBounds.Height / font_height;
+
+ while (count < lines_page) {
+ line = stream.ReadLine ();
+
+ if (line == null)
+ break;
+
+ y = top + (count * font_height);
+ e.Graphics.DrawString (line, font, Brushes.Black, left, y, new StringFormat());
+
+ count++;
+ }
+
+ if (line != null)
+ e.HasMorePages = true;
+ else
+ e.HasMorePages = false;
+ }
+
+
+ public static void Main (string[] args)
+ {
+ stream = new StreamReader ("PrintMe.txt");
+ PrintDocument p = new PrintDocument ();
+ p.PrintPage += new PrintPageEventHandler (PrintPageEvent);
+ p.Print ();
+ stream.Close();
+ }
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Text/ChangeLog b/mcs/class/System.Drawing/Samples/System.Drawing.Text/ChangeLog
new file mode 100644
index 00000000000..927ceb18fc4
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing.Text/ChangeLog
@@ -0,0 +1,4 @@
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Created this repository for samples for System.Drawing.Text
+ namespace.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/BmpPaint.cs b/mcs/class/System.Drawing/Samples/System.Drawing/BmpPaint.cs
new file mode 100644
index 00000000000..01b204173ca
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/BmpPaint.cs
@@ -0,0 +1,91 @@
+//
+// BmpPaint.cs sample application
+//
+// Author:
+// Alexandre Pigolkine(pigolkine@gmx.de)
+//
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+
+namespace MonoSamples.System.Drawing
+{
+ public class BmpPaint
+ {
+ static public void CreateBitmap (string filename, ImageFormat imgFmt) {
+ Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format24bppRgb);
+ Console.WriteLine ("Bitmap created OK {0}", bmp != null);
+ if ( bmp != null) {
+ Console.WriteLine ("Bitmap Pixelformat {0}", bmp.PixelFormat);
+ }
+
+ Graphics gr = Graphics.FromImage (bmp);
+ Console.WriteLine ("Graphics created OK {0}", gr != null);
+ if (gr != null) {
+ Pen p = new Pen (Color.Red, 2);
+ gr.DrawLine (p, 10.0F, 10.0F, 90.0F, 90.0F);
+ gr.DrawRectangle (p, 10.0F, 10.0F, 80.0F, 80.0F);
+ p.Dispose ();
+ }
+ bmp.Save (filename, imgFmt);
+ gr.Dispose ();
+ bmp.Dispose ();
+ Console.WriteLine ("Bitmap stored to " + filename);
+ }
+
+ static public void PaintOnBitmap (string filename, string newname, ImageFormat imgFmt) {
+ Bitmap bmp = new Bitmap (filename);
+ Console.WriteLine ("Bitmap read OK {0}", bmp != null);
+ if (bmp != null) {
+ Console.WriteLine ("Bitmap Pixelformat {0}", bmp.PixelFormat);
+ }
+ Graphics gr = Graphics.FromImage (bmp);
+ Console.WriteLine ("Graphics created OK {0}", gr != null);
+ if (gr != null) {
+ Pen p = new Pen (Color.Blue, 2);
+ gr.DrawLine (p, 20.0F, 20.0F, 80.0F, 80.0F);
+ gr.DrawRectangle (p, 20.0F, 20.0F, 60.0F, 60.0F);
+ p.Dispose ();
+ }
+ bmp.Save (newname, imgFmt);
+ gr.Dispose ();
+ bmp.Dispose ();
+ Console.WriteLine ("Modified Bitmap stored to " + newname);
+ }
+
+ static public void Main (string[] args) {
+ CreateBitmap ("BmpPaint.bmp", ImageFormat.Bmp);
+ PaintOnBitmap ("BmpPaint.bmp", "Bmp-Painted.bmp", ImageFormat.Bmp);
+ CreateBitmap ("BmpPaint.jpg", ImageFormat.Jpeg);
+ PaintOnBitmap ("BmpPaint.jpg", "Bmp-Painted.jpg", ImageFormat.Jpeg);
+ CreateBitmap ("BmpPaint.png", ImageFormat.Png);
+ PaintOnBitmap ("BmpPaint.png", "Bmp-Painted.png", ImageFormat.Png);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/ChangeLog b/mcs/class/System.Drawing/Samples/System.Drawing/ChangeLog
new file mode 100644
index 00000000000..67434ec298a
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/ChangeLog
@@ -0,0 +1,69 @@
+2006-01-15 Jordi Mas <jordimash@gmail.com>
+
+ * Adds GraphicsUnits.cs
+
+2005-09-06 Jordi Mas <jordi@ximian.com>
+
+ * clipping: Sample to test clipping
+
+2004-06-17 Ravindra <rkumar@novell.com>
+
+ * BmpPaint.cs: Fixed, formatted and moved here from
+ Test/System.Drawing directory.
+ * font.cs: Formatted and moved here from Test/System.Drawing
+ directory.
+ * bmpsave.cs: Formatted and moved here from Test/System.Drawing
+ directory.
+ * graphicsUi.cs: Formatted and moved here from
+ Test/System.Drawing directory.
+
+2004-05-31 Ravindra <rkumar@novell.com>
+
+ * pie.cs: Made the output image little organized and added a
+ case where DrawPie and FillPie were crashing the system. It
+ was happening with zero degree sweep angle.
+
+2004-05-04 Ravindra <rkumar@novell.com>
+
+ * ImageRotateFlip.cs: Changed text color from white to
+ black and set the white background.
+
+2004-05-04 Jordi Mas <jordi@ximian.com>
+ * ImageRotateFlip.cs: Added ImageRotateFlip.cs example.
+
+2004-04-24 Ravindra <rkumar@novell.com>
+
+ * pie.cs: Added a case to clear the graphics surface
+ and fill it with a background color. Fixing
+ Graphics.Clear(color) method.
+
+2004-04-07 Ravindra <rkumar@novell.com>
+ * TextureWrapModes.cs: Use PNG, instead of BMP.
+
+2004-04-07 Duncan Mak <duncan@ximian.com>
+
+ * pie.cs: Added a case where the sweep angle is greater than 360
+ degrees.
+
+2004-04-06 Duncan Mak <duncan@ximian.com>
+
+ * pie.cs: Save to PNG, instead of BMP.
+
+2004-03-26 Ravindra <rkumar@novell.com>
+ * TextureWrapModes.cs: Changed the file format dos2unix and
+ adjusted the generated image size.
+
+2004-03-25 Ravindra <rkumar@novell.com>
+ * bitmaps: Added a repository for the bitmaps required by some of
+ the samples of this repository.
+ * TextureWrapModes.cs: Added a sample for texture brush wrapmodes.
+
+2004-03-24 Jordi <jordi@ximian.com>
+ * Added drawimage.cs example
+
+2004-03-22 Jordi <jordi@ximian.com>
+ * Added pie.cs example
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Created this repository for samples for System.Drawing namespace.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/CopyFromScreen.cs b/mcs/class/System.Drawing/Samples/System.Drawing/CopyFromScreen.cs
new file mode 100644
index 00000000000..e3386a5e2e1
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/CopyFromScreen.cs
@@ -0,0 +1,23 @@
+//
+// Sample that show the default SystemFonts and its names
+// Requieres .NET 2.0 class library
+//
+
+using System;
+using System.Drawing;
+
+
+public class SystemFontsSample
+{
+ public static void Main ()
+ {
+ Bitmap bmp = new Bitmap (800, 800);
+ Graphics gr = Graphics.FromImage (bmp);
+
+ gr.CopyFromScreen (0, 0/*src*/, 0,0 /*dst*/, new Size (800, 800));
+ bmp.Save ("CopyFromScreen.bmp");
+ }
+
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/FontDrawing.cs b/mcs/class/System.Drawing/Samples/System.Drawing/FontDrawing.cs
new file mode 100644
index 00000000000..811d2615d52
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/FontDrawing.cs
@@ -0,0 +1,148 @@
+//
+//
+// Simple font handeling
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Drawing.Imaging;
+
+namespace Font1Sample {
+ public class FontDrawing {
+
+ public static void listFonts()
+ {
+ FontCollection ifc = new InstalledFontCollection();
+ foreach( FontFamily ffm in ifc.Families) {
+ try
+ {
+ Font f = new Font(ffm.Name,12);
+ Console.WriteLine("Family Name:" + ffm.Name + "," + f.Name);
+ }
+ catch (Exception ex) {}
+ }
+ }
+
+ public static void checkFontProperties()
+ {
+ Font f = new Font("Arial",12);
+ Console.WriteLine("Font:" + f.Name + " size:" + f.Size);
+
+ f = new Font("Verdana", 12);
+ Console.WriteLine("Font:" + f.Name + " size:" + f.Size);
+
+ f = new Font("Courier New", 12);
+ Console.WriteLine("Font:" + f.Name + " size:" + f.Size);
+
+ }
+
+ public static void Main( )
+ {
+ Console.WriteLine("Fonts--------------------");
+ listFonts();
+
+ Console.WriteLine("Propierties--------------------");
+ checkFontProperties();
+
+ Console.WriteLine("Draw--------------------");
+ float width = 800.0F;
+ float height = 650.0F;
+ string str = "";
+
+ Font f1 = new Font("Arial",12);
+ Font f2 = new Font("Verdana", 12, FontStyle.Bold);
+ Font f3 = new Font("Courier New", 12, FontStyle.Italic);
+
+ Font f4 = new Font(FontFamily.GenericSansSerif, 19, FontStyle.Regular, GraphicsUnit.Millimeter);
+ Console.WriteLine("Font:" + f4.Name + " size:" + f4.Size + "Points: " + f4.SizeInPoints);
+
+ Font f5 = new Font(FontFamily.GenericSerif, 15, FontStyle.Regular, GraphicsUnit.Point);
+ Console.WriteLine("Font:" + f5.Name + " size:" + f5.Size + "Points: " + f5.SizeInPoints);
+
+ Font f6 = new Font("Arial", 40, FontStyle.Regular, GraphicsUnit.Pixel);
+ Console.WriteLine("Font:" + f6.Name + " size:" + f6.Size + "Points: " + f6.SizeInPoints);
+
+ Font f7 = new Font("Courier New", 19, FontStyle.Regular, GraphicsUnit.World);
+ Console.WriteLine("Font:" + f7.Name + " size:" + f7.Size + "Points: " + f7.SizeInPoints);
+
+ Font f8 = new Font("Courier New", 19, FontStyle.Bold | FontStyle.Underline, GraphicsUnit.World);
+ Console.WriteLine("Font:" + f8.Name + " size:" + f8.Size + "Points: " + f8.SizeInPoints);
+
+ Font f9 = new Font("Courier New", 19, FontStyle.Bold | FontStyle.Underline| FontStyle.Italic, GraphicsUnit.World);
+ Console.WriteLine("Font:" + f9.Name + " size:" + f9.Size + "Points: " + f9.SizeInPoints);
+
+ Font f10 = new Font(FontFamily.GenericSansSerif, 14, FontStyle.Strikeout, GraphicsUnit.Millimeter);
+ Console.WriteLine("Font:" + f10.Name + " size:" + f10.Size + "Points: " + f10.SizeInPoints);
+
+
+ Bitmap bmp = new Bitmap((int)width, (int)height);
+ Graphics gr = Graphics.FromImage(bmp);
+ SolidBrush br = new SolidBrush(Color.White);
+ SolidBrush colorRed = new SolidBrush(Color.Red);
+
+ gr.FillRectangle(br, 0.0F, 0.0F, width, height);
+
+ br = new SolidBrush(Color.Black);
+
+ str = "This an " + f1.Name + " test string size: "+ f1.Height;
+ gr.DrawString (str, f1, br, 10, 10);
+
+ str = "This a " + f2.Name + " bold test string size: "+ f2.Height;
+ gr.DrawString( str, f2, colorRed, 10, 50);
+
+ str = "This a " + f3.Name + " italic test string size: "+ f3.Height;
+ gr.DrawString( str, f3, br, 10, 100);
+
+ str = "This an " + f4.Name + " test string size: "+ f4.Height;
+ gr.DrawString (str, f4, br, 10, 150);
+
+ str = "This a " + f5.Name + " test string size: "+ f5.Height;
+ gr.DrawString( str, f5, colorRed, 10, 250);
+
+ str = "This a " + f6.Name + " test string size: "+ f6.Height;
+ gr.DrawString( str, f6, br, new Rectangle(10,300,0,0));
+
+ str = "This a " + f7.Name + " test string size: "+ f7.Height;
+ gr.DrawString( str, f7, br, 10,350);
+
+ str = "This a " + f8.Name + " test (Underline/Bold) string size: "+ f8.Height;
+ gr.DrawString( str, f8, br, 10,400);
+
+ str = "This a " + f9.Name + " test (Underline/Bold/Italic) string size: "+ f9.Height;
+ gr.DrawString( str, f9, br, 10,450);
+
+ str = "This a " + f10.Name + " test (Strikeout) string size: "+ f10.Height;
+ gr.DrawString( str, f10, br, 10,500);
+
+
+ bmp.Save("FontDrawing.bmp", ImageFormat.Bmp);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/FontDrawingAdv.cs b/mcs/class/System.Drawing/Samples/System.Drawing/FontDrawingAdv.cs
new file mode 100644
index 00000000000..05e3e7e489b
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/FontDrawingAdv.cs
@@ -0,0 +1,359 @@
+//
+//
+// Advanced text drawing and formatting sample
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Drawing.Imaging;
+
+namespace Font1Sample {
+ public class FontDrawing {
+
+ static string flagProcessing(StringFormat format)
+ {
+ string str = "";
+
+ switch (format.Alignment) {
+ case StringAlignment.Far:
+ str = "halign: Far - ";
+ break;
+ case StringAlignment.Near:
+ str = "halign: Near - ";
+ break;
+ case StringAlignment.Center:
+ str = "halign: Center - ";
+ break;
+ default:
+ break;
+ }
+
+ switch (format.LineAlignment) {
+ case StringAlignment.Far:
+ str += "valign: Far - ";
+ break;
+ case StringAlignment.Near:
+ str += "valign: Near - ";
+ break;
+ case StringAlignment.Center:
+ str += "valign: Center - ";
+ break;
+ default:
+ break;
+ }
+
+ switch (format.Trimming) {
+ case StringTrimming.Character:
+ str += "trimm: Char - ";
+ break;
+ case StringTrimming.EllipsisCharacter:
+ str += "trimm: EllipsisChar - ";
+ break;
+ case StringTrimming.EllipsisPath:
+ str += "trimm: EllipsisPath - ";
+ break;
+ case StringTrimming.EllipsisWord:
+ str += "trimm: EllipsisWord - ";
+ break;
+ case StringTrimming.None:
+ str += "trimm: None - ";
+ break;
+ case StringTrimming.Word:
+ str += "trimm: Word - ";
+ break;
+ default:
+ break;
+ }
+
+ switch (format.FormatFlags) {
+ case StringFormatFlags.NoWrap:
+ str+="fmt: NoWrap";
+ break;
+ case StringFormatFlags.DirectionVertical:
+ str+="fmt: DirVer ";
+ break;
+ case StringFormatFlags.DirectionRightToLeft:
+ str+="fmt: rtl ";
+ break;
+
+ default:
+ break;
+ }
+
+ return str;
+ }
+
+ static Rectangle calcRect(Rectangle rect)
+ {
+ return new Rectangle (rect.X, rect.Y+rect.Height+10, rect.Width,200);
+ }
+
+ public static void Main( )
+ {
+ float width = 750.0F;
+ float height = 1000.0F;
+ string str;
+ int chars = 0;
+ int lines = 0;
+ SizeF sz;
+
+ Font f1 = new Font("Arial",12);
+ Font f2 = new Font("Verdana", 8);
+ Font f3 = new Font("Courier New", 14);
+ Font f4 = new Font(FontFamily.GenericSansSerif, 14);
+ Font f5 = new Font(FontFamily.GenericMonospace, 14);
+ Font f6 = new Font(FontFamily.GenericSerif, 16);
+ Font fonttxt= new Font("Verdana", 8);
+ SolidBrush brushtxt = new SolidBrush(Color.Pink);
+
+ StringFormat strfmt1 = new StringFormat();
+ StringFormat strfmt2 = new StringFormat();
+ StringFormat strfmt3 = new StringFormat();
+ StringFormat strfmt4 = new StringFormat();
+ StringFormat strfmt5 = new StringFormat();
+ StringFormat strfmt6 = new StringFormat();
+ StringFormat strfmttxt = new StringFormat();
+
+ Bitmap bmp = new Bitmap((int)width, (int)height);
+ Graphics gr = Graphics.FromImage(bmp);
+ SolidBrush br = new SolidBrush(Color.White);
+ SolidBrush colorRed = new SolidBrush(Color.Red);
+
+ strfmttxt.Alignment = StringAlignment.Near;
+ strfmttxt.LineAlignment = StringAlignment.Near;
+ strfmttxt.Trimming = StringTrimming.Character;
+
+ strfmt1.Alignment = StringAlignment.Center;
+ strfmt1.LineAlignment = StringAlignment.Near;
+ strfmt1.Trimming = StringTrimming.Character;
+ strfmt1.HotkeyPrefix = HotkeyPrefix.Show;
+
+ strfmt2.Alignment = StringAlignment.Far;
+ strfmt2.LineAlignment = StringAlignment.Center;
+ strfmt2.Trimming = StringTrimming.Character;
+
+ strfmt3.Alignment = StringAlignment.Far;
+ strfmt3.LineAlignment = StringAlignment.Near;
+ strfmt3.Trimming = StringTrimming.None;
+
+ strfmt4.Alignment = StringAlignment.Far;
+ strfmt4.LineAlignment = StringAlignment.Far;
+ strfmt4.Trimming = StringTrimming.EllipsisCharacter;
+
+ strfmt5.Alignment = StringAlignment.Far;
+ strfmt5.LineAlignment = StringAlignment.Near;
+ strfmt5.Trimming = StringTrimming.None;
+ strfmt5.FormatFlags = StringFormatFlags.DirectionVertical;
+
+ strfmt6.Alignment = StringAlignment.Far;
+ strfmt6.LineAlignment = StringAlignment.Far;
+ strfmt6.Trimming = StringTrimming.EllipsisCharacter;
+ strfmt6.FormatFlags = StringFormatFlags.NoWrap;
+
+ Rectangle rect1 = new Rectangle (10,50,100,150);
+ Rectangle rect2 = new Rectangle (10,300,150,150);
+
+ Rectangle rect3 = new Rectangle (200,50,175,175);
+ Rectangle rect4 = new Rectangle (200,300,150,150);
+
+ Rectangle rect5 = new Rectangle (400,50,175,175);
+ Rectangle rect6 = new Rectangle (400,300,150,150);
+ Rectangle rect7 = new Rectangle (550,300, 140,120);
+
+ gr.DrawRectangle( new Pen(Color.Yellow), rect3);
+ gr.DrawRectangle( new Pen(Color.Blue), rect4);
+
+ gr.DrawRectangle( new Pen(Color.Yellow), rect5);
+ gr.DrawRectangle( new Pen(Color.Blue), rect6);
+
+ SolidBrush solid = new SolidBrush(Color.Blue);
+
+ gr.DrawString("Samples of text with different fonts and formatting",
+ new Font("Verdana",16), new SolidBrush(Color.White), new Rectangle (5,5,600,100), strfmttxt);
+
+
+ gr.FillEllipse(solid, rect1);
+
+ gr.DrawRectangle( new Pen(Color.Green), rect2);
+ gr.DrawRectangle( new Pen(Color.Green), rect7);
+
+ str = "Ara que tinc &vint anys, ara que encara tinc força,que no tinc l'ànima morta, i em sento bullir la sang. (" + f1.Name + ")";
+ gr.DrawString( str, f1, new SolidBrush(Color.White), rect1, strfmt1);
+ gr.DrawString(flagProcessing(strfmt1), fonttxt, brushtxt, calcRect(rect1), strfmttxt);
+ sz = gr.MeasureString (str, f1, new SizeF (rect1.Width, rect1.Height), strfmt1, out chars, out lines);
+ Console.WriteLine("MeasureString str1 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);
+
+ str = "Ara que em sento capaç de cantar si un altre canta. Avui que encara tinc veu i encara puc creure en déus (" + f2.Name + ")";
+ gr.DrawString(str, f2, new SolidBrush(Color.Red),rect2, strfmt2);
+ gr.DrawString(flagProcessing(strfmt2), fonttxt, brushtxt, calcRect(rect2), strfmttxt);
+ sz = gr.MeasureString (str, f2, new SizeF (rect2.Width, rect2.Height), strfmt2, out chars, out lines);
+ Console.WriteLine("MeasureString str2 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);
+
+ str = "Vull cantar a les pedres, la terra, l'aigua, al blat i al camí, que vaig trepitjant. (" + f3.Name + ")";
+ gr.DrawString(str,f3, new SolidBrush(Color.White), rect3, strfmt3);
+ gr.DrawString(flagProcessing(strfmt3), fonttxt, brushtxt, calcRect(rect3), strfmttxt);
+ sz = gr.MeasureString (str, f3, new SizeF (rect3.Width, rect3.Height), strfmt3, out chars, out lines);
+ Console.WriteLine("MeasureString str3 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);
+
+ str = "A la nit, al cel i a aquet mar tan nostre i al vent que al matí ve a besar-me el rostre (" + f4.Name + ")";
+ gr.DrawString(str, f4, new SolidBrush(Color.Red),rect4, strfmt4);
+ gr.DrawString(flagProcessing(strfmt4), fonttxt, brushtxt, calcRect(rect4), strfmttxt);
+ sz = gr.MeasureString (str, f4, new SizeF (rect4.Width, rect4.Height), strfmt4, out chars, out lines);
+ Console.WriteLine("MeasureString str4 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);
+
+ str = "Vull cantar a les pedres, la terra, l'aigua, al blat i al camí, que vaig trepitjant. (" + f5.Name + ")";
+ gr.DrawString(str, f5, new SolidBrush(Color.White), rect5, strfmt5);
+ gr.DrawString(flagProcessing(strfmt5), fonttxt, brushtxt, calcRect(rect5), strfmttxt);
+ sz = gr.MeasureString (str, f5, new SizeF (rect5.Width, rect5.Height), strfmt5, out chars, out lines);
+ Console.WriteLine("MeasureString str4 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);
+
+ str = "Ve a besar-me el rostre (" + f6.Name + ")";
+ gr.DrawString(str, f6, new SolidBrush(Color.Red),rect6, strfmt6);
+ gr.DrawString(flagProcessing(strfmt6), fonttxt, brushtxt, calcRect(rect6), strfmttxt);
+ sz = gr.MeasureString (str, f6, new SizeF (rect6.Width, rect6.Height), strfmt6, out chars, out lines);
+ Console.WriteLine("MeasureString str6 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);
+
+ str = "Vull plorar amb aquells que es troben tots sols, sense cap amor van passant pel món.. (" + f5.Name + ")";
+ gr.DrawString(str, f5, new SolidBrush(Color.White), rect7, strfmt4);
+ gr.DrawString(flagProcessing(strfmt4), fonttxt, brushtxt, calcRect(rect7), strfmttxt);
+ sz = gr.MeasureString (str, f5, new SizeF (rect7.Width, rect7.Height), strfmt5, out chars, out lines);
+ Console.WriteLine("MeasureString str7 [" + str + "] " + sz + ";chars:" + chars + " lines:" + lines);
+
+ /* 3rd row */
+
+ Font f8 = new Font("Verdana", 10);
+ Font f9 = new Font("Verdana", 6);
+ Font f10 = new Font("Verdana", 12);
+ Font f11 = new Font("Verdana", 14);
+
+ Rectangle rect8 = new Rectangle (10, 550,100,100);
+ Rectangle rect9 = new Rectangle (150,550, 100,100);
+ Rectangle rect10 = new Rectangle (300,550, 100,100);
+ Rectangle rect11 = new Rectangle (420,550, 100,100);
+ Rectangle rect12 = new Rectangle (530,550, 200,100);
+ Rectangle rect13 = new Rectangle (530,600, 200,100);
+ Rectangle rect14 = new Rectangle (530,650, 200,100);
+
+ gr.DrawRectangle( new Pen(Color.Yellow), rect8);
+ gr.DrawRectangle( new Pen(Color.Yellow), rect9);
+ gr.DrawRectangle( new Pen(Color.Yellow), rect10);
+
+ StringFormat strfmt8 = new StringFormat();
+ strfmt8.Alignment = StringAlignment.Center;
+ strfmt8.LineAlignment = StringAlignment.Near;
+ strfmt8.Trimming = StringTrimming.EllipsisCharacter;
+ strfmt8.HotkeyPrefix = HotkeyPrefix.Show;
+
+ StringFormat strfmt9 = new StringFormat();
+ strfmt9.Alignment = StringAlignment.Center;
+ strfmt9.LineAlignment = StringAlignment.Center;
+ strfmt9.Trimming = StringTrimming.EllipsisCharacter;
+ strfmt9.HotkeyPrefix = HotkeyPrefix.None;
+
+ StringFormat strfmt10 = new StringFormat();
+ strfmt10.Alignment = StringAlignment.Center;
+ strfmt10.LineAlignment = StringAlignment.Near;
+ strfmt10.Trimming = StringTrimming.Word;
+ strfmt10.HotkeyPrefix = HotkeyPrefix.Show;
+
+ StringFormat strfmt11 = new StringFormat();
+ strfmt11.Alignment = StringAlignment.Center;
+ strfmt11.LineAlignment = StringAlignment.Near;
+ strfmt11.Trimming = StringTrimming.Word;
+ strfmt11.HotkeyPrefix = HotkeyPrefix.Show;
+ strfmt11.FormatFlags = StringFormatFlags.DirectionRightToLeft;
+
+ StringFormat strfmt12 = new StringFormat();
+ float[] tabs = {10, 20, 30};
+ strfmt12.Alignment = StringAlignment.Center;
+ strfmt12.LineAlignment = StringAlignment.Near;
+ strfmt12.Trimming = StringTrimming.Word;
+ strfmt12.HotkeyPrefix = HotkeyPrefix.Show;
+ strfmt12.SetTabStops(20, tabs);
+
+ StringFormat strfmt13 = new StringFormat();
+ float[] tabs2 = {5, 50, 60};
+ strfmt13.Alignment = StringAlignment.Center;
+ strfmt13.LineAlignment = StringAlignment.Near;
+ strfmt13.Trimming = StringTrimming.Word;
+ strfmt13.HotkeyPrefix = HotkeyPrefix.Show;
+ strfmt13.SetTabStops(0, tabs2);
+
+ StringFormat strfmt14 = new StringFormat();
+ strfmt14.Alignment = StringAlignment.Center;
+ strfmt14.LineAlignment = StringAlignment.Near;
+ strfmt14.Trimming = StringTrimming.Word;
+ strfmt14.HotkeyPrefix = HotkeyPrefix.Show;
+ strfmt14.FormatFlags = StringFormatFlags.DirectionRightToLeft;
+
+ str = "Vull alçar la veu,per cantar als homes que han nascut dempeus (" + f8.Name + ")";
+ gr.DrawString(str, f8, new SolidBrush(Color.White), rect8, strfmt8);
+ gr.DrawString(flagProcessing(strfmt8), fonttxt, brushtxt, calcRect(rect8), strfmttxt);
+ sz = gr.MeasureString (str, f8, new SizeF (rect8.Width, rect8.Height), strfmt8, out chars, out lines);
+ gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect8.X, rect8.Y, (int)sz.Width, (int)sz.Height));
+
+ str = "I no tinc l'ànima morta i em sento bollir la sang (" + f9.Name + ")";
+ gr.DrawString(str, f9, new SolidBrush(Color.White), rect9, strfmt9);
+ gr.DrawString(flagProcessing(strfmt9), fonttxt, brushtxt, calcRect(rect9), strfmttxt);
+ sz = gr.MeasureString (str, f9, new SizeF (rect9.Width, rect9.Height), strfmt9, out chars, out lines);
+ gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect9.X, rect9.Y, (int)sz.Width, (int)sz.Height));
+
+ str = "I no tinc l'ànima morta i em sento bollir la sang (" + f10.Name + ")";
+ gr.DrawString(str, f10, new SolidBrush(Color.White), rect10, strfmt10);
+ gr.DrawString(flagProcessing(strfmt10), fonttxt, brushtxt, calcRect(rect10), strfmttxt);
+ sz = gr.MeasureString (str, f10, new SizeF (rect10.Width, rect10.Height), strfmt10, out chars, out lines);
+ gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect10.X, rect10.Y, (int)sz.Width, (int)sz.Height));
+
+ str = "I no tinc l'ànima morta i em sento bollir la sang (" + f11.Name + ")";
+ gr.DrawString(str, f11, new SolidBrush(Color.White), rect11, strfmt11);
+ gr.DrawString(flagProcessing(strfmt11), fonttxt, brushtxt, calcRect(rect11), strfmttxt);
+ sz = gr.MeasureString (str, f11, new SizeF (rect11.Width, rect11.Height), strfmt11, out chars, out lines);
+ gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect11.X, rect11.Y, (int)sz.Width, (int)sz.Height));
+
+ str = "Tab1\tTab2\tTab3";
+ gr.DrawString(str, f8, new SolidBrush(Color.White), rect12, strfmt12);
+ sz = gr.MeasureString (str, f8, new SizeF (rect12.Width, rect12.Height), strfmt12, out chars, out lines);
+ gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect12.X, rect12.Y, (int)sz.Width, (int)sz.Height));
+
+ str = "Nom\tCognom\tAdreça";
+ gr.DrawString(str, f8, new SolidBrush(Color.White), rect13, strfmt13);
+ sz = gr.MeasureString (str, f8, new SizeF (rect13.Width, rect13.Height), strfmt13, out chars, out lines);
+ gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect13.X, rect13.Y, (int)sz.Width, (int)sz.Height));
+
+ str = "Nom Cognom Adreça";
+ gr.DrawString(str, f8, new SolidBrush(Color.White), rect14, strfmt14);
+ sz = gr.MeasureString (str, f8, new SizeF (rect14.Width, rect13.Height), strfmt14, out chars, out lines);
+ gr.DrawRectangle(new Pen(Color.Red), new Rectangle (rect14.X, rect14.Y, (int)sz.Width, (int)sz.Height));
+
+ bmp.Save("fontDrawingAdv.bmp", ImageFormat.Bmp);
+
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/GraphicsUnits.cs b/mcs/class/System.Drawing/Samples/System.Drawing/GraphicsUnits.cs
new file mode 100644
index 00000000000..3fe5f362e6a
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/GraphicsUnits.cs
@@ -0,0 +1,133 @@
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//
+// Author:
+// Jordi Mas <jordimash@gmail.com>
+//
+// Graphics PageUnit test sample
+//
+
+using System;
+using System.Drawing;
+using System.IO;
+using System.Drawing.Printing;
+using System.Drawing.Imaging;
+using System.Drawing.Drawing2D;
+
+public class PrintingMargins
+{
+
+ public static void Main (string[] args)
+ {
+ Bitmap bmp = new Bitmap (600, 600);
+ Graphics gr = Graphics.FromImage (bmp);
+ Rectangle rect = new Rectangle (20, 20, 100, 100);
+
+ PointF[] polygon_pnts = {new PointF(150.0F, 150.0F),
+ new PointF(200.0F, 125.0F), new PointF(300.0F, 105.0F),
+ new PointF(350.0F, 150.0F), new PointF(400.0F, 200.0F),
+ new PointF(450.0F, 300.0F), new PointF(350.0F, 350.0F) };
+
+
+ // Default Display
+ gr.DrawRectangle (Pens.Red, rect);
+ gr.DrawString ("Unit " + gr.PageUnit, new Font ("Arial", 10), Brushes.Red, 50, 50);
+ gr.DrawArc (Pens.Red, 30, 30, 60, 60, 0, 180);
+ gr.DrawPolygon (Pens.Red, polygon_pnts);
+
+ // Point
+ gr.PageUnit = GraphicsUnit.Point;
+ gr.DrawRectangle (Pens.Yellow, rect);
+ gr.DrawString ("Unit " + gr.PageUnit, new Font ("Arial", 10), Brushes.Yellow, 50, 50);
+ gr.DrawArc (Pens.Yellow, 30, 30, 60, 60, 0, 180);
+ gr.DrawPolygon (Pens.Yellow, polygon_pnts);
+
+ // Document
+ gr.PageUnit = GraphicsUnit.Document;
+ gr.DrawRectangle (Pens.Pink, rect);
+ gr.DrawString ("Unit " + gr.PageUnit, new Font ("Arial", 10), Brushes.Pink, 50, 50);
+ gr.DrawArc (Pens.Pink, 30, 30, 60, 60, 0, 180);
+ gr.DrawPolygon (Pens.Pink, polygon_pnts);
+
+ // Inc
+ gr.PageUnit = GraphicsUnit.Inch;
+ gr.DrawRectangle (Pens.Blue, 3f, 1f, 1f, 1f);
+ gr.DrawString ("Unit " + gr.PageUnit, new Font ("Arial", 10), Brushes.Blue, 0.7f, 0.7f);
+ gr.DrawArc (Pens.Blue, 3f, 3f, 1f, 1f, 0, 180);
+
+
+ bmp.Save ("units1.bmp");
+ bmp.Dispose ();
+ gr.Dispose ();
+
+ bmp = new Bitmap (600, 600);
+ gr = Graphics.FromImage (bmp);
+
+ GraphicsPath graphPath = new GraphicsPath();
+ graphPath.AddEllipse (0, 80, 100, 200);
+
+ // Default Display
+ gr.DrawBezier (Pens.Red, new Point (10, 10), new Point (20, 10),
+ new Point (35, 50), new Point (50, 10));
+
+ gr.DrawEllipse (Pens.Red, 10, 50, 30, 50);
+ gr.DrawPath (Pens.Red, graphPath);
+ gr.DrawPie (Pens.Red, 150, 20, 60, 60, 100, 140);
+ gr.DrawCurve (Pens.Red, polygon_pnts, 2, 4, 0.5f);
+
+
+ // Point
+ gr.PageUnit = GraphicsUnit.Display;
+ gr.PageUnit = GraphicsUnit.Point;
+ gr.DrawBezier (Pens.Pink, new Point (10, 10), new Point (20, 10),
+ new Point (35, 50), new Point (50, 10));
+ gr.DrawCurve (Pens.Pink, polygon_pnts, 2, 4, 0.5f);
+
+ gr.DrawEllipse (Pens.Pink, 10, 50, 30, 50);
+ gr.DrawPath (Pens.Pink, graphPath);
+ gr.DrawPie (Pens.Pink, 150, 20, 60, 60, 100, 140);
+
+ // Document
+ gr.PageUnit = GraphicsUnit.Document;
+ gr.DrawBezier (Pens.Yellow, new Point (10, 10), new Point (20, 10),
+ new Point (35, 50), new Point (50, 10));
+
+ gr.DrawEllipse (Pens.Yellow, 10, 50, 30, 50);
+ gr.DrawPath (Pens.Yellow, graphPath);
+ gr.DrawPie (Pens.Yellow, 150, 20, 60, 60, 100, 140);
+ gr.DrawCurve (Pens.Yellow, polygon_pnts, 2, 4, 0.5f);
+
+ // Inc
+ gr.PageUnit = GraphicsUnit.Inch;
+ gr.DrawBezier (Pens.Blue, new Point (10, 10), new Point (20, 10),
+ new Point (35, 50), new Point (50, 10));
+
+ gr.DrawEllipse (Pens.Blue, 10, 50, 30, 50);
+ gr.DrawPath (Pens.Blue, graphPath);
+ gr.DrawPie (Pens.Blue, 150, 20, 60, 60, 100, 140);
+ gr.DrawCurve (Pens.Blue, polygon_pnts, 2, 4, 0.5f);
+
+ bmp.Save ("units2.bmp");
+ }
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/ImageRotateFlip.cs b/mcs/class/System.Drawing/Samples/System.Drawing/ImageRotateFlip.cs
new file mode 100644
index 00000000000..3a42ef41146
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/ImageRotateFlip.cs
@@ -0,0 +1,91 @@
+//
+// Image rotation / flip
+//
+// Author:
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+// (C) 2004 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+
+public class ImageRotateSample
+{
+ static Pen p = new Pen(Color.Red, 2);
+ static SolidBrush br = new SolidBrush(Color.Black);
+
+ public static void CreateImage (RotateFlipType rotate, int movex, int movey, string text, Bitmap dest, Graphics grdest)
+ {
+ Color clr;
+ Bitmap bmp = new Bitmap (80, 80, PixelFormat.Format32bppArgb);
+ Graphics gr = Graphics.FromImage (bmp);
+ gr.Clear (Color.White);
+
+ gr.DrawLine (p, 10.0F, 10.0F, 70.0F, 70.0F);
+ gr.DrawLine (p, 10.0F, 15.0F, 70.0F, 15.0F);
+ gr.DrawRectangle (p, 10.0F, 10.0F, 60.0F, 60.0F);
+ bmp.RotateFlip (rotate);
+
+ for (int y = 0; y < 80; y++) {
+ for (int x = 0; x < 80; x++) {
+ clr = bmp.GetPixel (x,y);
+ dest.SetPixel (x+movex, y+movey, clr);
+ }
+ }
+
+ grdest.DrawString (text, new Font ("Arial", 8), br, movex+5, movey+85);
+ }
+
+ public static void Main(string[] argv)
+ {
+
+ string filename = "output.bmp";
+ Bitmap bmp = new Bitmap(800,800, PixelFormat.Format32bppArgb);
+ Console.WriteLine("Bitmap created OK {0}", bmp != null);
+
+ Graphics gr = Graphics.FromImage(bmp);
+ gr.Clear (Color.White);
+
+ CreateImage (RotateFlipType.RotateNoneFlipNone, 0, 0, "RotateNoneFlipNone", bmp, gr);
+ CreateImage (RotateFlipType.Rotate90FlipNone, 150, 0, "Rotate90FlipNone", bmp, gr);
+ CreateImage (RotateFlipType.Rotate180FlipNone, 300, 0, "Rotate180FlipNone", bmp, gr);
+ CreateImage (RotateFlipType.Rotate270FlipNone, 450, 0, "Rotate270FlipNone", bmp, gr);
+
+ CreateImage (RotateFlipType.RotateNoneFlipX, 0, 120, "RotateNoneFlipX", bmp, gr);
+ CreateImage (RotateFlipType.Rotate90FlipX, 150, 120, "Rotate90FlipX", bmp, gr);
+ CreateImage (RotateFlipType.Rotate180FlipX, 300, 120, "Rotate180FlipX", bmp, gr);
+ CreateImage (RotateFlipType.Rotate270FlipX, 450, 120, "Rotate270FlipX", bmp, gr);
+
+ bmp.Save(filename, ImageFormat.Bmp);
+
+ Console.WriteLine("Bitmap stored to " + filename);
+ }
+}
+
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/ImageStream.cs b/mcs/class/System.Drawing/Samples/System.Drawing/ImageStream.cs
new file mode 100644
index 00000000000..724c75d0acf
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/ImageStream.cs
@@ -0,0 +1,53 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Jordi's simple test for streams (work on Win32 and Linux)
+//
+
+using System;
+using System.IO;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+//
+public class SampleDrawingImage
+{
+
+ public static void Main (string[] args)
+ {
+ Stream stout, stin;
+
+ stin = File.OpenRead ("bitmaps/horse.bmp");
+ Bitmap bmp = new Bitmap (stin);
+
+ // Draw a red rectangle
+ Graphics gr = Graphics.FromImage (bmp);
+ gr.DrawRectangle (new Pen (Color.Red, 2), 10.0F, 10.0F, 40.0F, 40.0F);
+
+ stout = File.Open ("horse.jpg", FileMode.Create);
+ bmp.Save (stout, ImageFormat.Jpeg);
+ }
+
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/RegionsGraphicsPath.cs b/mcs/class/System.Drawing/Samples/System.Drawing/RegionsGraphicsPath.cs
new file mode 100644
index 00000000000..5c1d36a535f
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/RegionsGraphicsPath.cs
@@ -0,0 +1,160 @@
+//
+// Sample application for region graphics functions using GraphicsPaths implementation
+//
+// Author:
+// Jordi Mas i Hernandez, jordi@ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Imaging;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+//
+public class Regions
+{
+
+ public static void Main ()
+ {
+
+ Bitmap bmp = new Bitmap (600, 300);
+ Graphics dc = Graphics.FromImage (bmp);
+ Font fnt = new Font ("Arial", 8);
+ Font fnttitle = new Font ("Arial", 8, FontStyle.Underline);
+ Matrix matrix = new Matrix ();
+ GraphicsPath patha = new GraphicsPath ();
+ GraphicsPath pathb = new GraphicsPath ();
+ Pen redPen = new Pen (Color.Red, 2);
+ Region rgn1;
+ Region rgn2;
+ int x = 0;
+
+ SolidBrush whiteBrush = new SolidBrush (Color.White);
+
+ dc.DrawString ("Region samples using GraphicsPath", fnttitle, whiteBrush, 5, 5);
+
+ /* First*/
+ patha.AddLine (60, 40, 90, 90);
+ patha.AddLine (90, 90, 10, 90);
+ patha.AddLine (10, 90, 60, 40);
+ dc.DrawPath (redPen, patha);
+
+ pathb.AddEllipse(30, 55, 60, 60);
+ dc.DrawPath(redPen, pathb);
+
+ rgn1 = new Region (patha);
+ rgn2 = new Region (pathb);
+ rgn1.Complement (rgn2);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawString ("Complement (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 140);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ x += 110;
+
+ /* Second*/
+ patha.Reset ();
+ pathb.Reset ();
+ patha.AddLine (60+x, 40, 90+x, 90);
+ patha.AddLine (90+x, 90, 10+x, 90);
+ patha.AddLine (10+x, 90, 60+x, 40);
+
+ dc.DrawPath (redPen, patha);
+
+ pathb.AddEllipse (30+x, 55, 60, 60);
+ dc.DrawPath(redPen, pathb);
+
+ rgn1 = new Region (patha);
+ rgn2 = new Region (pathb);
+ rgn1.Exclude (rgn2);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawString ("Exclude (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 140, 140);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ x += 110;
+
+ /* Third*/
+ patha.Reset ();
+ pathb.Reset ();
+ patha.AddLine (60+x, 40, 90+x, 90);
+ patha.AddLine (90+x, 90, 10+x, 90);
+ patha.AddLine (10+x, 90, 60+x, 40);
+
+ dc.DrawPath (redPen, patha);
+
+ pathb.AddEllipse (30+x, 55, 60, 60);
+ dc.DrawPath (redPen, pathb);
+
+ rgn1 = new Region (patha);
+ rgn2 = new Region (pathb);
+ rgn1.Intersect (rgn2);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawString ("Intersect (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 270, 140);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ x += 110;
+
+ /* Four*/
+ patha.Reset ();
+ pathb.Reset ();
+ patha.AddLine (60+x, 40, 90+x, 90);
+ patha.AddLine (90+x, 90, 10+x, 90);
+ patha.AddLine (10+x, 90, 60+x, 40);
+
+ dc.DrawPath (redPen, patha);
+
+ pathb.AddEllipse (30+x, 55, 60, 60);
+ dc.DrawPath (redPen, pathb);
+
+ rgn1 = new Region (patha);
+ rgn2 = new Region (pathb);
+ rgn1.Xor (rgn2);
+ dc.FillRegion(Brushes.Blue, rgn1);
+ dc.DrawString ("Xor (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 380, 140);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ x += 110;
+
+ /* Fifth */
+ patha.Reset ();
+ pathb.Reset ();
+ patha.AddLine (60+x, 40, 90+x, 90);
+ patha.AddLine (90+x, 90, 10+x, 90);
+ patha.AddLine (10+x, 90, 60+x, 40);
+
+ dc.DrawPath (redPen, patha);
+
+ pathb.AddEllipse (30+x, 55, 60, 60);
+ dc.DrawPath (redPen, pathb);
+
+ rgn1 = new Region (patha);
+ rgn2 = new Region (pathb);
+ rgn1.Union (rgn2);
+ dc.FillRegion(Brushes.Blue, rgn1);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ dc.DrawString ("Union (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 490, 140);
+
+ bmp.Save("regionsgp.bmp", ImageFormat.Bmp);
+ }
+
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/RegionsRectangle.cs b/mcs/class/System.Drawing/Samples/System.Drawing/RegionsRectangle.cs
new file mode 100644
index 00000000000..8998f74d4e3
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/RegionsRectangle.cs
@@ -0,0 +1,428 @@
+//
+// Sample application for region graphics functions using Rects implementation
+//
+// Author:
+// Jordi Mas, jordi@ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Imaging;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+//
+public class Regions
+{
+ public static void DumpRegion (Region rgn)
+ {
+ Matrix matrix = new Matrix ();
+ RectangleF [] rects = rgn.GetRegionScans (matrix);
+
+ for (int i = 0; i < rects.Length; i++)
+ Console.WriteLine ( rects[i]);
+ }
+
+ public static void Main ()
+ {
+ Bitmap bmp = new Bitmap (600, 800);
+ Graphics dc = Graphics.FromImage (bmp);
+ Font fnt = new Font ("Arial", 8);
+ Font fnttitle = new Font("Arial", 8, FontStyle.Underline);
+ Matrix matrix = new Matrix ();
+ int x = 0;
+ Rectangle rect1, rect2, rect3, rect4;
+ Region rgn1, rgn2, rgn3, rgn4;
+
+ bool complement = true, exclude = true, union = true, xor = true, intersect = true;
+
+ SolidBrush whiteBrush = new SolidBrush (Color.White);
+
+ dc.DrawString ("Region samples using two Rectangle classes", fnttitle, whiteBrush, 5, 5);
+
+ /* First */
+ if (complement) {
+ rect1 = new Rectangle (20, 30, 60, 80);
+ rect2 = new Rectangle (50, 40, 60, 80);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ rgn1.Complement (rgn2);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawString ("Complement (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 130);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ DumpRegion (rgn1);
+ }
+
+ /* Second */
+ if (exclude) {
+ rect3 = new Rectangle (130, 30, 60, 80);
+ rect4 = new Rectangle (170, 40, 60, 80);
+ rgn3 = new Region (rect3);
+ rgn4 = new Region (rect4);
+ dc.DrawRectangle (Pens.Green, rect3);
+ dc.DrawRectangle (Pens.Red, rect4);
+ rgn3.Exclude (rgn4);
+ dc.FillRegion (Brushes.Blue, rgn3);
+ dc.DrawString ("Exclude (" + rgn3.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 130, 130);
+ dc.DrawRectangles (Pens.Yellow, rgn3.GetRegionScans (matrix));
+ DumpRegion (rgn3);
+ }
+
+ /* Third */
+ if (intersect) {
+
+ Rectangle rect5 = new Rectangle (260, 30, 60, 80);
+ Rectangle rect6 = new Rectangle (290, 40, 60, 80);
+ Region rgn5 = new Region (rect5);
+ Region rgn6 = new Region (rect6);
+ dc.DrawRectangle (Pens.Green, rect5);
+ dc.DrawRectangle (Pens.Red, rect6);
+ rgn5.Intersect (rgn6);
+ dc.FillRegion (Brushes.Blue, rgn5);
+ dc.DrawString ("Intersect (" + rgn5.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 270, 130);
+ dc.DrawRectangles (Pens.Yellow, rgn5.GetRegionScans (matrix));
+ DumpRegion (rgn5);
+ }
+
+ /* Four */
+ if (xor) {
+ Rectangle rect7 = new Rectangle (380, 30, 60, 80);
+ Rectangle rect8 = new Rectangle (410, 40, 60, 80);
+ Region rgn7 = new Region (rect7);
+ Region rgn8 = new Region (rect8);
+ dc.DrawRectangle (Pens.Green, rect7);
+ dc.DrawRectangle (Pens.Red, rect8);
+ rgn7.Xor (rgn8);
+ dc.FillRegion (Brushes.Blue, rgn7);
+ dc.DrawString ("Xor (" + rgn7.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 400, 130);
+ dc.DrawRectangles (Pens.Yellow, rgn7.GetRegionScans (matrix));
+ DumpRegion (rgn7);
+ }
+
+ /* Fifht */
+ if (union) {
+ Rectangle rect9 = new Rectangle (500, 30, 60, 80);
+ Rectangle rect10 = new Rectangle (520, 40, 60, 80);
+ Region rgn9 = new Region(rect9);
+ Region rgn10 = new Region(rect10);
+ dc.DrawRectangle (Pens.Green, rect9);
+ dc.DrawRectangle (Pens.Red, rect10);
+ rgn9.Union(rgn10);
+ dc.FillRegion (Brushes.Blue, rgn9);
+ dc.DrawString ("Union (" + rgn9.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 530, 130);
+ dc.DrawRectangles (Pens.Yellow, rgn9.GetRegionScans (matrix));
+ DumpRegion (rgn9);
+ }
+
+ dc.DrawString ("Region samples using three Rectangle class", fnttitle, whiteBrush, 5, 155);
+
+ /* First */
+ x = 0;
+
+ if (complement) {
+ rect1 = new Rectangle (20+x, 180, 40, 50);
+ rect2 = new Rectangle (50+x, 190, 40, 50);
+ rect3 = new Rectangle (70+x, 210, 30, 50);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawEllipse (Pens.Red, rect3);
+
+ rgn1.Complement (rgn2);
+ rgn1.Complement (rgn3);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawString ("Complement (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 275);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ DumpRegion (rgn1);
+ }
+ x += 110;
+
+ /* Second */
+ if (exclude) {
+ rect1 = new Rectangle (20+x, 180, 40, 50);
+ rect2 = new Rectangle (50+x, 190, 40, 50);
+ rect3 = new Rectangle (70+x, 210, 30, 50);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawEllipse (Pens.Red, rect3);
+
+ rgn1.Exclude (rgn2);
+ rgn1.Exclude (rgn3);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ dc.DrawString ("Exclude (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 130, 275);
+ DumpRegion (rgn1);
+ }
+ x += 110;
+
+ /* Third */
+ if (intersect) {
+
+ rect1 = new Rectangle (20+x, 180, 40, 50);
+ rect2 = new Rectangle (50+x, 190, 40, 50);
+ rect3 = new Rectangle (70+x, 210, 30, 50);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawEllipse (Pens.Red, rect3);
+
+ rgn1.Union (rgn2);
+ rgn1.Intersect (rgn3);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ dc.DrawString ("Intersect (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 270, 275);
+ DumpRegion (rgn1);
+
+ }
+ x += 110;
+
+ /* Fourth */
+ if (xor) {
+ rect1 = new Rectangle (20+x, 180, 40, 50);
+ rect2 = new Rectangle (50+x, 190, 40, 50);
+ rect3 = new Rectangle (70+x, 210, 30, 50);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawEllipse (Pens.Red, rect3);
+
+ rgn1.Union (rgn2);
+ rgn1.Xor (rgn3);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ dc.DrawString ("Xor (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 380, 275);
+ DumpRegion (rgn1);
+ }
+ x += 110;
+
+ /* Fifth */
+ if (union) {
+ rect1 = new Rectangle (20+x, 180, 40, 50);
+ rect2 = new Rectangle (50+x, 190, 40, 50);
+ rect3 = new Rectangle (70+x, 210, 30, 50);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawEllipse (Pens.Red, rect3);
+
+ rgn1.Union (rgn2);
+ rgn1.Union (rgn3);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawString ("Union (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 500, 275);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ DumpRegion (rgn1);
+ }
+ x += 110;
+
+ dc.DrawString ("Region samples using four Rectangle class", fnttitle, whiteBrush, 5, 300);
+
+ /* First */
+ x = 0;
+
+ if (complement) {
+ rect1 = new Rectangle (20+x, 330, 40, 50);
+ rect2 = new Rectangle (50+x, 340, 40, 50);
+ rect3 = new Rectangle (70+x, 360, 30, 50);
+ rect4 = new Rectangle (80+x, 400, 30, 10);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+ rgn4 = new Region (rect4);
+
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawEllipse (Pens.Red, rect3);
+ dc.DrawRectangle (Pens.Red, rect4);
+
+ rgn1.Complement (rgn2);
+ rgn1.Complement (rgn3);
+ rgn1.Complement (rgn4);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawString ("Complement (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 430);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ DumpRegion (rgn1);
+ }
+ x += 110;
+
+ /* Second */
+ if (exclude) {
+ rect1 = new Rectangle (20+x, 330, 40, 50);
+ rect2 = new Rectangle (50+x, 340, 40, 50);
+ rect3 = new Rectangle (70+x, 360, 30, 50);
+ rect4 = new Rectangle (80+x, 400, 30, 10);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+ rgn4 = new Region (rect4);
+
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawEllipse (Pens.Red, rect3);
+ dc.DrawRectangle (Pens.Red, rect4);
+
+ rgn1.Union (rgn2);
+ rgn1.Union (rgn3);
+ rgn1.Exclude (rgn4);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ dc.DrawString ("Exclude (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 130, 430);
+ }
+ x += 110;
+
+ /* Third */
+ if (intersect) {
+
+ rect1 = new Rectangle (20+x, 330, 40, 50);
+ rect2 = new Rectangle (50+x, 340, 40, 50);
+ rect3 = new Rectangle (70+x, 360, 30, 50);
+ rect4 = new Rectangle (80+x, 400, 30, 10);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+ rgn4 = new Region (rect4);
+
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawEllipse (Pens.Red, rect3);
+ dc.DrawRectangle (Pens.Red, rect4);
+
+ rgn1.Union (rgn2);
+ rgn1.Union (rgn3);
+ rgn1.Intersect (rgn4);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ dc.DrawString ("Intersect (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 250, 430);
+ DumpRegion (rgn1);
+ }
+ x += 110;
+
+ /* Fourth */
+ if (xor) {
+ rect1 = new Rectangle (20+x, 330, 40, 50);
+ rect2 = new Rectangle (50+x, 340, 40, 50);
+ rect3 = new Rectangle (70+x, 360, 30, 50);
+ rect4 = new Rectangle (80+x, 400, 30, 10);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+ rgn4 = new Region (rect4);
+
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawEllipse (Pens.Red, rect3);
+ dc.DrawRectangle (Pens.Red, rect4);
+
+ rgn1.Union (rgn2);
+ rgn3.Union (rgn4);
+ rgn1.Xor (rgn3);
+
+ dc.FillRegion(Brushes.Blue, rgn1);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ dc.DrawString ("Xor (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 370, 430);
+ DumpRegion (rgn1);
+ }
+ x += 110;
+
+ /* Fifth */
+ if (union) {
+ rect1 = new Rectangle (20+x, 330, 40, 50);
+ rect2 = new Rectangle (50+x, 340, 40, 50);
+ rect3 = new Rectangle (70+x, 360, 30, 50);
+ rect4 = new Rectangle (80+x, 400, 30, 10);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+ rgn4 = new Region (rect4);
+
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawEllipse (Pens.Red, rect3);
+ dc.DrawRectangle (Pens.Red, rect4);
+
+ rgn1.Union (rgn2);
+ rgn1.Union (rgn3);
+ rgn1.Union (rgn4);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawString ("Union (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 490, 430);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ DumpRegion (rgn1);
+ }
+ x += 110;
+
+ dc.DrawString ("Region samples using Regions with two Rectangles", fnttitle, whiteBrush, 5, 455);
+
+ x = 0;
+
+ if (complement) {
+ rect1 = new Rectangle (20+x, 330+150, 40, 50);
+ rect2 = new Rectangle (50+x, 340+150, 40, 50);
+ rect3 = new Rectangle (70+x, 360+150, 30, 50);
+ rect4 = new Rectangle (80+x, 400+150, 30, 10);
+ rgn1 = new Region (rect1);
+ rgn1.Union (rect2);
+ rgn2 = new Region (rect3);
+ rgn2.Union (rect4);
+
+ dc.DrawRectangle (Pens.Red, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ dc.DrawRectangle (Pens.Green, rect3);
+ dc.DrawRectangle (Pens.Green, rect4);
+
+ rgn1.Complement (rgn2);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawString ("Complement (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 430+150);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+ DumpRegion (rgn1);
+ }
+ x += 110;
+
+ rect1 = new Rectangle (1, 1, 4, 1);
+ dc.DrawRectangle (Pens.Pink, rect1);
+
+
+ bmp.Save("regionsrc.bmp", ImageFormat.Bmp);
+ }
+
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/SystemFonts.cs b/mcs/class/System.Drawing/Samples/System.Drawing/SystemFonts.cs
new file mode 100644
index 00000000000..46066c5a1f9
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/SystemFonts.cs
@@ -0,0 +1,29 @@
+//
+// Sample that show the default SystemFonts and its names
+// Requieres .NET 2.0 class library
+//
+
+using System;
+using System.Drawing;
+
+
+public class SystemFontsSample
+{
+ public static void Main ()
+ {
+ Console.WriteLine ("--> CaptionFont [{0}] {1}", SystemFonts.CaptionFont.SystemFontName, SystemFonts.CaptionFont);
+ Console.WriteLine ("--> DefaultFont [{0}] {1}", SystemFonts.DefaultFont.SystemFontName, SystemFonts.DefaultFont);
+ Console.WriteLine ("--> DialogFont [{0}] {1}", SystemFonts.DialogFont.SystemFontName, SystemFonts.DialogFont);
+ Console.WriteLine ("--> IconTitleFont [{0}] {1}", SystemFonts.IconTitleFont.SystemFontName, SystemFonts.IconTitleFont);
+ Console.WriteLine ("--> MenuFont [{0}] {1}", SystemFonts.MenuFont.SystemFontName, SystemFonts.MenuFont);
+ Console.WriteLine ("--> MessageBoxFont [{0}] {1}", SystemFonts.MessageBoxFont.SystemFontName, SystemFonts.MessageBoxFont);
+ Console.WriteLine ("--> SmallCaptionFont [{0}] {1}", SystemFonts.SmallCaptionFont.SystemFontName, SystemFonts.SmallCaptionFont);
+ Console.WriteLine ("--> StatusFont [{0}] {1}", SystemFonts.StatusFont.SystemFontName, SystemFonts.StatusFont);
+
+ Font fnt = new Font ("Arial", 12);
+ Console.WriteLine ("--> IsSystemFontName {0} {1}", SystemFonts.StatusFont.IsSystemFont, fnt.IsSystemFont);
+ }
+
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/TextureWrapModes.cs b/mcs/class/System.Drawing/Samples/System.Drawing/TextureWrapModes.cs
new file mode 100644
index 00000000000..8cb0bfa7271
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/TextureWrapModes.cs
@@ -0,0 +1,121 @@
+//
+// Sample application for drawing figures using TextureBrush
+// with different WrapModes
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+namespace MonoSamples.System.Drawing
+{
+ public class TextureWrapModes
+ {
+ Image img; // To be used by brush
+ Graphics gr; // To be used for creating a new bitmap
+ Bitmap bmp;
+ int currentTop;
+ int spacing;
+ int left = 100;
+ int width = 450;
+ int height = 250;
+
+ public TextureWrapModes (string imgName, int wd, int ht, int top, int sp)
+ {
+ currentTop = top;
+ spacing = sp;
+ bmp = new Bitmap (wd,ht);
+ gr = Graphics.FromImage (bmp);
+ img = Image.FromFile ("./bitmaps/" + imgName);
+ }
+
+ public void DrawWrapModes ()
+ {
+ int top = currentTop;
+ top += spacing;
+ TextureBrush tbr = new TextureBrush (img);
+
+ // #1: Clamp
+ tbr.WrapMode = WrapMode.Clamp;
+ gr.FillRectangle (tbr, 0, 0, width, height);
+ top = top + height + spacing;
+
+ tbr = new TextureBrush (img);
+
+ // #2: Default
+ gr.FillRectangle (tbr, left, top, width, height);
+ top = top + height + spacing;
+
+ // #3: Tile
+ tbr.WrapMode = WrapMode.Tile;
+ gr.FillRectangle (tbr, left, top, width, height);
+ top = top + height + spacing;
+
+ // #4: TileFlipX
+ tbr.WrapMode = WrapMode.TileFlipX;
+ gr.FillRectangle (tbr, left, top, width, height);
+ top = top + height + spacing;
+
+ // #5: TileFlipY
+ tbr.WrapMode = WrapMode.TileFlipY;
+ gr.FillRectangle (tbr, left, top, width, height);
+ top = top + height + spacing;
+
+ // #6: TileFlipXY
+ tbr.WrapMode = WrapMode.TileFlipXY;
+ gr.FillRectangle (tbr, left, top, width, height);
+ top = top + height + spacing;
+
+ currentTop = top;
+ }
+
+ public void SaveDrawing ()
+ {
+ // save the bmp
+ bmp.Save ("TextureWrapModes.png", ImageFormat.Png);
+ }
+
+ // Main to draw the things
+ public static void Main ()
+ {
+ // Make sure that the image dimensions are
+ // sufficient to hold all the test results.
+ // TextureWrapModes (imgName, width, height, top, spacing)
+
+ TextureWrapModes twm = new TextureWrapModes ("horse.png", 650,
+ 1850, 0, 50);
+
+ // Draw different wrapmodes
+ twm.DrawWrapModes ();
+
+ // Save the drawing when done
+ twm.SaveDrawing ();
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/bitmaps/ChangeLog b/mcs/class/System.Drawing/Samples/System.Drawing/bitmaps/ChangeLog
new file mode 100644
index 00000000000..239045ecb7d
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/bitmaps/ChangeLog
@@ -0,0 +1,5 @@
+2004-03-25 Ravindra <rkumar@novell.com>
+ * Created this repository for input images for samples for
+ System.Drawing namespace.
+ * ChangeLog: Added.
+ * horse.bmp: Added for TextureWrapModes.cs sample.
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/bitmaps/horse.bmp b/mcs/class/System.Drawing/Samples/System.Drawing/bitmaps/horse.bmp
new file mode 100644
index 00000000000..95f35d32b30
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/bitmaps/horse.bmp
Binary files differ
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/bmpsave.cs b/mcs/class/System.Drawing/Samples/System.Drawing/bmpsave.cs
new file mode 100644
index 00000000000..122167cfc22
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/bmpsave.cs
@@ -0,0 +1,50 @@
+//
+// bmpsave.cs sample
+//
+// Author:
+// Alexandre Pigolkine(pigolkine@gmx.de)
+//
+// Copyright (C) Ximian, Inc. http://www.ximian.com
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+
+namespace MonoSamples.System.Drawing
+{
+ public class BmpSave
+ {
+ public static void Main (string[] argv) {
+ if (argv.Length == 1) {
+ Bitmap bmp = new Bitmap (argv[0]);
+ Console.WriteLine ("Output file bmpsave.bmp");
+ bmp.Save ("bmpsave.bmp", ImageFormat.Bmp);
+ }
+ else {
+ Console.WriteLine ("usage: bmpsave.exe <filename>");
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/clip.cs b/mcs/class/System.Drawing/Samples/System.Drawing/clip.cs
new file mode 100644
index 00000000000..3dc94e0c673
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/clip.cs
@@ -0,0 +1,52 @@
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Autor Jordi Mas <jordi@ximian.com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Imaging;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+//
+public class ClipSample
+{
+ public static void Main ()
+ {
+ Bitmap bmp = new Bitmap (600, 500);
+ Graphics dc = Graphics.FromImage (bmp);
+ RectangleF[] rects = dc.Clip.GetRegionScans (new Matrix());
+
+ for (int i = 0; i < rects.GetLength(0); i++)
+ Console.WriteLine ("clip: " + rects[i].ToString());
+
+ Console.WriteLine ("VisibleClipBounds: " + dc.VisibleClipBounds);
+ Console.WriteLine ("IsVisible Point 650, 650: " + dc.IsVisible (650,650));
+ Console.WriteLine ("IsVisible Point 0, 0: " + dc.IsVisible (0.0f, 0.0f));
+
+ Console.WriteLine ("IsVisible Rectangle (20,20,100,100): " + dc.IsVisible (new Rectangle (20,20,100,100)));
+ Console.WriteLine ("IsVisible Rectangle (1000, 1000,100,100): " + dc.IsVisible (new RectangleF (1000, 1000,100,100)));
+
+ }
+
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/clipping.cs b/mcs/class/System.Drawing/Samples/System.Drawing/clipping.cs
new file mode 100644
index 00000000000..e7541cceda8
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/clipping.cs
@@ -0,0 +1,103 @@
+//
+// Author:
+// Jordi Mas i Hernandez
+//
+// Sample to test clipping. Requires SWF.
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Windows.Forms;
+using System.Drawing;
+using System;
+
+namespace MyFormProject
+{
+
+
+ class MainForm : System.Windows.Forms.Form
+ {
+ class ourLabelTwoAreas : Label
+ {
+ public ourLabelTwoAreas ()
+ {
+
+ }
+ protected override void OnPaint (PaintEventArgs pevent)
+ {
+ Console.WriteLine ("ourLabelTwoAreas pevents {0}, pos {1} - size {2}", pevent.ClipRectangle,
+ Location, Size);
+
+ Region reg = new Region (new Rectangle (20, 20, 10, 10));
+ reg.Union (new Rectangle (5, 5, 10, 10));
+ pevent.Graphics.Clip = reg;
+ pevent.Graphics.FillRectangle (Brushes.Red, pevent.ClipRectangle);
+ }
+ }
+
+ class ourLabelOverflows : Label
+ {
+ public ourLabelOverflows ()
+ {
+
+ }
+ protected override void OnPaint (PaintEventArgs pevent)
+ {
+ Console.WriteLine ("ourLabelOverflows pevents {0}, pos {1} - size {2}", pevent.ClipRectangle,
+ Location, Size);
+
+ pevent.Graphics.FillRectangle (Brushes.Yellow,
+ new Rectangle (0,0, 1000, 1000));
+ }
+ }
+
+ protected override void OnPaint (PaintEventArgs pevent)
+ {
+ pevent.Graphics.FillRectangle (Brushes.Green, pevent.ClipRectangle);
+ }
+
+ static private ourLabelTwoAreas label = new ourLabelTwoAreas ();
+ static private ourLabelOverflows label2 = new ourLabelOverflows ();
+
+ public MainForm ()
+ {
+ label.Location = new Point (20, 20);
+ label.Size = new Size (50, 80);
+ label.Text = "Hola";
+ Controls.Add (label);
+
+ label2.Location = new Point (100, 100);
+ label2.Size = new Size (50, 80);
+ label2.Text = "Hola";
+ Controls.Add (label2);
+
+ ClientSize = new Size (400, 400);
+ }
+
+ public static void Main(string[] args)
+ {
+ Application.Run (new MainForm ());
+ }
+ }
+
+}
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/drawimage.cs b/mcs/class/System.Drawing/Samples/System.Drawing/drawimage.cs
new file mode 100644
index 00000000000..e5fee691777
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/drawimage.cs
@@ -0,0 +1,82 @@
+//
+// Sample application for drawing image implementation
+//
+// Author:
+// Jordi Mas i Hernàndez, jordi@ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+//
+public class SampleDrawingImage
+{
+
+ /* DrawImageAbort callback method */
+ static private bool DrawImageCallback(IntPtr callBackData)
+ {
+ Console.WriteLine("DrawImageCallback");
+ return false;
+ }
+
+ public static void Main(string[] args)
+ {
+ Graphics.DrawImageAbort imageCallback;
+ Bitmap outbmp = new Bitmap (300, 300);
+ Bitmap bmp = new Bitmap("../../Test/System.Drawing/bitmaps/almogaver24bits.bmp");
+ Graphics dc = Graphics.FromImage (outbmp);
+
+ ImageAttributes imageAttr = new ImageAttributes();
+
+ /* Simple image drawing */
+ dc.DrawImage(bmp, 0,0);
+
+ /* Drawing using points */
+ PointF ulCorner = new PointF(150.0F, 0.0F);
+ PointF urCorner = new PointF(350.0F, 0.0F);
+ PointF llCorner = new PointF(200.0F, 150.0F);
+ RectangleF srcRect = new Rectangle (0,0,100,100);
+ PointF[] destPara = {ulCorner, urCorner, llCorner};
+ imageCallback = new Graphics.DrawImageAbort(DrawImageCallback);
+ dc.DrawImage (bmp, destPara, srcRect, GraphicsUnit.Pixel, imageAttr, imageCallback);
+
+ /* Using rectangles */
+ RectangleF destRect = new Rectangle (10,200,100,100);
+ RectangleF srcRect2 = new Rectangle (50,50,100,100);
+ dc.DrawImage (bmp, destRect, srcRect2, GraphicsUnit.Pixel);
+
+ /* Simple image drawing with with scaling*/
+ dc.DrawImage(bmp, 200,200, 75, 75);
+
+ outbmp.Save("drawimage.bmp", ImageFormat.Bmp);
+
+ }
+
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/font.cs b/mcs/class/System.Drawing/Samples/System.Drawing/font.cs
new file mode 100644
index 00000000000..b9c96e8f628
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/font.cs
@@ -0,0 +1,63 @@
+//
+// font.cs
+// font/text operations
+//
+// Author:
+// Alexandre Pigolkine(pigolkine@gmx.de)
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Drawing.Imaging;
+
+namespace MonoSamples.System.Drawing
+{
+ public class FontSample
+ {
+ public static void Main () {
+
+ float width = 400.0F;
+ float height = 800.0F;
+
+ FontCollection ifc = new InstalledFontCollection ();
+ foreach (FontFamily ffm in ifc.Families) {
+ Console.WriteLine (ffm.Name);
+ }
+
+ Font f = new Font ("Arial",12);
+ Console.WriteLine ("Height: {0}", f.Height);
+
+ Bitmap bmp = new Bitmap ((int) width, (int) height);
+ Graphics gr = Graphics.FromImage (bmp);
+ gr.Clear (Color.White);
+
+ Brush br = new SolidBrush (Color.Black);
+ gr.DrawString ("The test string", f, br, 10, 10);
+
+ bmp.Save ("font.png", ImageFormat.Png);
+ Console.WriteLine ("output file font.png");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/fontsizes.cs b/mcs/class/System.Drawing/Samples/System.Drawing/fontsizes.cs
new file mode 100644
index 00000000000..5013885c84f
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/fontsizes.cs
@@ -0,0 +1,52 @@
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// (c) 2005 Jordi Mas i Hernandez, <jordi@ximian.com>
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Drawing.Imaging;
+
+namespace MonoSamples.System.Drawing
+{
+ public class FontSizes
+ {
+ public static void PrintFontInfo (Font f)
+ {
+ Console.WriteLine ("Font: {0} size in pixels: {1}", f, f.Height);
+ }
+
+ public static void Main ()
+ {
+ Console.WriteLine (";----------------------------------------------------");
+ PrintFontInfo (new Font ("Arial", 12));
+ PrintFontInfo (new Font ("Arial", 14));
+ PrintFontInfo (new Font ("Arial", 16));
+ PrintFontInfo (new Font ("Arial", 22));
+ PrintFontInfo (new Font ("Verdana", 44));
+ PrintFontInfo (new Font ("Verdana", 8));
+
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/graphicsUi.cs b/mcs/class/System.Drawing/Samples/System.Drawing/graphicsUi.cs
new file mode 100644
index 00000000000..10c87ec7eba
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/graphicsUi.cs
@@ -0,0 +1,134 @@
+//
+// A sample application for some graphics.cs functions implementation
+//
+// Author:
+// Jordi Mas i Hernàndez, jordi@ximian.com
+//
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Imaging;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace MonoSamples.System.Drawing
+{
+ public class graphicsUI
+ {
+ public static void Main () {
+
+ Bitmap bmp = new Bitmap (500, 250);
+ Graphics dc = Graphics.FromImage (bmp);
+
+ Pen BluePen = new Pen (Color.Blue, 3);
+ Pen GreenPen = new Pen (Color.Green, 3);
+ Pen RedPen = new Pen (Color.Red, 3);
+ SolidBrush redBrush = new SolidBrush (Color.Red);
+ SolidBrush blueBrush = new SolidBrush (Color.Blue);
+
+ int x = 0;
+ int y = 0;
+
+ /* First Row */
+ dc.DrawRectangle (BluePen, x, y, 50, 50);
+ x += 50;
+ dc.DrawEllipse (RedPen, x, y, 70, 50);
+ dc.DrawArc (BluePen, x, y, 50, 40, (float) 0, (float) 120);
+ x += 70;
+
+ dc.DrawBezier (GreenPen, new Point (x, y + 5),
+ new Point (x + 50, y + 5),
+ new Point (x + 20, y + 20),
+ new Point (x + 50, y + 50));
+ x += 50;
+
+ PointF point1 = new PointF (10.0F + x, 10.0F);
+ PointF point2 = new PointF (10.0F + x, 5.0F);
+ PointF point3 = new PointF (40.0F + x, 5.0F);
+ PointF point4 = new PointF (50.0F + x, 10.0F);
+ PointF point5 = new PointF (60.0F + x, 20.0F);
+ PointF point6 = new PointF (70.0F + x, 40.0F);
+ PointF point7 = new PointF (50.0F + x, 50.0F);
+ PointF[] curvePoints = {point1, point2, point3, point4,
+ point5, point6, point7};
+ dc.DrawLines (RedPen, curvePoints);
+ float tension = 1.0F;
+ FillMode aFillMode = FillMode.Alternate;
+ dc.DrawClosedCurve (GreenPen, curvePoints, tension, aFillMode);
+
+ x += 80;
+
+ // FillClosedCurve
+ PointF point10 = new PointF (x, y + 15.0F);
+ PointF point20 = new PointF (x + 40.0F, y + 10.0F);
+ PointF point30 = new PointF (x + 50.0F, y + 40.0F);
+ PointF point40 = new PointF (x + 10.0F, y + 30.0F);
+ PointF[] points = {point10, point20, point30, point40};
+ FillMode newFillMode = FillMode.Winding;
+ dc.FillClosedCurve (redBrush, points, newFillMode, tension);
+
+ // Fill pie to screen.
+ dc.FillPie (blueBrush, x, 0, 200.0F, 100.0f, 300.0F, 45.0F);
+
+ /* second row */
+ y += 80;
+ x = 0;
+
+ // Clipping and Graphics container test
+ dc.SetClip (new Rectangle (5 + x, 5 + y, 75, 75));
+
+ // Begin a graphics container.
+ GraphicsContainer container = dc.BeginContainer ();
+
+ // Set an additional clipping region for the container.
+ dc.SetClip (new Rectangle (50 + x, 25 + y, 50, 37));
+
+ // Fill a red rectangle in the container.
+ dc.FillRectangle (redBrush, 0, 0, 200, 200);
+
+ dc.EndContainer (container);
+ SolidBrush blueBrushLight = new SolidBrush (
+ Color.FromArgb (128, 0, 0, 255));
+ dc.FillRectangle (blueBrushLight, 0, 0, 200, 200);
+
+ dc.ResetClip ();
+ Pen blackPen = new Pen (Color.FromArgb (255, 0, 0, 0), 2.0f);
+ dc.DrawRectangle (blackPen, 5 + x, 5 + y, 75, 75);
+ dc.DrawRectangle (blackPen, 50 + x, 25 + y, 50, 37);
+
+ x = 100;
+ y += 10;
+
+ Point[] ptstrans = {new Point(x, y), new Point (50 + x, 25 + y)};
+ dc.DrawLine (BluePen, ptstrans [0], ptstrans [1]);
+ dc.TranslateTransform (40.0F, 30.0F);
+ dc.TransformPoints (CoordinateSpace.Page, CoordinateSpace.World,
+ ptstrans);
+ dc.ResetTransform ();
+ dc.DrawLine (RedPen, ptstrans [0], ptstrans [1]);
+
+ bmp.Save ("graphicsui.bmp", ImageFormat.Bmp);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/imagecompose.cs b/mcs/class/System.Drawing/Samples/System.Drawing/imagecompose.cs
new file mode 100644
index 00000000000..0e17a8b9923
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/imagecompose.cs
@@ -0,0 +1,68 @@
+//
+// Sample application for adding two images into a single TIFF file
+//
+// Author:
+// Jordi Mas i Hernàndez, jordi@ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+//
+public class SampleComposeImages
+{
+
+ public static void Main(string[] args)
+ {
+ //get the codec for tiff files
+ ImageCodecInfo info = null;
+ Bitmap pages = null;
+
+ foreach(ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders())
+ if(ice.MimeType=="image/tiff")
+ info = ice;
+
+ //use the save encoder
+ Encoder enc = Encoder.SaveFlag;
+ EncoderParameters ep=new EncoderParameters(1);
+ ep.Param[0] = new EncoderParameter (enc,(long)EncoderValue.MultiFrame);
+
+ pages = (Bitmap) Image.FromFile ("../../Test/System.Drawing/bitmaps/almogaver32bits.bmp");
+ pages.Save ("out.tiff", info, ep);
+
+ //save second frame
+ ep.Param[0] = new EncoderParameter (enc,(long)EncoderValue.FrameDimensionPage);
+ Bitmap bm=(Bitmap)Image.FromFile ("../../Test/System.Drawing/bitmaps/nature24bits.jpg");
+ pages.SaveAdd (bm,ep);
+
+ ep.Param[0] = new EncoderParameter (enc,(long)EncoderValue.Flush);
+ pages.SaveAdd (ep);
+ }
+}
+
+
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/pie.cs b/mcs/class/System.Drawing/Samples/System.Drawing/pie.cs
new file mode 100644
index 00000000000..4d00a1d3a4d
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/pie.cs
@@ -0,0 +1,94 @@
+//
+// Test application for pie graphics functions implementation
+//
+// Author:
+// Jordi Mas, jordi@ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Imaging;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+//
+public class graphicsUI
+{
+
+ public static void Main ()
+ {
+
+ Bitmap bmp = new Bitmap (400, 600);
+ Graphics dc = Graphics.FromImage (bmp);
+
+ // Clears and set the background color to red
+ dc.Clear (Color.Red);
+
+ SolidBrush blueBrush = new SolidBrush (Color.Blue);
+ SolidBrush redBrush = new SolidBrush (Color.Red);
+ SolidBrush yellowBrush = new SolidBrush (Color.Yellow);
+ SolidBrush whiteBrush = new SolidBrush (Color.White);
+ Pen bluePen = new Pen (Color.Blue);
+
+ // We have a column starting at x=50 for Draw operations
+ // and another column starting at x=200 for Fill operations.
+ // Both the columns grow downwards.
+
+ // Column 1
+ Rectangle rect11 = new Rectangle (50, 0, 75, 75);
+ dc.DrawPie (bluePen, rect11, 10, 60);
+
+ Rectangle rect12 = new Rectangle (50,100, 75, 75);
+ dc.DrawPie (bluePen, rect12, 100, 75);
+
+ Rectangle rect13 = new Rectangle (50, 200, 75, 75);
+ dc.DrawPie (bluePen, rect13, 100, 400);
+
+ Rectangle rect14 = new Rectangle (50, 300, 75, 75);
+ dc.DrawPie (bluePen, rect14, 0, 0);
+
+ // Column 2
+ Rectangle rect21 = new Rectangle (200, 0, 75, 75);
+ dc.FillPie (yellowBrush, rect21, 0, 300);
+
+ Rectangle rect22 = new Rectangle (200, 100, 75, 75);
+ dc.FillPie (whiteBrush, rect22, 200, 30);
+
+ Rectangle rect23 = new Rectangle (200, 200, 75, 75);
+ dc.FillPie (whiteBrush, rect23, 200, 400);
+
+ Rectangle rect24 = new Rectangle (200, 300, 75, 75);
+ dc.FillPie (yellowBrush, rect24, 190, 300);
+
+ Rectangle rect25 = new Rectangle (200, 400, 75, 75);
+ dc.FillPie (whiteBrush, rect25, 200, 20);
+
+ Rectangle rect26 = new Rectangle (200, 500, 75, 75);
+ dc.FillPie (yellowBrush, rect26, 50, 0);
+
+ bmp.Save("fillpie.png", ImageFormat.Png);
+ }
+
+}
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing/region.cs b/mcs/class/System.Drawing/Samples/System.Drawing/region.cs
new file mode 100644
index 00000000000..61194092898
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/System.Drawing/region.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+
+//
+// Dumps an empty region
+//
+
+namespace MyFormProject
+{
+
+ class MainForm
+ {
+ public MainForm()
+ {
+
+ }
+
+ public static void Main(string[] args)
+ {
+ Region region = new Region ();
+
+ RectangleF[] rects = region.GetRegionScans (new Matrix ());
+
+ for (int i = 0; i < rects.Length; i++)
+ Console.WriteLine ("{0}", rects [i]);
+ }
+ }
+
+}
diff --git a/mcs/class/System.Drawing/Samples/run-samples.sh b/mcs/class/System.Drawing/Samples/run-samples.sh
new file mode 100755
index 00000000000..3f8af55f0ce
--- /dev/null
+++ b/mcs/class/System.Drawing/Samples/run-samples.sh
@@ -0,0 +1,148 @@
+#!/bin/sh
+################## System.Drawing: run-samples.sh #######################
+# #
+# This script compiles and runs samples from each directory in #
+# System.Drawing.Samples directory. Compiled exes and output #
+# images, if any, are saved to respective directories. #
+# Compile time logs are saved to compile-log.txt and runtime logs are #
+# saved to runtime-log.txt. Both log files are saved at the same #
+# location where this script is run. #
+# #
+# Following are the two ways to run this script, #
+# $ run-samples.sh #
+# OR #
+# $ run-samples.sh [option] #
+# #
+# NOTE: Possible options are (m)ake, (c)lean, (r)un, (a)ll #
+# --run is default option, when no option is specified. #
+# Only one option can be specified at a time. #
+# -m, --make - compiles all the samples #
+# -c, --clean - deletes all the exes generated #
+# -r, --run - compiles and runs all the samples. [Default] #
+# -a, --all - runs all the samples and also cleans #
+# #
+# **** This script would hang, if any sample hangs!!! #
+# #
+# Authors: #
+# Sachin <skumar1@novell.com> #
+# Ravindra <rkumar@novell.com> #
+# #
+# Copyright (C) 2004, Novell, Inc. http://www.novell.com #
+# #
+#########################################################################
+
+# Prints the script usage
+print_usage ()
+{
+ echo "Usage: run-samples [option]"
+ echo "Only one option is processed at a time."
+ echo "Possible options are: (m)ake, (c)lean, (r)un, (a)ll"
+ echo " -m, --make: Just compiles all the samples."
+ echo " -c, --clean: Just removes all the exes."
+ echo " -r, --run: makes and runs all the samples. [Default]"
+ echo " -a, --all: same as run and clean combined."
+ echo " --run option is assumed, if no option is specified."
+ exit 1
+}
+
+# Compiles all the samples
+compile ()
+{
+ echo === Compiling samples in $dir ===
+
+ for src in *.cs
+ do
+ echo " $src"
+ echo -n " $src:: " >> $CLOG
+ $MCS $COMPILE_OPS $src >> $CLOG 2>&1
+ done
+}
+
+# Deletes all the exes
+clean ()
+{
+ echo === Cleaning $dir ===
+ rm *.exe
+}
+
+# Compiles and runs all the samples
+run ()
+{
+ compile
+ echo === Running samples in $dir ===
+ for exe in *.exe
+ do
+ echo " $exe"
+ echo >> $RLOG
+ echo "$dir: $exe :: " >> $RLOG
+ echo >> $RLOG
+ $MONO $RUN_OPS $exe >> $RLOG 2>&1
+ done
+}
+
+# Compliles, runs and deletes all the exes
+all ()
+{
+ run
+ clean
+}
+
+# Environment setup
+
+ROOT=$PWD
+CLOG=$ROOT/compile-log.txt
+RLOG=$ROOT/runtime-log.txt
+MCS=mcs
+MONO=mono
+LIB=System.Drawing
+COMPILE_OPS="-g -r:$LIB"
+RUN_OPS=--debug
+
+# Uncomment the following line, if you are running this script on MS
+#MSNet=yes
+
+# We don't process more than one command line arguments
+if [ $# -gt 1 ]; then
+ print_usage
+fi
+
+# Default option is run, if no command line argument is present
+if [ -z $1 ]; then
+ arg=--run
+else
+ arg=$1
+fi
+
+# Creates the log files
+echo '*** LOG FILE for compile-time messages for System.Drawing Samples ***' > $CLOG
+echo '*** LOG FILE for run-time output messages for System.Drawing Samples ***' > $RLOG
+
+# All directories are processed under Samples.
+for dir in `ls -d System.Drawing*`
+ do
+ echo >> $CLOG
+ echo ===== $dir ===== >> $CLOG
+
+ echo >> $RLOG
+ echo ===== $dir ===== >> $RLOG
+
+ # Change dir if it exists
+ if [ -d $ROOT/$dir ]; then
+ cd $ROOT/$dir
+ case $arg in
+ "-m") compile ;;
+ "--make") compile ;;
+ "-r") run ;;
+ "--run") run ;;
+ "-a") all ;;
+ "--all") all ;;
+ "-c") clean ;;
+ "--clean") clean ;;
+ *) print_usage ;;
+ esac
+ cd ..
+ else
+ echo "$dir not found." >> $CLOG
+ echo "$dir not found." >> $RLOG
+ fi
+done
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/CategoryNameCollection.cs b/mcs/class/System.Drawing/System.Drawing.Design/CategoryNameCollection.cs
new file mode 100644
index 00000000000..a2754641c76
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/CategoryNameCollection.cs
@@ -0,0 +1,79 @@
+//
+// System.Drawing.Design.CategoryNameCollection.cs
+//
+// Authors:
+// Alejandro Sánchez Acosta
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections;
+using System.Security.Permissions;
+
+namespace System.Drawing.Design
+{
+ [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
+ public sealed class CategoryNameCollection : ReadOnlyCollectionBase
+ {
+
+ public CategoryNameCollection (CategoryNameCollection value)
+ {
+ if (value == null)
+ throw new ArgumentNullException ("value");
+ InnerList.AddRange (value);
+ }
+
+ public CategoryNameCollection (string[] value)
+ {
+ if (value == null)
+ throw new ArgumentNullException ("value");
+ InnerList.AddRange (value);
+ }
+
+ public string this[int index] {
+ get {
+ return (string) InnerList[index];
+ }
+ }
+
+ public bool Contains (string value)
+ {
+ return InnerList.Contains (value);
+ }
+
+ public void CopyTo (string[] array, int index)
+ {
+ InnerList.CopyTo (array, index);
+ }
+
+ public int IndexOf (string value)
+ {
+ return InnerList.IndexOf (value);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ChangeLog b/mcs/class/System.Drawing/System.Drawing.Design/ChangeLog
new file mode 100644
index 00000000000..f462303c333
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/ChangeLog
@@ -0,0 +1,91 @@
+2005-12-05 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * ToolboxItem.cs: Add new methods and properties for .Net and
+ also moved to an internal properties hashtable implementation
+
+ * IToolboxItemProvider.cs: New .Net 2.0 interface
+
+2005-09-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * CategoryNameCollection.cs: Added LinkDemand for Unrestricted
+ permissions. Added null checks in constructors.
+ * PaintValueEventArgs.cs: Added LinkDemand and InheritanceDemand for
+ Unrestricted permissions. Added null checks in constructor.
+ * PropertyValueItem.cs: Added LinkDemand and InheritanceDemand for
+ Unrestricted permissions. Added null checks in constructor.
+ * ToolboxComponentsCreatedEventArgs.cs: Added LinkDemand and
+ InheritanceDemand for Unrestricted permissions.
+ * ToolboxComponentsCreatingEventArgs.cs: Added LinkDemand and
+ InheritanceDemand for Unrestricted permissions.
+ * ToolboxItem.cs: Added LinkDemand and InheritanceDemand for
+ Unrestricted permissions.
+ * ToolboxItemCollection.cs: Added LinkDemand for Unrestricted
+ permissions.
+ * UITypeEditor.cs: Added LinkDemand and InheritanceDemand for
+ Unrestricted permissions.
+
+2005-08-24 Michael Hutchinson <m.j.hutchinson@gmail.com>
+
+ * ToolboxItem.cs: Implemented retrieving item's bitmap
+
+2005-08-09 Michael Hutchinson <m.j.hutchinson@gmail.com>
+
+ * ToolboxItemCollection.cs: Call base constructor
+ * ToolboxItem: Implemented CreateComponentsCore, GetType, Initialize
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * UITypeEditor.cs: Added TARGET_JVM support
+
+2003-06-30 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ToolboxItem.cs: Added serialization/deserialization support
+
+2003-06-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * CategoryNameCollection.cs
+ * ToolboxItemCollection.cs: Implemented
+
+ * PropertyValueItem.cs: Implemented
+ * IDesignerHost.cs: Deleted (not defined in this namespace)
+
+ * IToolboxService.cs: Fixed missing imports, added missing interface declarations
+ * ToolboxComponentsCreatingEventArgs.cs: Fixed missing imports
+
+ * ToolboxItem.cs: Fixed missing imports, Partially implemented
+
+ * UITypeEditor.cs: Implemented
+
+ * UITypeEditorEditStyle.cs: Fixed incorrect values
+
+2003-03-31 Alan Tam <Tam@SiuLung.com>
+
+ * UITypeEditor.cs: Added
+ * PaintValueEventArgs.cs: Fixed typo in namespace
+
+2002-12-01 Alejandro Sánchez Acosta <raciel@es.gnu.org>
+
+ * PaintValueEventArgs.cs,
+ ToolboxComponentsCreatingEventArgs.cs,
+ PropertyValueItem.cs,
+ ToolboxComponentsCreatingEventHandler.cs
+ IDesignerHost.cs,
+ ToolboxItemCreatorCallback.cs,
+ ToolboxItem.cs,
+ ToolboxComponentsCreatedEventArgs.cs
+ UITypeEditorEditStyle.cs,
+ IToolboxUser.cs
+ ToolboxComponentsCreatedEventHandler.cs
+ CategoryNameCollection.cs : Added
+
+2002-11-20 Alejandro Sánchez Acosta <raciel@es.gnu.org>
+
+ * IPropertyValueUIService.cs: Added
+
+ * PropertyValueItem.cs: Added
+
+ * PropertyValueUIHandler.cs: Added
+
+ * PropertyValueUIItemInvokeHandler.cs: Added
+
+ * ChangeLog: new file.
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/IPropertyValueUIService.cs b/mcs/class/System.Drawing/System.Drawing.Design/IPropertyValueUIService.cs
new file mode 100644
index 00000000000..9cb50b8548d
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/IPropertyValueUIService.cs
@@ -0,0 +1,54 @@
+// System.Drawing.Design.IPropertyValueUIService.cs
+//
+// Author:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+//
+// (C) Alejandro Sánchez Acosta
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Drawing.Design
+{
+ public interface IPropertyValueUIService
+ {
+
+ #region Methods
+ void AddPropertyValueUIHandler (PropertyValueUIHandler newHandler);
+ PropertyValueUIItem[] GetPropertyUIValueItems (ITypeDescriptorContext context, PropertyDescriptor propDesc);
+
+ void NotifyPropertyValueUIItemsChanged ();
+
+ void RemovePropertyValueUIHandler (PropertyValueUIHandler newHandler);
+ #endregion Methods
+
+ #region Events
+ event EventHandler PropertyUIValueItemsChanged;
+ #endregion Events
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/IToolboxItemProvider.cs b/mcs/class/System.Drawing/System.Drawing.Design/IToolboxItemProvider.cs
new file mode 100644
index 00000000000..6f50e5a954e
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/IToolboxItemProvider.cs
@@ -0,0 +1,40 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+//
+// Jordi Mas i Hernandez <jordimash@gmail.com>
+//
+//
+
+#if NET_2_0
+
+namespace System.Drawing.Design
+{
+ public interface IToolboxItemProvider
+ {
+ ToolboxItemCollection Items { get; }
+ }
+}
+
+#endif
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/IToolboxService.cs b/mcs/class/System.Drawing/System.Drawing.Design/IToolboxService.cs
new file mode 100644
index 00000000000..ba20fc7f0a7
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/IToolboxService.cs
@@ -0,0 +1,103 @@
+//
+// System.Drawing.Design.IToolboxService.cs
+//
+// Authors:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections;
+using System.ComponentModel.Design;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Design
+{
+ [Guid("4BACD258-DE64-4048-BC4E-FEDBEF9ACB76"),
+ InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IToolboxService
+ {
+ CategoryNameCollection CategoryNames {get;}
+
+ string SelectedCategory {get; set;}
+
+ void AddCreator (ToolboxItemCreatorCallback creator, string format);
+
+ void AddCreator (ToolboxItemCreatorCallback creator, string format, IDesignerHost host);
+
+ void AddLinkedToolboxItem (ToolboxItem toolboxItem, IDesignerHost host);
+
+ void AddLinkedToolboxItem (ToolboxItem toolboxItem, string category, IDesignerHost host);
+
+ void AddToolboxItem (ToolboxItem toolboxItem, String category);
+
+ void AddToolboxItem (ToolboxItem toolboxItem);
+
+ ToolboxItem DeserializeToolboxItem (object serializedObject);
+
+ ToolboxItem DeserializeToolboxItem (object serializedObject, IDesignerHost host);
+
+ ToolboxItem GetSelectedToolboxItem ();
+
+ ToolboxItem GetSelectedToolboxItem (IDesignerHost host);
+
+ ToolboxItemCollection GetToolboxItems ();
+
+ ToolboxItemCollection GetToolboxItems (IDesignerHost host);
+
+ ToolboxItemCollection GetToolboxItems (String category);
+
+ ToolboxItemCollection GetToolboxItems (String category, IDesignerHost host);
+
+ bool IsSupported (object serializedObject, ICollection filterAttributes);
+
+ bool IsSupported (object serializedObject, IDesignerHost host);
+
+ bool IsToolboxItem (object serializedObject);
+
+ bool IsToolboxItem (object serializedObject, IDesignerHost host);
+
+ void Refresh();
+
+ void RemoveCreator (string format);
+
+ void RemoveCreator (string format, IDesignerHost host);
+
+ void RemoveToolboxItem (ToolboxItem toolboxItem);
+
+ void RemoveToolboxItem (ToolboxItem toolboxItem, string category);
+
+ void SelectedToolboxItemUsed ();
+
+ object SerializeToolboxItem (ToolboxItem toolboxItem);
+
+ bool SetCursor ();
+
+ void SetSelectedToolboxItem (ToolboxItem toolboxItem);
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/IToolboxUser.cs b/mcs/class/System.Drawing/System.Drawing.Design/IToolboxUser.cs
new file mode 100644
index 00000000000..267cdf478b1
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/IToolboxUser.cs
@@ -0,0 +1,40 @@
+// System.Drawing.Design.IToolboxUser.cs
+//
+// Author:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+//
+// (C) Alejandro Sánchez Acosta
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Drawing.Design
+{
+ public interface IToolboxUser
+ {
+ bool GetToolSupported (ToolboxItem tool);
+
+ void ToolPicked (ToolboxItem tool);
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/PaintValueEventArgs.cs b/mcs/class/System.Drawing/System.Drawing.Design/PaintValueEventArgs.cs
new file mode 100644
index 00000000000..9c3ba7dd8d6
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/PaintValueEventArgs.cs
@@ -0,0 +1,85 @@
+// System.Drawing.Design.PaintvalueEventArgs.cs
+//
+// Author:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+//
+// (C) Alejandro Sánchez Acosta
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.ComponentModel;
+using System.Security.Permissions;
+
+namespace System.Drawing.Design
+{
+ [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
+ [PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
+ public class PaintValueEventArgs : EventArgs
+ {
+ private ITypeDescriptorContext context;
+ private object value;
+ private Graphics graphics;
+ private Rectangle bounds;
+
+ public PaintValueEventArgs(ITypeDescriptorContext context, object value, Graphics graphics, Rectangle bounds)
+ {
+ if (graphics == null)
+ throw new ArgumentNullException ("graphics");
+ this.context = context;
+ this.value = value;
+ this.graphics = graphics;
+ this.bounds = bounds;
+ }
+
+ public Rectangle Bounds
+ {
+ get {
+ return bounds;
+ }
+ }
+
+ public ITypeDescriptorContext Context
+ {
+ get {
+ return context;
+ }
+ }
+
+ public Graphics Graphics
+ {
+ get {
+ return graphics;
+ }
+ }
+
+ public object Value
+ {
+ get {
+ return value;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueItem.cs b/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueItem.cs
new file mode 100644
index 00000000000..b9eaaf6fe0d
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueItem.cs
@@ -0,0 +1,89 @@
+//
+// System.Drawing.Design.PropertyValueItem.cs
+//
+// Authors:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Security.Permissions;
+
+namespace System.Drawing.Design
+{
+ [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
+ [PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
+ public class PropertyValueUIItem
+ {
+
+ private Image uiItemImage;
+ private PropertyValueUIItemInvokeHandler handler;
+ private string tooltip;
+
+ public PropertyValueUIItem (Image uiItemImage,
+ PropertyValueUIItemInvokeHandler handler, string tooltip)
+ {
+ if (uiItemImage == null)
+ throw new ArgumentNullException ("uiItemImage");
+ if (handler == null)
+ throw new ArgumentNullException ("handler");
+ this.uiItemImage = uiItemImage;
+ this.handler = handler;
+ this.tooltip = tooltip;
+ }
+
+ public virtual Image Image
+ {
+ get
+ {
+ return uiItemImage;
+ }
+ }
+
+ public virtual PropertyValueUIItemInvokeHandler InvokeHandler
+ {
+ get
+ {
+ return handler;
+ }
+ }
+
+ public virtual string ToolTip
+ {
+ get
+ {
+ return tooltip;
+ }
+ }
+
+ public virtual void Reset()
+ {
+ // To be overriden in child classes
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIHandler.cs b/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIHandler.cs
new file mode 100644
index 00000000000..38f37db43b3
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIHandler.cs
@@ -0,0 +1,42 @@
+// System.Drawing.Design.PropertyValueUIHandler.cs
+//
+// Author:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+//
+// (C) Alejandro Sánchez Acosta
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace System.Drawing.Design
+{
+
+ [Serializable]
+ public delegate void PropertyValueUIHandler (ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList);
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIItemInvokeHandler.cs b/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIItemInvokeHandler.cs
new file mode 100644
index 00000000000..7b73cc2394e
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIItemInvokeHandler.cs
@@ -0,0 +1,42 @@
+// System.Drawing.Design.PropertyValueUIItemInvokeHandler.cs
+//
+// Author:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+//
+// (C) Alejandro Sánchez Acosta
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Drawing.Design
+{
+ [Serializable]
+ public delegate void PropertyValueUIItemInvokeHandler (
+ ITypeDescriptorContext context,
+ PropertyDescriptor descriptor,
+ PropertyValueUIItem invokedItem);
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventArgs.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventArgs.cs
new file mode 100644
index 00000000000..65790a10768
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventArgs.cs
@@ -0,0 +1,54 @@
+// System.Drawing.Design.ToolboxComponentsCreatedEventArgs.cs
+//
+// Author:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+//
+// (C) Alejandro Sánchez Acosta
+//
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.ComponentModel;
+using System.Security.Permissions;
+
+namespace System.Drawing.Design
+{
+ [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
+ [PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
+ public class ToolboxComponentsCreatedEventArgs : EventArgs
+ {
+ private IComponent[] components;
+
+ public ToolboxComponentsCreatedEventArgs (IComponent[] components) {
+ this.components = components;
+ }
+
+ public IComponent[] Components {
+ get {
+ return components;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventHandler.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventHandler.cs
new file mode 100644
index 00000000000..83ff75efaa1
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventHandler.cs
@@ -0,0 +1,37 @@
+// System.Drawing.Design.IDesignerHost.cs
+//
+// Author:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+//
+// (C) Alejandro Sánchez Acosta
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Drawing.Design
+{
+ [Serializable]
+ public delegate void ToolboxComponentsCreatedEventHandler (object sender, ToolboxComponentsCreatedEventArgs e);
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventArgs.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventArgs.cs
new file mode 100644
index 00000000000..cd7c35346de
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventArgs.cs
@@ -0,0 +1,57 @@
+//
+// System.Drawing.Design.ToolboxComponentsCreatingEventArgs.cs
+//
+// Author:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+//
+// (C) Alejandro Sánchez Acosta
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.ComponentModel.Design;
+using System.Security.Permissions;
+
+namespace System.Drawing.Design
+{
+ [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
+ [PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
+ public class ToolboxComponentsCreatingEventArgs : EventArgs
+ {
+ private IDesignerHost host;
+
+ public ToolboxComponentsCreatingEventArgs (IDesignerHost host)
+ {
+ this.host = host;
+ }
+
+ public IDesignerHost DesignerHost {
+ get {
+ return host;
+ }
+ }
+ }
+}
+
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventHandler.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventHandler.cs
new file mode 100644
index 00000000000..11761f8861c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventHandler.cs
@@ -0,0 +1,36 @@
+// System.Drawing.Design.ToolboxComponentsCreatingEventHandler.cs
+//
+// Author:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+//
+// (C) Alejandro Sánchez Acosta
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Drawing.Design
+{
+ [Serializable]
+ public delegate void ToolboxComponentsCreatingEventHandler (object sender, ToolboxComponentsCreatingEventArgs e);
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItem.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItem.cs
new file mode 100644
index 00000000000..ce9d388b14b
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItem.cs
@@ -0,0 +1,351 @@
+//
+// System.Drawing.Design.ToolboxItem.cs
+//
+// Authors:
+// Alejandro Sánchez Acosta
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Jordi Mas i Hernandez, jordimash@gmail.com
+//
+// (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.Security.Permissions;
+
+namespace System.Drawing.Design
+{
+ [Serializable]
+ [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
+ [PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
+ public class ToolboxItem : ISerializable
+ {
+ private bool locked = false;
+ private ICollection filter = new ToolboxItemFilterAttribute[0];
+ private Hashtable properties = new Hashtable ();
+
+ public ToolboxItem() {
+ }
+
+ public ToolboxItem (Type toolType) {
+ Initialize (toolType);
+ }
+
+ public AssemblyName AssemblyName {
+ get {
+ return (AssemblyName) properties["AssemblyName"];
+ }
+
+ set {
+ CheckUnlocked ();
+ properties["AssemblyName"] = value;
+ }
+ }
+
+ public Bitmap Bitmap {
+ get {
+ return (Bitmap) properties["Bitmap"];
+ }
+
+ set {
+ CheckUnlocked ();
+ properties["Bitmap"] = value;
+ }
+ }
+
+ public string DisplayName {
+ get {
+ return (string) properties["DisplayName"];
+ }
+
+ set {
+ CheckUnlocked ();
+ properties["DisplayName"] = value;
+ }
+ }
+
+ public ICollection Filter {
+ get {
+ return filter;
+ }
+
+ set {
+ CheckUnlocked ();
+ filter = value;
+ }
+ }
+#if NET_2_0
+ public virtual bool Locked {
+#else
+ protected bool Locked {
+#endif
+ get {
+ return locked;
+ }
+ }
+
+ public string TypeName {
+ get {
+ return (string) properties["TypeName"];
+ }
+
+ set {
+ CheckUnlocked ();
+ properties["TypeName"] = value;
+ }
+ }
+#if NET_2_0
+ public string Company {
+ get { return (string) properties["Company"]; }
+ set { properties["Company"] = value; }
+ }
+
+ public virtual string ComponentType {
+ get { return "DotNET_ComponentType"; }
+ }
+
+ public AssemblyName[] DependentAssemblies {
+ get { return (AssemblyName[]) properties["DependentAssemblies"]; }
+ set { properties["DependentAssemblies"] = value; }
+ }
+
+ public string Description {
+ get { return (string) properties["Description"]; }
+ set { properties["Description"] = value; }
+ }
+
+ public bool IsTransient {
+ get { return (bool) properties["IsTransient"]; }
+ set { properties["IsTransient"] = value; }
+ }
+
+ public IDictionary Properties {
+ get { return properties; }
+ }
+
+ public virtual string Version {
+ get { return string.Empty; }
+ }
+
+#endif
+ protected void CheckUnlocked ()
+ {
+ if (locked)
+ throw new InvalidOperationException ("The ToolboxItem is locked");
+ }
+
+ public IComponent[] CreateComponents ()
+ {
+ return CreateComponents (null);
+ }
+
+ public IComponent[] CreateComponents (IDesignerHost host)
+ {
+ OnComponentsCreating (new ToolboxComponentsCreatingEventArgs (host));
+ IComponent[] Comp = CreateComponentsCore (host);
+ OnComponentsCreated ( new ToolboxComponentsCreatedEventArgs (Comp));
+ return Comp;
+ }
+
+ [MonoTODO ("get error handling logic correct")]
+ protected virtual IComponent[] CreateComponentsCore (IDesignerHost host)
+ {
+ if (host == null)
+ throw new ArgumentNullException("host");
+
+ OnComponentsCreating(new ToolboxComponentsCreatingEventArgs(host));
+
+ IComponent[] components;
+ Type type = GetType(host, AssemblyName, TypeName, true);
+ if (type == null)
+ components = new IComponent[] { };
+ else
+ components = new IComponent[] { host.CreateComponent(type) };
+
+ OnComponentsCreated(new ToolboxComponentsCreatedEventArgs(components));
+ return components;
+ }
+
+#if NET_2_0
+ [MonoTODO]
+ public IComponent[] CreateComponents (IDesignerHost host, IDictionary defaultValues)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Type GetType (IDesignerHost host)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual object FilterPropertyValue(string propertyName, object value)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
+ protected virtual void Deserialize (SerializationInfo info, StreamingContext context)
+ {
+ AssemblyName = (AssemblyName)info.GetValue ("AssemblyName", typeof (AssemblyName));
+ Bitmap = (Bitmap)info.GetValue ("Bitmap", typeof (Bitmap));
+ filter = (ICollection)info.GetValue ("Filter", typeof (ICollection));
+ DisplayName = info.GetString ("DisplayName");
+ locked = info.GetBoolean ("Locked");
+ TypeName = info.GetString ("TypeName");
+ }
+
+ public override bool Equals (object obj)
+ {
+ // FIXME: too harsh??
+ if (!(obj is ToolboxItem))
+ return false;
+ if (obj == this)
+ return true;
+ return ((ToolboxItem) obj).AssemblyName.Equals (AssemblyName) &&
+ ((ToolboxItem) obj).Locked.Equals (locked) &&
+ ((ToolboxItem) obj).TypeName.Equals (TypeName) &&
+ ((ToolboxItem) obj).DisplayName.Equals (DisplayName) &&
+ ((ToolboxItem) obj).Bitmap.Equals (Bitmap);
+ }
+
+ public override int GetHashCode ()
+ {
+ // FIXME: other algorithm?
+ return string.Concat (TypeName, DisplayName).GetHashCode ();
+ }
+
+ [MonoTODO]
+ protected virtual Type GetType (IDesignerHost host, AssemblyName assemblyName, string typeName, bool reference)
+ {
+ if (host == null)
+ throw new ArgumentNullException("host");
+
+ //get ITypeResolutionService from host, as we have no other IServiceProvider here
+ ITypeResolutionService typeRes = host.GetService(typeof(ITypeResolutionService)) as ITypeResolutionService;
+ if (typeRes == null)
+ throw new Exception("Host does not provide an ITypeResolutionService");
+
+ //TODO: Using Assembly loader to throw errors. Silent fail and return null?
+ Assembly assembly = typeRes.GetAssembly(assemblyName, true);
+ if (reference)
+ typeRes.ReferenceAssembly(assemblyName);
+ return typeRes.GetType(typeName, true);
+ }
+
+ [MonoTODO ("Should we be returning empty bitmap, or null?")]
+ public virtual void Initialize (Type type)
+ {
+ AssemblyName = type.Assembly.GetName();
+ DisplayName = type.Name;
+ TypeName = type.FullName;
+
+ // seems to be a right place to create the bitmap
+ System.Drawing.Image image = null;
+ foreach (object attribute in type.GetCustomAttributes(true)) {
+ ToolboxBitmapAttribute tba = attribute as ToolboxBitmapAttribute;
+ if (tba != null) {
+ image = tba.GetImage (type);
+ break;
+ }
+ }
+ //fallback: check for image even if not attribute
+ if (image == null)
+ image = ToolboxBitmapAttribute.GetImageFromResource (type, null, false);
+
+ if (image != null) {
+ if (image is Bitmap)
+ Bitmap = (Bitmap) image;
+ else
+ Bitmap = new Bitmap (image);
+ }
+
+ filter = type.GetCustomAttributes (typeof (ToolboxItemFilterAttribute), true);
+ }
+
+ void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ Serialize (info, context);
+ }
+
+#if NET_2_0
+ public virtual void Lock ()
+#else
+ public void Lock ()
+#endif
+ {
+ locked = true;
+ }
+
+ protected virtual void OnComponentsCreated (ToolboxComponentsCreatedEventArgs args)
+ {
+ if (ComponentsCreated != null)
+ this.ComponentsCreated (this, args);
+ }
+
+ protected virtual void OnComponentsCreating (ToolboxComponentsCreatingEventArgs args)
+ {
+ if (ComponentsCreated != null)
+ this.ComponentsCreating (this, args);
+ }
+
+ protected virtual void Serialize (SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue ("AssemblyName", AssemblyName);
+ info.AddValue ("Bitmap", Bitmap);
+ info.AddValue ("Filter", filter);
+ info.AddValue ("DisplayName", DisplayName);
+ info.AddValue ("Locked", locked);
+ info.AddValue ("TypeName", TypeName);
+ }
+
+ public override string ToString()
+ {
+ return DisplayName;
+ }
+
+#if NET_2_0
+ protected void ValidatePropertyType (string propertyName, object value, Type expectedType, bool allowNull)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected virtual object ValidatePropertyValue (string propertyName, object value)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
+ public event ToolboxComponentsCreatedEventHandler ComponentsCreated;
+
+ public event ToolboxComponentsCreatingEventHandler ComponentsCreating;
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCollection.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCollection.cs
new file mode 100644
index 00000000000..dc76d7a48e2
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCollection.cs
@@ -0,0 +1,73 @@
+//
+// System.Drawing.Design.ToolboxItemCollection.cs
+//
+// Authors:
+// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Martin Willemoes Hansen
+// (C) 2003 Andreas Nahr
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections;
+using System.Security.Permissions;
+
+namespace System.Drawing.Design
+{
+ [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
+ public sealed class ToolboxItemCollection : ReadOnlyCollectionBase
+ {
+
+ public ToolboxItemCollection (ToolboxItem[] value) : base()
+ {
+ InnerList.AddRange (value);
+ }
+
+ public ToolboxItemCollection (ToolboxItemCollection value) : base()
+ {
+ InnerList.AddRange (value);
+ }
+
+ public ToolboxItem this [int index] {
+ get { return (ToolboxItem) InnerList[index]; }
+ }
+
+ public bool Contains (ToolboxItem value)
+ {
+ return InnerList.Contains (value);
+ }
+
+ public void CopyTo (ToolboxItem[] array, int index)
+ {
+ InnerList.CopyTo (array, index);
+ }
+
+ public int IndexOf (ToolboxItem value)
+ {
+ return InnerList.IndexOf (value);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCreatorCallback.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCreatorCallback.cs
new file mode 100644
index 00000000000..a814f643fe0
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCreatorCallback.cs
@@ -0,0 +1,38 @@
+// System.Drawing.Design.ToolboxItemCreatorCallback.cs
+//
+// Author:
+// Alejandro Sánchez Acosta <raciel@es.gnu.org>
+//
+// (C) Alejandro Sánchez Acosta
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Drawing.Design
+{
+ [Serializable]
+ public delegate ToolboxItem ToolboxItemCreatorCallback(
+ object serializedObject,
+ string format);
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditor.cs b/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditor.cs
new file mode 100644
index 00000000000..8c5ada85a07
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditor.cs
@@ -0,0 +1,89 @@
+//
+// System.Drawing.Design.UITypeEditor.cs
+//
+// Authors:
+// Alan Tam Siu Lung <Tam@SiuLung.com>
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Alan Tam Siu Lung <Tam@SiuLung.com>
+// (C) 2003 Andreas Nahr
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.ComponentModel;
+using System.Security.Permissions;
+
+namespace System.Drawing.Design
+{
+ [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
+ [PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
+ public class UITypeEditor
+ {
+
+ public UITypeEditor()
+ {
+ }
+
+ public virtual object EditValue (ITypeDescriptorContext context,
+ IServiceProvider provider, object value)
+ {
+ // We already stated that we can't edit ;)
+ return value;
+ }
+ public object EditValue(IServiceProvider provider, object value)
+ {
+ return EditValue (null, provider, value);
+ }
+ public virtual UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context)
+ {
+ return UITypeEditorEditStyle.None;
+ }
+ public UITypeEditorEditStyle GetEditStyle ()
+ {
+ return GetEditStyle (null);
+ }
+ public bool GetPaintValueSupported ()
+ {
+ return GetPaintValueSupported (null);
+ }
+ public virtual bool GetPaintValueSupported (ITypeDescriptorContext context)
+ {
+ return false;
+ }
+#if !TARGET_JVM
+ public void PaintValue (object value, Graphics canvas, Rectangle rectangle)
+ {
+ PaintValue (new PaintValueEventArgs (null, value, canvas, rectangle));
+ }
+ public virtual void PaintValue (PaintValueEventArgs e)
+ {
+ // LAMESPEC: Did not find info in the docs if this should do something here.
+ // Usually you would expect, that this class gets inherited and this overridden,
+ // but on the other hand the class is not abstract. Could never observe it did paint anything
+ return;
+ }
+#endif
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditorEditStyle.cs b/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditorEditStyle.cs
new file mode 100644
index 00000000000..97c4807e8bb
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditorEditStyle.cs
@@ -0,0 +1,38 @@
+//
+// System.Drawing.Design.UITypeEditorEditStyle.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Design
+{
+ public enum UITypeEditorEditStyle{
+ DropDown=3,
+ Modal=2,
+ None=1
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.cs
new file mode 100644
index 00000000000..497b578e5b4
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.cs
@@ -0,0 +1,122 @@
+//
+// System.Drawing.Drawing2D.AdjustableArrowCap.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002/3 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for AdjustableArrowCap.
+ /// </summary>
+ public sealed class AdjustableArrowCap : CustomLineCap
+ {
+ // Constructors
+
+ internal AdjustableArrowCap (IntPtr ptr) : base (ptr)
+ {
+ }
+
+ public AdjustableArrowCap (float width, float height) : this (width, height, true)
+ {
+ }
+
+ public AdjustableArrowCap (float width, float height, bool isFilled)
+ {
+ Status status = GDIPlus.GdipCreateAdjustableArrowCap (height, width, isFilled, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ // Public Properities
+
+ public bool Filled {
+ get {
+ bool isFilled;
+ Status status = GDIPlus.GdipGetAdjustableArrowCapFillState (nativeObject, out isFilled);
+ GDIPlus.CheckStatus (status);
+
+ return isFilled;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetAdjustableArrowCapFillState (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public float Width {
+ get {
+ float width;
+ Status status = GDIPlus.GdipGetAdjustableArrowCapWidth (nativeObject, out width);
+ GDIPlus.CheckStatus (status);
+
+ return width;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetAdjustableArrowCapWidth (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public float Height {
+ get {
+ float height;
+ Status status = GDIPlus.GdipGetAdjustableArrowCapHeight (nativeObject, out height);
+ GDIPlus.CheckStatus (status);
+
+ return height;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetAdjustableArrowCapHeight (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public float MiddleInset {
+ get {
+ float middleInset;
+ Status status = GDIPlus.GdipGetAdjustableArrowCapMiddleInset (nativeObject, out middleInset);
+ GDIPlus.CheckStatus (status);
+
+ return middleInset;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetAdjustableArrowCapMiddleInset (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.jvm.cs
new file mode 100755
index 00000000000..8e707cc74b0
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.jvm.cs
@@ -0,0 +1,102 @@
+//
+// System.Drawing.Drawing2D.AdjustableArrowCap.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002/3 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for AdjustableArrowCap.
+ /// </summary>
+ [MonoTODO]
+ public sealed class AdjustableArrowCap : CustomLineCap
+ {
+ // Constructors
+
+ public AdjustableArrowCap (float width, float height) : this (width, height, true)
+ {
+ }
+
+ [MonoTODO]
+ public AdjustableArrowCap (float width, float height, bool isFilled)
+ {
+ throw new NotImplementedException();
+ }
+
+ // Public Properities
+ [MonoTODO]
+ public bool Filled {
+ get {
+ throw new NotImplementedException();
+ }
+
+ set {
+ throw new NotImplementedException();
+ }
+ }
+
+ [MonoTODO]
+ public float Width {
+ get {
+ throw new NotImplementedException();
+ }
+
+ set {
+ throw new NotImplementedException();
+ }
+ }
+
+ [MonoTODO]
+ public float Height {
+ get {
+ throw new NotImplementedException();
+ }
+
+ set {
+ throw new NotImplementedException();
+ }
+ }
+
+ [MonoTODO]
+ public float MiddleInset {
+ get {
+ throw new NotImplementedException();
+ }
+
+ set {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs
new file mode 100644
index 00000000000..a3cb2e9af5a
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs
@@ -0,0 +1,81 @@
+//
+// System.Drawing.Drawing2D.Blend.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) 2002/3 Ximian, Inc. http://www.ximian.com
+// (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for Blend.
+ /// </summary>
+#if TARGET_JVM
+ [MonoTODO]
+#endif
+ public sealed class Blend
+ {
+ private float [] positions;
+ private float [] factors;
+
+ public Blend ()
+ {
+ positions = new float [1];
+ factors = new float [1];
+ }
+
+ public Blend (int count)
+ {
+ positions = new float [count];
+ factors = new float [count];
+ }
+
+ public float [] Factors {
+ get {
+ return factors;
+ }
+
+ set {
+ factors = value;
+ }
+ }
+
+ public float [] Positions {
+ get {
+ return positions;
+ }
+
+ set {
+ positions = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog
new file mode 100644
index 00000000000..cb26a5c16ac
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog
@@ -0,0 +1,553 @@
+2006-01-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * GraphicsPath.cs: Updated TODO description on GetBounds as it's now
+ only missing support for Pens (when used with libgidplus).
+
+2006-01-13 Sebastien Pouliot <sebastien@ximian.com>
+
+ * GraphicsPath.cs: Added more parameter checks to methods (to match
+ unit tests). Added descriptions to TODOs.
+ * PathData.cs: Don't clone the arrays! Removed unused internal
+ properties.
+
+2006-01-12 Sebastien Pouliot <sebastien@ximian.com>
+
+ * GraphicsPath.cs: Throw an ArgumentException if either PathPoints or
+ PathTypes properties are empty (0 length). Note that PathData property
+ still works in that case.
+ * PathData.cs: Don't clone empty arrays (results in NRE).
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.jvm.cs: AddString support.
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * ExtendedGeneralPath.jvm.cs: restore quadTo as curveTo affects quality
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * PathData.cs: fixing access modifiers.
+
+2005-10-31 Konstantin Triger <kostat@mainsoft.com>
+
+ * ExtendedGeneralPath.jvm.cs: forward quadTo to curveTo
+
+2005-10-23 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * GraphicsState.jvm.cs: fixed ResetState, RestoreBaseClip
+
+2005-10-19 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * GraphicsPath.jvm.cs: fixed FillMode, ConvertArcAngle, AddPath,
+ CloseFigure
+
+2005-10-19 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * LinearGradientBrush.jvm.cs: fixed clone(), SetBlendTriangularShape,
+ LinearColors, InterpolationColors, GetMedianeEnclosingRect, Init, NativeObject
+ * PathGradientBrush.jvm.cs: fixed clone()
+
+2005-10-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Matrix.cs: Call GC.SuppressFinalize with 'this' instead of 'true'
+
+2005-09-26 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * PathGradientBrush.jvm.cs: implemetated transform, WrapMode, ctors
+ * HatchBrush.jvm.cs: fallback to solid brush
+
+2005-09-14 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.jvm.cs: fix drawing arcs for angles >= 360
+
+2005-09-14 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsState.jvm.cs: container
+
+2005-09-11 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsState.jvm.cs: fixing visible window for containers
+
+2005-09-07 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.jvm.cs: correct angle to compute the quarter
+
+2005-09-07 Konstantin Triger <kostat@mainsoft.com>
+
+ * Matrix.jvm.cs: Fix copy order in CopyTo
+
+2005-09-07 Boris Kirzner <borisk@mainsoft.com>
+
+ * ExtendedGeneralPath.jvm.cs: Cache PathData and GeneralPath.
+ * PathData.cs: always return cloned points and types. Use internals
+ without clone for internal processing.
+
+2005-09-07 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * LinearGradientBrush.jvm.cs: FIxed transform methods
+ * Matrix.jvm.cs: Added CopyTo(), fixed Invert()
+
+2005-09-06 Boris Kirzner <borisk@mainsoft.com>
+
+ * ExtendedGeneralPath.jvm.cs: Imported functionality from GraphicsPAth.
+ Added copyright.
+ * GeneralPathIterator.jvm.cs: Added copyright.
+ * GraphicsPath.jvm.cs: Implemented methods. Some functionality moved
+ to ExtendedGeneralPath. Added copyright.
+ * GraphicsPathIterator.jvm.cs: Implemented.
+
+2005-09-06 Konstantin Triger <kostat@mainsoft.com>
+
+ * Matrix.jvm.cs: fix scale, added static IdentityMatrix
+ * GraphicsState.jvm.cs, GraphicsContainer.jvm.cs: fix
+ containers implementation
+
+2005-08-30 Boris Kirzner <borisk@mainsoft.com>
+
+ * Matrix.jvm.cs: Bug fix
+
+2005-08-30 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * LinearGradientBrush.jvm.cs: Refactoring, bug fix
+ * GraphicsState.jvm.cs: fixed SaveState, ResetState
+
+2005-08-30 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.jvm.cs: use correct object in Widen
+
+2005-08-28 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Added: GraphicsContainer.jvm.cs
+ * Added: GraphicsState.jvm.cs
+
+2005-08-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Matrix.jvm.cs: Refactoring
+
+2005-08-10 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.jvm.cs: Implemented DrawClosedCurve.
+ * ExtendedGeneralPath.jvm.cs: cleanup.
+
+2005-08-10 Boris Kirzner <borisk@mainsoft.com>
+ * ExtendedGeneralPath.jvm.cs: Added new class. Extends java GeneralPath
+ functionality.
+ * GeneralPathIterator.jvm.cs: Added new class. Implements java PathIterator.
+ * GraphicsPath.jvm.cs:
+ - Redefined JPI enums so their values are defined in the single place.
+ - NativeObject is now of type ExtendedGeneralPath.
+ - Implemented missing constructors.
+ - Implemented PathData and PointCount.
+ - Decision about connecting to previous figure is now handled in
+ ExtendedGeneralPath.
+ - Reimplemented AddRectangle to obtain right number of points.
+ - Reimplemented GetLastPoint using ExtendedGeneralPath.
+ - CloseAllFigures must close path at the end.
+ - Fixed StartFigure.
+
+2005-08-10 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.jvm.cs: implemented GraphicsPath.Widen
+
+2005-08-10 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.jvm.cs: fix default curve tension.
+
+2005-08-0 9Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.jvm.cs, DashStyle.cs: refactoring
+
+2005-08-08 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.cs: Implemented AddBeziers
+
+2005-08-08 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * GraphicsPath.jvm.cs: Fixed AddPolygon methods
+
+2005-08-08 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.cs: Fix AddLines
+
+2005-08-08 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.cs: Fix AddArc/AddPie
+
+2005-08-08 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * GraphicsPath.jvm.cs: Fixed AddLines methods
+
+2005-08-07 Konstantin Triger <kostat@mainsoft.com>
+
+ * GraphicsPath.cs: Fix AddCurve implementation and cosmetic changes.
+
+2005-08-07 Andrew Skiba <andrews@mainsoft.com>
+
+ * GraphicsPath.cs: BasicShape as a base class and cosmetic changes
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * DashStyle.cs: TARGET_JVM - add internal dash attribs arrays
+ * AdjustableArrowCap.jvm.cs, CustomLineCap.jvm.cs, GraphicsPath.jvm.cs,
+ GraphicsPathIterator.jvm.cs, HatchBrush.jvm.cs, LinearGradientBrush.jvm.cs,
+ Matrix.jvm.cs, PathGradientBrush.jvm.cs: added TARGET_JVM implementation of
+ these classes.
+
+2005-03-15 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * GraphicsState.cs: should only contain the nativeState cookie
+ * Matrix.cs: Fixes Dispose method to allow to be called multiple times
+
+2005-01-02 Geoff Norton <gnorton@customerdna.com>
+
+ * GraphicsPath.cs: Fixed the AddPoints methods. Fixes bug #70916
+
+2004-07-21 Ravindra <rkumar@novell.com>
+
+ * GraphicsPath.cs: Implemented Dispose method and added error
+ checking in constructors.
+ * GraphicsPathIterator.cs: Fixed CopyData and Enumerate methods.
+
+2004-07-16 Ravindra <rkumar@novell.com>
+
+ * GraphicsPathIterator.cs: New implementation using GDI+ APIs.
+ This change makes this class fit into the rest of the design well
+ and also it takes care of a scenario when path gets modified. Old
+ implementation was not taking care of this.
+
+2004-07-15 Ravindra <rkumar@novell.com>
+
+ * GraphicsPath.cs: Implemented PathData property and some formatting.
+
+2004-07-15 Ravindra <rkumar@novell.com>
+
+ * CombineMode.cs, CompositingMode.cs, CompositingQuality.cs,
+ GraphicsPath.cs, CoordinateSpace.cs, DashCap.cs, DashStyle.cs,
+ FillMode.cs, FlushIntention.cs, GraphicsPath.cs, GraphicsState.cs,
+ InterpolationMode.cs, LineCap.cs, LineJoin.cs, LinearGradientMode.cs,
+ Matrix.cs, MatrixOrder.cs, PathPointType.cs, PenAlignment.cs,
+ PenType.cs, PixelOffsetMode.cs, QualityMode.cs, SmoothingMode.cs,
+ WarpMode.cs, WrapMode.cs: Changed format dos2unix.
+
+ * GraphicsContainer.cs, GraphicsPathIterator.cs, PathData.cs,
+ RegionData.cs: Changed format dos2unix and changed instance variables'
+ access default/internal to private.
+
+2004-07-13 Ravindra <rkumar@novell.com>
+
+ * PathGradientBrush.cs: Removed all the private variables.
+ Now, we get/set everything from libgdiplus. This is cleaner.
+
+2004-05-18 Ravindra <rkumar@novell.com>
+
+ * LinearGradientBrush.cs: Added checks for the values of
+ focus and scale parameters in SetBlendTriangularShape and
+ SetSigmaBellShape methods.
+ * PathGradientBrush.cs: Same as above.
+
+2004-06-13 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * DashCap.cs: fixed mismatches in enum field values
+ * HatchStyle.cs: fixes mismatches in enum field values
+
+2004-05-18 Ravindra <rkumar@novell.com>
+
+ * CustomLineCap.cs: Added null checks and corrected Dispose method.
+
+2004-05-17 Duncan Mak <duncan@ximian.com>
+
+ * GraphicsPathIterator.cs: Untabify and fixed coding style.
+ (GraphicsPathIterator): Store the path count, path points and path
+ type arrays instead of calling unmanaged functions in GDI+ each
+ time to get to get the path data.
+ (CopyData, Enumerate, HasCurve, Rewind, SubpathCount):
+ Implemented.
+
+2004-05-16 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * GraphicsPath.cs: renamed SetMarker to SetMarkers, to fix
+ public API to match MS.NET
+
+2004-05-15 Duncan Mak <duncan@ximian.com>
+
+ * GraphicsPath.cs: Instead of casting null to an IntPtr, use
+ IntPtr.Zero instead. Thanks to Nick Drochak for spotting this.
+
+2004-05-14 Nick Drochak <ndrochak@gol.com>
+
+ * GraphicsPath.cs: fix build with csc. No implicit conversion from
+ null to IntPtr. Bug in mcs?
+
+2004-05-14 Duncan Mak <duncan@ximian.com>
+
+ * GraphicsPath.cs (ConvertPoints): Removed, we'll do the
+ conversion in C.
+ (GraphicsPath): Use GdipCreatePath2I instead.
+ (SetMarker, ClearMarkers):
+ (Flatten, GetBounds, IsOutlineVisible, IsVisible):
+ (StartFigure, CloseFigure, CloseFigures):
+ (Warp, Widen): Implemented. I left the MonoTODO attribute on for
+ the methods where the equivalent C function has not yet been
+ implemented.
+
+ * GraphicsPathIterator.cs (Count): Implemented.
+
+2004-05-13 Sanjay Gupta <gsanjay@novell.com>
+
+ * GraphicsState.cs: Added internal constructor.
+
+2004-05-13 Sanjay Gupta <gsanjay@novell.com>
+
+ * GraphicsPath.cs: Added stub for missing method CloseFigure().
+
+2004-05-11 Ravindra <rkumar@novell.com>
+
+ * AdjustableArrowCap.cs: Implemented.
+ * CustomLineCap.cs: Implemented.
+
+2004-05-04 Ravindra <rkumar@novell.com>
+
+ * LinearGradientBrush.cs: Fixed Transform property.
+
+2004-04-30 Ravindra <rkumar@novell.com>
+
+ * LinearGradientBrush.cs: Fixed some errors.
+
+2004-04-06 Duncan Mak <duncan@ximian.com>
+
+ * GraphicsPath.cs (GraphicsPath): Filled out the missing
+ constructors.
+ (ConvertPoints): New helper function. Converts a Point array to a
+ PointF array.
+
+2004-04-05 Jordi Mas i Hernandez <jordi@ximian.com>
+ * GraphicsPath.cs: added missing methods
+
+2004-04-01 Duncan Mak <duncan@ximian.com>
+ * GraphicsPath.cs (AddCurve, AddClosedCurve): Added all overloads.
+
+2004-03-26 Ravindra <rkumar@novell.com>
+ * WrapMode.cs: Corrected the TileFlipXY and TileFlipY values.
+
+2004-03-23 Ravindra <rkumar@novell.com>
+ * LinearGradientBrush.cs: Implemented public methods.
+
+2004-03-22 Ravindra <rkumar@novell.com>
+ * LinearGradientBrush.cs: Implemented constructors and properties.
+ * PathGradientBrush.cs: Fixed a constructor and few coding
+ style fixes.
+
+2004-03-18 Ravindra <rkumar@novell.com>
+ * HatchBrush.cs: Fixed Clone method.
+ * PathGradientBrush.cs: Fixed Clone method and few minor
+ fixes.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Blend.cs: Fixed.
+ * ColorBlend.cs: Fixed.
+
+2004-03-06 Ravindra <rkumar@novell.com>
+ * PathGradientBrush.cs: Implemented methods.
+
+2004-03-06 Ravindra <rkumar@novell.com>
+ * PathGradientBrush.cs: Implemented constructors and properties.
+
+2004-03-04 Duncan Mak <duncan@ximian.com>
+
+ * GraphicsPath.cs (PathCount): Corrected. The name should be PointCount.
+ (AddPath): Implemented.
+
+2004-02-27 Ravindra <rkumar@novell.com>
+
+ * WrapMode.cs: Corrected enum values. Tile should be zero
+ and Clamp should be four.
+
+2004-02-11 Ravindra <rkumar@novell.com>
+
+ * Matrix.cs: Added status checks using
+ GDIPlus.CheckStatus(Status) method.
+
+2004-02-07 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * GraphicsPathIterator.cs: Fixed signature, added TODOs
+ * Matrix.cs: Removed additional method
+
+2004-02-06 Ravindra <rkumar@novell.com>
+
+ * HatchBrush.cs: Using CheckStatus method instead of
+ GetException.
+
+2004-02-05 Ravindra <rkumar@novell.com>
+
+ * HatchBrush.cs: Implemented.
+ * HatchStyle.cs: Corrected enum values. Changed file format
+ from DOS to UNIX.
+
+2004-01-30 Duncan Mak <duncan@ximian.com>
+
+ * GraphicsPath.cs (AddPie): Corrected arguments sent to
+ P/Invoke. This fixes the strange NaNs we were getting when we
+ tried to draw Paths with a Pie figure.
+
+2004-01-24 Duncan Mak <duncan@ximian.com>
+
+ * GraphicsPath.cs (AddEllipse): Added.
+
+2004-01-19 Duncan Mak <duncan@ximian.com>
+
+ * GraphicsPath.cs: Implemented. Still needs testing, though.
+ Particular the PathPoints property, I ran into a P/Invoke problem,
+ I need to first fix that before I can go on with the rest of the testing.
+
+2004-01-13 Ravindra <rkumar@novell.com>
+
+ * Matrix.cs: Made the Matrix(IntPtr) constructor internal.
+ Because default access is private, that makes it unusable
+ by other classes.
+
+2004-01-11 Duncan Mak <duncan@ximian.com>
+
+ * Matrix.cs (Matrix): Removed reference to GpRect/GpRectF.
+
+2004-01-10 Ravindra <rkumar@novell.com>
+
+ * All Enums: Made serializable.
+
+ * GraphicsPathIterator.cs: Implements IDisposable.
+
+ * GraphicsState.cs: Inherits MarshalByRefObject.
+
+2003-12-25 Duncan Mak <duncan@ximian.com>
+
+ * Matrix.cs (ToString): Cache the elements inside a local variable
+ to avoid calling the Elements property repeatedly.
+
+2003-12-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Blend.cs: fix array sizes in the constructors. Closes bug #51564.
+ System.Web moves in mysterious ways.
+
+2003-11-22 Duncan Mak <duncan@ximian.com>
+
+ * Matrix.cs: Rewrote to use GDI+ implementation, doing all the
+ math in unmanaged code instead of doing it in C#.
+
+2003-11-04 Miguel de Icaza <miguel@ximian.com>
+
+ * GraphicsPathIterator.cs: Do not make this protected.
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * QualityMode.cs: Fixed typo
+ * InterpolationMode.cs: Fixed typo
+ * RegionData.cs: Fixed signatures, partially implemented
+ * PathGradientBrush.cs: Fixed signatures
+ * PathData.cs: Fixed signature, implemented
+ * LinearGradientBrush.cs: Added missing MonoTODOs, fixed typo
+ * GraphicsContainer.cs: Added private constructor
+ * CustomLineCap.cs: Fixed typos, fixed inheritance, removed unneeded member
+
+2003-11-11 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * ColorBlend.cs (Positions): another one.
+
+2003-11-11 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * Blend.cs (Positions): recursion in prop.
+
+2003-10-24 Miguel de Icaza <miguel@ximian.com>
+
+ * GraphicsPath.cs: Stub some more.
+
+2003-10-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * GraphicsState.cs internal member added
+
+2003-06-26 Alexandre Pigolkine <pigolkine@gmx.de>
+ * GraphicsState.cs internal member added
+
+2003-04-26 Alexandre Pigolkine <pigolkine@gmx.de>
+ * LinearGradientBrush.cs some implementation added
+
+2003-3-15 DennisHayes <dennish@raytek.com>
+ * Stubbed and somewhat implmented
+
+ * CustomLineCap.cs
+ * GraphicsContainer.cs
+ * GraphicsPath.cs
+ * GraphicsPathIterator.cs
+ * GraphicsState.cs
+ * HatchBrush.cs
+ * LinearGradientBrush.cs
+
+2003-3-5 DennisHayes <dennish@raytek.com>
+ * Added values for enums
+ * Stubbed and somewhat implmented Blend, ColorBlend, CustomLineCap
+
+
+2003-3-2 DennisHayes <dennish@raytek.com>
+
+ * Created changelog
+ * updated copyrights to 2002/3
+ * changed namespace from System.Drawing, System.Drawing.Drawing2d to System.Drawing.Drawing2D
+ * cosmetic improvments
+
+2002-10-13 DennisHayes <dennish@raytek.com>
+ * Changed namespace from *2d to *2D
+ * Changed comment header from system.Drawing to System.Drawing.Drawing2D
+
+2002-9-2 DennisHayes <dennish@raytek.com>
+
+ * AdjustableArrowCap.cs
+ * Blend.cs
+ * ColorBlend.cs
+ * CombineMode.cs
+ * CompostingMode.cs
+ * CompostingQuality.cs
+ * CoordinateSpace.cs
+ * CustomLineCap.cs
+ * DashCap.cs
+ * DashStyle.cs
+ * FillMode.cs
+ * FlushIntention.cs
+ * GraphicsContainer.cs
+ * GraphicsPathIterator.cs
+ * GraphicsState.cs
+ * HatchBrush.cs
+ * HatchStyle.cs
+ * InterpolationMode.cs
+ * LinearGradientBrush.cs
+ * LinearGradientMode.cs
+ * LineCap.cs
+ * LineJoin.cs
+ * MatrixOrder.cs
+ * PathData.cs
+ * PathGradientBrush.cs
+ * PathPointType.cs
+ * PenAligment.cs
+ * PenType.cs
+ * PixelOffsetMode.cs
+ * QualityMode.cs
+ * RegionData.cs
+ * SmoothingMode.cs
+ * WarpMode.cs
+ * WrapMode.cs
+ * Added null classes for most/all classes, Many stubs, and some implmentation
+
+2002-9-2 DennisHayes <dennish@raytek.com>
+
+ * Matrix.cs
+ * Added stubs, implmentation
+
+2002-9-2 DennisHayes <dennish@raytek.com>
+
+ * GraphicsPath.cs
+ * added stub needed for system.windows.forms
+
+2002-01-06 Ravi Pratap <ravi@ximian.com>
+
+ * ChangeLog : Add.
+
+ * Matrix.cs : MonoTODO everywhere.
+
+ * TODOAttribute.cs : Add here too.
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs
new file mode 100644
index 00000000000..f1eae656822
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs
@@ -0,0 +1,78 @@
+//
+// System.Drawing.Drawing2D.ColorBlend.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) 2002/3 Ximian, Inc. http://www.ximian.com
+// (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D
+{
+ public sealed class ColorBlend
+ {
+ private float [] positions;
+ private Color [] colors;
+
+ public ColorBlend ()
+ {
+ positions = new float [1];
+ colors = new Color [1];
+ }
+
+ [MonoTODO]
+ public ColorBlend (int count)
+ {
+ positions = new float [count];
+ colors = new Color [count];
+ }
+
+ [MonoTODO]
+ public Color [] Colors {
+ get {
+ return colors;
+ }
+
+ set {
+ colors = value;
+ }
+ }
+
+ [MonoTODO]
+ public float [] Positions {
+ get {
+ return positions;
+ }
+
+ set {
+ positions = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CombineMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CombineMode.cs
new file mode 100644
index 00000000000..b459c5cae8a
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CombineMode.cs
@@ -0,0 +1,48 @@
+//
+// System.Drawing.Drawing2D.CombineMode.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for CombineMode.
+ /// </summary>
+ [Serializable]
+ public enum CombineMode {
+ Complement = 5,
+ Exclude = 4,
+ Intersect = 1,
+ Replace = 0,
+ Union = 2,
+ Xor = 3
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingMode.cs
new file mode 100644
index 00000000000..4f7b3b31ab5
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingMode.cs
@@ -0,0 +1,44 @@
+//
+// System.Drawing.Drawing2D.CompostingMode.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for CompostingMode.
+ /// </summary>
+ [Serializable]
+ public enum CompositingMode {
+ SourceCopy = 1,
+ SourceOver = 0
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingQuality.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingQuality.cs
new file mode 100644
index 00000000000..cbb0de05fe6
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingQuality.cs
@@ -0,0 +1,48 @@
+//
+// System.Drawing.Drawing2D.CompostingQuality.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for CompostingQuality.
+ /// </summary>
+ [Serializable]
+ public enum CompositingQuality {
+ AssumeLinear = 4,
+ Default = 0,
+ GammaCorrected = 3,
+ HighQuality = 2,
+ HighSpeed = 1,
+ Invalid = -1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CoordinateSpace.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CoordinateSpace.cs
new file mode 100644
index 00000000000..982351f2485
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CoordinateSpace.cs
@@ -0,0 +1,45 @@
+//
+// System.Drawing.Drawing2D.CoordinateSpace.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for CoordinateSpace.
+ /// </summary>
+ [Serializable]
+ public enum CoordinateSpace {
+ Device = 2,
+ Page = 1,
+ World = 0
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs
new file mode 100644
index 00000000000..a01ee407c70
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs
@@ -0,0 +1,183 @@
+//
+// System.Drawing.Drawing2D.CustomLineCap.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002/3 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for CustomLineCap.
+ /// </summary>
+ public class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable
+ {
+ private bool disposed;
+ internal IntPtr nativeObject;
+
+ // Constructors
+
+ internal CustomLineCap () { }
+
+ internal CustomLineCap (IntPtr ptr)
+ {
+ nativeObject = ptr;
+ }
+
+ public CustomLineCap (GraphicsPath fillPath, GraphicsPath strokePath) : this (fillPath, strokePath, LineCap.Flat, 0)
+ {
+ }
+
+ public CustomLineCap (GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap) : this (fillPath, strokePath, baseCap, 0)
+ {
+ }
+
+ public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
+ {
+ IntPtr fill = IntPtr.Zero;
+ IntPtr stroke = IntPtr.Zero;
+
+ if (fillPath != null)
+ fill = fillPath.nativePath;
+ if (strokePath != null)
+ stroke = strokePath.nativePath;
+
+ Status status = GDIPlus.GdipCreateCustomLineCap (fill, stroke, baseCap, baseInset, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public LineCap BaseCap {
+ get {
+ LineCap baseCap;
+ Status status = GDIPlus.GdipGetCustomLineCapBaseCap (nativeObject, out baseCap);
+ GDIPlus.CheckStatus (status);
+
+ return baseCap;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetCustomLineCapBaseCap (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public LineJoin StrokeJoin {
+ get {
+ LineJoin strokeJoin;
+ Status status = GDIPlus.GdipGetCustomLineCapStrokeJoin (nativeObject, out strokeJoin);
+ GDIPlus.CheckStatus (status);
+
+ return strokeJoin;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetCustomLineCapStrokeJoin (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public float BaseInset {
+ get {
+ float baseInset;
+ Status status = GDIPlus.GdipGetCustomLineCapBaseInset (nativeObject, out baseInset);
+ GDIPlus.CheckStatus (status);
+
+ return baseInset;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetCustomLineCapBaseInset (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public float WidthScale {
+ get {
+ float widthScale;
+ Status status = GDIPlus.GdipGetCustomLineCapWidthScale (nativeObject, out widthScale);
+ GDIPlus.CheckStatus (status);
+
+ return widthScale;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetCustomLineCapWidthScale (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ // Public Methods
+
+ public virtual object Clone ()
+ {
+ IntPtr clonePtr;
+ Status status = GDIPlus.GdipCloneCustomLineCap (nativeObject, out clonePtr);
+ GDIPlus.CheckStatus (status);
+
+ return new CustomLineCap (clonePtr);
+ }
+
+ public virtual void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (! disposed) {
+ Status status = GDIPlus.GdipDeleteCustomLineCap (nativeObject);
+ GDIPlus.CheckStatus (status);
+ disposed = true;
+ nativeObject = IntPtr.Zero;
+ }
+ }
+
+ ~CustomLineCap ()
+ {
+ Dispose (false);
+ }
+
+ public void GetStrokeCaps (out LineCap startCap, out LineCap endCap)
+ {
+ Status status = GDIPlus.GdipGetCustomLineCapStrokeCaps (nativeObject, out startCap, out endCap);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetStrokeCaps(LineCap startCap, LineCap endCap)
+ {
+ Status status = GDIPlus.GdipSetCustomLineCapStrokeCaps (nativeObject, startCap, endCap);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.jvm.cs
new file mode 100755
index 00000000000..a05a86a4efe
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.jvm.cs
@@ -0,0 +1,129 @@
+//
+// System.Drawing.Drawing2D.CustomLineCap.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002/3 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for CustomLineCap.
+ /// </summary>
+ [MonoTODO]
+ public class CustomLineCap : MarshalByRefObject, ICloneable
+ {
+ private bool disposed;
+
+ // Constructors
+
+ internal CustomLineCap () { }
+
+ public CustomLineCap (GraphicsPath fillPath, GraphicsPath strokePath) : this (fillPath, strokePath, LineCap.Flat, 0)
+ {
+ }
+
+ public CustomLineCap (GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap) : this (fillPath, strokePath, baseCap, 0)
+ {
+ }
+
+ [MonoTODO]
+ public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public LineCap BaseCap {
+ get {
+ throw new NotImplementedException();
+ }
+
+ set {
+ throw new NotImplementedException();
+ }
+ }
+
+ [MonoTODO]
+ public LineJoin StrokeJoin {
+ get {
+ throw new NotImplementedException();
+ }
+
+ set {
+ throw new NotImplementedException();
+ }
+ }
+
+ [MonoTODO]
+ public float BaseInset {
+ get {
+ throw new NotImplementedException();
+ }
+
+ set {
+ throw new NotImplementedException();
+ }
+ }
+
+ [MonoTODO]
+ public float WidthScale {
+ get {
+ throw new NotImplementedException();
+ }
+
+ set {
+ throw new NotImplementedException();
+ }
+ }
+
+ // Public Methods
+ [MonoTODO]
+ public virtual object Clone ()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public void GetStrokeCaps (out LineCap startCap, out LineCap endCap)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public void SetStrokeCaps(LineCap startCap, LineCap endCap)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/DashCap.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/DashCap.cs
new file mode 100644
index 00000000000..06fa7367222
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/DashCap.cs
@@ -0,0 +1,45 @@
+//
+// System.Drawing.Drawing2D.DashCap.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for DashCap.
+ /// </summary>
+ [Serializable]
+ public enum DashCap {
+ Flat,
+ Round = 2,
+ Triangle = 3
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/DashStyle.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/DashStyle.cs
new file mode 100644
index 00000000000..7ffff02174c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/DashStyle.cs
@@ -0,0 +1,48 @@
+//
+// System.Drawing.Drawing2D.DashStyle.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for DashStyle.
+ /// </summary>
+ [Serializable]
+ public enum DashStyle {
+ Custom = 5,
+ Dash = 1,
+ DashDot = 3,
+ DashDotDot = 4,
+ Dot = 2,
+ Solid = 0
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ExtendedGeneralPath.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ExtendedGeneralPath.jvm.cs
new file mode 100644
index 00000000000..7c9c9d81363
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ExtendedGeneralPath.jvm.cs
@@ -0,0 +1,700 @@
+//
+// System.Drawing.Drawing2D.ExtendedGeneralPath.cs
+//
+// Author:
+// Bors Kirzner <boris@mainsoft.com>
+//
+// Copyright (C) 2005 Mainsoft Corporation, (http://www.mainsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+using java.awt;
+using java.awt.geom;
+using java.lang;
+
+namespace System.Drawing.Drawing2D
+{
+ internal class ExtendedGeneralPath : Shape, ICloneable
+ {
+ #region Fields
+
+ public const int WIND_EVEN_ODD = 0; //PathIterator__Finals.WIND_EVEN_ODD;
+ public const int WIND_NON_ZERO = 1; //PathIterator__Finals.WIND_NON_ZERO;
+
+ public const sbyte SEG_MOVETO = 0; //(byte) PathIterator__Finals.SEG_MOVETO;
+ public const sbyte SEG_LINETO = 1; //(byte) PathIterator__Finals.SEG_LINETO;
+ public const sbyte SEG_QUADTO = 2; //(byte) PathIterator__Finals.SEG_QUADTO;
+ public const sbyte SEG_CUBICTO = 3; //(byte) PathIterator__Finals.SEG_CUBICTO;
+ public const sbyte SEG_CLOSE = 4; //(byte) PathIterator__Finals.SEG_CLOSE;
+
+ public const sbyte SEG_START = 16; // segment start
+
+ public const sbyte SEG_MASK = SEG_MOVETO | SEG_LINETO | SEG_QUADTO | SEG_CUBICTO | SEG_CLOSE; // mask to eliminate SEG_CLOSE and SEG_MARKER
+
+ private const sbyte SEG_MARKER = 32; // path marker
+
+
+ private sbyte [] _types;
+ private float [] _coords;
+ private int _typesCount;
+ private int _coordsCount;
+ private int _windingRule;
+
+ private PathData _pathData;
+ private GeneralPath _generalPath;
+
+ const int INIT_SIZE = 20;
+ const int EXPAND_MAX = 500;
+
+ #endregion // Fileds
+
+ #region Constructors
+
+ public ExtendedGeneralPath() : this (WIND_NON_ZERO, INIT_SIZE, INIT_SIZE)
+ {
+ }
+
+ public ExtendedGeneralPath(int rule) : this (rule, INIT_SIZE, INIT_SIZE)
+ {
+ }
+
+ public ExtendedGeneralPath(int rule, int initialCapacity) : this (rule, initialCapacity, initialCapacity)
+ {
+ }
+
+ public ExtendedGeneralPath(Shape s) : this(WIND_NON_ZERO, INIT_SIZE, INIT_SIZE)
+ {
+ PathIterator pi = s.getPathIterator (null);
+ setWindingRule (pi.getWindingRule ());
+ append (pi, false);
+ }
+
+ private ExtendedGeneralPath(int rule, int initialTypes, int initialCoords)
+ {
+ setWindingRule(rule);
+ Reset (initialTypes, initialCoords);
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ private GeneralPath GeneralPath
+ {
+ get {
+ if (_generalPath == null) {
+ _generalPath = GetGeneralPath ();
+ }
+ return _generalPath;
+ }
+ }
+
+ public sbyte [] Types
+ {
+ get { return _types; }
+ }
+
+ public float [] Coords
+ {
+ get { return _coords; }
+ }
+
+ public int TypesCount
+ {
+ get { return _typesCount; }
+ }
+
+ public int CoordsCount
+ {
+ get { return _coordsCount; }
+ }
+
+ public bool LastFigureClosed
+ {
+ get {
+ return ((TypesCount == 0) ||
+ ((Types [TypesCount - 1] & ExtendedGeneralPath.SEG_CLOSE) != 0) ||
+ ((Types [TypesCount - 1] & ExtendedGeneralPath.SEG_START) != 0));
+ }
+ }
+
+ public int PointCount
+ {
+ get {
+ return CoordsCount / 2;
+ }
+ }
+
+ public PathData PathData
+ {
+ get
+ {
+ if (_pathData == null)
+ _pathData = GetPathData ();
+
+ return _pathData;
+ }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ #region CachedData
+
+ private void ClearCache ()
+ {
+ _pathData = null;
+ _generalPath = null;
+ }
+
+ private GeneralPath GetGeneralPath ()
+ {
+ PathIterator iter = getPathIterator (null);
+ GeneralPath path = new GeneralPath ();
+ path.append (iter, false);
+ return path;
+ }
+
+ private PathData GetPathData ()
+ {
+ PathData pathData = new PathData();
+ int nPts = PointCount;
+ for (int i = 0; i < TypesCount; i++)
+ if ((Types [i] & SEG_MASK) == SEG_QUADTO)
+ nPts++;
+
+ pathData.Types = new byte [nPts];
+ pathData.Points = new PointF [nPts];
+ int tpos = 0;
+ int ppos = 0;
+ int cpos = 0;
+ byte marker;
+ bool start;
+ for (int i = 0; i < TypesCount; i++) {
+ sbyte segmentType = (sbyte)(Types [i] & SEG_MASK);
+
+ // set the masks and the markers
+ marker = ((Types [i] & SEG_MARKER) != 0) ? (byte)PathPointType.PathMarker : (byte)0;
+ start = ((Types [i] & SEG_START) != 0);
+
+ switch (segmentType) {
+ case SEG_CLOSE:
+ pathData.InternalTypes [tpos - 1] = (byte) (pathData.InternalTypes [tpos - 1] | (byte) PathPointType.CloseSubpath | marker);
+ break;
+ case SEG_MOVETO:
+ pathData.InternalTypes [tpos++] = (byte)((byte) PathPointType.Start | marker);
+ pathData.InternalPoints [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
+ break;
+ case SEG_LINETO:
+ pathData.InternalTypes [tpos++] = (byte) ((byte) PathPointType.Line | marker);
+ pathData.InternalPoints [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
+ break;
+ case SEG_QUADTO:
+ /*
+ .net does not support Quadratic curves, so convert to Cubic according to http://pfaedit.sourceforge.net/bezier.html
+
+ The end points of the cubic will be the same as the quadratic's.
+ CP0 = QP0
+ CP3 = QP2
+
+ The two control points for the cubic are:
+
+ CP1 = QP0 + 2/3 *(QP1-QP0)
+ CP2 = CP1 + 1/3 *(QP2-QP0)
+ */
+
+ float x0 = Coords[cpos-2]; //QP0
+ float y0 = Coords[cpos-1]; //QP0
+
+ float x1 = x0 + (2/3 * (Coords [cpos++]-x0));
+ float y1 = y0 + (2/3 * (Coords [cpos++]-y0));
+
+ float x3 = Coords [cpos++]; //QP2
+ float y3 = Coords [cpos++]; //QP2
+
+ float x2 = x1 + (1/3 * (x3-x0));
+ float y2 = y1 + (1/3 * (y3-y0));
+
+ pathData.InternalTypes [tpos++] = (byte)(byte) PathPointType.Bezier;
+ pathData.InternalPoints [ppos++] = new PointF (x1, y1);
+ pathData.InternalTypes [tpos++] = (byte)(byte) PathPointType.Bezier;
+ pathData.InternalPoints [ppos++] = new PointF (x2, y2);
+ pathData.InternalTypes [tpos++] = (byte) ((byte)PathPointType.Bezier | marker);
+ pathData.InternalPoints [ppos++] = new PointF (x3, y3);
+ break;
+ case SEG_CUBICTO:
+ pathData.InternalTypes [tpos++] = (byte)(byte) PathPointType.Bezier3;
+ pathData.InternalPoints [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
+ pathData.InternalTypes [tpos++] = (byte) PathPointType.Bezier3;
+ pathData.InternalPoints [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
+ pathData.InternalTypes [tpos++] = (byte) ((byte)PathPointType.Bezier3 | marker);
+ pathData.InternalPoints [ppos++] = new PointF (Coords [cpos++], Coords [cpos++]);
+ break;
+ }
+ }
+ return pathData;
+ }
+
+ #endregion // CachedData
+
+ public void append(Shape s)
+ {
+ append (s, !LastFigureClosed);
+ }
+
+ #region GeneralPath
+
+ public void append(PathIterator pi, bool connect)
+ {
+ ClearCache ();
+ float [] coords = new float [6];
+ while (!pi.isDone ()) {
+ switch (pi.currentSegment (coords)) {
+ case SEG_MOVETO:
+ if (!connect || _typesCount < 1 || _coordsCount < 2) {
+ moveTo (coords [0], coords [1]);
+ break;
+ }
+ if (_types [_typesCount - 1] != SEG_CLOSE &&
+ _coords [_coordsCount - 2] == coords [0] &&
+ _coords [_coordsCount - 1] == coords [1])
+ break;
+ goto case SEG_LINETO;
+ case SEG_LINETO:
+ lineTo (coords [0], coords [1]);
+ break;
+ case SEG_QUADTO:
+ quadTo (coords [0], coords [1], coords [2], coords [3]);
+ break;
+ case SEG_CUBICTO:
+ curveTo (coords [0], coords [1], coords [2], coords [3], coords [4], coords [5]);
+ break;
+ case SEG_CLOSE:
+ closePath ();
+ break;
+ }
+ pi.next ();
+ connect = false;
+ }
+ }
+
+ public void append(Shape s, bool connect)
+ {
+ PathIterator pi = s.getPathIterator (null);
+ append (pi,connect);
+ }
+
+ public object Clone()
+ {
+ ExtendedGeneralPath copy = (ExtendedGeneralPath)MemberwiseClone ();
+ copy._types = (sbyte []) _types.Clone ();
+ copy._coords = (float []) _coords.Clone ();
+ return copy;
+ }
+
+ public void closePath()
+ {
+ ClearCache ();
+ if (_typesCount == 0 || _types[_typesCount - 1] != SEG_CLOSE) {
+ needRoom (1, 0, true);
+ _types [_typesCount++] = SEG_CLOSE;
+ }
+ }
+
+ public bool contains(double x, double y)
+ {
+ return GeneralPath.contains (x, y);
+ }
+
+ public bool contains(double x, double y, double w, double h)
+ {
+ return GeneralPath.contains (x, y, w, h);
+ }
+
+ public bool contains(Point2D p)
+ {
+ return contains (p.getX (), p.getY ());
+ }
+
+ public bool contains(Rectangle2D r)
+ {
+ return contains (r.getX (), r.getY (), r.getWidth (), r.getHeight ());
+ }
+
+ public Shape createTransformedShape(AffineTransform at)
+ {
+ ExtendedGeneralPath gp = (ExtendedGeneralPath) Clone ();
+ if (at != null) {
+ gp.transform (at);
+ }
+ return gp;
+ }
+
+ public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
+ {
+ ClearCache ();
+ needRoom (1, 6, true);
+ _types [_typesCount++] = SEG_CUBICTO;
+ _coords [_coordsCount++] = x1;
+ _coords [_coordsCount++] = y1;
+ _coords [_coordsCount++] = x2;
+ _coords [_coordsCount++] = y2;
+ _coords [_coordsCount++] = x3;
+ _coords [_coordsCount++] = y3;
+ }
+
+ public java.awt.Rectangle getBounds()
+ {
+ return getBounds2D ().getBounds ();
+ }
+
+ public Rectangle2D getBounds2D()
+ {
+ float x1, y1, x2, y2;
+ int i = _coordsCount;
+ if (i > 0) {
+ y1 = y2 = _coords [--i];
+ x1 = x2 = _coords [--i];
+ while (i > 0) {
+ float y = _coords [--i];
+ float x = _coords [--i];
+ if (x < x1) x1 = x;
+ if (y < y1) y1 = y;
+ if (x > x2) x2 = x;
+ if (y > y2) y2 = y;
+ }
+ }
+ else {
+ x1 = y1 = x2 = y2 = 0f;
+ }
+ return new Rectangle2D.Float (x1, y1, x2 - x1, y2 - y1);
+ }
+
+ public Point2D getCurrentPoint()
+ {
+ if (_typesCount < 1 || _coordsCount < 2)
+ return null;
+
+ int index = _coordsCount;
+ if (_types [_typesCount - 1] == SEG_CLOSE)
+ for (int i = _typesCount - 2; i > 0; i--) {
+ switch (_types [i]) {
+ case SEG_MOVETO:
+ //break loop;
+ goto loopend;
+ case SEG_LINETO:
+ index -= 2;
+ break;
+ case SEG_QUADTO:
+ index -= 4;
+ break;
+ case SEG_CUBICTO:
+ index -= 6;
+ break;
+ case SEG_CLOSE:
+ break;
+ }
+ }
+ loopend:
+
+ return new Point2D.Float (_coords [index - 2], _coords [index - 1]);
+ }
+
+ public PathIterator getPathIterator(AffineTransform at) {
+ return new GeneralPathIterator (this, at);
+ }
+
+ public PathIterator getPathIterator(AffineTransform at, double flatness) {
+ return new FlatteningPathIterator (getPathIterator (at), flatness);
+ }
+
+ public int getWindingRule()
+ {
+ return _windingRule;
+ }
+
+ public bool intersects(double x, double y, double w, double h)
+ {
+ return GeneralPath.intersects (x, y, w, h);
+ }
+
+ public bool intersects(Rectangle2D r)
+ {
+ return intersects (r.getX (), r.getY (), r.getWidth (), r.getHeight ());
+ }
+
+ public void lineTo(float x, float y)
+ {
+ ClearCache ();
+ needRoom (1, 2, true);
+ _types [_typesCount++] = SEG_LINETO;
+ _coords [_coordsCount++] = x;
+ _coords [_coordsCount++] = y;
+ }
+
+ public void moveTo(float x, float y)
+ {
+ ClearCache ();
+ if (_typesCount > 0 && _types [_typesCount - 1] == SEG_MOVETO) {
+ _coords [_coordsCount - 2] = x;
+ _coords [_coordsCount - 1] = y;
+ }
+ else {
+ needRoom (1, 2, false);
+ _types [_typesCount++] = SEG_MOVETO;
+ _coords [_coordsCount++] = x;
+ _coords [_coordsCount++] = y;
+ }
+ }
+
+ public void quadTo(float x1, float y1, float x2, float y2)
+ {
+ // restore quadTo as cubic affects quality
+ ClearCache ();
+ needRoom (1, 4, true);
+ _types [_typesCount++] = SEG_QUADTO;
+ _coords [_coordsCount++] = x1;
+ _coords [_coordsCount++] = y1;
+ _coords [_coordsCount++] = x2;
+ _coords [_coordsCount++] = y2;
+ }
+
+ public void reset()
+ {
+ ClearCache ();
+ _typesCount = 0;
+ _coordsCount = 0;
+ }
+
+ public void setWindingRule(int rule)
+ {
+ if (rule != WIND_EVEN_ODD && rule != WIND_NON_ZERO) {
+ throw new IllegalArgumentException ("winding rule must be WIND_EVEN_ODD or WIND_NON_ZERO");
+ }
+ _windingRule = rule;
+ }
+
+ public void transform(AffineTransform at)
+ {
+ transform(at, 0, CoordsCount);
+ }
+
+ public void transform(AffineTransform at, int startCoord, int numCoords) {
+ ClearCache ();
+ at.transform (_coords, startCoord, _coords, startCoord, numCoords/2);
+ }
+
+ private void needRoom(int newTypes, int newCoords, bool needMove)
+ {
+ if (needMove && _typesCount == 0)
+ throw new IllegalPathStateException ("missing initial moveto in path definition");
+
+ int size = _coords.Length;
+ if (_coordsCount + newCoords > size) {
+ int grow = size;
+ if (grow > EXPAND_MAX * 2)
+ grow = EXPAND_MAX * 2;
+
+ if (grow < newCoords)
+ grow = newCoords;
+
+ float [] arr = new float [size + grow];
+ Array.Copy (_coords, 0, arr, 0, _coordsCount);
+ _coords = arr;
+ }
+ size = _types.Length;
+ if (_typesCount + newTypes > size) {
+ int grow = size;
+ if (grow > EXPAND_MAX)
+ grow = EXPAND_MAX;
+
+ if (grow < newTypes)
+ grow = newTypes;
+
+ sbyte [] arr = new sbyte [size + grow];
+ Array.Copy (_types, 0, arr, 0, _typesCount);
+ _types = arr;
+ }
+ }
+
+ #endregion // GeneralPath
+
+ public void SetMarkers()
+ {
+ ClearCache ();
+ if (TypesCount > 0)
+ Types [ TypesCount - 1] |= SEG_MARKER;
+ }
+
+ public void ClearMarkers()
+ {
+ ClearCache ();
+ for (int i = 0; i < TypesCount; i++)
+ Types [i] &= ~SEG_MARKER;
+ }
+
+ public void StartFigure ()
+ {
+ ClearCache ();
+ if (TypesCount > 0)
+ Types [TypesCount - 1] |= ExtendedGeneralPath.SEG_START;
+ }
+
+ private void Reset (int initialTypes, int initialCoords)
+ {
+ ClearCache ();
+ _types = new sbyte [initialTypes];
+ _coords = new float [initialCoords * 2];
+ _typesCount = 0;
+ _coordsCount = 0;
+ }
+
+ internal void Clear ()
+ {
+ Reset (INIT_SIZE, INIT_SIZE);
+ }
+
+ internal void Reverse ()
+ {
+ ClearCache ();
+ // revert coordinates
+ for (int i=0, max = CoordsCount / 2; i < max;) {
+ int ix = i++;
+ int iy = i++;
+ int rix = CoordsCount - i;
+ int riy = rix + 1;
+ float tmpx = Coords [ix];
+ float tmpy = Coords [iy];
+ Coords [ix] = Coords [rix];
+ Coords [iy] = Coords [riy];
+ Coords [rix] = tmpx;
+ Coords [riy] = tmpy;
+ }
+
+ // revert types
+ sbyte [] newTypes = new sbyte [TypesCount];
+ int oldIdx = 0;
+ int newIdx = TypesCount - 1;
+ int copyStart;
+ int copyEnd;
+ sbyte mask1 = 0;
+ sbyte mask2 = 0;
+ sbyte closeMask = 0;
+ bool closedFigure = false;
+
+ while (oldIdx < TypesCount) {
+ // start copying after moveto
+ copyStart = ++oldIdx;
+ // continue to the next figure start
+ while ((Types [oldIdx] != SEG_MOVETO) && (oldIdx < TypesCount))
+ oldIdx++;
+
+ copyEnd = oldIdx - 1;
+ // check whenever current figure is closed
+ if ((Types [oldIdx - 1] & SEG_CLOSE) != 0) {
+ closedFigure = true;
+ // close figure
+ newTypes [newIdx--] = (sbyte)(SEG_CLOSE | mask1);
+ mask1 = 0;
+ mask2 = 0;
+ // end copy one cell earlier
+ copyEnd--;
+ closeMask = (sbyte)(Types [oldIdx - 1] & (sbyte)SEG_MARKER);
+ }
+ else {
+ mask2 = mask1;
+ mask1 = 0;
+ }
+
+ // copy reverted "inner" types
+ for(int i = copyStart; i <= copyEnd; i++) {
+ newTypes [newIdx--] = (sbyte)((Types [i] & SEG_MASK) | mask2);
+ mask2 = mask1;
+ mask1 = (sbyte)(Types [i] & (sbyte)SEG_MARKER);
+ }
+
+ // copy moveto
+ newTypes [newIdx--] = SEG_MOVETO;
+
+ // pass close mask to the nex figure
+ if (closedFigure) {
+ mask1 = closeMask;
+ closedFigure = false;
+ }
+ }
+
+ _types = newTypes;
+ }
+
+ public PointF GetLastPoint ()
+ {
+ if (CoordsCount == 0)
+ throw new System.ArgumentException ("Invalid parameter used.");
+
+ return new PointF (Coords [CoordsCount - 2], Coords [CoordsCount - 1]);
+ }
+
+ #endregion //Methods
+
+ #region Private helpers
+
+#if DEBUG
+ private void Print()
+ {
+ Console.WriteLine ("\n\n");
+ float [] fpoints = _coords;
+ int cpos = 0;
+ for (int i=0; i < _typesCount; i++) {
+ sbyte type = _types [i];
+ string marker = String.Empty;
+ if ((type & SEG_MARKER) != 0)
+ marker = " | MARKER";
+
+ switch (type & SEG_MASK) {
+ case SEG_CLOSE:
+ Console.WriteLine ("CLOSE {0}",marker);
+ break;
+ case SEG_MOVETO:
+ Console.WriteLine("{0}{3} ({1},{2})","MOVETO", fpoints[cpos++], fpoints[cpos++], marker);
+ break;
+ case SEG_LINETO:
+ Console.WriteLine("{0}{3} ({1},{2})","LINETO", fpoints[cpos++], fpoints[cpos++], marker);
+ break;
+ case SEG_QUADTO:
+ Console.WriteLine("{0}{3} ({1},{2})","QUADTO", fpoints[cpos++], fpoints[cpos++], marker);
+ Console.WriteLine(" ({1},{2})","QUADTO", fpoints[cpos++], fpoints[cpos++]);
+ break;
+ case SEG_CUBICTO:
+ Console.WriteLine("{0}{3} ({1},{2})","CUBICTO", fpoints[cpos++], fpoints[cpos++], marker);
+ Console.WriteLine(" ({1},{2})","CUBICTO", fpoints[cpos++], fpoints[cpos++]);
+ Console.WriteLine(" ({1},{2})","CUBICTO", fpoints[cpos++], fpoints[cpos++]);
+ break;
+ }
+ }
+ }
+#endif
+ #endregion // Private helpers
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/FillMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/FillMode.cs
new file mode 100644
index 00000000000..f9b6f9e3f10
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/FillMode.cs
@@ -0,0 +1,45 @@
+//
+// System.Drawing.Drawing2D.FillMode.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for FillMode.
+ /// </summary>
+ [Serializable]
+ public enum FillMode {
+ Alternate = 0,
+ Winding = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/FlushIntention.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/FlushIntention.cs
new file mode 100644
index 00000000000..c37c7d7b99b
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/FlushIntention.cs
@@ -0,0 +1,44 @@
+//
+// System.Drawing.Drawing2D.FlushIntention.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for FlushIntention.
+ /// </summary>
+ [Serializable]
+ public enum FlushIntention {
+ Flush = 0,
+ Sync = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GeneralPathIterator.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GeneralPathIterator.jvm.cs
new file mode 100644
index 00000000000..1cfa230a4e8
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GeneralPathIterator.jvm.cs
@@ -0,0 +1,105 @@
+//
+// System.Drawing.Drawing2D.GeneralPathIterator.cs
+//
+// Author:
+// Bors Kirzner <boris@mainsoft.com>
+//
+// Copyright (C) 2005 Mainsoft Corporation, (http://www.mainsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+using java.awt.geom;
+
+namespace System.Drawing.Drawing2D
+{
+ internal class GeneralPathIterator : PathIterator
+ {
+ #region Fields
+
+ int typeIdx = 0;
+ int pointIdx = 0;
+ ExtendedGeneralPath _path;
+ AffineTransform _affine;
+
+ private static readonly int [] curvesize = {2, 2, 4, 6, 0};
+
+ #endregion // Fileds
+
+ #region Constructors
+
+ public GeneralPathIterator(ExtendedGeneralPath _path) : this (_path, null)
+ {
+ }
+
+ public GeneralPathIterator(ExtendedGeneralPath _path, AffineTransform at)
+ {
+ this._path = _path;
+ this._affine = at;
+ }
+
+ #endregion // Constructors
+
+ #region Methods
+
+ public int getWindingRule()
+ {
+ return _path.getWindingRule ();
+ }
+
+ public bool isDone()
+ {
+ return (typeIdx >= _path.TypesCount);
+ }
+
+ public void next()
+ {
+ int type = _path.Types [typeIdx++] & ExtendedGeneralPath.SEG_MASK;
+ pointIdx += curvesize [type];
+ }
+
+ public int currentSegment(float [] coords) {
+ int type = _path.Types [typeIdx] & ExtendedGeneralPath.SEG_MASK;
+ int numCoords = curvesize [type];
+ if (numCoords > 0 && _affine != null)
+ _affine.transform (_path.Coords, pointIdx, coords, 0, numCoords/2);
+ else
+ Array.Copy (_path.Coords, pointIdx, coords, 0, numCoords);
+ return type;
+ }
+
+ public int currentSegment(double [] coords)
+ {
+ int type = _path.Types [typeIdx] & ExtendedGeneralPath.SEG_MASK;
+ int numCoords = curvesize [type];
+ if (numCoords > 0 && _affine != null)
+ _affine.transform (_path.Coords, pointIdx, coords, 0, numCoords/2);
+ else
+ for (int i=0; i < numCoords; i++)
+ coords [i] = _path.Coords [pointIdx + i];
+
+ return type;
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.cs
new file mode 100644
index 00000000000..9389c0a0a22
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.cs
@@ -0,0 +1,59 @@
+//
+// System.Drawing.Drawing2D.GraphicsContainer.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for GraphicsContainer.
+ /// </summary>
+ public sealed class GraphicsContainer : MarshalByRefObject {
+
+ private int nativeState = 0;
+
+ private GraphicsContainer () { }
+
+ internal GraphicsContainer (int state)
+ {
+ nativeState = state;
+ }
+
+ internal int NativeObject {
+ get {
+ return nativeState;
+ }
+ set {
+ nativeState = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.jvm.cs
new file mode 100644
index 00000000000..7981c0acd09
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsContainer.jvm.cs
@@ -0,0 +1,54 @@
+//
+// System.Drawing.Drawing2D.GraphicsContainer.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for GraphicsContainer.
+ /// </summary>
+ public sealed class GraphicsContainer : MarshalByRefObject
+ {
+ readonly GraphicsState _stateObject;
+
+ internal GraphicsContainer (GraphicsState stateObject)
+ {
+ _stateObject = stateObject;
+ }
+
+ internal GraphicsState StateObject
+ {
+ get {return _stateObject;}
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs
new file mode 100644
index 00000000000..2a49d4a5290
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs
@@ -0,0 +1,883 @@
+//
+// System.Drawing.Drawing2D.GraphicsPath.cs
+//
+// Authors:
+//
+// Miguel de Icaza (miguel@ximian.com)
+// Duncan Mak (duncan@ximian.com)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+// Ravindra (rkumar@novell.com)
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.ComponentModel;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Drawing2D
+{
+ public sealed class GraphicsPath : MarshalByRefObject, ICloneable, IDisposable
+ {
+ internal IntPtr nativePath = IntPtr.Zero;
+
+ GraphicsPath (IntPtr ptr)
+ {
+ nativePath = ptr;
+ }
+
+ public GraphicsPath ()
+ {
+ Status status = GDIPlus.GdipCreatePath (FillMode.Alternate, out nativePath);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public GraphicsPath (FillMode fillMode)
+ {
+ Status status = GDIPlus.GdipCreatePath (fillMode, out nativePath);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public GraphicsPath (Point[] pts, byte[] types)
+ : this (pts, types, FillMode.Alternate)
+ {
+ }
+
+ public GraphicsPath (PointF[] pts, byte[] types)
+ : this (pts, types, FillMode.Alternate)
+ {
+ }
+
+ public GraphicsPath (Point[] pts, byte[] types, FillMode fillMode)
+ {
+ if (pts == null)
+ throw new ArgumentNullException ("pts");
+ if (pts.Length != types.Length)
+ throw new ArgumentException ("Invalid parameter passed. Number of points and types must be same.");
+
+ Status status = GDIPlus.GdipCreatePath2I (pts, types, pts.Length, fillMode, out nativePath);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public GraphicsPath (PointF[] pts, byte[] types, FillMode fillMode)
+ {
+ if (pts == null)
+ throw new ArgumentNullException ("pts");
+ if (pts.Length != types.Length)
+ throw new ArgumentException ("Invalid parameter passed. Number of points and types must be same.");
+
+ Status status = GDIPlus.GdipCreatePath2 (pts, types, pts.Length, fillMode, out nativePath);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public object Clone ()
+ {
+ IntPtr clone;
+
+ Status status = GDIPlus.GdipClonePath (nativePath, out clone);
+ GDIPlus.CheckStatus (status);
+
+ return new GraphicsPath (clone);
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ ~GraphicsPath ()
+ {
+ Dispose (false);
+ }
+
+ void Dispose (bool disposing)
+ {
+ Status status;
+ if (nativePath != IntPtr.Zero) {
+ status = GDIPlus.GdipDeletePath (nativePath);
+ GDIPlus.CheckStatus (status);
+
+ nativePath = IntPtr.Zero;
+ }
+ }
+
+ public FillMode FillMode {
+ get {
+ FillMode mode;
+ Status status = GDIPlus.GdipGetPathFillMode (nativePath, out mode);
+ GDIPlus.CheckStatus (status);
+
+ return mode;
+ }
+ set {
+ if ((value < FillMode.Alternate) || (value > FillMode.Winding))
+ throw new InvalidEnumArgumentException ("FillMode", (int)value, typeof (FillMode));
+
+ Status status = GDIPlus.GdipSetPathFillMode (nativePath, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public PathData PathData {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
+ GDIPlus.CheckStatus (status);
+
+ PointF [] points = new PointF [count];
+ status = GDIPlus.GdipGetPathPoints (nativePath, points, count);
+ GDIPlus.CheckStatus (status);
+
+ byte [] types = new byte [count];
+ status = GDIPlus.GdipGetPathTypes (nativePath, types, count);
+ GDIPlus.CheckStatus (status);
+
+ PathData pdata = new PathData ();
+ pdata.Points = points;
+ pdata.Types = types;
+ return pdata;
+ }
+ }
+
+ public PointF [] PathPoints {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
+ GDIPlus.CheckStatus (status);
+ if (count == 0)
+ throw new ArgumentException ("PathPoints");
+
+ PointF [] points = new PointF [count];
+ status = GDIPlus.GdipGetPathPoints (nativePath, points, count);
+ GDIPlus.CheckStatus (status);
+
+ return points;
+ }
+ }
+
+ public byte [] PathTypes {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
+ GDIPlus.CheckStatus (status);
+ if (count == 0)
+ throw new ArgumentException ("PathTypes");
+
+ byte [] types = new byte [count];
+ status = GDIPlus.GdipGetPathTypes (nativePath, types, count);
+ GDIPlus.CheckStatus (status);
+
+ return types;
+ }
+ }
+
+ public int PointCount {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
+ GDIPlus.CheckStatus (status);
+
+ return count;
+ }
+ }
+
+ internal IntPtr NativeObject {
+ get {
+ return nativePath;
+ }
+ set {
+ nativePath = value;
+ }
+ }
+
+ //
+ // AddArc
+ //
+ public void AddArc (Rectangle rect, float start_angle, float sweep_angle)
+ {
+ Status status = GDIPlus.GdipAddPathArcI (nativePath, rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddArc (RectangleF rect, float start_angle, float sweep_angle)
+ {
+ Status status = GDIPlus.GdipAddPathArc (nativePath, rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddArc (int x, int y, int width, int height, float start_angle, float sweep_angle)
+ {
+ Status status = GDIPlus.GdipAddPathArcI (nativePath, x, y, width, height, start_angle, sweep_angle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddArc (float x, float y, float width, float height, float start_angle, float sweep_angle)
+ {
+ Status status = GDIPlus.GdipAddPathArc (nativePath, x, y, width, height, start_angle, sweep_angle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // AddBezier
+ //
+ public void AddBezier (Point pt1, Point pt2, Point pt3, Point pt4)
+ {
+ Status status = GDIPlus.GdipAddPathBezierI (nativePath, pt1.X, pt1.Y,
+ pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddBezier (PointF pt1, PointF pt2, PointF pt3, PointF pt4)
+ {
+ Status status = GDIPlus.GdipAddPathBezier (nativePath, pt1.X, pt1.Y,
+ pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddBezier (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
+ {
+ Status status = GDIPlus.GdipAddPathBezierI (nativePath, x1, y1, x2, y2, x3, y3, x4, y4);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddBezier (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
+ {
+ Status status = GDIPlus.GdipAddPathBezier (nativePath, x1, y1, x2, y2, x3, y3, x4, y4);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // AddBeziers
+ //
+ public void AddBeziers (Point [] pts)
+ {
+ if (pts == null)
+ throw new ArgumentNullException ("pts");
+ Status status = GDIPlus.GdipAddPathBeziersI (nativePath, pts, pts.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddBeziers (PointF [] pts)
+ {
+ if (pts == null)
+ throw new ArgumentNullException ("pts");
+ Status status = GDIPlus.GdipAddPathBeziers (nativePath, pts, pts.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // AddEllipse
+ //
+ public void AddEllipse (RectangleF r)
+ {
+ Status status = GDIPlus.GdipAddPathEllipse (nativePath, r.X, r.Y, r.Width, r.Height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddEllipse (float x, float y, float width, float height)
+ {
+ Status status = GDIPlus.GdipAddPathEllipse (nativePath, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddEllipse (Rectangle r)
+ {
+ Status status = GDIPlus.GdipAddPathEllipseI (nativePath, r.X, r.Y, r.Width, r.Height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddEllipse (int x, int y, int width, int height)
+ {
+ Status status = GDIPlus.GdipAddPathEllipseI (nativePath, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ //
+ // AddLine
+ //
+ public void AddLine (Point a, Point b)
+ {
+ Status status = GDIPlus.GdipAddPathLineI (nativePath, a.X, a.Y, b.X, b.Y);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddLine (PointF a, PointF b)
+ {
+ Status status = GDIPlus.GdipAddPathLine (nativePath, a.X, a.Y, b.X,
+ b.Y);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddLine (int x1, int y1, int x2, int y2)
+ {
+ Status status = GDIPlus.GdipAddPathLineI (nativePath, x1, y1, x2, y2);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddLine (float x1, float y1, float x2, float y2)
+ {
+ Status status = GDIPlus.GdipAddPathLine (nativePath, x1, y1, x2,
+ y2);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // AddLines
+ //
+ public void AddLines (Point [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ if (points.Length == 0)
+ throw new ArgumentException ("points");
+
+ int length = points.Length;
+ for (int i = 0; i < length - 1; i++) {
+ int j = i + 1;
+ Status status = GDIPlus.GdipAddPathLineI (
+ nativePath, points [i].X, points [i].Y, points [j].X, points [j].Y);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public void AddLines (PointF [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ if (points.Length == 0)
+ throw new ArgumentException ("points");
+
+ int length = points.Length;
+
+ for (int i = 0; i < length - 1; i++) {
+ int j = i + 1;
+ Status status = GDIPlus.GdipAddPathLine (
+ nativePath, points [i].X, points [i].Y, points [j].X, points [j].Y);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ //
+ // AddPie
+ //
+ public void AddPie (Rectangle rect, float startAngle, float sweepAngle)
+ {
+ Status status = GDIPlus.GdipAddPathPie (
+ nativePath, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddPie (int x, int y, int width, int height, float startAngle, float sweepAngle)
+ {
+ Status status = GDIPlus.GdipAddPathPieI (nativePath, x, y, width, height, startAngle, sweepAngle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddPie (float x, float y, float width, float height, float startAngle, float sweepAngle)
+ {
+ Status status = GDIPlus.GdipAddPathPie (nativePath, x, y, width, height, startAngle, sweepAngle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // AddPolygon
+ //
+ public void AddPolygon (Point [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathPolygonI (nativePath, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddPolygon (PointF [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathPolygon (nativePath, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // AddRectangle
+ //
+ public void AddRectangle (Rectangle rect)
+ {
+ Status status = GDIPlus.GdipAddPathRectangleI (nativePath, rect.X, rect.Y, rect.Width, rect.Height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddRectangle (RectangleF rect)
+ {
+ Status status = GDIPlus.GdipAddPathRectangle (nativePath, rect.X, rect.Y, rect.Width, rect.Height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // AddRectangles
+ //
+ public void AddRectangles (Rectangle [] rects)
+ {
+ if (rects == null)
+ throw new ArgumentNullException ("rects");
+ if (rects.Length == 0)
+ throw new ArgumentException ("rects");
+
+ Status status = GDIPlus.GdipAddPathRectanglesI (nativePath, rects, rects.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddRectangles (RectangleF [] rects)
+ {
+ if (rects == null)
+ throw new ArgumentNullException ("rects");
+ if (rects.Length == 0)
+ throw new ArgumentException ("rects");
+
+ Status status = GDIPlus.GdipAddPathRectangles (nativePath, rects, rects.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // AddPath
+ //
+ public void AddPath (GraphicsPath addingPath, bool connect)
+ {
+ if (addingPath == null)
+ throw new ArgumentNullException ("addingPath");
+
+ Status status = GDIPlus.GdipAddPathPath (nativePath, addingPath.nativePath, connect);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public PointF GetLastPoint ()
+ {
+ PointF pt;
+ Status status = GDIPlus.GdipGetPathLastPoint (nativePath, out pt);
+ GDIPlus.CheckStatus (status);
+
+ return pt;
+ }
+
+ //
+ // AddClosedCurve
+ //
+ public void AddClosedCurve (Point [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathClosedCurveI (nativePath, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddClosedCurve (PointF [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathClosedCurve (nativePath, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddClosedCurve (Point [] points, float tension)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathClosedCurve2I (nativePath, points, points.Length, tension);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddClosedCurve (PointF [] points, float tension)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathClosedCurve2 (nativePath, points, points.Length, tension);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // AddCurve
+ //
+ public void AddCurve (Point [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathCurveI (nativePath, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddCurve (PointF [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathCurve (nativePath, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddCurve (Point [] points, float tension)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathCurve2I (nativePath, points, points.Length, tension);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddCurve (PointF [] points, float tension)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathCurve2 (nativePath, points, points.Length, tension);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddCurve (Point [] points, int offset, int numberOfSegments, float tension)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathCurve3I (nativePath, points, points.Length,
+ offset, numberOfSegments, tension);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddCurve (PointF [] points, int offset, int numberOfSegments, float tension)
+ {
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status = GDIPlus.GdipAddPathCurve3 (nativePath, points, points.Length,
+ offset, numberOfSegments, tension);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Reset ()
+ {
+ Status status = GDIPlus.GdipResetPath (nativePath);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Reverse ()
+ {
+ Status status = GDIPlus.GdipReversePath (nativePath);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Transform (Matrix matrix)
+ {
+ if (matrix == null)
+ throw new ArgumentNullException ("matrix");
+
+ Status status = GDIPlus.GdipTransformPath (nativePath, matrix.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+
+ [MonoTODO]
+ public void AddString (string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void AddString (string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void AddString (string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void AddString (string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void ClearMarkers()
+ {
+ Status s = GDIPlus.GdipClearPathMarkers (nativePath);
+
+ GDIPlus.CheckStatus (s);
+ }
+
+ public void CloseAllFigures()
+ {
+ Status s = GDIPlus.GdipClosePathFigures (nativePath);
+
+ GDIPlus.CheckStatus (s);
+ }
+
+ public void CloseFigure()
+ {
+ Status s = GDIPlus.GdipClosePathFigure (nativePath);
+
+ GDIPlus.CheckStatus (s);
+ }
+
+ [MonoTODO ("GdipFlattenPath isn't implemented in libgdiplus")]
+ public void Flatten ()
+ {
+ // 1/4 is the FlatnessDefault as defined in GdiPlusEnums.h
+ Flatten (null, 1.0f / 4.0f);
+ }
+
+ [MonoTODO ("GdipFlattenPath isn't implemented in libgdiplus")]
+ public void Flatten (Matrix matrix)
+ {
+ Flatten (matrix, 1.0f / 4.0f);
+ }
+
+ [MonoTODO ("GdipFlattenPath isn't implemented in libgdiplus")]
+ public void Flatten (Matrix matrix, float flatness)
+ {
+ IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;
+ Status status = GDIPlus.GdipFlattenPath (nativePath, m, flatness);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public RectangleF GetBounds ()
+ {
+ return GetBounds (null, null);
+ }
+
+ public RectangleF GetBounds (Matrix matrix)
+ {
+ return GetBounds (matrix, null);
+ }
+
+ [MonoTODO ("GdipGetPathWorldBounds doesn't support pens in libgdiplus (missing GdipWidenPath)")]
+ public RectangleF GetBounds (Matrix matrix, Pen pen)
+ {
+ RectangleF retval;
+ IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;
+ IntPtr p = (pen == null) ? IntPtr.Zero : pen.nativeObject;
+
+ Status s = GDIPlus.GdipGetPathWorldBounds (nativePath, out retval, m, p);
+
+ GDIPlus.CheckStatus (s);
+
+ return retval;
+ }
+
+ public bool IsOutlineVisible (Point point, Pen pen)
+ {
+ return IsOutlineVisible (point.X, point.Y, pen, null);
+ }
+
+ public bool IsOutlineVisible (PointF point, Pen pen)
+ {
+ return IsOutlineVisible (point.X, point.Y, pen, null);
+ }
+
+ public bool IsOutlineVisible (int x, int y, Pen pen)
+ {
+ return IsOutlineVisible (x, y, pen, null);
+ }
+
+ public bool IsOutlineVisible (float x, float y, Pen pen)
+ {
+ return IsOutlineVisible (x, y, pen, null);
+ }
+
+ public bool IsOutlineVisible (Point pt, Pen pen, Graphics graphics)
+ {
+ return IsOutlineVisible (pt.X, pt.Y, pen, graphics);
+ }
+
+ public bool IsOutlineVisible (PointF pt, Pen pen, Graphics graphics)
+ {
+ return IsOutlineVisible (pt.X, pt.Y, pen, graphics);
+ }
+
+ [MonoTODO]
+ public bool IsOutlineVisible (int x, int y, Pen pen, Graphics graphics)
+ {
+ bool result;
+ IntPtr g = (graphics == null) ? IntPtr.Zero : graphics.nativeObject;
+
+ Status s = GDIPlus.GdipIsOutlineVisiblePathPointI (nativePath, x, y, g, out result);
+ GDIPlus.CheckStatus (s);
+
+ return result;
+ }
+
+ [MonoTODO]
+ public bool IsOutlineVisible (float x, float y, Pen pen, Graphics graphics)
+ {
+ bool result;
+ IntPtr g = (graphics == null) ? IntPtr.Zero : graphics.nativeObject;
+
+ Status s = GDIPlus.GdipIsOutlineVisiblePathPoint (nativePath, x, y, g, out result);
+ GDIPlus.CheckStatus (s);
+
+ return result;
+ }
+
+ public bool IsVisible (Point point)
+ {
+ return IsVisible (point.X, point.Y, null);
+ }
+
+ public bool IsVisible (PointF point)
+ {
+ return IsVisible (point.X, point.Y, null);
+ }
+
+ public bool IsVisible (int x, int y)
+ {
+ return IsVisible (x, y, null);
+ }
+
+ public bool IsVisible (float x, float y)
+ {
+ return IsVisible (x, y, null);
+ }
+
+ public bool IsVisible (Point pt, Graphics graphics)
+ {
+ return IsVisible (pt.X, pt.Y, graphics);
+ }
+
+ public bool IsVisible (PointF pt, Graphics graphics)
+ {
+ return IsVisible (pt.X, pt.Y, graphics);
+ }
+
+ [MonoTODO]
+ public bool IsVisible (int x, int y, Graphics graphics)
+ {
+ bool retval;
+
+ IntPtr g = (graphics == null) ? IntPtr.Zero : graphics.nativeObject;
+
+ Status s = GDIPlus.GdipIsVisiblePathPointI (nativePath, x, y, g, out retval);
+
+ GDIPlus.CheckStatus (s);
+
+ return retval;
+ }
+
+ [MonoTODO]
+ public bool IsVisible (float x, float y, Graphics graphics)
+ {
+ bool retval;
+
+ IntPtr g = (graphics == null) ? IntPtr.Zero : graphics.nativeObject;
+
+ Status s = GDIPlus.GdipIsVisiblePathPoint (nativePath, x, y, g, out retval);
+
+ GDIPlus.CheckStatus (s);
+
+ return retval;
+ }
+
+ public void SetMarkers ()
+ {
+ Status s = GDIPlus.GdipSetPathMarker (nativePath);
+
+ GDIPlus.CheckStatus (s);
+ }
+
+ public void StartFigure()
+ {
+ Status s = GDIPlus.GdipStartPathFigure (nativePath);
+
+ GDIPlus.CheckStatus (s);
+ }
+
+ [MonoTODO ("GdipWarpPath isn't implemented in libgdiplus")]
+ public void Warp (PointF[] destPoints, RectangleF srcRect)
+ {
+ Warp (destPoints, srcRect, null, WarpMode.Perspective, 1.0f / 4.0f);
+ }
+
+ [MonoTODO ("GdipWarpPath isn't implemented in libgdiplus")]
+ public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix)
+ {
+ Warp (destPoints, srcRect, matrix, WarpMode.Perspective, 1.0f / 4.0f);
+ }
+
+ [MonoTODO ("GdipWarpPath isn't implemented in libgdiplus")]
+ public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
+ {
+ Warp (destPoints, srcRect, matrix, warpMode, 1.0f / 4.0f);
+ }
+
+ [MonoTODO ("GdipWarpPath isn't implemented in libgdiplus")]
+ public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
+ {
+ if (destPoints == null)
+ throw new ArgumentNullException ("destPoints");
+
+ IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;
+
+ Status s = GDIPlus.GdipWarpPath (nativePath, m, destPoints, destPoints.Length,
+ srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, warpMode, flatness);
+
+ GDIPlus.CheckStatus (s);
+ }
+
+ [MonoTODO ("GdipWidenPath isn't implemented in libgdiplus")]
+ public void Widen (Pen pen)
+ {
+ Widen (pen, null, 1.0f / 4.0f);
+ }
+
+ [MonoTODO ("GdipWidenPath isn't implemented in libgdiplus")]
+ public void Widen (Pen pen, Matrix matrix)
+ {
+ Widen (pen, matrix, 1.0f / 4.0f);
+ }
+
+ [MonoTODO ("GdipWidenPath isn't implemented in libgdiplus")]
+ public void Widen (Pen pen, Matrix matrix, float flatness)
+ {
+ IntPtr p = (pen == null) ? IntPtr.Zero : pen.nativeObject;
+ IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;
+
+ Status s = GDIPlus.GdipWidenPath (nativePath, p, m, flatness);
+
+ GDIPlus.CheckStatus (s);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.jvm.cs
new file mode 100755
index 00000000000..76363d614d2
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.jvm.cs
@@ -0,0 +1,1082 @@
+//
+// System.Drawing.Drawing2D.GraphicsPath.cs
+//
+// Author:
+// Konstantin Triger <kostat@mainsoft.com>
+// Bors Kirzner <boris@mainsoft.com>
+//
+// Copyright (C) 2005 Mainsoft Corporation, (http://www.mainsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Collections;
+using java.awt.geom;
+using java.awt;
+
+namespace System.Drawing.Drawing2D
+{
+ public sealed class GraphicsPath : BasicShape, ICloneable
+ {
+ internal enum JPI {
+ SEG_MOVETO = ExtendedGeneralPath.SEG_MOVETO,
+ SEG_LINETO = ExtendedGeneralPath.SEG_LINETO,
+ SEG_QUADTO = ExtendedGeneralPath.SEG_QUADTO,
+ SEG_CUBICTO = ExtendedGeneralPath.SEG_CUBICTO,
+ SEG_CLOSE = ExtendedGeneralPath.SEG_CLOSE
+ }
+
+ #region Internal
+
+ internal ExtendedGeneralPath NativeObject
+ {
+ get
+ {
+ return (ExtendedGeneralPath)Shape;
+ }
+ }
+
+ GraphicsPath (ExtendedGeneralPath ptr) : base(ptr)
+ {
+ }
+ #endregion
+
+ #region C-tors.
+ public GraphicsPath ():
+ this(FillMode.Alternate)
+ {
+ }
+
+ public GraphicsPath (FillMode fillMode) : this(new ExtendedGeneralPath ())
+ {
+ FillMode = fillMode;
+ }
+
+ public GraphicsPath (Point[] pts, byte[] types) : this(pts, types, FillMode.Alternate)
+ {
+ }
+
+ public GraphicsPath (PointF [] pts, byte [] types) : this(pts, types, FillMode.Alternate)
+ {
+ }
+
+ public GraphicsPath (Point [] pts, byte [] types, FillMode fillMode) : this(new ExtendedGeneralPath ())
+ {
+ FillMode = fillMode;
+ SetPath (pts, types);
+ }
+
+ public GraphicsPath (PointF [] pts, byte [] types, FillMode fillMode) : this(new ExtendedGeneralPath ())
+ {
+ FillMode = fillMode;
+ SetPath (pts, types);
+ }
+
+ #endregion
+
+ #region Clone
+ public object Clone ()
+ {
+ return new GraphicsPath ((ExtendedGeneralPath) NativeObject.Clone ());
+ }
+ #endregion
+
+ #region Properties
+ public FillMode FillMode
+ {
+ get
+ { if(NativeObject.getWindingRule() == GeneralPath.WIND_EVEN_ODD)
+ return FillMode.Alternate;
+ else
+ return FillMode.Winding;
+ }
+
+ set
+ {
+ if (value == FillMode.Alternate)
+ NativeObject.setWindingRule (GeneralPath.WIND_EVEN_ODD);
+ else
+ NativeObject.setWindingRule (GeneralPath.WIND_NON_ZERO);
+ }
+ }
+
+ public PathData PathData
+ {
+ get { return NativeObject.PathData; }
+ }
+
+ public PointF [] PathPoints
+ {
+ get
+ {
+ return PathData.Points;
+ }
+ }
+
+ public byte [] PathTypes
+ {
+ get
+ {
+ return PathData.Types;
+ }
+ }
+ #endregion
+
+ #region PointCount
+ public int PointCount
+ {
+ get
+ {
+ return NativeObject.PointCount;
+ }
+ }
+ #endregion
+
+ #region AddArc
+ public void AddArc (Rectangle rect, float startAngle, float sweepAngle)
+ {
+ AddArc(rect.X,rect.Y,rect.Width,rect.Height,startAngle,sweepAngle);
+ }
+
+ public void AddArc (RectangleF rect, float startAngle, float sweepAngle)
+ {
+ AddArc(rect.X,rect.Y,rect.Width,rect.Height,startAngle,sweepAngle);
+ }
+
+ public void AddArc (int x, int y, int width, int height, float startAngle, float sweepAngle)
+ {
+ AddArc((float)x,(float)y,(float)width,(float)height,startAngle,sweepAngle);
+ }
+
+ public void AddArc (float x, float y, float width, float height, float startAngle, float sweepAngle)
+ {
+ Shape shape = null;
+
+ if (sweepAngle >= 360)
+ shape = new Ellipse2D.Float(x, y, width, height);
+ else {
+
+ double d1Tod2 = width/height;
+ double sqrd1Tod2 = d1Tod2*d1Tod2;
+ double start = ConvertArcAngle(sqrd1Tod2, startAngle);
+ double extent = ConvertArcAngle(sqrd1Tod2, startAngle+sweepAngle) - start;
+
+ shape = new Arc2D.Double(x,y,width,height,-start,-extent,Arc2D.OPEN);
+ }
+
+ NativeObject.append(shape);
+ }
+
+ /// <summary>
+ /// .Net computes an angle by intersection of ellipse with a ray
+ /// java does the following: x1 = d1*cos(a), y1 = d2*sin(a)
+ /// where: d1 = width/2, d2 = height/2
+ /// we need to find angle x, which satisfies:
+ /// x1 = m*cos(a) = d1*cos(x)
+ /// y1 = m*sin(a) = d2*sin(x)
+ /// (x1*x1)/(d1*d1) + (x2*x2)/(d2*d2) = 1
+ /// </summary>
+ /// <param name="sqrd1Tod2">(d1/d2)*(d1/d2)</param>
+ /// <param name="angle">angle in degrees</param>
+ /// <returns>converted angle in degrees</returns>
+ static double ConvertArcAngle(double sqrd1Tod2, double angle) {
+ double angleRad = java.lang.Math.toRadians(angle);
+ double tan = Math.Tan(angleRad);
+ double cosx = 1/Math.Sqrt( sqrd1Tod2 * (tan*tan) + 1);
+ double xRad = Math.Acos(cosx);
+ double x = java.lang.Math.toDegrees(xRad);
+ int q = (Math.Abs((int)angle))/90;
+
+ switch (q&3) {
+ case 1:
+ x = 180-x;
+ break;
+ case 2:
+ x = 180+x;
+ break;
+ case 3:
+ x = 360-x;
+ break;
+ }
+
+ if (angle < 0)
+ x = -x;
+
+ x += (((int)angle)/360)*360;
+
+ return x;
+ }
+
+ #endregion
+
+ #region AddBezier(s)
+ public void AddBezier (Point pt1, Point pt2, Point pt3, Point pt4)
+ {
+ AddBezier(pt1.X,pt1.Y,pt2.X,pt2.Y,pt3.X,pt3.Y,pt4.X,pt4.Y);
+ }
+
+ public void AddBezier (PointF pt1, PointF pt2, PointF pt3, PointF pt4)
+ {
+ AddBezier(pt1.X,pt1.Y,pt2.X,pt2.Y,pt3.X,pt3.Y,pt4.X,pt4.Y);
+ }
+
+ public void AddBezier (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
+ {
+ AddBezier((float)x1,(float)y1,(float)x2,(float)y2,(float)x3,(float)y3,(float)x4,(float)y4);
+ }
+
+ public void AddBezier (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
+ {
+ CubicCurve2D cc = new CubicCurve2D.Float(x1,y1,x2,y2,x3,y3,x4,y4);
+ NativeObject.append(cc);
+ }
+
+ public void AddBeziers (Point [] pts)
+ {
+ if (pts == null)
+ throw new ArgumentNullException("points");
+
+ AddBezier(pts [0].X,pts [0].Y,
+ pts [1].X,pts [1].Y,
+ pts [2].X,pts [2].Y,
+ pts [3].X,pts [3].Y);
+
+ for (int i = 4; i < pts.Length; i += 3) {
+ NativeObject.curveTo(
+ pts [i].X,pts [i].Y,
+ pts [i+1].X,pts [i+1].Y,
+ pts [i+2].X,pts [i+2].Y);
+ }
+ }
+
+ public void AddBeziers (PointF [] pts)
+ {
+ if (pts == null)
+ throw new ArgumentNullException("points");
+
+ AddBezier(pts [0].X,pts [0].Y,
+ pts [1].X,pts [1].Y,
+ pts [2].X,pts [2].Y,
+ pts [3].X,pts [3].Y);
+
+ for (int i = 4; i < pts.Length; i += 3) {
+ NativeObject.curveTo(
+ pts [i].X,pts [i].Y,
+ pts [i+1].X,pts [i+1].Y,
+ pts [i+2].X,pts [i+2].Y);
+ }
+ }
+ #endregion
+
+ #region AddEllipse
+ public void AddEllipse (float x, float y, float width, float height)
+ {
+ Ellipse2D e = new Ellipse2D.Float(x,y,width,height);
+ NativeObject.append(e,false);
+ }
+
+ public void AddEllipse (RectangleF r)
+ {
+ AddEllipse(r.X,r.Y,r.Width,r.Height);
+ }
+
+ public void AddEllipse (Rectangle r)
+ {
+ AddEllipse(r.X,r.Y,r.Width,r.Height);
+ }
+
+ public void AddEllipse (int x, int y, int width, int height)
+ {
+ AddEllipse((float)x, (float)y, (float)width, (float)height);
+ }
+ #endregion
+
+ #region AddLine
+ public void AddLine (float x1, float y1, float x2, float y2)
+ {
+ Line2D l = new Line2D.Float(x1,y1,x2,y2);
+ NativeObject.append(l);
+ }
+
+ public void AddLine (Point a, Point b)
+ {
+ AddLine(a.X,a.Y,b.X,b.Y);
+ }
+
+ public void AddLine (PointF a, PointF b)
+ {
+ AddLine(a.X,a.Y,b.X,b.Y);
+ }
+
+ public void AddLine (int x1, int y1, int x2, int y2)
+ {
+ AddLine((float)x1,(float)y1,(float)x2,(float)y2);
+ }
+
+ public void AddLines (Point [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException("points");
+
+ if (points.Length == 0)
+ return;
+
+ if (NativeObject.LastFigureClosed)
+ NativeObject.moveTo(points[0].X, points[0].Y);
+ else
+ NativeObject.lineTo(points[0].X, points[0].Y);
+
+ for (int i = 1; i < points.Length; i ++)
+ NativeObject.lineTo(points[i].X, points[i].Y);
+ }
+
+ public void AddLines (PointF [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException("points");
+
+ if (points.Length == 0)
+ return;
+
+ if (NativeObject.LastFigureClosed)
+ NativeObject.moveTo(points[0].X, points[0].Y);
+ else
+ NativeObject.lineTo(points[0].X, points[0].Y);
+
+ for (int i = 1; i < points.Length; i ++)
+ NativeObject.lineTo(points[i].X, points[i].Y);
+ }
+ #endregion
+
+ #region AddPie
+ public void AddPie (float x, float y, float width, float height, float startAngle, float sweepAngle)
+ {
+ Shape shape = null;
+
+ if (sweepAngle >= 360)
+ shape = new Ellipse2D.Float(x, y, width, height);
+ else {
+
+ double d1Tod2 = width/height;
+ double sqrd1Tod2 = d1Tod2*d1Tod2;
+ double start = ConvertArcAngle(sqrd1Tod2, startAngle);
+ double extent = ConvertArcAngle(sqrd1Tod2, startAngle+sweepAngle) - start;
+
+ shape = new Arc2D.Double(x,y,width,height,-start,-extent,Arc2D.PIE);
+ }
+
+ NativeObject.append(shape,false);
+ }
+
+ public void AddPie (Rectangle rect, float startAngle, float sweepAngle)
+ {
+ AddPie((float)rect.X, (float)rect.Y,(float)rect.Width,(float)rect.Height,startAngle,sweepAngle);
+ }
+
+ public void AddPie (int x, int y, int width, int height, float startAngle, float sweepAngle)
+ {
+ AddPie((float)x,(float)y,(float)width,(float)height,startAngle,sweepAngle);
+ }
+ #endregion
+
+ #region AddPolygon
+ public void AddPolygon (Point [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException("points");
+
+ if (points.Length < 3)
+ throw new ArgumentException("Invalid parameter used.");
+
+ NativeObject.moveTo((float)points[0].X,(float)points[0].Y);
+ for (int i = 1; i< points.Length; i++)
+ {
+ NativeObject.lineTo((float)points[i].X,(float)points[i].Y);
+ }
+ NativeObject.closePath();
+ }
+
+ public void AddPolygon (PointF [] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException("points");
+
+ if (points.Length < 3)
+ throw new ArgumentException("Invalid parameter used.");
+
+ NativeObject.moveTo(points[0].X,points[0].Y);
+ for (int i = 1; i < points.Length; i++)
+ {
+ NativeObject.lineTo(points[i].X,points[i].Y);
+ }
+ NativeObject.closePath();
+ }
+ #endregion
+
+ #region AddRectangle(s)
+ internal void AddRectangle(float x,float y, float w, float h)
+ {
+ NativeObject.moveTo(x, y);
+ NativeObject.lineTo (x + w, y);
+ NativeObject.lineTo (x + w, y + h);
+ NativeObject.lineTo (x, y + h);
+ NativeObject.closePath ();
+ }
+ public void AddRectangle (RectangleF rect)
+ {
+ AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
+ }
+
+ public void AddRectangle (Rectangle rect)
+ {
+ AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
+ }
+
+ public void AddRectangles (Rectangle [] rects)
+ {
+ foreach(Rectangle rect in rects)
+ AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
+ }
+
+ public void AddRectangles (RectangleF [] rects)
+ {
+ foreach(RectangleF rect in rects)
+ AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
+ }
+ #endregion
+
+ #region AddPath
+ public void AddPath (GraphicsPath addingPath, bool connect)
+ {
+ if (NativeObject.LastFigureClosed || addingPath.NativeObject.LastFigureClosed)
+ connect = false;
+
+ NativeObject.append(addingPath.NativeObject,connect);
+ }
+ #endregion
+
+ #region GetLastPoint
+ public PointF GetLastPoint ()
+ {
+ return NativeObject.GetLastPoint ();
+ }
+ #endregion
+
+ #region Reset
+ public void Reset ()
+ {
+ NativeObject.reset();
+ }
+ #endregion
+
+ #region GetBounds
+ public RectangleF GetBounds ()
+ {
+ return GetBounds (null, null);
+ }
+
+ public RectangleF GetBounds (Matrix matrix)
+ {
+ return GetBounds (matrix, null);
+ }
+
+ public RectangleF GetBounds (Matrix matrix, Pen pen)
+ {
+ // FIXME : we do not know exacly how the bounding rectangle
+ // is calculated so this implementation obtains different bounds
+ // that still contains the path widened by oen and transformed by matrix
+ // the order of operations is similar to widening, as .Net does.
+
+ // first get original shape bounds
+ //Shape shape = NativeObject.getBounds2D();
+ Shape shape = NativeObject;
+
+ // stroke bounds
+ if (pen != null)
+ shape = ((Stroke)pen).createStrokedShape (shape);
+
+ Rectangle2D rect = shape.getBounds2D ();
+
+ // transform bounds
+ if (matrix != null)
+ rect = matrix.NativeObject.createTransformedShape(rect).getBounds2D();
+
+ return new RectangleF (rect);
+ }
+ #endregion
+
+ #region Transform
+ public void Transform (Matrix matrix)
+ {
+ if(matrix == null)
+ return;
+
+ NativeObject.transform(matrix.NativeObject);
+ }
+ #endregion
+
+ #region IsVisible
+ public bool IsVisible (Point point)
+ {
+ return IsVisible (point.X, point.Y, null);
+ }
+
+ public bool IsVisible (PointF point)
+ {
+ return IsVisible (point.X, point.Y, null);
+ }
+
+ public bool IsVisible (int x, int y)
+ {
+ return IsVisible (x, y, null);
+ }
+
+ public bool IsVisible (float x, float y)
+ {
+ return IsVisible (x, y, null);
+ }
+
+ public bool IsVisible (Point pt, Graphics graphics)
+ {
+ return IsVisible (pt.X, pt.Y, graphics);
+ }
+
+ public bool IsVisible (PointF pt, Graphics graphics)
+ {
+ return IsVisible (pt.X, pt.Y, graphics);
+ }
+
+ public bool IsVisible (int x, int y, Graphics graphics)
+ {
+ return IsVisible((float)x,(float)y,null);
+ }
+
+ public bool IsVisible (float x, float y, Graphics graphics)
+ {
+ // LAMESPEC : .Net is currently ignorig Graphics object
+ //if (graphics != null && !graphics.IsVisible(x,y))
+ // return false;
+
+ return NativeObject.contains(x,y);
+ }
+ #endregion
+
+ #region Reverse
+ public void Reverse ()
+ {
+ NativeObject.Reverse ();
+ }
+ #endregion
+
+ #region AddClosedCurve
+ public void AddClosedCurve (Point [] points)
+ {
+ AddClosedCurve(points, 0.5f);
+ }
+
+ public void AddClosedCurve (PointF [] points)
+ {
+ AddClosedCurve(points, 0.5f);
+ }
+
+ public void AddClosedCurve (Point [] points, float tension)
+ {
+ if (points == null)
+ throw new ArgumentNullException("points");
+
+ if (points.Length < 3)
+ throw new ArgumentException("Invalid parameter used.");
+
+ int length = (points.Length + 3)*2;
+
+ float[] pts = new float[length];
+ pts[--length] = points[1].Y;
+ pts[--length] = points[1].X;
+ pts[--length] = points[0].Y;
+ pts[--length] = points[0].X;
+
+ for (int i = points.Length-1; i >= 0; i--) {
+ pts[--length] = points[i].Y;
+ pts[--length] = points[i].X;
+ }
+
+ pts[--length] = points[points.Length-1].Y;
+ pts[--length] = points[points.Length-1].X;
+
+ AddCurve(pts, !NativeObject.LastFigureClosed, tension);
+ CloseFigure ();
+ }
+
+ public void AddClosedCurve (PointF [] points, float tension)
+ {
+ if (points == null)
+ throw new ArgumentNullException("points");
+
+ if (points.Length < 3)
+ throw new ArgumentException("Invalid parameter used.");
+
+ int length = (points.Length + 3)*2;
+
+ float[] pts = new float[length];
+ pts[--length] = points[1].Y;
+ pts[--length] = points[1].X;
+ pts[--length] = points[0].Y;
+ pts[--length] = points[0].X;
+
+ for (int i = points.Length-1; i >= 0; i--) {
+ pts[--length] = points[i].Y;
+ pts[--length] = points[i].X;
+ }
+
+ pts[--length] = points[points.Length-1].Y;
+ pts[--length] = points[points.Length-1].X;
+
+ AddCurve(pts, !NativeObject.LastFigureClosed, tension);
+ CloseFigure ();
+ }
+ #endregion
+
+ #region AddCurve
+ //we have now two approaches for drawing cardinal curves
+ //the first one is to convert cardinals into approximate beziers
+ //the second one - to draw curve ourself with all interpolation staff
+ //here. I preffer the first one because we could utilize java antialiasing and
+ //flattening features, otherwise curves will be more strict but less cool
+ public void AddCurve (Point [] points)
+ {
+ AddCurve(points,0.5F);
+ }
+
+ public void AddCurve (PointF [] points)
+ {
+ AddCurve(points,0.5f);
+ }
+
+ public void AddCurve (Point [] points, float tension)
+ {
+ AddCurve(points, 0, points.Length-1, tension);
+ }
+
+ public void AddCurve (PointF [] points, float tension)
+ {
+ AddCurve(points, 0, points.Length-1, tension);
+ }
+
+ public void AddCurve (Point [] points, int offset, int numberOfSegments, float tension)
+ {
+ int nPoints = numberOfSegments + 1;
+ int length = nPoints*2 + 4;
+ float[] pts = new float[length];
+
+ int lastP = offset + nPoints;
+ if (lastP == points.Length) {
+ lastP--;
+ pts[--length] = points[lastP].Y;
+ pts[--length] = points[lastP].X;
+ }
+
+ for (; length > 0 && lastP >= 0; lastP--) {
+ pts[--length] = points[lastP].Y;
+ pts[--length] = points[lastP].X;
+ }
+
+ if (length > 0) {
+ pts[1] = points[0].Y;
+ pts[0] = points[0].X;
+ }
+
+ AddCurve(pts, !NativeObject.LastFigureClosed, tension);
+ }
+
+ public void AddCurve (PointF [] points, int offset, int numberOfSegments, float tension)
+ {
+ int nPoints = numberOfSegments + 1;
+ int length = nPoints*2 + 4;
+ float[] pts = new float[length];
+
+ int lastP = offset + nPoints;
+ if (lastP == points.Length) {
+ lastP--;
+ pts[--length] = points[lastP].Y;
+ pts[--length] = points[lastP].X;
+ }
+
+ for (; length > 0 && lastP >= 0; lastP--) {
+ pts[--length] = points[lastP].Y;
+ pts[--length] = points[lastP].X;
+ }
+
+ if (length > 0) {
+ pts[1] = points[0].Y;
+ pts[0] = points[0].X;
+ }
+
+ AddCurve(pts, !NativeObject.LastFigureClosed, tension);
+ }
+
+ /// <summary>
+ /// Based on http://pubpages.unh.edu/~cs770/a5/cardinal.html
+ /// </summary>
+ /// <param name="pts">point array (x1,y1,x2,y2 ...).
+ /// The first and last points considered only for calculations, but are not added.</param>
+ void AddCurve(float[] pts, bool connect, float tension) {
+ tension /= 3f; //looks like a good pick
+
+ if (connect)
+ NativeObject.lineTo(pts[2],pts[3]);
+ else
+ NativeObject.moveTo(pts[2],pts[3]);
+
+ float dx = pts[4] - pts[0];
+ float dy = pts[5] - pts[1];
+
+ float sx = pts[2] + tension*dx;
+ float sy = pts[3] + tension*dy;
+
+ for (int offset = 2, total = pts.Length-4; offset < total; offset += 2) {
+ int cur_offset = offset;
+ int pX = cur_offset++;
+ int pY = cur_offset++;
+ int X = cur_offset++;
+ int Y = cur_offset++;
+ int nX = cur_offset++;
+ int nY = cur_offset++;
+
+ dx = pts[nX] - pts[pX];
+ dy = pts[nY] - pts[pY];
+
+ float rx = pts[X] - tension*dx;
+ float ry = pts[Y] - tension*dy;
+
+ NativeObject.curveTo(sx, sy, rx, ry, pts[X], pts[Y]);
+
+ sx = pts[X] + tension*dx;
+ sy = pts[Y] + tension*dy;
+ }
+ }
+ #endregion
+
+ #region AddString
+ public void AddString (string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
+ {
+ AddString(s, new Font(family, emSize, (FontStyle)style, GraphicsUnit.World), origin.X, origin.Y, float.PositiveInfinity, float.PositiveInfinity,
+ format);
+ }
+
+ public void AddString (string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
+ {
+ AddString(s, new Font(family, emSize, (FontStyle)style, GraphicsUnit.World), origin.X, origin.Y, float.PositiveInfinity, float.PositiveInfinity,
+ format);
+ }
+
+ public void AddString (string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
+ {
+ AddString(s, new Font(family, emSize, (FontStyle)style, GraphicsUnit.World),
+ layoutRect.X, layoutRect.Y, layoutRect.Width, layoutRect.Height,
+ format);
+ }
+
+ public void AddString (string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
+ {
+ AddString(s, new Font(family, emSize, (FontStyle)style, GraphicsUnit.World),
+ layoutRect.X, layoutRect.Y, layoutRect.Width, layoutRect.Height,
+ format);
+ }
+
+ void AddString (string s, Font font,
+ float x, float y, float width, float height,
+ StringFormat format) {
+
+ TextLineIterator iter = new TextLineIterator(s, font,
+ new java.awt.font.FontRenderContext(null, false, false),
+ format, width, height);
+
+ int coordsCount = NativeObject.CoordsCount;
+
+ for (LineLayout layout = iter.NextLine(); layout != null; layout = iter.NextLine()) {
+ NativeObject.append(layout.GetOutline(x, y), false);
+ }
+
+ AffineTransform lineAlignT = iter.CalcLineAlignmentTransform();
+ if (lineAlignT != null)
+ NativeObject.transform(lineAlignT, coordsCount, NativeObject.CoordsCount - coordsCount);
+ }
+ #endregion
+
+ #region ClearMarkers
+ public void ClearMarkers()
+ {
+ NativeObject.ClearMarkers ();
+ }
+ #endregion
+
+ #region Close
+ public void CloseAllFigures()
+ {
+ ExtendedGeneralPath p = new ExtendedGeneralPath();
+ PathIterator pi = NativeObject.getPathIterator(null);
+ JPI lastSeg = JPI.SEG_CLOSE;
+ float [] points = new float[6];
+
+ p.setWindingRule(pi.getWindingRule());
+ while(!pi.isDone())
+ {
+ JPI curSeg = (JPI)pi.currentSegment(points);
+ switch(curSeg)
+ {
+ case JPI.SEG_CLOSE:
+ p.closePath();
+ break;
+ case JPI.SEG_MOVETO:
+ if(lastSeg != JPI.SEG_CLOSE)
+ p.closePath();
+ p.moveTo(points[0],points[1]);
+ break;
+ case JPI.SEG_LINETO:
+ p.lineTo(points[0],points[1]);
+ break;
+ case JPI.SEG_QUADTO:
+ p.quadTo(points[0],points[1],points[2],points[3]);
+ break;
+ case JPI.SEG_CUBICTO:
+ p.curveTo(points[0],points[1],points[2],points[3],points[4],points[5]);
+ break;
+ default:
+ break;
+ }
+ lastSeg = curSeg;
+ pi.next();
+ }
+
+ p.closePath();
+ Shape = p;
+ }
+
+ public void CloseFigure() {
+ if (!NativeObject.LastFigureClosed)
+ NativeObject.closePath();
+ }
+ #endregion
+
+ #region Flatten
+ public void Flatten ()
+ {
+ // 1/4 is the FlatnessDefault as defined in GdiPlusEnums.h
+ Flatten (null, 1.0f / 4.0f);
+ }
+
+ public void Flatten (Matrix matrix)
+ {
+ Flatten (matrix, 1.0f / 4.0f);
+ }
+
+ public void Flatten (Matrix matrix, float flatness)
+ {
+ AffineTransform tr = null;
+ if(matrix != null)
+ tr = matrix.NativeObject;
+
+ //FIXME : Review (perfomance reasons).
+ PathIterator pi = NativeObject.getPathIterator(tr,flatness);
+ ExtendedGeneralPath newPath = new ExtendedGeneralPath();
+ newPath.append(pi,false);
+ Shape = newPath;
+ }
+ #endregion
+
+ #region GetOutlineVisible
+ public bool IsOutlineVisible (Point point, Pen pen)
+ {
+ return IsOutlineVisible (point.X, point.Y, pen, null);
+ }
+
+ public bool IsOutlineVisible (PointF point, Pen pen)
+ {
+ return IsOutlineVisible (point.X, point.Y, pen, null);
+ }
+
+ public bool IsOutlineVisible (int x, int y, Pen pen)
+ {
+ return IsOutlineVisible (x, y, pen, null);
+ }
+
+ public bool IsOutlineVisible (float x, float y, Pen pen)
+ {
+ return IsOutlineVisible (x, y, pen, null);
+ }
+
+ public bool IsOutlineVisible (Point pt, Pen pen, Graphics graphics)
+ {
+ return IsOutlineVisible (pt.X, pt.Y, pen, graphics);
+ }
+
+ public bool IsOutlineVisible (PointF pt, Pen pen, Graphics graphics)
+ {
+ return IsOutlineVisible (pt.X, pt.Y, pen, graphics);
+ }
+
+ public bool IsOutlineVisible (int x, int y, Pen pen, Graphics graphics)
+ {
+ // LAMESPEC : .Net is currently ignorig Graphics object
+ //if (graphics != null) {
+ // if (!graphics.IsVisible (x, y))
+ // return false;
+ //}
+
+ return ((Stroke)pen).createStrokedShape (NativeObject).contains (x, y);
+ }
+
+ public bool IsOutlineVisible (float x, float y, Pen pen, Graphics graphics)
+ {
+ return ((Stroke)pen).createStrokedShape (NativeObject).contains (x, y);
+ }
+ #endregion
+
+ #region SetMarkers
+ public void SetMarkers ()
+ {
+ NativeObject.SetMarkers ();
+ }
+ #endregion
+
+ #region StartFigure
+ public void StartFigure()
+ {
+ NativeObject.StartFigure ();
+ }
+ #endregion
+
+ #region Warp
+ [MonoTODO]
+ public void Warp (PointF[] destPoints, RectangleF srcRect)
+ {
+ Warp (destPoints, srcRect, null, WarpMode.Perspective, 1.0f / 4.0f);
+ }
+
+ [MonoTODO]
+ public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix)
+ {
+ Warp (destPoints, srcRect, matrix, WarpMode.Perspective, 1.0f / 4.0f);
+ }
+
+ [MonoTODO]
+ public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
+ {
+ Warp (destPoints, srcRect, matrix, warpMode, 1.0f / 4.0f);
+ }
+
+ [MonoTODO]
+ public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
+ {
+ throw new NotImplementedException();
+ }
+ #endregion
+
+ #region Widen
+ public void Widen (Pen pen)
+ {
+ Widen (pen, null);
+ }
+
+ public void Widen (Pen pen, Matrix matrix)
+ {
+ Widen (pen, matrix, 2f/3f);
+ }
+
+ public void Widen (Pen pen, Matrix matrix, float flatness)
+ {
+ if (pen == null)
+ throw new ArgumentNullException("pen");
+
+ Shape = new ExtendedGeneralPath(((Stroke)pen).createStrokedShape(this));
+ Flatten(matrix, flatness);
+ }
+ #endregion
+
+ private void SetPath (Point [] pts, byte [] types)
+ {
+ NativeObject.Clear ();
+ if (((PathPointType)types [0] & PathPointType.PathTypeMask) != PathPointType.Start)
+ NativeObject.moveTo (pts [0].X, pts [0].Y);
+
+ for (int i=0; i < pts.Length; i++) {
+ switch (((PathPointType)types [i] & PathPointType.PathTypeMask)) {
+ case PathPointType.Start :
+ NativeObject.moveTo (pts [i].X, pts [i].Y);
+ break;
+ case PathPointType.Line :
+ NativeObject.lineTo (pts [i].X, pts [i].Y);
+ break;
+ case PathPointType.Bezier3 :
+ float x1 = pts [i].X;
+ float y1 = pts [i].Y;
+ i++;
+ float x2 = pts [i].X;
+ float y2 = pts [i].Y;
+ i++;
+ float x3 = pts [i].X;
+ float y3 = pts [i].Y;
+ NativeObject.curveTo (x1,y1, x2, y2, x3, y3);
+ break;
+ }
+ if (((PathPointType)types [i] & PathPointType.CloseSubpath) != 0)
+ NativeObject.closePath();
+
+ if (((PathPointType)types [i] & PathPointType.PathMarker) != 0)
+ NativeObject.SetMarkers ();
+ }
+ }
+
+ internal void SetPath (PointF [] pts, byte [] types)
+ {
+ NativeObject.Clear ();
+ if (((PathPointType)types [0] & PathPointType.PathTypeMask) != PathPointType.Start)
+ NativeObject.moveTo (pts [0].X, pts [0].Y);
+ for (int i=0; i < pts.Length; i++) {
+ switch (((PathPointType)types [i] & PathPointType.PathTypeMask)) {
+ case PathPointType.Start :
+ NativeObject.moveTo (pts [i].X, pts [i].Y);
+ break;
+ case PathPointType.Line :
+ NativeObject.lineTo (pts [i].X, pts [i].Y);
+ break;
+ case PathPointType.Bezier3 :
+ float x1 = pts [i].X;
+ float y1 = pts [i].Y;
+ i++;
+ float x2 = pts [i].X;
+ float y2 = pts [i].Y;
+ i++;
+ float x3 = pts [i].X;
+ float y3 = pts [i].Y;
+ NativeObject.curveTo (x1,y1, x2, y2, x3, y3);
+ break;
+ }
+ if (((PathPointType)types [i] & PathPointType.CloseSubpath) != 0)
+ NativeObject.closePath();
+
+ if (((PathPointType)types [i] & PathPointType.PathMarker) != 0)
+ NativeObject.SetMarkers ();
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.cs
new file mode 100644
index 00000000000..dbd2f4341dc
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.cs
@@ -0,0 +1,202 @@
+//
+// System.Drawing.Drawing2D.GraphicsPathIterator.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Duncan Mak (duncan@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002/3 Ximian, Inc (http://www.ximian.com)
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+
+namespace System.Drawing.Drawing2D
+{
+ public sealed class GraphicsPathIterator : MarshalByRefObject, IDisposable
+ {
+ private IntPtr nativeObject = IntPtr.Zero;
+
+ // Constructors
+ internal GraphicsPathIterator (IntPtr native)
+ {
+ this.nativeObject = native;
+ }
+
+ public GraphicsPathIterator (GraphicsPath path)
+ {
+ Status status = GDIPlus.GdipCreatePathIter (out nativeObject, path.NativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ internal IntPtr NativeObject {
+ get {
+ return nativeObject;
+ }
+ set {
+ nativeObject = value;
+ }
+ }
+
+ // Public Properites
+
+ public int Count {
+ get {
+ int count;
+ Status status = GDIPlus.GdipPathIterGetCount (nativeObject, out count);
+ GDIPlus.CheckStatus (status);
+
+ return count;
+ }
+ }
+
+ public int SubpathCount {
+ get {
+ int count;
+ Status status = GDIPlus.GdipPathIterGetSubpathCount (nativeObject, out count);
+ GDIPlus.CheckStatus (status);
+
+ return count;
+ }
+ }
+
+ internal void Dispose (bool disposing)
+ {
+ Status status;
+ if (nativeObject != IntPtr.Zero) {
+ status = GDIPlus.GdipDeletePathIter (nativeObject);
+ GDIPlus.CheckStatus (status);
+
+ nativeObject = IntPtr.Zero;
+ }
+ }
+
+ // Public Methods.
+
+ public int CopyData (ref PointF [] points, ref byte [] types, int startIndex, int endIndex)
+ {
+ Status status;
+ int resultCount;
+
+ if (points.Length != types.Length)
+ throw new ArgumentException ("Invalid arguments passed. Both arrays should have the same length.");
+
+ status = GDIPlus.GdipPathIterCopyData (nativeObject, out resultCount, points, types, startIndex, endIndex);
+ GDIPlus.CheckStatus (status);
+
+ return resultCount;
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ ~GraphicsPathIterator ()
+ {
+ Dispose (false);
+ }
+
+ public int Enumerate (ref PointF [] points, ref byte [] types)
+ {
+ Status status;
+ int resultCount;
+ int count = points.Length;
+
+ if (count != types.Length)
+ throw new ArgumentException ("Invalid arguments passed. Both arrays should have the same length.");
+
+ status = GDIPlus.GdipPathIterEnumerate (nativeObject, out resultCount, points, types, count);
+ GDIPlus.CheckStatus (status);
+
+ return resultCount;
+ }
+
+ public bool HasCurve ()
+ {
+ bool curve;
+ Status status = GDIPlus.GdipPathIterHasCurve (nativeObject, out curve);
+ GDIPlus.CheckStatus (status);
+
+ return curve;
+ }
+
+ public int NextMarker (GraphicsPath path)
+ {
+ Status status;
+ int resultCount;
+ status = GDIPlus.GdipPathIterNextMarkerPath (nativeObject, out resultCount, path.NativeObject);
+ GDIPlus.CheckStatus (status);
+
+ return resultCount;
+ }
+
+ public int NextMarker (out int startIndex, out int endIndex)
+ {
+ Status status;
+ int resultCount;
+ status = GDIPlus.GdipPathIterNextMarker (nativeObject, out resultCount, out startIndex, out endIndex);
+ GDIPlus.CheckStatus (status);
+
+ return resultCount;
+ }
+
+ public int NextPathType (out byte pathType, out int startIndex, out int endIndex)
+ {
+ Status status;
+ int resultCount;
+ status = GDIPlus.GdipPathIterNextPathType (nativeObject, out resultCount, out pathType, out startIndex, out endIndex);
+ GDIPlus.CheckStatus (status);
+
+ return resultCount;
+ }
+
+ public int NextSubpath (GraphicsPath path, out bool isClosed)
+ {
+ Status status;
+ int resultCount;
+ status = GDIPlus.GdipPathIterNextSubpathPath (nativeObject, out resultCount, path.NativeObject, out isClosed);
+ GDIPlus.CheckStatus (status);
+
+ return resultCount;
+ }
+
+ public int NextSubpath (out int startIndex, out int endIndex, out bool isClosed)
+ {
+ Status status;
+ int resultCount;
+ status = GDIPlus.GdipPathIterNextSubpath (nativeObject, out resultCount, out startIndex, out endIndex, out isClosed);
+ GDIPlus.CheckStatus (status);
+
+ return resultCount;
+ }
+
+ public void Rewind ()
+ {
+ Status status = GDIPlus.GdipPathIterRewind (nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.jvm.cs
new file mode 100755
index 00000000000..f0ce626b88c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.jvm.cs
@@ -0,0 +1,220 @@
+//
+// System.Drawing.Drawing2D.GraphicsPathIterator.cs
+//
+// Author:
+// Bors Kirzner <boris@mainsoft.com>
+//
+// Copyright (C) 2005 Mainsoft Corporation, (http://www.mainsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+
+namespace System.Drawing.Drawing2D
+{
+ public sealed class GraphicsPathIterator : MarshalByRefObject, IDisposable
+ {
+ #region Fields
+
+ private readonly GraphicsPath _path;
+ private int _marker = -1;
+ private int _subpath = -1;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ public GraphicsPathIterator (GraphicsPath path)
+ {
+ _path = path;
+ }
+
+ #endregion // Constructors
+
+ #region Properites
+
+ public int Count
+ {
+ get { return _path.NativeObject.PointCount; }
+ }
+
+ public int SubpathCount {
+ get {
+ int count = 0;
+ int start, end;
+ bool isClosed;
+ while (NextSubpath (out start, out end, out isClosed) != 0)
+ count++;
+ return count;
+ }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ public int CopyData (ref PointF [] points, ref byte [] types, int startIndex, int endIndex)
+ {
+ int j = 0;
+ for (int i = startIndex; i <= endIndex && i < _path.PointCount; i++) {
+ points [j] = _path.PathPoints [i];
+ types [j++] = _path.PathTypes [i];
+ }
+ return j;
+ }
+
+ public void Dispose ()
+ {
+ }
+
+ public int Enumerate (ref PointF [] points, ref byte [] types)
+ {
+ return CopyData (ref points, ref types, 0, _path.PointCount);
+ }
+
+ public bool HasCurve ()
+ {
+ byte [] types = _path.PathTypes;
+ for (int i=0; i < types.Length; i++)
+ if ((types [i] & (byte)PathPointType.PathTypeMask) == (byte)PathPointType.Bezier3)
+ return true;
+ return false;
+ }
+
+ public int NextMarker (GraphicsPath path)
+ {
+ if (path == null)
+ return 0;
+
+ int startIndex;
+ int endIndex;
+ int count = NextMarker (out startIndex, out endIndex);
+
+ if (count != 0)
+ SetPath (_path, startIndex, count, path);
+
+ return count;
+ }
+
+ public int NextMarker (out int startIndex, out int endIndex)
+ {
+ if (_marker >= _path.PointCount) {
+ startIndex = 0;
+ endIndex = 0;
+ return 0;
+ }
+
+ startIndex = ++_marker;
+ while ((_marker < _path.PointCount) && ((_path.PathTypes [_marker] & (byte)PathPointType.PathMarker) == 0))
+ _marker++;
+
+ endIndex = (_marker < _path.PointCount) ? _marker : _path.PointCount - 1;
+ return endIndex - startIndex + 1;
+ }
+
+ public int NextPathType (out byte pathType, out int startIndex, out int endIndex)
+ {
+ if ((_subpath >= _path.PointCount - 1) | (_subpath < 0)) {
+ startIndex = 0;
+ endIndex = 0;
+ pathType = (_subpath < 0) ? (byte)PathPointType.Start : _path.PathTypes [_path.PointCount - 1];
+ return 0;
+ }
+
+ // .net acts different, but it seems to be a bug
+ if ((_path.PathTypes [_subpath + 1] & (byte)PathPointType.PathMarker) != 0) {
+ startIndex = 0;
+ endIndex = 0;
+ pathType = _path.PathTypes [_subpath];
+ return 0;
+ }
+
+ startIndex = _subpath++;
+ endIndex = startIndex;
+ pathType = (byte)(_path.PathTypes [startIndex + 1] & (byte)PathPointType.PathTypeMask);
+
+ while (((_subpath) < _path.PointCount) && ((_path.PathTypes [_subpath] & (byte)PathPointType.PathTypeMask) == pathType))
+ _subpath++;
+
+ endIndex = (_subpath < _path.PointCount) ? --_subpath : _path.PointCount - 1;
+ return endIndex - startIndex + 1;
+ }
+
+ public int NextSubpath (GraphicsPath path, out bool isClosed)
+ {
+ int startIndex;
+ int endIndex;
+ int count = NextSubpath (out startIndex, out endIndex, out isClosed);
+
+ if ((count != 0) && (path != null))
+ SetPath (_path, startIndex, count, path);
+
+ return count;
+ }
+
+ private void SetPath (GraphicsPath source, int start, int count, GraphicsPath target)
+ {
+ PointF [] points = new PointF [count];
+ byte [] types = new byte [count];
+ PointF [] pathPoints = _path.PathPoints;
+ byte [] pathTypes = _path.PathTypes;
+
+ for (int i = 0; i < count; i++) {
+ points [i] = pathPoints [start + i];
+ types [i] = pathTypes [start + i];
+ }
+
+ target.SetPath (points, types);
+ }
+
+ public int NextSubpath (out int startIndex, out int endIndex, out bool isClosed)
+ {
+ _subpath++;
+ while (((_subpath) < _path.PointCount) && (_path.PathTypes [_subpath] != (byte)PathPointType.Start))
+ _subpath++;
+
+
+ if (_subpath >= _path.PointCount - 1) {
+ startIndex = 0;
+ endIndex = 0;
+ isClosed = true;
+ return 0;
+ }
+
+ startIndex = _subpath;
+ int offset = 1;
+ while (((_subpath + offset) < _path.PointCount) && (_path.PathTypes [_subpath + offset] != (byte)PathPointType.Start))
+ offset++;
+
+ endIndex = ((_subpath + offset) < _path.PointCount) ? _subpath + offset - 1 : _path.PointCount - 1;
+ isClosed = (_path.PathTypes [endIndex] & (byte)PathPointType.CloseSubpath) != 0;
+ return endIndex - startIndex + 1;
+ }
+
+ public void Rewind ()
+ {
+ _marker = -1;
+ _subpath = -1;
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.cs
new file mode 100644
index 00000000000..266780b028d
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.cs
@@ -0,0 +1,51 @@
+//
+// System.Drawing.Drawing2D.GraphicsState.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for GraphicsState.
+ /// </summary>
+ public sealed class GraphicsState : MarshalByRefObject
+ {
+ // All members inherited
+ internal uint nativeState;
+
+ // Constructor
+ internal GraphicsState()
+ {
+ // Nothing to be done here
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.jvm.cs
new file mode 100644
index 00000000000..79e445b5f59
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.jvm.cs
@@ -0,0 +1,150 @@
+//
+// System.Drawing.Drawing2D.ExtendedGraphicsState.jvm.cs
+//
+// Author:
+// Vladimir Krasnov (vladimirk@mainsoft.com)
+//
+// Copyright (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing.Text;
+using geom = java.awt.geom;
+using awt = java.awt;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for GraphicsState.
+ /// </summary>
+ public sealed class GraphicsState : MarshalByRefObject
+ {
+ readonly CompositingMode _compositingMode;
+ readonly CompositingQuality _compositingQuality;
+ readonly Region _clip;
+ readonly awt.Shape _baseClip;
+ readonly InterpolationMode _interpolationMode;
+ readonly float _pageScale;
+ readonly GraphicsUnit _pageUnit;
+ readonly PixelOffsetMode _pixelOffsetMode;
+ readonly Point _renderingOrigin;
+ readonly SmoothingMode _smoothingMode;
+ readonly int _textContrast;
+ readonly TextRenderingHint _textRenderingHint;
+
+ // additional transform in case that new container has one
+ readonly Matrix _transform;
+ readonly Matrix _baseTransform;
+
+ GraphicsState _next = null;
+
+ internal GraphicsState(Graphics graphics, bool resetState)
+ : this(graphics, Matrix.IdentityTransform, resetState) {}
+
+ internal GraphicsState Next {
+ get {
+ return _next;
+ }
+ set {
+ _next = value;
+ }
+ }
+
+ internal GraphicsState(Graphics graphics, Matrix matrix, bool resetState)
+ {
+ _compositingMode = graphics.CompositingMode;
+ _compositingQuality = graphics.CompositingQuality;
+ _clip = graphics.ScaledClip;
+ _baseClip = graphics.NativeObject.getClip();
+ _interpolationMode = graphics.InterpolationMode;
+ _pageScale = graphics.PageScale;
+ _pageUnit = graphics.PageUnit;
+ _pixelOffsetMode = graphics.PixelOffsetMode;
+
+ // FIXME: render orign is not implemented yet
+ //_renderingOrigin = new Point( g.RenderingOrigin.X, g.RenderingOrigin.Y );
+
+ _smoothingMode = graphics.SmoothingMode;
+ _transform = graphics.Transform;
+ _baseTransform = graphics.BaseTransform;
+
+ _textContrast = graphics.TextContrast;
+ _textRenderingHint = graphics.TextRenderingHint;
+
+ if (resetState)
+ ResetState(graphics, matrix);
+ }
+
+ internal void RestoreState(Graphics graphics)
+ {
+ graphics.CompositingMode = _compositingMode;
+ graphics.CompositingQuality = _compositingQuality;
+ graphics.ScaledClip = _clip;
+ graphics.InterpolationMode = _interpolationMode;
+ graphics.PageScale = _pageScale;
+ graphics.PageUnit = _pageUnit;
+ graphics.PixelOffsetMode = _pixelOffsetMode;
+
+ // FIXME: render orign is not implemented yet
+ //graphics.RenderingOrigin = new Point( _renderingOrigin.X, _renderingOrigin.Y );
+
+ graphics.SmoothingMode = _smoothingMode;
+ graphics.Transform = _transform;
+ graphics.BaseTransform = _baseTransform;
+ graphics.TextContrast = _textContrast;
+ graphics.TextRenderingHint = _textRenderingHint;
+
+ // must be set after the base transform is restored
+ graphics.NativeObject.setClip(_baseClip);
+ }
+
+ void ResetState(Graphics graphics, Matrix matrix)
+ {
+ //should be set before the base transform is changed
+ if (_baseClip == null)
+ graphics.IntersectScaledClipWithBase(graphics.VisibleShape);
+
+ graphics.CompositingMode = CompositingMode.SourceOver;
+ graphics.CompositingQuality = CompositingQuality.Default;
+ graphics.ScaledClip = Region.InfiniteRegion;
+ graphics.InterpolationMode = InterpolationMode.Bilinear;
+ graphics.PageScale = 1.0f;
+ graphics.PageUnit = GraphicsUnit.Display;
+ graphics.PixelOffsetMode = PixelOffsetMode.Default;
+
+ // FIXME: render orign is not implemented yet
+ //graphics.RenderingOrigin = new Point(0, 0);
+
+ graphics.SmoothingMode = SmoothingMode.None;
+ graphics.ResetTransform();
+ graphics.PrependBaseTransform(Graphics.GetFinalTransform(_transform.NativeObject, _pageUnit, _pageScale));
+ graphics.PrependBaseTransform(matrix.NativeObject);
+ graphics.TextContrast = 4;
+ graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
+ }
+
+ internal void RestoreBaseClip(Graphics graphics) {
+ graphics.NativeObject.setClip(_baseClip);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.cs
new file mode 100644
index 00000000000..024e0c2adde
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.cs
@@ -0,0 +1,97 @@
+//
+// System.Drawing.Drawing2D.HatchBrush.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) 2002/3 Ximian, Inc
+// (C) 2004 Novell, Inc.
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for HatchBrush.
+ /// </summary>
+ public sealed class HatchBrush : Brush
+ {
+
+ internal HatchBrush (IntPtr ptr) : base (ptr)
+ {
+ }
+
+ public HatchBrush (HatchStyle hatchStyle, Color foreColor)
+ : this (hatchStyle, foreColor, Color.Black)
+ {
+ }
+
+ public HatchBrush(HatchStyle hatchStyle, Color foreColor, Color backColor)
+ {
+ Status status = GDIPlus.GdipCreateHatchBrush (hatchStyle, foreColor.ToArgb (), backColor.ToArgb (), out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Color BackgroundColor {
+ get {
+ int argb;
+ Status status = GDIPlus.GdipGetHatchBackgroundColor (nativeObject, out argb);
+ GDIPlus.CheckStatus (status);
+ return Color.FromArgb (argb);
+ }
+ }
+
+ public Color ForegroundColor {
+ get {
+ int argb;
+ Status status = GDIPlus.GdipGetHatchForegroundColor (nativeObject, out argb);
+ GDIPlus.CheckStatus (status);
+ return Color.FromArgb (argb);
+ }
+ }
+
+ public HatchStyle HatchStyle {
+ get {
+ HatchStyle hatchStyle;
+ Status status = GDIPlus.GdipGetHatchStyle (nativeObject, out hatchStyle);
+ GDIPlus.CheckStatus (status);
+ return hatchStyle;
+ }
+ }
+
+ public override object Clone ()
+ {
+ IntPtr clonePtr;
+ Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
+ GDIPlus.CheckStatus (status);
+
+ HatchBrush clone = new HatchBrush (clonePtr);
+ return clone;
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.jvm.cs
new file mode 100755
index 00000000000..7d64fe85af9
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.jvm.cs
@@ -0,0 +1,60 @@
+
+using System;
+using java.awt;
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for HatchBrush.
+ /// </summary>
+ public sealed class HatchBrush : Brush
+ {
+ private HatchStyle _style;
+ private Color _foreColor;
+ private Color _backColor;
+
+ [MonoTODO]
+ public HatchBrush (HatchStyle hatchStyle, Color foreColor)
+ : this (hatchStyle, foreColor, Color.Black)
+ {
+ }
+
+ [MonoTODO]
+ public HatchBrush(HatchStyle hatchStyle, Color foreColor, Color backColor)
+ {
+ _style = hatchStyle;
+ _foreColor = foreColor;
+ _backColor = backColor;
+ }
+
+ public Color BackgroundColor {
+ get {
+ return _backColor;
+ }
+ }
+
+ public Color ForegroundColor {
+ get {
+ return _foreColor;
+ }
+ }
+
+ public HatchStyle HatchStyle {
+ get {
+ return _style;
+ }
+ }
+
+ public override object Clone ()
+ {
+ return new HatchBrush (_style, _foreColor, _backColor);
+ }
+
+ protected override Paint NativeObject {
+ get {
+ // FALLBACK: Solid color brush will be used
+ return _foreColor.NativeObject;
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchStyle.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchStyle.cs
new file mode 100644
index 00000000000..cdfe75df240
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchStyle.cs
@@ -0,0 +1,101 @@
+//
+// System.Drawing.Drawing2D.HatchStyle.cs
+//
+// Authors:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) 2002/3 Ximian, Inc.
+// (C) 2004 Novell, Inc.
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for HatchStyle.
+ /// </summary>
+ [Serializable]
+ public enum HatchStyle {
+ BackwardDiagonal = 3,
+ Cross = LargeGrid,
+ DarkDownwardDiagonal = 20,
+ DarkHorizontal = 29,
+ DarkUpwardDiagonal = 21,
+ DarkVertical = 28,
+ DashedDownwardDiagonal = 30,
+ DashedHorizontal = 32,
+ DashedUpwardDiagonal = 31,
+ DashedVertical = 33,
+ DiagonalBrick = 38,
+ DiagonalCross = 5,
+ Divot = 42,
+ DottedDiamond = 44,
+ DottedGrid = 43,
+ ForwardDiagonal = 2,
+ Horizontal = 0,
+ HorizontalBrick = 39,
+ LargeCheckerBoard = 50,
+ LargeConfetti = 35,
+ LargeGrid = 4,
+ LightDownwardDiagonal = 18,
+ LightHorizontal = 25,
+ LightUpwardDiagonal = 19,
+ LightVertical = 24,
+ Max = 4,
+ Min = 0,
+ NarrowHorizontal = 27,
+ NarrowVertical = 26,
+ OutlinedDiamond = 51,
+ Percent05 = 6,
+ Percent10 = 7,
+ Percent20 = 8,
+ Percent25 = 9,
+ Percent30 = 10,
+ Percent40 = 11,
+ Percent50 = 12,
+ Percent60 = 13,
+ Percent70 = 14,
+ Percent75 = 15,
+ Percent80 = 16,
+ Percent90 = 17,
+ Plaid = 41,
+ Shingle = 45,
+ SmallCheckerBoard = 49,
+ SmallConfetti = 34,
+ SmallGrid = 48,
+ SolidDiamond = 52,
+ Sphere = 47,
+ Trellis = 46,
+ Vertical = 1,
+ Wave = 37,
+ Weave = 40,
+ WideDownwardDiagonal = 22,
+ WideUpwardDiagonal = 23,
+ ZigZag = 36
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs
new file mode 100644
index 00000000000..6e0d5b3931f
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs
@@ -0,0 +1,51 @@
+//
+// System.Drawing.Drawing2D.InterpolationMode.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for InterpolationMode.
+ /// </summary>
+ [Serializable]
+ public enum InterpolationMode {
+ Bicubic = 4,
+ Bilinear = 3,
+ Default = 0,
+ High = 2,
+ HighQualityBicubic = 7,
+ HighQualityBilinear = 6,
+ Invalid = -1,
+ Low = 1,
+ NearestNeighbor = 5
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LineCap.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LineCap.cs
new file mode 100644
index 00000000000..35f010efca2
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LineCap.cs
@@ -0,0 +1,53 @@
+//
+// System.Drawing.Drawing2D.LineCap.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for LineCap.
+ /// </summary>
+ [Serializable]
+ public enum LineCap {
+ AnchorMask = 240,
+ ArrowAnchor = 20,
+ Custom = 255,
+ DiamondAnchor = 19,
+ Flat = 0,
+ NoAnchor = 16,
+ Round = 2,
+ RoundAnchor = 18,
+ Square = 1,
+ SquareAnchor = 17,
+ Triangle = 3
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LineJoin.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LineJoin.cs
new file mode 100644
index 00000000000..95eac817142
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LineJoin.cs
@@ -0,0 +1,46 @@
+//
+// System.Drawing.Drawing2D.LineJoin.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for LineJoin.
+ /// </summary>
+ [Serializable]
+ public enum LineJoin {
+ Bevel = 1,
+ Miter = 0,
+ MiterClipped = 3,
+ Round = 2
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs
new file mode 100644
index 00000000000..88bfcc8744f
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs
@@ -0,0 +1,348 @@
+//
+// System.Drawing.Drawing2D.LinearGradientBrush.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002/3 Ximian, Inc. http://www.ximian.com
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Drawing;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for LinearGradientBrush.
+ /// </summary>
+ public sealed class LinearGradientBrush : Brush
+ {
+ RectangleF rectangle;
+
+ internal LinearGradientBrush (IntPtr native) : base (native)
+ {
+ }
+
+ public LinearGradientBrush (Point point1, Point point2, Color color1, Color color2)
+ {
+ Status status = GDIPlus.GdipCreateLineBrushI (ref point1, ref point2, color1.ToArgb (), color2.ToArgb (), WrapMode.Tile, out nativeObject);
+ GDIPlus.CheckStatus (status);
+
+ Rectangle rect;
+ status = GDIPlus.GdipGetLineRectI (nativeObject, out rect);
+ GDIPlus.CheckStatus (status);
+ rectangle = (RectangleF) rect;
+ }
+
+ public LinearGradientBrush (PointF point1, PointF point2, Color color1, Color color2)
+ {
+ Status status = GDIPlus.GdipCreateLineBrush (ref point1, ref point2, color1.ToArgb (), color2.ToArgb (), WrapMode.Tile, out nativeObject);
+ GDIPlus.CheckStatus (status);
+
+ status = GDIPlus.GdipGetLineRect (nativeObject, out rectangle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public LinearGradientBrush (Rectangle rect, Color color1, Color color2, LinearGradientMode linearGradientMode)
+ {
+ Status status = GDIPlus.GdipCreateLineBrushFromRectI (ref rect, color1.ToArgb (), color2.ToArgb (), linearGradientMode, WrapMode.Tile, out nativeObject);
+ GDIPlus.CheckStatus (status);
+
+ rectangle = (RectangleF) rect;
+ }
+
+ public LinearGradientBrush (Rectangle rect, Color color1, Color color2, float angle) : this (rect, color1, color2, angle, false)
+ {
+ }
+
+ public LinearGradientBrush (RectangleF rect, Color color1, Color color2, LinearGradientMode linearGradientMode)
+ {
+ Status status = GDIPlus.GdipCreateLineBrushFromRect (ref rect, color1.ToArgb (), color2.ToArgb (), linearGradientMode, WrapMode.Tile, out nativeObject);
+ GDIPlus.CheckStatus (status);
+
+ rectangle = rect;
+ }
+
+ public LinearGradientBrush (RectangleF rect, Color color1, Color color2, float angle) : this (rect, color1, color2, angle, false)
+ {
+ }
+
+ public LinearGradientBrush (Rectangle rect, Color color1, Color color2, float angle, bool isAngleScaleable)
+ {
+ Status status = GDIPlus.GdipCreateLineBrushFromRectWithAngleI (ref rect, color1.ToArgb (), color2.ToArgb (), angle, isAngleScaleable, WrapMode.Tile, out nativeObject);
+ GDIPlus.CheckStatus (status);
+
+ rectangle = (RectangleF) rect;
+ }
+
+ public LinearGradientBrush (RectangleF rect, Color color1, Color color2, float angle, bool isAngleScaleable)
+ {
+ Status status = GDIPlus.GdipCreateLineBrushFromRectWithAngle (ref rect, color1.ToArgb (), color2.ToArgb (), angle, isAngleScaleable, WrapMode.Tile, out nativeObject);
+ GDIPlus.CheckStatus (status);
+
+ rectangle = rect;
+ }
+
+ // Public Properties
+
+ public Blend Blend {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetLineBlendCount (nativeObject, out count);
+ GDIPlus.CheckStatus (status);
+ float [] factors = new float [count];
+ float [] positions = new float [count];
+ status = GDIPlus.GdipGetLineBlend (nativeObject, factors, positions, count);
+ GDIPlus.CheckStatus (status);
+
+ Blend blend = new Blend ();
+ blend.Factors = factors;
+ blend.Positions = positions;
+
+ return blend;
+ }
+ set {
+ int count;
+ float [] factors = value.Factors;
+ float [] positions = value.Positions;
+ count = factors.Length;
+
+ if (count == 0 || positions.Length == 0)
+ throw new ArgumentException ("Invalid Blend object. It should have at least 2 elements in each of the factors and positions arrays.");
+
+ if (count != positions.Length)
+ throw new ArgumentException ("Invalid Blend object. It should contain the same number of factors and positions values.");
+
+ if (positions [0] != 0.0F)
+ throw new ArgumentException ("Invalid Blend object. The positions array must have 0.0 as its first element.");
+
+ if (positions [count - 1] != 1.0F)
+ throw new ArgumentException ("Invalid Blend object. The positions array must have 1.0 as its last element.");
+
+ Status status = GDIPlus.GdipSetLineBlend (nativeObject, factors, positions, count);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public bool GammaCorrection {
+ get {
+ bool gammaCorrection;
+ Status status = GDIPlus.GdipGetLineGammaCorrection (nativeObject, out gammaCorrection);
+ GDIPlus.CheckStatus (status);
+ return gammaCorrection;
+ }
+ set {
+ Status status = GDIPlus.GdipSetLineGammaCorrection (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public ColorBlend InterpolationColors {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetLinePresetBlendCount (nativeObject, out count);
+ GDIPlus.CheckStatus (status);
+ int [] intcolors = new int [count];
+ float [] positions = new float [count];
+ status = GDIPlus.GdipGetLinePresetBlend (nativeObject, intcolors, positions, count);
+ GDIPlus.CheckStatus (status);
+
+ ColorBlend interpolationColors = new ColorBlend ();
+ Color [] colors = new Color [count];
+ for (int i = 0; i < count; i++)
+ colors [i] = Color.FromArgb (intcolors [i]);
+ interpolationColors.Colors = colors;
+ interpolationColors.Positions = positions;
+
+ return interpolationColors;
+ }
+ set {
+ int count;
+ Color [] colors = value.Colors;
+ float [] positions = value.Positions;
+ count = colors.Length;
+
+ if (count == 0 || positions.Length == 0)
+ throw new ArgumentException ("Invalid ColorBlend object. It should have at least 2 elements in each of the colors and positions arrays.");
+
+ if (count != positions.Length)
+ throw new ArgumentException ("Invalid ColorBlend object. It should contain the same number of positions and color values.");
+
+ if (positions [0] != 0.0F)
+ throw new ArgumentException ("Invalid ColorBlend object. The positions array must have 0.0 as its first element.");
+
+ if (positions [count - 1] != 1.0F)
+ throw new ArgumentException ("Invalid ColorBlend object. The positions array must have 1.0 as its last element.");
+
+ int [] blend = new int [colors.Length];
+ for (int i = 0; i < colors.Length; i++)
+ blend [i] = colors [i].ToArgb ();
+
+ Status status = GDIPlus.GdipSetLinePresetBlend (nativeObject, blend, positions, count);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public Color [] LinearColors {
+ get {
+ int [] colors = new int [2];
+ Status status = GDIPlus.GdipGetLineColors (nativeObject, colors);
+ GDIPlus.CheckStatus (status);
+ Color [] linearColors = new Color [2];
+ linearColors [0] = Color.FromArgb (colors [0]);
+ linearColors [1] = Color.FromArgb (colors [1]);
+
+ return linearColors;
+ }
+ set {
+ Status status = GDIPlus.GdipSetLineColors (nativeObject, value [0].ToArgb (), value [1].ToArgb ());
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public RectangleF Rectangle {
+ get {
+ return rectangle;
+ }
+ }
+
+ public Matrix Transform {
+ get {
+ Matrix matrix = new Matrix ();
+ Status status = GDIPlus.GdipGetLineTransform (nativeObject, matrix.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+
+ return matrix;
+ }
+ set {
+ Status status = GDIPlus.GdipSetLineTransform (nativeObject, value.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public WrapMode WrapMode {
+ get {
+ WrapMode wrapMode;
+ Status status = GDIPlus.GdipGetLineWrapMode (nativeObject, out wrapMode);
+ GDIPlus.CheckStatus (status);
+
+ return wrapMode;
+ }
+ set {
+ Status status = GDIPlus.GdipSetLineWrapMode (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ // Public Methods
+
+ public void MultiplyTransform (Matrix matrix)
+ {
+ MultiplyTransform (matrix, MatrixOrder.Prepend);
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipMultiplyLineTransform (nativeObject, matrix.nativeMatrix, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ResetTransform ()
+ {
+ Status status = GDIPlus.GdipResetLineTransform (nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void RotateTransform (float angle)
+ {
+ RotateTransform (angle, MatrixOrder.Prepend);
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipRotateLineTransform (nativeObject, angle, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ScaleTransform (float sx, float sy)
+ {
+ ScaleTransform (sx, sy, MatrixOrder.Prepend);
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipScaleLineTransform (nativeObject, sx, sy, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetBlendTriangularShape (float focus)
+ {
+ SetBlendTriangularShape (focus, 1.0F);
+ }
+
+ public void SetBlendTriangularShape (float focus, float scale)
+ {
+ if (focus < 0 || focus > 1 || scale < 0 || scale > 1)
+ throw new ArgumentException ("Invalid parameter passed.");
+
+ Status status = GDIPlus.GdipSetLineLinearBlend (nativeObject, focus, scale);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetSigmaBellShape (float focus)
+ {
+ SetSigmaBellShape (focus, 1.0F);
+ }
+
+ public void SetSigmaBellShape (float focus, float scale)
+ {
+ if (focus < 0 || focus > 1 || scale < 0 || scale > 1)
+ throw new ArgumentException ("Invalid parameter passed.");
+
+ Status status = GDIPlus.GdipSetLineSigmaBlend (nativeObject, focus, scale);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TranslateTransform (float dx, float dy)
+ {
+ TranslateTransform (dx, dy, MatrixOrder.Prepend);
+ }
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipTranslateLineTransform (nativeObject, dx, dy, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public override object Clone ()
+ {
+ IntPtr clonePtr;
+ Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
+ GDIPlus.CheckStatus (status);
+
+ LinearGradientBrush clone = new LinearGradientBrush (clonePtr);
+ return clone;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.jvm.cs
new file mode 100755
index 00000000000..7d728a1058b
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.jvm.cs
@@ -0,0 +1,346 @@
+using System;
+using java.awt;
+using awt = java.awt;
+using geom = java.awt.geom;
+using image = java.awt.image;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for LinearGradientBrush.
+ /// </summary>
+ public sealed class LinearGradientBrush : Brush {
+ Blend _blend;
+ bool _gammaCorrection;
+ ColorBlend _interpolationColors;
+ WrapMode _wrapmode;
+ RectangleF _gradientRectangle;
+
+ // gradient brush data
+ float _x1 = 0;
+ float _y1 = 0;
+
+ float _x2 = 0;
+ float _y2 = 0;
+
+ Color _color1, _color2;
+ bool _cyclic;
+
+ #region NativeObject
+
+ GradientPaint _nativeObject = null;
+ protected override Paint NativeObject {
+ get {
+ if ( _nativeObject == null )
+ _nativeObject = new GradientPaint(
+ _x1, _y1,
+ new java.awt.Color(_color1.R, _color1.G, _color1.B, _color1.A),
+ _x2, _y2,
+ new java.awt.Color(_color2.R, _color2.G, _color2.B, _color2.A), _cyclic);
+
+ return _nativeObject;
+ }
+ }
+
+ #endregion
+
+ #region Initialization
+
+ private void Init(float x1, float y1, Color color1, float x2, float y2, Color color2, bool cyclic) {
+ _x1 = x1;
+ _y1 = y1;
+ _color1 = color1;
+
+ _x2 = x2;
+ _y2 = y2;
+ _color2 = color2;
+
+ _cyclic = cyclic;
+ _nativeObject = null;
+ }
+
+ private void Init(float x1, float y1, Color color1, float x2, float y2, Color color2, float angle) {
+ _gradientRectangle = new RectangleF(x1, y1, x2-x1, y2-y1);
+ PointF [] points = GetMedianeEnclosingRect(x1, y1, x2, y2, angle);
+ Init(points[0].X, points[0].Y, color1, points[1].X, points[1].Y, color2, false);
+ }
+
+ private void Init(float x1, float y1, Color color1, float x2, float y2, Color color2, LinearGradientMode linearGradientMode) {
+ _gradientRectangle = new RectangleF(x1, y1, x2-x1, y2-y1);
+ PointF [] points;
+
+ switch (linearGradientMode) {
+ case LinearGradientMode.Horizontal :
+ Init(x1, y1, color1, x2, y1, color2, false);
+ break;
+
+ case LinearGradientMode.Vertical :
+ Init(x1, y1, color1, x1, y2, color2, false);
+ break;
+
+ case LinearGradientMode.BackwardDiagonal :
+ points = GetMedianeEnclosingRect(x1, y1, x2, y2, false);
+ Init(points[0].X, points[0].Y, color2, points[1].X, points[1].Y, color1, false);
+ break;
+
+ case LinearGradientMode.ForwardDiagonal :
+ points = GetMedianeEnclosingRect(x1, y1, x2, y2, true);
+ Init(points[0].X, points[0].Y, color1, points[1].X, points[1].Y, color2, false);
+ break;
+
+ default :
+ throw new ArgumentException("LinearGradientMode");
+ }
+ }
+
+ #endregion
+
+ #region Constructors
+
+ private LinearGradientBrush (float x1, float y1, Color color1, float x2, float y2, Color color2, bool cyclic) {
+ Init(x1, y1, color1, x2, y2, color2, cyclic);
+ }
+
+ internal LinearGradientBrush (float x1, float y1, Color color1, float x2, float y2, Color color2, LinearGradientMode mode) {
+ Init(x1, y1, color1, x2, y2, color2, mode);
+ }
+ internal LinearGradientBrush (float x1, float y1, Color color1, float x2, float y2, Color color2) {
+ Init(x1, y2, color1, x1, y2, color2, false);
+ }
+ public LinearGradientBrush (Point point1, Point point2, Color color1, Color color2) {
+ _gradientRectangle = new RectangleF(point1.X, point1.Y, point2.X - point1.X, point2.Y - point2.Y);
+ Init(point1.X, point1.Y, color1, point2.X, point2.Y, color2, false);
+ }
+ public LinearGradientBrush (PointF point1, PointF point2, Color color1, Color color2) {
+ _gradientRectangle = new RectangleF(point1.X, point1.Y, point2.X - point1.X, point2.Y - point2.Y);
+ Init(point1.X, point1.Y, color1, point2.X, point2.Y, color2, false);
+ }
+ public LinearGradientBrush (Rectangle rect, Color color1, Color color2, LinearGradientMode linearGradientMode) {
+ Init(rect.X, rect.Y, color1, rect.X + rect.Width, rect.Y + rect.Height, color2, linearGradientMode);
+ }
+ public LinearGradientBrush (RectangleF rect, Color color1, Color color2, LinearGradientMode linearGradientMode) {
+ Init(rect.X, rect.Y, color1, rect.X + rect.Width, rect.Y + rect.Height, color2, linearGradientMode);
+ }
+ public LinearGradientBrush (Rectangle rect, Color color1, Color color2, float angle) {
+ Init(rect.X, rect.Y, color1, rect.X + rect.Width, rect.Y + rect.Height, color2, angle);
+ }
+ public LinearGradientBrush (RectangleF rect, Color color1, Color color2, float angle) {
+ Init(rect.X, rect.Y, color1, rect.X + rect.Width, rect.Y + rect.Height, color2, angle);
+ }
+ public LinearGradientBrush (Rectangle rect, Color color1, Color color2, float angle, bool isAngleScaleable):
+ this(rect, color1, color2, angle) {
+ }
+ public LinearGradientBrush (RectangleF rect, Color color1, Color color2, float angle, bool isAngleScaleable):
+ this(rect, color1, color2, angle) {
+ }
+ #endregion
+
+ #region GetMedianeEnclosingRect
+
+ internal PointF [] GetMedianeEnclosingRect(float x1, float y1, float x2, float y2, float rotateAngle) {
+ float width = x2 - x1;
+ float height = y2 - y1;
+ PointF rectCenter = new PointF(x1 + width/2, y1 + height/2);
+ float gradLen = width * Math.Abs((float)Math.Cos(rotateAngle * Math.PI / 180)) +
+ height * Math.Abs((float)Math.Sin(rotateAngle * Math.PI / 180));
+
+ PointF [] points = new PointF []{ new PointF(rectCenter.X - gradLen/2, rectCenter.Y),
+ new PointF(rectCenter.X + gradLen/2, rectCenter.Y) };
+
+ Matrix mx = new Matrix();
+ mx.RotateAt((float)rotateAngle, rectCenter);
+ mx.TransformPoints(points);
+ return points;
+ }
+ internal PointF [] GetMedianeEnclosingRect(float x1, float y1, float x2, float y2, bool forwardDiagonal) {
+ float width = x2 - x1;
+ float height = y2 - y1;
+ PointF rectCenter = new PointF(x1 + width/2, y1 + height/2);
+ float rotateAngle = (float)Math.Atan2(width, height);
+ float gradLen = width * (float)Math.Cos(rotateAngle);
+
+ if (!forwardDiagonal)
+ rotateAngle = -rotateAngle;
+
+ PointF [] points = new PointF []{ new PointF(rectCenter.X - gradLen, rectCenter.Y),
+ new PointF(rectCenter.X + gradLen, rectCenter.Y) };
+
+ Matrix mx = new Matrix();
+ mx.RotateAt((float)rotateAngle * (float)(180/Math.PI), rectCenter);
+ mx.TransformPoints(points);
+ return points;
+ }
+
+ #endregion
+
+ #region Public Properties
+
+ // FALLBACK: no functionality implemented for this property
+ [MonoTODO]
+ public Blend Blend {
+ get {
+ return _blend;
+ }
+ set {
+ _blend = value;
+ }
+ }
+
+ // FALLBACK: no functionality implemented for this property
+ [MonoTODO]
+ public bool GammaCorrection {
+ get {
+ return _gammaCorrection;
+ }
+ set {
+ _gammaCorrection = value;
+ }
+ }
+
+ // FALLBACK: functionality of two color gradient is implemented
+ [MonoTODO]
+ public ColorBlend InterpolationColors {
+ get {
+ return _interpolationColors;
+ }
+ set {
+ if (value == null)
+ throw new ArgumentNullException("ColorBlend");
+
+ if ( (value.Colors == null) || (value.Colors.Length == 0) )
+ throw new ArgumentException("ColorBlend");
+
+ _interpolationColors = value;
+
+ _color1 = value.Colors[0];
+ _color2 = value.Colors[value.Colors.Length - 1];
+ _nativeObject = null;
+ }
+ }
+
+ public Color [] LinearColors {
+ get {
+ Color [] cl = new Color[2];
+ cl[0] = _color1;
+ cl[1] = _color2;
+ return cl;
+ }
+ set {
+ if (value == null)
+ throw new ArgumentNullException("colors");
+
+ _color1 = value[0];
+ _color2 = value[1];
+ _nativeObject = null;
+ }
+ }
+
+ public RectangleF Rectangle {
+ get {
+ return _gradientRectangle;
+ }
+ }
+
+ public Matrix Transform {
+ get { return BrushTransform; }
+ set { BrushTransform = value; }
+ }
+
+ // FALLBACK: not functionality implemented for this property
+ [MonoTODO]
+ public WrapMode WrapMode {
+ get {
+ return _wrapmode;
+ }
+ set {
+ _wrapmode = value;
+ }
+ }
+ #endregion
+
+ #region Public Methods
+
+ public void MultiplyTransform (Matrix matrix) {
+ BrushMultiplyTransform(matrix, MatrixOrder.Prepend);
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order) {
+ BrushMultiplyTransform(matrix, order);
+ }
+
+ public void ResetTransform () {
+ BrushResetTransform();
+ }
+
+ public void RotateTransform (float angle) {
+ BrushRotateTransform(angle, MatrixOrder.Prepend);
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order) {
+ BrushRotateTransform(angle, order);
+ }
+
+ public void ScaleTransform (float sx, float sy) {
+ BrushScaleTransform(sx, sy, MatrixOrder.Prepend);
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order) {
+ BrushScaleTransform(sx, sy, order);
+ }
+
+ public void SetBlendTriangularShape (float focus) {
+ SetBlendTriangularShape (focus, 1.0F);
+ }
+
+ public void SetBlendTriangularShape (float focus, float scale) {
+ _x2 = (_x1 + _x2) / 2;
+ _y2 = (_y1 + _y2) / 2;
+ _cyclic = true;
+ _nativeObject = null;
+ }
+
+ public void SetSigmaBellShape (float focus) {
+ SetSigmaBellShape (focus, 1.0F);
+ }
+
+ [MonoTODO]
+ public void SetSigmaBellShape (float focus, float scale) {
+ // FALLBACK: Triangle shape used
+ SetBlendTriangularShape (focus, scale);
+ }
+
+ public void TranslateTransform (float dx, float dy) {
+ BrushTranslateTransform (dx, dy);
+ }
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order) {
+ BrushTranslateTransform(dx, dy, order);
+ }
+
+ public override object Clone () {
+ LinearGradientBrush copy = (LinearGradientBrush)InternalClone();
+
+ if (copy._nativeObject != null)
+ copy._nativeObject = null;
+
+ if (_interpolationColors != null) {
+ copy._interpolationColors = new ColorBlend();
+ if (_interpolationColors.Colors != null)
+ copy._interpolationColors.Colors = (Color[])_interpolationColors.Colors.Clone();
+ if (_interpolationColors.Positions != null)
+ copy._interpolationColors.Positions = (float[])_interpolationColors.Positions.Clone();
+ }
+
+ if (_blend != null) {
+ copy._blend = new Blend();
+ if (_blend.Factors != null)
+ copy._blend.Factors = (float[])_blend.Factors.Clone();
+ if (_blend.Positions != null)
+ copy._blend.Positions = (float[])_blend.Positions.Clone();
+ }
+
+ copy.LinearColors = (Color[])LinearColors.Clone();
+ return copy;
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientMode.cs
new file mode 100644
index 00000000000..4e4472d2547
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientMode.cs
@@ -0,0 +1,46 @@
+//
+// System.Drawing.Drawing2D.LinearGradientMode.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for LinearGradientMode.
+ /// </summary>
+ [Serializable]
+ public enum LinearGradientMode {
+ BackwardDiagonal = 3,
+ ForwardDiagonal = 2,
+ Horizontal = 0,
+ Vertical = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.cs
new file mode 100644
index 00000000000..8a5694be928
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.cs
@@ -0,0 +1,308 @@
+//
+// System.Drawing.Drawing2D.Matrix.cs
+//
+// Authors:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+// Duncan Mak (duncan@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+// (C) Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Drawing2D
+{
+ public sealed class Matrix : MarshalByRefObject, IDisposable
+ {
+ internal IntPtr nativeMatrix;
+
+ // constructors
+ internal Matrix (IntPtr ptr)
+ {
+ nativeMatrix = ptr;
+ }
+
+ public Matrix ()
+ {
+ Status status = GDIPlus.GdipCreateMatrix (out nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Matrix (Rectangle rect , Point[] plgpts)
+ {
+ Status status = GDIPlus.GdipCreateMatrix3I (rect, plgpts, out nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Matrix (RectangleF rect , PointF[] pa)
+ {
+ Status status = GDIPlus.GdipCreateMatrix3 (rect, pa, out nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Matrix (float m11, float m12, float m21, float m22, float dx, float dy)
+ {
+ Status status = GDIPlus.GdipCreateMatrix2 (m11, m12, m21, m22, dx, dy, out nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+
+ // properties
+ public float[] Elements {
+ get {
+ IntPtr tmp = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (float)) * 6);
+ float [] retval = new float [6];
+
+ Status status = GDIPlus.GdipGetMatrixElements (nativeMatrix, tmp);
+ GDIPlus.CheckStatus (status);
+
+ Marshal.Copy (tmp, retval, 0, 6);
+
+ Marshal.FreeHGlobal (tmp);
+ return retval;
+ }
+ }
+
+ public bool IsIdentity {
+ get {
+ bool retval;
+ Status status = GDIPlus.GdipIsMatrixIdentity (nativeMatrix, out retval);
+ GDIPlus.CheckStatus (status);
+ return retval;
+ }
+ }
+
+ public bool IsInvertible {
+ get {
+ bool retval;
+ Status status = GDIPlus.GdipIsMatrixInvertible (nativeMatrix, out retval);
+ GDIPlus.CheckStatus (status);
+ return retval;
+ }
+ }
+
+ public float OffsetX {
+ get {
+ return this.Elements [4];
+ }
+ }
+
+ public float OffsetY {
+ get {
+ return this.Elements [5];
+ }
+ }
+
+ public Matrix Clone()
+ {
+ IntPtr retval;
+ Status status = GDIPlus.GdipCloneMatrix (nativeMatrix, out retval);
+ GDIPlus.CheckStatus (status);
+ return new Matrix (retval);
+ }
+
+
+ public void Dispose ()
+ {
+ if (nativeMatrix != IntPtr.Zero) {
+ Status status = GDIPlus.GdipDeleteMatrix (nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ nativeMatrix = IntPtr.Zero;
+ }
+
+ GC.SuppressFinalize (this);
+ }
+
+ public override bool Equals (object obj)
+ {
+ Matrix m = obj as Matrix;
+
+ if (m != null) {
+ bool retval;
+ Status status = GDIPlus.GdipIsMatrixEqual (nativeMatrix, m.nativeMatrix, out retval);
+ GDIPlus.CheckStatus (status);
+ return retval;
+
+ } else
+ return false;
+ }
+
+ ~Matrix()
+ {
+ Dispose ();
+ }
+
+ public override int GetHashCode ()
+ {
+ return base.GetHashCode ();
+ }
+
+ public void Invert ()
+ {
+ Status status = GDIPlus.GdipInvertMatrix (nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Multiply (Matrix matrix)
+ {
+ Multiply (matrix, MatrixOrder.Prepend);
+ }
+
+ public void Multiply (Matrix matrix, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipMultiplyMatrix (nativeMatrix, matrix.nativeMatrix, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Reset()
+ {
+ Status status = GDIPlus.GdipSetMatrixElements (nativeMatrix, 1, 0, 0, 1, 0, 0);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Rotate (float angle)
+ {
+ Rotate (angle, MatrixOrder.Prepend);
+ }
+
+ public void Rotate (float angle, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipRotateMatrix (nativeMatrix, angle, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void RotateAt (float angle, PointF point)
+ {
+ RotateAt (angle, point, MatrixOrder.Prepend);
+ }
+
+ public void RotateAt (float angle, PointF point, MatrixOrder order)
+ {
+ angle *= (float) (Math.PI / 180.0); // degrees to radians
+ float cos = (float) Math.Cos (angle);
+ float sin = (float) Math.Sin (angle);
+ float e4 = -point.X * cos + point.Y * sin + point.X;
+ float e5 = -point.X * sin - point.Y * cos + point.Y;
+ float[] m = this.Elements;
+
+ Status status;
+
+ if (order == MatrixOrder.Prepend)
+ status = GDIPlus.GdipSetMatrixElements (nativeMatrix,
+ cos * m[0] + sin * m[2],
+ cos * m[1] + sin * m[3],
+ -sin * m[0] + cos * m[2],
+ -sin * m[1] + cos * m[3],
+ e4 * m[0] + e5 * m[2] + m[4],
+ e4 * m[1] + e5 * m[3] + m[5]);
+ else
+ status = GDIPlus.GdipSetMatrixElements (nativeMatrix,
+ m[0] * cos + m[1] * -sin,
+ m[0] * sin + m[1] * cos,
+ m[2] * cos + m[3] * -sin,
+ m[2] * sin + m[3] * cos,
+ m[4] * cos + m[5] * -sin + e4,
+ m[4] * sin + m[5] * cos + e5);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Scale (float scaleX, float scaleY)
+ {
+ Scale (scaleX, scaleY, MatrixOrder.Prepend);
+ }
+
+ public void Scale (float scaleX, float scaleY, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipScaleMatrix (nativeMatrix, scaleX, scaleY, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Shear (float shearX, float shearY)
+ {
+ Shear (shearX, shearY, MatrixOrder.Prepend);
+ }
+
+ public void Shear (float shearX, float shearY, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipShearMatrix (nativeMatrix, shearX, shearY, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TransformPoints (Point[] pts)
+ {
+ Status status = GDIPlus.GdipTransformMatrixPointsI (nativeMatrix, pts, pts.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TransformPoints (PointF[] pts)
+ {
+ Status status = GDIPlus.GdipTransformMatrixPoints (nativeMatrix, pts, pts.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TransformVectors (Point[] pts)
+ {
+ Status status = GDIPlus.GdipVectorTransformMatrixPointsI (nativeMatrix, pts, pts.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TransformVectors (PointF[] pts)
+ {
+ Status status = GDIPlus.GdipVectorTransformMatrixPoints (nativeMatrix, pts, pts.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Translate (float offsetX, float offsetY)
+ {
+ Translate (offsetX, offsetY, MatrixOrder.Prepend);
+ }
+
+ public void Translate (float offsetX, float offsetY, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipTranslateMatrix (nativeMatrix, offsetX, offsetY, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void VectorTransformPoints (Point[] pts)
+ {
+ TransformVectors (pts);
+ }
+
+ internal IntPtr NativeObject
+ {
+ get{
+ return nativeMatrix;
+ }
+ set {
+ nativeMatrix = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.jvm.cs
new file mode 100755
index 00000000000..5b0ef229b01
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Matrix.jvm.cs
@@ -0,0 +1,295 @@
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using geom = java.awt.geom;
+using JMath = java.lang.Math;
+
+namespace System.Drawing.Drawing2D
+{
+ public sealed class Matrix : MarshalByRefObject, IDisposable
+ {
+ #region fields
+
+ static internal readonly Matrix IdentityTransform = new Matrix();
+ readonly geom.AffineTransform _nativeMatrix;
+
+ #endregion
+
+ #region ctors
+
+ internal Matrix (geom.AffineTransform ptr)
+ {
+ _nativeMatrix = ptr;
+ }
+
+ public Matrix () : this(new geom.AffineTransform())
+ {
+ }
+
+ public Matrix (Rectangle rect , Point[] plgpts)
+ {
+ double x1 = plgpts[1].X - plgpts[0].X;
+ double y1 = plgpts[1].Y - plgpts[0].Y;
+
+ double x2 = plgpts[2].X - plgpts[0].X;
+ double y2 = plgpts[2].Y - plgpts[0].Y;
+
+ _nativeMatrix = new geom.AffineTransform(x1/rect.Width, y1/rect.Width, x2/rect.Height, y2/rect.Height, plgpts[0].X, plgpts[0].Y);
+ _nativeMatrix.translate(-rect.X,-rect.Y);
+ }
+
+ public Matrix (RectangleF rect , PointF[] plgpts)
+ {
+ double x1 = plgpts[1].X - plgpts[0].X;
+ double y1 = plgpts[1].Y - plgpts[0].Y;
+
+ double x2 = plgpts[2].X - plgpts[0].X;
+ double y2 = plgpts[2].Y - plgpts[0].Y;
+
+ _nativeMatrix = new geom.AffineTransform(x1/rect.Width, y1/rect.Width, x2/rect.Height, y2/rect.Height, plgpts[0].X, plgpts[0].Y);
+ _nativeMatrix.translate(-rect.X,-rect.Y);
+ }
+
+ public Matrix (float m11, float m12, float m21, float m22, float dx, float dy)
+ : this(new geom.AffineTransform(m11,m12,m21,m22,dx,dy))
+ {
+ }
+
+ #endregion
+
+ #region properties
+
+ public float[] Elements
+ {
+ get
+ {
+ float [] elems = new float[] {
+ (float)NativeObject.getScaleX(),
+ (float)NativeObject.getShearY(),
+ (float)NativeObject.getShearX(),
+ (float)NativeObject.getScaleY(),
+ (float)NativeObject.getTranslateX(),
+ (float)NativeObject.getTranslateY()};
+ return elems;
+ }
+ }
+
+ public bool IsIdentity
+ {
+ get
+ {
+ return NativeObject.isIdentity();
+ }
+ }
+
+ public bool IsInvertible
+ {
+ get
+ {
+ try
+ {
+ return NativeObject.getDeterminant() != 0.0;
+ }
+ catch(geom.NoninvertibleTransformException)
+ {
+ return false;
+ }
+ }
+ }
+
+ public float OffsetX
+ {
+ get
+ {
+ return (float)NativeObject.getTranslateX();
+ }
+ }
+
+ public float OffsetY
+ {
+ get
+ {
+ return (float)NativeObject.getTranslateY();
+ }
+ }
+
+ #endregion
+
+ #region methods
+
+ public Matrix Clone()
+ {
+ return new Matrix ((geom.AffineTransform)NativeObject.clone());
+ }
+
+
+ public void Dispose ()
+ {
+ }
+
+ internal void CopyTo(Matrix matrix) {
+ matrix.NativeObject.setTransform(NativeObject);
+ }
+
+ public override bool Equals (object obj)
+ {
+ Matrix m = obj as Matrix;
+
+
+ if (m == null)
+ return false;
+
+ return NativeObject.equals(m.NativeObject);
+ }
+
+ public override int GetHashCode ()
+ {
+ return NativeObject.hashCode();
+ }
+
+ public void Invert ()
+ {
+ try {
+ _nativeMatrix.setTransform( _nativeMatrix.createInverse() );
+ }
+ catch(geom.NoninvertibleTransformException e) {
+ throw new ArgumentException(e.Message, e);
+ }
+ }
+
+ public void Multiply (Matrix matrix)
+ {
+ Multiply (matrix, MatrixOrder.Prepend);
+ }
+
+ public void Multiply (Matrix matrix, MatrixOrder order)
+ {
+ Multiply(matrix.NativeObject, order);
+ }
+
+ public void Reset()
+ {
+ NativeObject.setToIdentity();
+ }
+
+ public void Rotate (float angle)
+ {
+ NativeObject.rotate (JMath.toRadians(angle));
+ }
+
+ public void Rotate (float angle, MatrixOrder order)
+ {
+ Multiply(geom.AffineTransform.getRotateInstance(JMath.toRadians(angle)), order);
+ }
+
+ public void RotateAt (float angle, PointF point)
+ {
+ NativeObject.rotate (JMath.toRadians(angle), point.X, point.Y);
+ }
+
+ public void RotateAt (float angle, PointF point, MatrixOrder order)
+ {
+ Multiply(geom.AffineTransform.getRotateInstance(JMath.toRadians(angle),point.X, point.Y), order);
+ }
+
+ public void Scale (float scaleX, float scaleY)
+ {
+ NativeObject.scale (scaleX, scaleY);
+ }
+
+ public void Scale (float scaleX, float scaleY, MatrixOrder order)
+ {
+ Multiply(geom.AffineTransform.getScaleInstance(scaleX, scaleY), order);
+ }
+
+ public void Shear (float shearX, float shearY)
+ {
+ NativeObject.shear(shearX, shearY);
+ }
+
+ public void Shear (float shearX, float shearY, MatrixOrder order)
+ {
+ Multiply(geom.AffineTransform.getShearInstance (shearX, shearY), order);
+ }
+
+ public void TransformPoints (Point[] pts)
+ {
+ geom.Point2D.Float pt = new geom.Point2D.Float();
+ for(int i =0;i < pts.Length;i++) {
+ pt.setLocation(pts[i].X,pts[i].Y);
+ NativeObject.transform(pt,pt);
+ pts[i].X=(int)pt.getX();
+ pts[i].Y=(int)pt.getY();
+ }
+ }
+
+ public void TransformPoints (PointF[] pts)
+ {
+ geom.Point2D.Float pt = new geom.Point2D.Float();
+ for(int i =0;i < pts.Length;i++) {
+ pt.setLocation(pts[i].X,pts[i].Y);
+ NativeObject.transform(pt,pt);
+ pts[i].X=(float)pt.getX();
+ pts[i].Y=(float)pt.getY();
+ }
+ }
+
+ public void TransformVectors (Point[] pts)
+ {
+ geom.Point2D.Float pt = new geom.Point2D.Float();
+ for(int i =0;i < pts.Length;i++) {
+ pt.setLocation(pts[i].X,pts[i].Y);
+ NativeObject.deltaTransform(pt,pt);
+ pts[i].X=(int)pt.getX();
+ pts[i].Y=(int)pt.getY();
+ }
+ }
+
+ public void TransformVectors (PointF[] pts)
+ {
+ geom.Point2D.Float pt = new geom.Point2D.Float();
+ for(int i =0;i < pts.Length;i++) {
+ pt.setLocation(pts[i].X,pts[i].Y);
+ NativeObject.deltaTransform(pt,pt);
+ pts[i].X=(float)pt.getX();
+ pts[i].Y=(float)pt.getY();
+ }
+ }
+
+ public void Translate (float offsetX, float offsetY)
+ {
+ NativeObject.translate (offsetX, offsetY);
+ }
+
+ public void Translate (float offsetX, float offsetY, MatrixOrder order)
+ {
+ Multiply(geom.AffineTransform.getTranslateInstance(offsetX, offsetY), order);
+ }
+
+ public void VectorTransformPoints (Point[] pts)
+ {
+ TransformVectors (pts);
+ }
+
+ internal geom.AffineTransform NativeObject
+ {
+ get
+ {
+ return _nativeMatrix;
+ }
+ }
+
+ void Multiply(geom.AffineTransform at, MatrixOrder order) {
+ Multiply(NativeObject, at, order);
+ }
+
+ internal static void Multiply(geom.AffineTransform to, geom.AffineTransform add, MatrixOrder order) {
+ if(order == MatrixOrder.Prepend)
+ to.concatenate(add);
+ else
+ to.preConcatenate(add);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/MatrixOrder.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/MatrixOrder.cs
new file mode 100644
index 00000000000..bd8149d7e97
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/MatrixOrder.cs
@@ -0,0 +1,44 @@
+//
+// System.Drawing.Drawing2D.MatrixOrder.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for MatrixOrder.
+ /// </summary>
+ [Serializable]
+ public enum MatrixOrder {
+ Append = 1,
+ Prepend = 0
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs
new file mode 100644
index 00000000000..9114be093d6
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs
@@ -0,0 +1,53 @@
+//
+// System.Drawing.Drawing2D.PathData.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// (C) 2002/3 Ximian, Inc
+// Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Drawing.Drawing2D
+{
+ public sealed class PathData
+ {
+ private PointF[] points;
+ private byte[] types;
+
+ public PathData ()
+ {
+ }
+
+ public PointF[] Points {
+ get { return points; }
+ set { points = value; }
+ }
+
+ public byte[] Types {
+ get { return types; }
+ set { types = value; }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.cs
new file mode 100644
index 00000000000..162baded814
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.cs
@@ -0,0 +1,357 @@
+//
+// System.Drawing.Drawing2D.PathGradientBrush.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002/3 Ximian, Inc. http://www.ximian.com
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Drawing;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for PathGradientBrush.
+ /// </summary>
+ public sealed class PathGradientBrush : Brush
+ {
+ internal PathGradientBrush (IntPtr native) : base (native)
+ {
+ }
+
+ public PathGradientBrush (GraphicsPath path)
+ {
+ Status status = GDIPlus.GdipCreatePathGradientFromPath (path.NativeObject, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public PathGradientBrush (Point [] points) : this (points, WrapMode.Clamp)
+ {
+ }
+
+ public PathGradientBrush (PointF [] points) : this (points, WrapMode.Clamp)
+ {
+ }
+
+ public PathGradientBrush (Point [] points, WrapMode wrapMode)
+ {
+ Status status = GDIPlus.GdipCreatePathGradientI (points, points.Length, wrapMode, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public PathGradientBrush (PointF [] points, WrapMode wrapMode)
+ {
+ Status status = GDIPlus.GdipCreatePathGradient (points, points.Length, wrapMode, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ // Properties
+
+ public Blend Blend {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetPathGradientBlendCount (nativeObject, out count);
+ GDIPlus.CheckStatus (status);
+ float [] factors = new float [count];
+ float [] positions = new float [count];
+ status = GDIPlus.GdipGetPathGradientBlend (nativeObject, factors, positions, count);
+ GDIPlus.CheckStatus (status);
+
+ Blend blend = new Blend ();
+ blend.Factors = factors;
+ blend.Positions = positions;
+
+ return blend;
+ }
+ set {
+ int count;
+ float [] factors = value.Factors;
+ float [] positions = value.Positions;
+ count = factors.Length;
+
+ if (count == 0 || positions.Length == 0)
+ throw new ArgumentException ("Invalid Blend object. It should have at least 2 elements in each of the factors and positions arrays.");
+
+ if (count != positions.Length)
+ throw new ArgumentException ("Invalid Blend object. It should contain the same number of factors and positions values.");
+
+ if (positions [0] != 0.0F)
+ throw new ArgumentException ("Invalid Blend object. The positions array must have 0.0 as its first element.");
+
+ if (positions [count - 1] != 1.0F)
+ throw new ArgumentException ("Invalid Blend object. The positions array must have 1.0 as its last element.");
+
+ Status status = GDIPlus.GdipSetPathGradientBlend (nativeObject, factors, positions, count);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public Color CenterColor {
+ get {
+ int centerColor;
+ Status status = GDIPlus.GdipGetPathGradientCenterColor (nativeObject, out centerColor);
+ GDIPlus.CheckStatus (status);
+ return Color.FromArgb (centerColor);
+ }
+ set {
+ Status status = GDIPlus.GdipSetPathGradientCenterColor (nativeObject, value.ToArgb ());
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public PointF CenterPoint {
+ get {
+ PointF center;
+ Status status = GDIPlus.GdipGetPathGradientCenterPoint (nativeObject, out center);
+ GDIPlus.CheckStatus (status);
+
+ return center;
+ }
+ set {
+ PointF center = value;
+ Status status = GDIPlus.GdipSetPathGradientCenterPoint (nativeObject, ref center);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public PointF FocusScales {
+ get {
+ float xScale;
+ float yScale;
+ Status status = GDIPlus.GdipGetPathGradientFocusScales (nativeObject, out xScale, out yScale);
+ GDIPlus.CheckStatus (status);
+
+ return new PointF (xScale, yScale);
+ }
+ set {
+ Status status = GDIPlus.GdipSetPathGradientFocusScales (nativeObject, value.X, value.Y);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public ColorBlend InterpolationColors {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetPathGradientPresetBlendCount (nativeObject, out count);
+ GDIPlus.CheckStatus (status);
+ int [] intcolors = new int [count];
+ float [] positions = new float [count];
+ status = GDIPlus.GdipGetPathGradientPresetBlend (nativeObject, intcolors, positions, count);
+ GDIPlus.CheckStatus (status);
+
+ ColorBlend interpolationColors = new ColorBlend ();
+ Color [] colors = new Color [count];
+ for (int i = 0; i < count; i++)
+ colors [i] = Color.FromArgb (intcolors [i]);
+ interpolationColors.Colors = colors;
+ interpolationColors.Positions = positions;
+
+ return interpolationColors;
+ }
+ set {
+ int count;
+ Color [] colors = value.Colors;
+ float [] positions = value.Positions;
+ count = colors.Length;
+
+ if (count == 0 || positions.Length == 0)
+ throw new ArgumentException ("Invalid ColorBlend object. It should have at least 2 elements in each of the colors and positions arrays.");
+
+ if (count != positions.Length)
+ throw new ArgumentException ("Invalid ColorBlend object. It should contain the same number of positions and color values.");
+
+ if (positions [0] != 0.0F)
+ throw new ArgumentException ("Invalid ColorBlend object. The positions array must have 0.0 as its first element.");
+
+ if (positions [count - 1] != 1.0F)
+ throw new ArgumentException ("Invalid ColorBlend object. The positions array must have 1.0 as its last element.");
+
+ int [] blend = new int [colors.Length];
+ for (int i = 0; i < colors.Length; i++)
+ blend [i] = colors [i].ToArgb ();
+
+ Status status = GDIPlus.GdipSetPathGradientPresetBlend (nativeObject, blend, positions, count);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public RectangleF Rectangle {
+ get {
+ RectangleF rect;
+ Status status = GDIPlus.GdipGetPathGradientRect (nativeObject, out rect);
+ GDIPlus.CheckStatus (status);
+
+ return rect;
+ }
+ }
+
+ public Color [] SurroundColors {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetPathGradientSurroundColorCount (nativeObject, out count);
+ GDIPlus.CheckStatus (status);
+
+ int [] intcolors = new int [count];
+ status = GDIPlus.GdipGetPathGradientSurroundColorsWithCount (nativeObject, intcolors, ref count);
+ GDIPlus.CheckStatus (status);
+
+ Color [] colors = new Color [count];
+ for (int i = 0; i < count; i++)
+ colors [i] = Color.FromArgb (intcolors [i]);
+
+ return colors;
+ }
+ set {
+ int count = value.Length;
+ int [] colors = new int [count];
+ for (int i = 0; i < count; i++)
+ colors [i] = value [i].ToArgb ();
+
+ Status status = GDIPlus.GdipSetPathGradientSurroundColorsWithCount (nativeObject, colors, ref count);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public Matrix Transform {
+ get {
+ Matrix matrix = new Matrix ();
+ Status status = GDIPlus.GdipGetPathGradientTransform (nativeObject, matrix.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+
+ return matrix;
+ }
+ set {
+ Status status = GDIPlus.GdipSetPathGradientTransform (nativeObject, value.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public WrapMode WrapMode {
+ get {
+ WrapMode wrapMode;
+ Status status = GDIPlus.GdipGetPathGradientWrapMode (nativeObject, out wrapMode);
+ GDIPlus.CheckStatus (status);
+
+ return wrapMode;
+ }
+ set {
+ Status status = GDIPlus.GdipSetPathGradientWrapMode (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ // Methods
+
+ public void MultiplyTransform (Matrix matrix)
+ {
+ MultiplyTransform (matrix, MatrixOrder.Prepend);
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipMultiplyPathGradientTransform (nativeObject, matrix.nativeMatrix, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ResetTransform ()
+ {
+ Status status = GDIPlus.GdipResetPathGradientTransform (nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void RotateTransform (float angle)
+ {
+ RotateTransform (angle, MatrixOrder.Prepend);
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipRotatePathGradientTransform (nativeObject, angle, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ScaleTransform (float sx, float sy)
+ {
+ ScaleTransform (sx, sy, MatrixOrder.Prepend);
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipScalePathGradientTransform (nativeObject, sx, sy, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetBlendTriangularShape (float focus)
+ {
+ SetBlendTriangularShape (focus, 1.0F);
+ }
+
+ public void SetBlendTriangularShape (float focus, float scale)
+ {
+ if (focus < 0 || focus > 1 || scale < 0 || scale > 1)
+ throw new ArgumentException ("Invalid parameter passed.");
+
+ Status status = GDIPlus.GdipSetPathGradientLinearBlend (nativeObject, focus, scale);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetSigmaBellShape (float focus)
+ {
+ SetSigmaBellShape (focus, 1.0F);
+ }
+
+ public void SetSigmaBellShape (float focus, float scale)
+ {
+ if (focus < 0 || focus > 1 || scale < 0 || scale > 1)
+ throw new ArgumentException ("Invalid parameter passed.");
+
+ Status status = GDIPlus.GdipSetPathGradientSigmaBlend (nativeObject, focus, scale);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TranslateTransform (float dx, float dy)
+ {
+ TranslateTransform (dx, dy, MatrixOrder.Prepend);
+ }
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipTranslatePathGradientTransform (nativeObject, dx, dy, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public override object Clone ()
+ {
+ IntPtr clonePtr;
+ Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
+ GDIPlus.CheckStatus (status);
+
+ PathGradientBrush clone = new PathGradientBrush (clonePtr);
+ return clone;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.jvm.cs
new file mode 100755
index 00000000000..dc59acff752
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.jvm.cs
@@ -0,0 +1,286 @@
+
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using awt = java.awt;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for PathGradientBrush.
+ /// </summary>
+ [MonoTODO]
+ public sealed class PathGradientBrush : Brush {
+ Brush _nativeObject;
+ Blend _blend;
+ Color _centerColor;
+ PointF _center;
+ PointF _focus;
+ RectangleF _rectangle;
+ Color [] _surroundColors;
+ ColorBlend _interpolationColors;
+ WrapMode _wrapMode;
+ GraphicsPath _texturePath;
+ bool _triangularShape = false;
+
+ protected override java.awt.Paint NativeObject {
+ get {
+ return _nativeObject;
+ }
+ }
+
+ #region initialize
+
+ void Initialize(GraphicsPath path, WrapMode wrapMode, bool initColors, bool calcCenter) {
+
+ _texturePath = path;
+ _wrapMode = wrapMode;
+ _rectangle = path.GetBounds();
+
+ if (initColors) {
+ _centerColor = Color.Black;
+ _surroundColors = new Color []{ Color.White };
+ }
+
+ Bitmap texture = new Bitmap( (int)_rectangle.Width, (int)_rectangle.Height );
+ Graphics g = Graphics.FromImage( texture );
+ PointF [] pathPoints = path.PathPoints;
+
+ if (calcCenter) {
+ for (int i=0; i < pathPoints.Length; i++) {
+ _center.X += pathPoints[i].X;
+ _center.Y += pathPoints[i].Y;
+ }
+ _center.X /= pathPoints.Length;
+ _center.Y /= pathPoints.Length;
+ }
+
+ int outerColor = 0;
+ DrawSector( g, CenterPoint, pathPoints[pathPoints.Length-1], pathPoints[0], CenterColor, SurroundColors[outerColor] );
+ for(int i=0; i < pathPoints.Length - 1; i++) {
+ if (outerColor < SurroundColors.Length - 1)
+ outerColor++;
+ DrawSector( g, CenterPoint, pathPoints[i], pathPoints[i+1], CenterColor, SurroundColors[outerColor] );
+ }
+
+ _nativeObject = new TextureBrush( texture );
+ }
+ private void DrawSector(Graphics g, PointF center, PointF p1, PointF p2, Color innerColor, Color outerColor) {
+ GraphicsPath pt = new GraphicsPath();
+ pt.AddLine(p1, center);
+ pt.AddLine(center, p2);
+ LinearGradientBrush lgb = new LinearGradientBrush( GetVertical(center, p1, p2) , center, outerColor, innerColor );
+ if (_triangularShape)
+ lgb.SetBlendTriangularShape(0.5f);
+ g.FillPath( lgb, pt );
+ }
+ private PointF GetVertical(PointF c, PointF p1, PointF p2) {
+ if (p1.X == p2.X)
+ return new PointF(p1.X, c.Y);
+ if (p1.Y == p2.Y)
+ return new PointF(c.X, p2.Y);
+
+ float a = (float)(p2.Y - p1.Y) / (p2.X - p1.X);
+ float av = - 1 / a;
+
+ float b1 = p1.Y - a * p1.X;
+ float b2 = c.Y - av * c.X;
+
+ float ox = (b1 - b2) / (av - a);
+ float oy = av * ox + b2;
+
+ return new PointF(ox, oy);
+ }
+
+ #endregion
+
+ #region ctors
+
+ public PathGradientBrush (GraphicsPath path) {
+ Initialize( path, WrapMode.Clamp, true, true );
+ }
+
+ public PathGradientBrush (Point [] points) : this (points, WrapMode.Clamp) {
+ }
+
+ public PathGradientBrush (PointF [] points) : this (points, WrapMode.Clamp) {
+ }
+
+ public PathGradientBrush (Point [] points, WrapMode wrapMode) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddLines( points );
+ Initialize( path, wrapMode, true, true );
+ }
+
+ public PathGradientBrush (PointF [] points, WrapMode wrapMode) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddLines( points );
+ Initialize( path, wrapMode, true, true );
+ }
+
+ #endregion
+
+ #region Properties
+
+ [MonoTODO]
+ public Blend Blend {
+ get {
+ return _blend;
+ }
+ set {
+ _blend = value;
+ }
+ }
+
+ public Color CenterColor {
+ get {
+ return _centerColor;
+ }
+ set {
+ _centerColor = value;
+ Initialize(_texturePath, _wrapMode, false, false );
+ }
+ }
+
+ public PointF CenterPoint {
+ get {
+ return _center;
+ }
+ set {
+ _center = value;
+ Initialize(_texturePath, _wrapMode, false, false );
+ }
+ }
+
+ public PointF FocusScales {
+ get {
+ return _focus;
+ }
+ set {
+ _focus = value;
+ }
+ }
+
+ public ColorBlend InterpolationColors {
+ get {
+ return _interpolationColors;
+ }
+ set {
+ _interpolationColors = value;
+ }
+ }
+
+ public RectangleF Rectangle {
+ get {
+ return _rectangle;
+ }
+ }
+
+ public Color [] SurroundColors {
+ get {
+ return _surroundColors;
+ }
+ set {
+ _surroundColors = value;
+ Initialize(_texturePath, _wrapMode, false, false );
+ }
+ }
+
+ public Matrix Transform {
+ get {
+ return BrushTransform;
+ }
+ set {
+ BrushTransform = value;
+ }
+ }
+
+ public WrapMode WrapMode {
+ get {
+ return _wrapMode;
+ }
+ set {
+ _wrapMode = value;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public void MultiplyTransform (Matrix matrix) {
+ base.BrushMultiplyTransform( matrix );
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order) {
+ base.BrushMultiplyTransform( matrix, order );
+ }
+
+ public void ResetTransform () {
+ base.BrushResetTransform();
+ }
+
+ public void RotateTransform (float angle) {
+ base.BrushRotateTransform( angle );
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order) {
+ base.BrushRotateTransform( angle, order );
+ }
+
+ public void ScaleTransform (float sx, float sy) {
+ base.BrushScaleTransform( sx, sy );
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order) {
+ base.BrushScaleTransform( sx, sy, order );
+ }
+
+ public void SetBlendTriangularShape (float focus) {
+ SetBlendTriangularShape (focus, 1.0F);
+ }
+
+ public void SetBlendTriangularShape (float focus, float scale) {
+ _triangularShape = true;
+ Initialize( _texturePath, _wrapMode, false, false );
+ }
+
+ public void SetSigmaBellShape (float focus) {
+ SetSigmaBellShape (focus, 1.0F);
+ }
+
+ [MonoTODO]
+ public void SetSigmaBellShape (float focus, float scale) {
+ // FALLBACK: Triangle shape used
+ SetBlendTriangularShape (focus, scale);
+ }
+
+ public void TranslateTransform (float dx, float dy) {
+ base.BrushTranslateTransform( dx, dy );
+ }
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order) {
+ base.BrushTranslateTransform( dx, dy, order );
+ }
+
+ public override object Clone () {
+ PathGradientBrush copy = (PathGradientBrush)InternalClone();
+
+ if (copy._nativeObject != null)
+ copy._nativeObject = (Brush)copy._nativeObject.Clone();
+
+ if (copy._surroundColors != null)
+ copy._surroundColors = (Color[])copy._surroundColors.Clone();
+
+ if (copy._texturePath != null)
+ copy._texturePath = (GraphicsPath)copy._texturePath.Clone();
+
+ //TBD: clone _blend, _interpolationColors
+ //copy._blend = copy._blend
+
+ return copy;
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathPointType.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathPointType.cs
new file mode 100644
index 00000000000..eb67406f57f
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathPointType.cs
@@ -0,0 +1,50 @@
+//
+// System.Drawing.Drawing2D.PathPointType.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for PathPointType.
+ /// </summary>
+ [Serializable]
+ public enum PathPointType {
+ Bezier = 3,
+ Bezier3 = 3,
+ CloseSubpath = 128,
+ DashMode = 16,
+ Line = 1,
+ PathMarker = 32,
+ PathTypeMask = 7,
+ Start = 0
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PenAlignment.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PenAlignment.cs
new file mode 100644
index 00000000000..b35e4f0a48c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PenAlignment.cs
@@ -0,0 +1,45 @@
+//
+// System.Drawing.Drawing2D.PenAlignment.cs
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+// Dennis Hayes (dennish@Raytek.com)
+// (C) 2002/3 Ximian, Inc http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Drawing2D {
+
+ [Serializable]
+ public enum PenAlignment {
+ Center = 0,
+ Inset = 1,
+ Outset = 2,
+ Left = 3,
+ Right =4
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PenType.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PenType.cs
new file mode 100644
index 00000000000..892fc23e56d
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PenType.cs
@@ -0,0 +1,46 @@
+//
+// System.Drawing.Drawing2D.PenType.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//using System;
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for PenType.
+ /// </summary>
+ [Serializable]
+ public enum PenType {
+ HatchFill = 1,
+ LinearGradient = 4,
+ PathGradient = 3,
+ SolidColor = 0,
+ TextureFill = 2
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PixelOffsetMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PixelOffsetMode.cs
new file mode 100644
index 00000000000..858f9ebe9ac
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PixelOffsetMode.cs
@@ -0,0 +1,49 @@
+//
+// System.Drawing.Drawing2D.PixelOffsetMode.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for PixelOffsetMode.
+ /// </summary>
+ [Serializable]
+ public enum PixelOffsetMode {
+ Default = 0,
+ Half = 4,
+ HighQuality = 2,
+ HighSpeed = 1,
+ Invalid = -1,
+ None = 3
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs
new file mode 100644
index 00000000000..23a8c2277a4
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs
@@ -0,0 +1,46 @@
+//
+// System.Drawing.Drawing2D.QualityMode.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for QualityMode.
+ /// </summary>
+ [Serializable]
+ public enum QualityMode {
+ Default = 0,
+ High = 2,
+ Invalid = -1,
+ Low = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs
new file mode 100644
index 00000000000..8483f4b63a2
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs
@@ -0,0 +1,52 @@
+//
+// System.Drawing.Drawing2D.RegionData.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Drawing2D
+{
+ /// <summary>
+ /// Summary description for RegionData.
+ /// </summary>
+ public sealed class RegionData
+ {
+ private byte[] data;
+
+ internal RegionData () { }
+
+ public byte[] Data {
+ get {return data;}
+ set {data = value;}
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/SmoothingMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/SmoothingMode.cs
new file mode 100644
index 00000000000..303e1d8c088
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/SmoothingMode.cs
@@ -0,0 +1,48 @@
+//
+// System.Drawing.Drawing2D.SmoothingMode.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002/3 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for SmoothingMode.
+ /// </summary>
+ [Serializable]
+ public enum SmoothingMode {
+ AntiAlias = 4,
+ Default = 0,
+ HighQuality = 2,
+ HighSpeed = 1,
+ Invalid = -1,
+ None = 3
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/WarpMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/WarpMode.cs
new file mode 100644
index 00000000000..f094fb12e65
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/WarpMode.cs
@@ -0,0 +1,44 @@
+//
+// System.Drawing.WarpMode.cs
+//
+// Author:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for WarpMode.
+ /// </summary>
+ [Serializable]
+ public enum WarpMode {
+ Bilinear = 1,
+ Perspective = 0
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/WrapMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/WrapMode.cs
new file mode 100644
index 00000000000..d1195710d3e
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/WrapMode.cs
@@ -0,0 +1,49 @@
+//
+// System.Drawing.Drawing2D.WrapMode.cs
+//
+// Authors:
+// Stefan Maierhofer <sm@cg.tuwien.ac.at>
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) 2002/3 Ximian, Inc. http://www.ximian.com
+// (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Drawing2D {
+ /// <summary>
+ /// Summary description for WrapMode.
+ /// </summary>
+ [Serializable]
+ public enum WrapMode {
+ Tile,
+ TileFlipX,
+ TileFlipY,
+ TileFlipXY,
+ Clamp
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/BitmapData.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/BitmapData.cs
new file mode 100644
index 00000000000..bf937143559
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/BitmapData.cs
@@ -0,0 +1,120 @@
+//
+// System.Drawing.Imaging.BitmapData.cs
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+// Vladimir Vukicevic (vladimir@pobox.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+using System.IO;
+
+namespace System.Drawing.Imaging
+{
+ // MUST BE KEPT IN SYNC WITH gdip.h in libgdiplus!
+#if TARGET_JVM
+ [MonoTODO]
+#endif
+ [StructLayout(LayoutKind.Sequential)]
+ public sealed class BitmapData {
+ internal int width;
+ internal int height;
+ internal int stride;
+ internal PixelFormat pixel_format; // int
+ internal IntPtr address;
+ internal int reserved;
+
+ // following added to keep track of frames
+ internal int top;
+ internal int left;
+ internal int byteCount;
+ internal IntPtr bytes;
+
+ public int Height {
+ get {
+ return height;
+ }
+
+ set {
+ height = value;
+ }
+ }
+
+ public int Width {
+ get {
+ return width;
+ }
+
+ set {
+ width = value;
+ }
+ }
+
+ public PixelFormat PixelFormat {
+ get {
+
+ return pixel_format;
+ }
+
+ set {
+ pixel_format = value;
+ }
+ }
+
+ public int Reserved {
+ get {
+ return reserved;
+ }
+
+ set {
+ reserved = value;
+ }
+ }
+
+ public IntPtr Scan0 {
+ get {
+ return address;
+ }
+
+ set {
+ address = value;
+ }
+ }
+
+ public int Stride {
+ get {
+ return stride;
+ }
+
+ set {
+ stride = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog b/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
new file mode 100644
index 00000000000..7bb92d72a8d
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ChangeLog
@@ -0,0 +1,412 @@
+2005-11-23 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ImageCodec.jvm.cs: fixed ProcessOneCodec, sometime it was failed
+ on parsing version of codec
+
+2005-11-17 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ImageCodec.jvm.cs: fixed WriteImage, removed flush
+ of native output
+
+2005-11-17 Raja R Harinath <rharinath@novell.com>
+
+ * ColorMatrix.cs: Make it have Sequential layout.
+
+2005-11-16 Konstantin Triger <kostat@mainsoft.com>
+
+ * ImageCodec.jvm.cs: refactoring.
+
+2005-11-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ImageCodec.jvm.cs: Fixed error handling in codecs emumeration flow
+
+2005-11-13 Kornél Pál <kornelpal@hotmail.com>
+
+ * ImageFormat.cs: Fixed ToString to use this.Equals to reflect argument
+ changes to ImageFormat objects. Added Exif and Icon strings to ToString
+ and reordered formats to match declaration.
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * ImageCodec.jvm.cs: throw an exception if codec is not found.
+
+2005-10-31 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ImageFormat.cs: Fixes ToString method
+
+2005-09-27 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ImageCodec.jvm.cs: implemented IDsposable,
+ fixed NativeReader, NativeWriter, NativeStream
+
+2005-10-20 Konstantin Triger <kostat@mainsoft.com>
+
+ * Metafile.jvm.cs: implement abstact Clone
+
+2005-10-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * EncoderParameter.cs, EncoderParameters.cs: Calling GC.SuppressFinalize
+ from the Dispose method; fixes bug #76329
+
+2005-09-21 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ImageCodec.jvm.cs: refactoring of read/write methods, members access levels
+
+2005-09-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ImageCodecInfo.jvm.cs: fixed ImageCodec namespace
+ * ImageCodec.jvm.cs: refactoring of read/write methods
+
+2005-09-07 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ImageCodecInfo.jvm.cs: fixed GetValueFromMetadata, SetResolution
+
+2005-09-07 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ImageCodecInfo.jvm.cs: Refactoring
+ * Added ImageCodec.jvm.cs
+
+2005-08-28 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ImageCodecInfo.jvm.cs: Fixed Iterate
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * ImageCodecInfo.jvm.cs: implement via java imageio, add internal APIs for
+ fast read-only requests
+ * Methafile.jvm.cs: change in not implemented api to match image.jvm.cs
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * Metafile.jvm.cs: add TARGET_JVM implementation
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * ColorPalette.cs, FrameDimension.cs, EncoderParameters.cs: TARGET_JVM
+ exclude not supported internal methods
+ * EncoderParameter.jvm.cs, ImageAttributes.jvm.cs, ImageFormat.jvm.cs,
+ ImageCodecInfo.jvm.cs: added TARGET_JVM implementation of these classes
+
+2005-03-23 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * ColorPalette.cs: fixes ColorPalette marshaling
+
+2004-03-21 Jordi Mas i Hernadez <jordi@ximian.com>
+
+ * ColorMatrix.cs: fixes Matrix00 init
+ * ImageAttributes.cs: fixes dispose method and signature
+
+2004-02-25 Jordi Mas i Hernadez <jordi@ximian.com>
+
+ * ColorMatrix.cs: rewritten to be able to marshall it properly
+
+2004-12-27 Zoltan Varga <vargaz@freemail.hu>
+
+ * ImageCodecInfo.cs: Fix marshalling of arrays on amd64.
+
+2004-11-25 Marek Safar <marek.safar@seznam.cz>
+
+ * ColorPalette.cs: Add CheckStatus to GetAdjustedPalette.
+
+2004-11-03 Miguel de Icaza <miguel@ximian.com>
+
+ * ColorPalette.cs: Add internal Clone method
+
+2004-10-08 Ravindra <rkumar@novell.com>
+
+ * BitmapData.cs: Synchronized the class with BitmapData struct
+ in libgdiplus.
+
+2004-06-13 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * EmfPlusRecordType.cs: fixed mismatches in enum field values
+
+2004-05-18 Jordi Mas i Hernadez <jordi@ximian.com>
+ * ImageAttributes.cs: SetBrushRemapTable and SetRemapTable were
+ passing bad parameters to GDI+ causing them not to work
+
+2004-05-16 Gert Driesen (drieseng@users.sourceforge.net)
+
+ * EncoderParameterValueType.cs: fix Windows build (CSC),
+ MCS bug #58571
+
+ * EncoderParameter.cs: removed ctors taking int value,
+ to fix public API
+
+2004-05-14 Vladimir Vukicevic <vladimir@pobox.com>
+
+ * EncoderParameters.cs: Added ToNativePtr() method to marshal
+ struct correctly to a native struct. Resulting data should be
+ FreeHGlobal'd when finished.
+
+ * EncoderParameter.cs: Changed data storage to correspond to
+ native code layout (so we can pass these structs directly to
+ native code). Also changed layout to match native layout.
+
+ * EncoderParameterValueType.cs: force EncoderParameterValueType to
+ be Int32
+
+2004-05-13 Jordi Mas i Hernadez <jordi@ximian.com>
+
+ * ColorMatrix.cs:Make private data private
+ * ColorPalette.cs: Make private data private
+ * Encoder.cs: Make private data private
+ * EncoderParameter.cs: Make private data private
+ * EncoderParameters.cs: Make private data private
+ * MetaHeader.cs: Make private data private
+ * PropertyItem.cs: Make private data private
+
+2004-05-04 Vladimir Vukicevic <vladimir@pobox.com>
+
+ * BitmapData.cs: re-synchronized with libgdiplus; also
+ removed memory deallocs here (as the data is always owned
+ by libgdiplus)
+
+2004-04-28 Sanjay Gupta <gsanjay@novell.com>
+
+ Modified files from dos2unix format.
+
+2004-04-27 Ravindra <rkumar@novell.com>
+
+ * ImageAttributes.cs: Implemented SetWrapMode(WrapMode) method.
+
+2004-04-27 Jordi Mas i Hernadez <jordi@ximian.com>
+
+ * ImageFormat.cs: completed missimg members
+ * ImageCodecInfo.cs: Use GDI+ calls instead of native C#
+
+2004-04-27 Sanjay Gupta <gsanjay@novell.com>
+ * ImageFormat.cs: Implemented Equals() method.
+
+2004-04-27 Sanjay Gupta <gsanjay@novell.com>
+ * ImageFormat.cs: Implemented ToString() method.
+
+2004-04-06 Vladimir Vukicevic <vladimir@pobox.com>
+
+ * BitmapData.cs: synced up data structure with libgdiplus
+
+ * BmpCodec.cs, JPEGCodec.cs, PNGCodec.cs: Removed codec impls,
+ left just codecinfo getters; the codecs are in libgdiplus
+
+ * ImageCodecInfo.cs: removed encode/decode delegates
+
+2004-03-31 Jordi Mas i Hernadez <jordi@ximian.com>
+ * FrameDimension.cs: added missing members
+
+2004-03-26 Jordi Mas i Hernadez <jordi@ximian.com>
+ * ImageAttributes.cs: added missing members and complete the wrapper
+
+2004-03-04 Jordi Mas i Hernadez <jordi@ximian.com>
+ * BmpCodec.cs: fixes DPI in BMP
+ * Image.cs: gets DPI using GDI+ api
+
+2004-03-04 Jordi Mas i Hernadez <jordi@ximian.com>
+ * BmpCodec.cs
+ Added support for diffent formats
+ Fixed bugs in import and export
+ Support for OS/2 and palettes
+ * Image.cs
+ Palettes
+
+2004-03-04 Sanjay Gupta <gsanjay@novell.com>
+ * Metafile.cs: Added constructor with correct signature.
+
+2004-03-04 Nick Drochak <ndrochak@ieee.org>
+
+ * Metafile.cs: Fix build, remove duplicate member.
+
+2004-03-03 Sanjay Gupta <gsanjay@novell.com>
+ *ImageAttributes.cs: Added few missing functions
+ *Metafile.cs: Added stubs for missing constructors and functions
+
+2004-03-03 Nick Drochak <ndrochak@ieee.org>
+
+ * BmpCodec.cs: Remove unsed variable.
+
+2004-02-17 Ravindra <rkumar@novell.com>
+ * EncoderParameter.cs: Did few bug fixes and changed the file
+ format to unix.
+
+2004-02-13 Sanjay Gupta <gsanjay@novell.com>
+ * FrameDimension.cs: Implemented missing functionalities
+
+2004-02-12 Ravindra <rkumar@novell.com>
+ * EncoderParameters.cs: Implemented.
+ * EncoderParameter.cs: Implemented.
+
+2004-01-21 Jordi Mas i Hernàdez <jmas@softcatala.org>
+ * BmpBitmap.cs: fixed encoding and decoding problems
+ * ImageAttributes.cs: implemented
+
+2004-01-19 Ravindra <rkumar@novell.com>
+
+ * Encoder.cs: Implemented.
+
+2004-01-10 Ravindra <rkumar@novell.com>
+
+ * All Enums: Made serializable.
+
+ * ImageAttributes.cs: Implements ICloneable.
+
+ * Metafile.cs: Made serializable and invisible to COM.
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ColorMap.cs: Implemented
+ * ColorMatrix.cs: Implemented, Removed unneccesary members
+ * ImageAttributes.cs: Fixed signature
+ * ImageCodecInfo.cs: Added missing attribure, hide constructor
+ * ImageFormat.cs: Implemented, Added attribute
+ * MetaHeader.cs: Implemented
+ * PropertyItem.cs: Implemented
+ * ImageFlags.cs: Added Attribute
+ * ImageCodecFlags.cs: Added Attribute
+ * EmfPlusRecordType.cs: Added missing members
+
+2003-11-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * BitmapData.cs new function to convert BRG to RGB
+ * JPEGCodec.cs convert BRG to RBG
+ * PNGCodec.cs
+
+
+2003-11-02 Alexandre Pigolkine <pigolkine@gmx.de>
+ * BmpCodec.cs
+ * ImageCodecInfo.cs
+ * JPEGCodec.cs
+ * PNGCodec.cs
+ codec can select pixel format of bitmap
+
+2003-10-23 Miguel de Icaza <miguel@ximian.com>
+
+ * JPEGCodec.cs (JSAMPARRAY): Do not allocate memory here anymore,
+ we will just have the JPEG library copy directly into our buffer.
+
+ (Encode, Decode): Ported to the new model which avoid copies, and
+ eliminates InternalImageInfo.
+
+ TODO: need to port the PNG coder/decoder, and add support for RGBA
+ images which got dropped from this version
+
+ * BmpCodec.cs: Rework this one to use BitmapData and Image. Do
+ not use the RawBytes property, instead pull the data one line at a
+ time, and write that out.
+
+ * ImageCodecInfo.cs: Make the encoding and decoding delegates take
+ a Image parameter;
+
+ * BmpCodec.cs:
+
+ * BitmapData.cs: Make this one sequential, and also mimic the
+ layout of GdiPlus.h so we can use this instead of making copies
+ back and forth.
+
+2003-10-12 Alexandre Pigolkine
+ * BmpCodec.cs warning removed
+
+2003-07-23 Alexandre Pigolkine
+ * JPEGCodec.cs
+ * PNGCodec.cs
+ * BmpCodec.cs cosmetic changes
+
+2003-07-22 Alexandre Pigolkine
+ * ImageCodecInfo.cs
+ * ImageFormat.cs
+ * JPEGCodec.cs
+ changes for PNG codec
+
+ * PNGCodec.cs added
+
+2003-07-21 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Metafile.cs: Inherits from image (fix for System.Drawing.Design)
+
+2003-06-29 Alexandre Pigolkine
+ * BmpCodec.cs handle 32bpp images
+ * JPEGCodec.cs small fix
+
+2003-06-27 Alexandre Pigolkine <pigolkine@gmx.de>
+ * JPEGCodec.cs encode 32 bpp images
+
+2003-06-23 Alexandre Pigolkine <pigolkine@gmx.de>
+ * JPEGCodec.cs set pixel format in InternalImageInfo
+
+2003-06-23 Alexandre Pigolkine <pigolkine@gmx.de>
+ * BmpCodec.cs pixel format check added
+ * JPEGCodec.cs encoder implemented
+
+2003-06-15 Alexandre Pigolkine <pigolkine@gmx.de>
+ * ColorPalette.cs
+ * ImageCodecInfo.cs
+ * ImageFormat.cs
+ implementation added
+
+ * BmpCodec.cs
+ * JPEGCodec.cs
+ added
+
+2002-9-2 DennisHayes <dennish@raytek.com>
+
+* PropertyItem.cs t
+* MetaHeader.cs t
+* MetafileHeader.cs t
+* Metafile.cs t
+* ImageFormat.cs t
+* ImageCodecInfo.cs t
+* ColorMatrix.cs t
+* ColorMap.cs t
+* WmfPlaceableFileHeader.cs t
+* Added todos back
+
+2002-9-2 DennisHayes <dennish@raytek.com>
+ * checked in for Everaldo Canuto (everaldo.canuto@bol,com.br)
+ * BitmapData.cs
+ * ColorAdjustType.cs
+ * ColorChannelFlag.cs
+ * ColorMap.cs
+ * ColorMapType.cs
+ * ColorMatrix.cs
+ * ColorMatrixFlag.cs
+ * ColorMode.cs
+ * EmfPlusRecordType.cs
+ * EmfType.cs
+ * EncoderParameterValueType.cs
+ * EncoderValue.cs
+ * ImageCodecFlags.cs
+ * ImageCodecInfo.cs
+ * ImageFlags.cs
+ * ImageFormat.cs
+ * ImageLockMode.cs
+ * MetafileFrameUnit.cs
+ * MetafileHeader.cs
+ * MetaHeader.cs
+ * PaletteFlags.cs
+ * PixelFormat.cs
+ * PlayRecordCallback.cs
+ * PropertyItem.cs
+ * WmfPlaceableFileHeader.cs
+ * Added null classes for most/all classes, Many stubs, and some implmentation
+
+2002-9-2 DennisHayes <dennish@raytek.com>
+
+ * ColorPalette.cs
+ * FrameDimension.cs
+ * Metafile.cs
+ * Added stubs, implmentation
+
+2002-05-03 Mike Kestner <mkestner@speakeasy.net>
+
+ * Metafile.cs : Use System.IO. Fix exception typos.
+
+2002-04-27 Christian Meyer <Christian.Meyer@cs.tum.edu>
+
+ * Metafile.cs: Copyright now holds Ximian.
+
+2002-04-21 Dennis Hayes <dennish@raytek.com>
+
+ * corrected emum values.
+
+2002-04-14 Christian Meyer <Christian.Meyer@cs.tum.edu>
+
+ * ChangeLog: created.
+ * Metafile.cs: Added. Wrote some ctors. No impl done, yet.
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorAdjustType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorAdjustType.cs
new file mode 100644
index 00000000000..7244eb94ad5
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorAdjustType.cs
@@ -0,0 +1,43 @@
+//
+// System.Drawing.Imaging.ColorAdjustType.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum ColorAdjustType {
+ Any = 6,
+ Bitmap = 1,
+ Brush = 2,
+ Count = 5,
+ Default = 0,
+ Pen = 3,
+ Text = 4
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorChannelFlag.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorChannelFlag.cs
new file mode 100644
index 00000000000..2c7800080c9
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorChannelFlag.cs
@@ -0,0 +1,41 @@
+//
+// System.Drawing.Imaging.ColorChannelFlag.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum ColorChannelFlag {
+ ColorChannelC = 0,
+ ColorChannelK = 3,
+ ColorChannelLast = 4,
+ ColorChannelM = 1,
+ ColorChannelY = 2
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs
new file mode 100644
index 00000000000..602434eedbb
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs
@@ -0,0 +1,64 @@
+//
+// System.Drawing.Imaging.ColorMap.cs
+//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Reflection;
+
+namespace System.Drawing.Imaging {
+#if TARGET_JVM
+ [MonoTODO]
+#endif
+ public sealed class ColorMap {
+
+ private Color newColor;
+ private Color oldColor;
+
+ // constructors
+ public ColorMap() {
+ }
+
+ // properties
+ public Color NewColor {
+ get { return newColor; }
+ set { newColor = value; }
+ }
+
+ public Color OldColor {
+ get { return oldColor; }
+ set { oldColor = value; }
+ }
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMapType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMapType.cs
new file mode 100644
index 00000000000..59317e0be89
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMapType.cs
@@ -0,0 +1,38 @@
+//
+// System.Drawing.Imaging.ColorMapType.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum ColorMapType{//check
+ Brush = 1,
+ Default = 0
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs
new file mode 100644
index 00000000000..a9e64359ded
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs
@@ -0,0 +1,372 @@
+//
+// Copyright 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//
+// Authors:
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+// Partially based on work by:
+//
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+//
+
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging
+{
+#if TARGET_JVM
+ [MonoTODO]
+#endif
+ [StructLayout (LayoutKind.Sequential)]
+ public sealed class ColorMatrix
+ {
+ private float color00;
+ private float color01;
+ private float color02;
+ private float color03;
+ private float color04;
+ private float color10;
+ private float color11;
+ private float color12;
+ private float color13;
+ private float color14;
+ private float color20;
+ private float color21;
+ private float color22;
+ private float color23;
+ private float color24;
+ private float color30;
+ private float color31;
+ private float color32;
+ private float color33;
+ private float color34;
+ private float color40;
+ private float color41;
+ private float color42;
+ private float color43;
+ private float color44;
+
+ // constructors
+ public ColorMatrix ()
+ {
+ color01 = color02 = color03 = color04 = 0;
+ color10 = color12 = color13 = color14 = 0;
+ color20 = color21 = color23 = color24 = 0;
+ color30 = color31 = color32 = color34 = 0;
+ color40 = color41 = color42 = color43 = 0;
+ color00 = color11 = color22 = color33 = color44 = 1;
+ }
+
+ [CLSCompliant(false)]
+ public ColorMatrix (float[][] matrix)
+ {
+ color00 = matrix [0][0];
+ color01 = matrix [0][1];
+ color02 = matrix [0][2];
+ color03 = matrix [0][3];
+ color04 = matrix [0][4];
+ color10 = matrix [1][0];
+ color11 = matrix [1][1];
+ color12 = matrix [1][2];
+ color13 = matrix [1][3];
+ color14 = matrix [1][4];
+ color20 = matrix [2][0];
+ color21 = matrix [2][1];
+ color22 = matrix [2][2];
+ color23 = matrix [2][3];
+ color24 = matrix [2][4];
+ color30 = matrix [3][0];
+ color31 = matrix [3][1];
+ color32 = matrix [3][2];
+ color33 = matrix [3][3];
+ color34 = matrix [3][4];
+ color40 = matrix [4][0];
+ color41 = matrix [4][1];
+ color42 = matrix [4][2];
+ color43 = matrix [4][3];
+ color44 = matrix [4][4];
+ }
+
+ // properties
+ public float this[int row, int column] {
+ get {
+ switch (row) {
+ case 0: {
+ switch (column) {
+ case 0: return color00;
+ case 1: return color01;
+ case 2: return color02;
+ case 3: return color03;
+ case 4: return color04;
+ default: break;
+ }
+ break;
+ }
+ case 1: {
+ switch (column) {
+ case 0: return color10;
+ case 1: return color11;
+ case 2: return color12;
+ case 3: return color13;
+ case 4: return color14;
+ default: break;
+ }
+ break;
+ }
+ case 2: {
+ switch (column) {
+ case 0: return color20;
+ case 1: return color21;
+ case 2: return color22;
+ case 3: return color23;
+ case 4: return color24;
+ default: break;
+ }
+ break;
+ }
+ case 3: {
+ switch (column) {
+ case 0: return color30;
+ case 1: return color31;
+ case 2: return color32;
+ case 3: return color33;
+ case 4: return color34;
+ default: break;
+ }
+ break;
+ }
+ case 4: {
+ switch (column) {
+ case 0: return color40;
+ case 1: return color41;
+ case 2: return color42;
+ case 3: return color43;
+ case 4: return color44;
+ default: break;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ throw new IndexOutOfRangeException ("Index was outside the bounds of the array");
+ }
+
+ set {
+ switch (row) {
+ case 0: {
+ switch (column) {
+ case 0: color00 = value; return;
+ case 1: color01 = value; return;
+ case 2: color02 = value; return;
+ case 3: color03 = value; return;
+ case 4: color04 = value; return;
+ default: break;
+ }
+ break;
+ }
+ case 1: {
+ switch (column) {
+ case 0: color10 = value; return;
+ case 1: color11 = value; return;
+ case 2: color12 = value; return;
+ case 3: color13 = value; return;
+ case 4: color14 = value; return;
+ default: break;
+ }
+ break;
+ }
+ case 2: {
+ switch (column) {
+ case 0: color20 = value; return;
+ case 1: color21 = value; return;
+ case 2: color22 = value; return;
+ case 3: color23 = value; return;
+ case 4: color24 = value; return;
+ default: break;
+ }
+ break;
+ }
+ case 3: {
+ switch (column) {
+ case 0: color30 = value; return;
+ case 1: color31 = value; return;
+ case 2: color32 = value; return;
+ case 3: color33 = value; return;
+ case 4: color34 = value; return;
+ default: break;
+ }
+ break;
+ }
+ case 4: {
+ switch (column) {
+ case 0: color40 = value; return;
+ case 1: color41 = value; return;
+ case 2: color42 = value; return;
+ case 3: color43 = value; return;
+ case 4: color44 = value; return;
+ default: break;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ throw new IndexOutOfRangeException ("Index was outside the bounds of the array");
+ }
+ }
+
+
+ public float Matrix00 {
+ get { return color00; }
+ set { color00 = value; }
+ }
+
+ public float Matrix01 {
+ get { return color01; }
+ set { color01 = value; }
+ }
+
+ public float Matrix02 {
+ get { return color02; }
+ set { color02 = value; }
+ }
+
+ public float Matrix03 {
+ get { return color03; }
+ set { color03 = value; }
+ }
+
+ public float Matrix04 {
+ get { return color04; }
+ set { color04 = value; }
+ }
+
+ public float Matrix10 {
+ get { return color10; }
+ set { color10 = value; }
+ }
+
+ public float Matrix11 {
+ get { return color11; }
+ set { color11 = value; }
+ }
+
+ public float Matrix12 {
+ get { return color12; }
+ set { color12 = value; }
+ }
+
+ public float Matrix13 {
+ get { return color13; }
+ set { color13 = value; }
+ }
+
+ public float Matrix14 {
+ get { return color14; }
+ set { color14 = value; }
+ }
+
+ public float Matrix20 {
+ get { return color20; }
+ set { color20 = value; }
+ }
+
+ public float Matrix21 {
+ get { return color21; }
+ set { color21 = value; }
+ }
+
+ public float Matrix22 {
+ get { return color22; }
+ set { color22 = value; }
+ }
+
+ public float Matrix23 {
+ get { return color23; }
+ set { color23 = value; }
+ }
+
+ public float Matrix24 {
+ get { return color24; }
+ set { color24 = value; }
+ }
+
+ public float Matrix30 {
+ get { return color30; }
+ set { color30 = value; }
+ }
+
+ public float Matrix31 {
+ get { return color31; }
+ set { color31 = value; }
+ }
+
+ public float Matrix32 {
+ get { return color32; }
+ set { color32 = value; }
+ }
+
+ public float Matrix33 {
+ get { return color33; }
+ set { color33 = value; }
+ }
+
+ public float Matrix34 {
+ get { return color34; }
+ set { color34 = value; }
+ }
+
+ public float Matrix40 {
+ get { return color40; }
+ set { color40 = value; }
+ }
+
+ public float Matrix41 {
+ get { return color41; }
+ set { color41 = value; }
+ }
+
+ public float Matrix42 {
+ get { return color42; }
+ set { color42 = value; }
+ }
+
+ public float Matrix43 {
+ get { return color43; }
+ set { color43 = value; }
+ }
+
+ public float Matrix44 {
+ get { return color44; }
+ set { color44 = value; }
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrixFlag.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrixFlag.cs
new file mode 100644
index 00000000000..3b5b678805c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrixFlag.cs
@@ -0,0 +1,39 @@
+//
+// System.Drawing.Imaging.ColorMatrixFlag.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum ColorMatrixFlag{
+ AltGrays = 2,
+ Default = 0,
+ SkipGrays = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMode.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMode.cs
new file mode 100644
index 00000000000..46408177f22
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMode.cs
@@ -0,0 +1,38 @@
+//
+// System.Drawing.Imaging.ColorMode.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum ColorMode {
+ Argb32Mode = 0,
+ Argb64Mode = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs
new file mode 100644
index 00000000000..7b231135537
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs
@@ -0,0 +1,116 @@
+//
+// System.Drawing.Imaging.ColorPalette.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging
+{
+ public sealed class ColorPalette {
+ // 0x1: the color values in the array contain alpha information
+ // 0x2: the color values are grayscale values.
+ // 0x4: the colors in the array are halftone values.
+
+ private int flags;
+ private Color [] entries;
+
+ //
+ // There is no public constructor, this will be used somewhere in the
+ // drawing code
+ //
+ internal ColorPalette ()
+ {
+ flags = 0;
+ entries = new Color [0];
+ }
+
+ internal ColorPalette (int flags, Color[] colors) {
+ this.flags = flags;
+ entries = colors;
+ }
+
+ public Color [] Entries {
+ get {
+ return entries;
+ }
+ }
+
+ public int Flags {
+ get {
+ return flags;
+ }
+ }
+#if !TARGET_JVM
+ /* Caller should call FreeHGlobal*/
+ internal IntPtr getGDIPalette()
+ {
+ GdiColorPalette palette = new GdiColorPalette ();
+ Color[] entries = Entries;
+ int entry = 0;
+ int size = Marshal.SizeOf (palette) + (Marshal.SizeOf (entry) * entries.Length);
+ IntPtr lfBuffer = Marshal.AllocHGlobal(size);
+
+ palette.Flags = Flags;
+ palette.Count = entries.Length;
+
+ int[] values = new int[palette.Count];
+
+ for (int i = 0; i < values.Length; i++) {
+ values[i] = entries[i].ToArgb();
+ }
+
+ Marshal.StructureToPtr (palette, lfBuffer, false);
+ Marshal.Copy (values, 0, (IntPtr) (lfBuffer.ToInt32() + Marshal.SizeOf (palette)), values.Length);
+
+ return lfBuffer;
+ }
+
+ internal void setFromGDIPalette (IntPtr palette)
+ {
+ IntPtr ptr = palette;
+ int cnt, color;
+
+ flags = Marshal.ReadInt32 (ptr); ptr = (IntPtr) (ptr.ToInt32() + 4);
+ cnt = Marshal.ReadInt32 (ptr); ptr = (IntPtr) (ptr.ToInt32() + 4);
+
+ entries = new Color [cnt];
+
+ for (int i = 0; i < cnt; i++) {
+ color = Marshal.ReadInt32 (ptr);
+ entries[i] = Color.FromArgb (color);
+ ptr = (IntPtr) (ptr.ToInt32() + 4);
+ }
+ }
+#endif
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs
new file mode 100644
index 00000000000..f068a4afcb2
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs
@@ -0,0 +1,289 @@
+//
+// System.Drawing.Imaging.EmfPlusRecordType.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum EmfPlusRecordType {
+ BeginContainer = 16423,
+ BeginContainerNoParams = 16424,
+ Clear = 16393,
+ Comment = 16387,
+ DrawArc = 16402,
+ DrawBeziers = 16409,
+ DrawClosedCurve = 16407,
+ DrawCurve = 16408,
+ DrawDriverString = 16438,
+ DrawEllipse = 16399,
+ DrawImage = 16410,
+ DrawImagePoints = 16411,
+ DrawLines = 16397,
+ DrawPath = 16405,
+ DrawPie = 16401,
+ DrawRects = 16395,
+ DrawString = 16412,
+ EmfAbortPath = 68,
+ EmfAlphaBlend = 114,
+ EmfAngleArc = 41,
+ EmfArcTo = 55,
+ EmfBeginPath = 59,
+ EmfBitBlt = 76,
+ EmfChord = 46,
+ EmfCloseFigure = 61,
+ EmfColorCorrectPalette = 111,
+ EmfColorMatchToTargetW = 121,
+ EmfCreateBrushIndirect = 39,
+ EmfCreateColorSpace = 99,
+ EmfCreateColorSpaceW = 122,
+ EmfCreateDibPatternBrushPt = 94,
+ EmfCreateMonoBrush = 93,
+ EmfCreatePalette = 49,
+ EmfCreatePen = 38,
+ EmfDeleteColorSpace = 101,
+ EmfDeleteObject = 40,
+ EmfDrawEscape = 105,
+ EmfEllipse = 42,
+ EmfEndPath = 60,
+ EmfEof = 14,
+ EmfExcludeClipRect = 29,
+ EmfExtCreateFontIndirect = 82,
+ EmfExtCreatePen = 95,
+ EmfExtEscape = 106,
+ EmfExtFloodFill = 53,
+ EmfExtSelectClipRgn = 75,
+ EmfExtTextOutA = 83,
+ EmfExtTextOutW = 84,
+ EmfFillPath = 62,
+ EmfFillRgn = 71,
+ EmfFlattenPath = 65,
+ EmfForceUfiMapping = 109,
+ EmfFrameRgn = 72,
+ EmfGdiComment = 70,
+ EmfGlsBoundedRecord = 103,
+ EmfGlsRecord = 102,
+ EmfGradientFill = 118,
+ EmfHeader = 1,
+ EmfIntersectClipRect = 30,
+ EmfInvertRgn = 73,
+ EmfLineTo = 54,
+ EmfMaskBlt = 78,
+ EmfMax = 122,
+ EmfMin = 1,
+ EmfModifyWorldTransform = 36,
+ EmfMoveToEx = 27,
+ EmfNamedEscpae = 110,
+ EmfOffsetClipRgn = 26,
+ EmfPaintRgn = 74,
+ EmfPie = 47,
+ EmfPixelFormat = 104,
+ EmfPlgBlt = 79,
+ EmfPlusRecordBase = 16384,
+ EmfPolyBezier = 2,
+ EmfPolyBezier16 = 85,
+ EmfPolyBezierTo = 5,
+ EmfPolyBezierTo16 = 88,
+ EmfPolyDraw = 56,
+ EmfPolyDraw16 = 92,
+ EmfPolygon = 3,
+ EmfPolygon16 = 86,
+ EmfPolyline = 4,
+ EmfPolyPolygon16 = 91,
+ EmfPolyPolyline = 7,
+ EmfPolyline16 = 87,
+ EmfPolyPolygon = 8,
+ EmfPolyPolyline16 = 90,
+ EmfPolyTextOutA = 96,
+ EmfPolyTextOutW = 97,
+ EmfRealizePalette = 52,
+ EmfRectangle = 43,
+ EmfReserved069 = 69,
+ EmfReserved117 = 117,
+ EmfResizePalette = 51,
+ EmfRestoreDC = 34,
+ EmfRoundArc = 45,
+ EmfRoundRect = 44,
+ EmfSaveDC = 33,
+ EmfScaleViewportExtEx = 31,
+ EmfScaleWindowExtEx = 32,
+ EmfSelectClipPath = 67,
+ EmfSelectObject = 37,
+ EmfSelectPalette = 48,
+ EmfSetArcDirection = 57,
+ EmfSetBkColor = 25,
+ EmfSetBkMode = 18,
+ EmfSetBrushOrgEx = 13,
+ EmfSetColorAdjustment = 23,
+ EmfSetColorSpace = 100,
+ EmfSetDIBitsToDevice = 80,
+ EmfSetIcmMode = 98,
+ EmfSetIcmProfileA = 112,
+ EmfSetIcmProfileW = 113,
+ EmfSetLayout = 115,
+ EmfSetLinkedUfis = 119,
+ EmfSetMapMode = 17,
+ EmfSetMapperFlags = 16,
+ EmfSetMetaRgn = 28,
+ EmfSetMiterLimit = 58,
+ EmfSetPaletteEntries = 50,
+ EmfSetPixelV = 15,
+ EmfSetPolyFillMode = 19,
+ EmfSetROP2 = 20,
+ EmfSetStretchBltMode = 21,
+ EmfSetTextAlign = 22,
+ EmfSetTextColor = 24,
+ EmfSetTextJustification =120 ,
+ EmfSetViewportExtEx = 11,
+ EmfSetViewportOrgEx = 12,
+ EmfSetWindowExtEx = 9,
+ EmfSetWindowOrgEx = 10,
+ EmfSetWorldTransform = 35,
+ EmfSmallTextOut = 108,
+ EmfStartDoc = 107,
+ EmfStretchBlt = 77,
+ EmfStretchDIBits = 81,
+ EmfStrokeAndFillPath = 63,
+ EmfStrokePath = 64,
+ EmfTransparentBlt = 116,
+ EmfWidenPath = 66,
+ EndContainer = 16425,
+ EndOfFile = 16386,
+ FillClosedCurve = 16406,
+ FillEllipse = 16398,
+ FillPath = 16404,
+ FillPie = 16400,
+ FillPolygon = 16396,
+ FillRects = 16394,
+ FillRegion = 16403,
+ GetDC = 16388,
+ Header = 16385,
+ Invalid = 16384,
+ Max = 16438,
+ Min = 16385,
+ MultiFormatEnd = 16391,
+ MultiFormatSection = 16390,
+ MultiFormatStart = 16389,
+ MultiplyWorldTransform = 16428,
+ Object = 16392,
+ OffsetClip = 16437,
+ ResetClip = 16433,
+ ResetWorldTransform = 16427,
+ Restore = 16422,
+ RotateWorldTransform = 16431,
+ Save = 16421,
+ ScaleWorldTransform = 16430,
+ SetAntiAliasMode = 16414,
+ SetClipPath = 16435,
+ SetClipRect = 16434,
+ SetClipRegion = 16436,
+ SetCompositingMode = 16419,
+ SetCompositingQuality = 16420,
+ SetInterpolationMode = 16417,
+ SetPageTransform = 16432,
+ SetPixelOffsetMode = 16418,
+ SetRenderingOrigin = 16413,
+ SetTextContrast = 16416,
+ SetTextRenderingHint = 16415,
+ SetWorldTransform = 16426,
+ Total = 16439,
+ TranslateWorldTransform = 16429,
+ WmfAnimatePalette = 66614,
+ WmfArc = 67607,
+ WmfBitBlt = 67874,
+ WmfChord = 67632,
+ WmfCreateBrushIndirect = 66300,
+ WmfCreateFontIndirect = 66299,
+ WmfCreatePalette = 65783,
+ WmfCreatePatternBrush = 66041,
+ WmfCreatePenIndirect = 66298,
+ WmfCreateRegion = 67327,
+ WmfDeleteObject = 66032,
+ WmfDibBitBlt = 67904,
+ WmfDibCreatePatternBrush = 65858,
+ WmfFillRegion = 66088,
+ WmfFloodFill = 66585,
+ WmfFrameRegion = 66601,
+ WmfIntersectClipRect = 66582,
+ WmfInvertRegion = 65834,
+ WmfLineTo = 66067,
+ WmfMoveTo = 66068,
+ WmfOffsetCilpRgn = 66080,
+ WmfOffsetViewportOrg = 66065,
+ WmfOffsetWindowOrg = 66063,
+ WmfPaintRegion = 65835,
+ WmfPatBlt = 67101,
+ WmfPie = 67610,
+ WmfPolygon = 66340,
+ WmfPolyline = 66341,
+ WmfPolyPolygon = 66872,
+ WmfRealizePalette = 65589,
+ WmfRecordBase = 65536,
+ WmfRectangle = 66587,
+ WmfResizePalette = 65849,
+ WmfRestoreDC = 65831,
+ WmfRoundRect = 67100,
+ WmfSaveDC = 65566,
+ WmfScaleViewportExt = 66578,
+ WmfScaleWindowExt = 66576,
+ WmfSelectClipRegion = 65836,
+ WmfSelectObject = 65837,
+ WmfSelectPalette = 66100,
+ WmfSetBkColor = 66049,
+ WmfSetBkMode = 65794,
+ WmfSetDibToDev = 68915,
+ WmfSetLayout = 65865,
+ WmfSetMapMode = 65795,
+ WmfSetMapperFlags = 66097,
+ WmfSetPalEntries = 65591,
+ WmfSetPixel = 66591,
+ WmfSetPolyFillMode = 65798,
+ WmfSetRelAbs = 65797,
+ WmfSetROP2 = 65796,
+ WmfSetStretchBltMode = 65799,
+ WmfSetTextAlign = 65838,
+ WmfSetTextCharExtra = 65800,
+ WmfSetTextColor = 66057,
+ WmfSetTextJustification = 66058,
+ WmfSetViewportExt = 66062,
+ WmfSetViewportOrg = 66061,
+ WmfSetWindowExt = 66060,
+ WmfSetWindowOrg = 66059,
+ WmfStretchBlt = 68387,
+ WmfStretchDib = 69443,
+ WmfTextOut = 66849,
+ EmfPolyLineTo = 6,
+ EmfPolylineTo16 = 89,
+ WmfDibStretchBlt = 68417,
+ WmfEllipse = 66584,
+ WmfEscape = 67110,
+ WmfExcludeClipRect = 66581,
+ WmfExtFloodFill = 66888,
+ WmfExtTextOut = 68146
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EmfType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EmfType.cs
new file mode 100644
index 00000000000..76287fd72c3
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/EmfType.cs
@@ -0,0 +1,39 @@
+//
+// System.Drawing.Imaging.EmfType.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum EmfType {
+ EmfOnly = 3,
+ EmfPlusDual = 5,
+ EmfPlusOnly = 4
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/Encoder.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/Encoder.cs
new file mode 100644
index 00000000000..e085b6c7fbe
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/Encoder.cs
@@ -0,0 +1,79 @@
+//
+// System.Drawing.Imaging.Encoder.cs
+//
+// (C) 2004 Novell, Inc. http://www.novell.com
+// Author: Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Imaging
+{
+ public sealed class Encoder
+ {
+ private Guid guid;
+
+ public static readonly Encoder ChrominanceTable;
+ public static readonly Encoder ColorDepth;
+ public static readonly Encoder Compression;
+ public static readonly Encoder LuminanceTable;
+ public static readonly Encoder Quality;
+ public static readonly Encoder RenderMethod;
+ public static readonly Encoder SaveFlag;
+ public static readonly Encoder ScanMethod;
+ public static readonly Encoder Transformation;
+ public static readonly Encoder Version;
+
+ static Encoder ()
+ {
+ // GUID values are taken from my windows machine.
+ ChrominanceTable = new Encoder ("f2e455dc-09b3-4316-8260-676ada32481c");
+ ColorDepth = new Encoder ("66087055-ad66-4c7c-9a18-38a2310b8337");
+ Compression = new Encoder ("e09d739d-ccd4-44ee-8eba-3fbf8be4fc58");
+ LuminanceTable = new Encoder ("edb33bce-0266-4a77-b904-27216099e717");
+ Quality = new Encoder ("1d5be4b5-fa4a-452d-9cdd-5db35105e7eb");
+ RenderMethod = new Encoder ("6d42c53a-229a-4825-8bb7-5c99e2b9a8b8");
+ SaveFlag = new Encoder ("292266fc-ac40-47bf-8cfc-a85b89a655de");
+ ScanMethod = new Encoder ("3a4e2661-3109-4e56-8536-42c156e7dcfa");
+ Transformation = new Encoder ("8d0eb2d1-a58e-4ea8-aa14-108074b7b6f9");
+ Version = new Encoder ("24d18c76-814a-41a4-bf53-1c219cccf797");
+ }
+
+ internal Encoder (String guid) {
+ this.guid = new Guid (guid);
+ }
+
+ public Encoder (Guid guid) {
+ this.guid = guid;
+ }
+
+ public Guid Guid {
+ get {
+ return guid;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.cs
new file mode 100644
index 00000000000..d11bf4ecce3
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.cs
@@ -0,0 +1,358 @@
+//
+// System.Drawing.Imaging.EncoderParameter.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+// Vladimir Vukicevic (vladimir@pobox.com)
+//
+// (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging {
+
+ [StructLayout(LayoutKind.Sequential)]
+ public sealed class EncoderParameter : IDisposable {
+
+ private Encoder encoder;
+ private int valuesCount;
+ private EncoderParameterValueType type;
+ private IntPtr valuePtr;
+
+ internal EncoderParameter ()
+ {
+ }
+
+ public EncoderParameter (Encoder encoder, byte value)
+ {
+ this.encoder = encoder;
+ this.valuesCount = 1;
+ this.type = EncoderParameterValueType.ValueTypeByte;
+ this.valuePtr = Marshal.AllocHGlobal (1);
+ Marshal.WriteByte (this.valuePtr, value);
+ }
+
+ public EncoderParameter (Encoder encoder, byte[] value)
+ {
+ this.encoder = encoder;
+ this.valuesCount = value.Length;
+ this.type = EncoderParameterValueType.ValueTypeByte;
+ this.valuePtr = Marshal.AllocHGlobal (1 * valuesCount);
+ Marshal.Copy (value, 0, this.valuePtr, valuesCount);
+ }
+
+ public EncoderParameter (Encoder encoder, short value)
+ {
+ this.encoder = encoder;
+ this.valuesCount = 1;
+ this.type = EncoderParameterValueType.ValueTypeShort;
+ this.valuePtr = Marshal.AllocHGlobal (2);
+ Marshal.WriteInt16 (this.valuePtr, value);
+ }
+
+ public EncoderParameter (Encoder encoder, short[] value)
+ {
+ this.encoder = encoder;
+ this.valuesCount = value.Length;
+ this.type = EncoderParameterValueType.ValueTypeShort;
+ this.valuePtr = Marshal.AllocHGlobal (2 * valuesCount);
+ Marshal.Copy (value, 0, this.valuePtr, valuesCount);
+ }
+
+
+ public EncoderParameter (Encoder encoder, long value)
+ {
+ this.encoder = encoder;
+ this.valuesCount = 1;
+ this.type = EncoderParameterValueType.ValueTypeLong;
+ this.valuePtr = Marshal.AllocHGlobal (4);
+ Marshal.WriteInt32 (this.valuePtr, (int) value);
+ }
+
+ public EncoderParameter (Encoder encoder, long[] value)
+ {
+ this.encoder = encoder;
+ this.valuesCount = value.Length;
+ this.type = EncoderParameterValueType.ValueTypeLong;
+ this.valuePtr = Marshal.AllocHGlobal (4 * valuesCount);
+ int [] ivals = new int[value.Length];
+ for (int i = 0; i < value.Length; i++) ivals[i] = (int) value[i];
+ Marshal.Copy (ivals, 0, this.valuePtr, valuesCount);
+ }
+
+ public EncoderParameter (Encoder encoder, string value)
+ {
+ this.encoder = encoder;
+
+ ASCIIEncoding ascii = new ASCIIEncoding ();
+ int asciiByteCount = ascii.GetByteCount (value);
+ byte[] bytes = new byte [asciiByteCount];
+ ascii.GetBytes (value, 0, value.Length, bytes, 0);
+
+ this.valuesCount = bytes.Length;
+ this.type = EncoderParameterValueType.ValueTypeAscii;
+ this.valuePtr = Marshal.AllocHGlobal (valuesCount);
+ Marshal.Copy (bytes, 0, this.valuePtr, valuesCount);
+ }
+
+ public EncoderParameter (Encoder encoder, byte value, bool undefined)
+ {
+ this.encoder = encoder;
+ this.valuesCount = 1;
+ if (undefined)
+ this.type = EncoderParameterValueType.ValueTypeUndefined;
+ else
+ this.type = EncoderParameterValueType.ValueTypeByte;
+ this.valuePtr = Marshal.AllocHGlobal (1);
+ Marshal.WriteByte (this.valuePtr, value);
+ }
+
+ public EncoderParameter (Encoder encoder, byte[] value, bool undefined)
+ {
+ this.encoder = encoder;
+ this.valuesCount = value.Length;
+ if (undefined)
+ this.type = EncoderParameterValueType.ValueTypeUndefined;
+ else
+ this.type = EncoderParameterValueType.ValueTypeByte;
+ this.valuePtr = Marshal.AllocHGlobal (valuesCount);
+ Marshal.Copy (value, 0, this.valuePtr, valuesCount);
+ }
+
+ public EncoderParameter (Encoder encoder, int numerator, int denominator)
+ {
+ this.encoder = encoder;
+ this.valuesCount = 1;
+ this.type = EncoderParameterValueType.ValueTypeRational;
+ this.valuePtr = Marshal.AllocHGlobal (8);
+ int [] valuearray = { numerator, denominator };
+ Marshal.Copy (valuearray, 0, this.valuePtr, valuearray.Length);
+ }
+
+ public EncoderParameter (Encoder encoder, int[] numerator, int[] denominator)
+ {
+ if (numerator.Length != denominator.Length)
+ throw new ArgumentException ("Invalid parameter used.");
+
+ this.encoder = encoder;
+ this.valuesCount = numerator.Length;
+ this.type = EncoderParameterValueType.ValueTypeRational;
+ this.valuePtr = Marshal.AllocHGlobal (4 * valuesCount * 2);
+ IntPtr dest = this.valuePtr;
+ for (int i = 0; i < valuesCount; i++) {
+ Marshal.WriteInt32 (dest, (int) numerator[i]);
+ dest = (IntPtr) ((int) dest + 4);
+ Marshal.WriteInt32 (dest, (int) denominator[i]);
+ dest = (IntPtr) ((int) dest + 4);
+ }
+ }
+
+ public EncoderParameter (Encoder encoder, long rangebegin, long rangeend)
+ {
+ this.encoder = encoder;
+ this.valuesCount = 1;
+ this.type = EncoderParameterValueType.ValueTypeLongRange;
+ this.valuePtr = Marshal.AllocHGlobal (8);
+ int [] valuearray = { (int) rangebegin, (int) rangeend };
+ Marshal.Copy (valuearray, 0, this.valuePtr, valuearray.Length);
+ }
+
+ public EncoderParameter (Encoder encoder, long[] rangebegin, long[] rangeend)
+ {
+ if (rangebegin.Length != rangeend.Length)
+ throw new ArgumentException ("Invalid parameter used.");
+
+ this.encoder = encoder;
+ this.valuesCount = rangebegin.Length;
+ this.type = EncoderParameterValueType.ValueTypeLongRange;
+
+ this.valuePtr = Marshal.AllocHGlobal (4 * valuesCount * 2);
+ IntPtr dest = this.valuePtr;
+ for (int i = 0; i < valuesCount; i++) {
+ Marshal.WriteInt32 (dest, (int) rangebegin[i]);
+ dest = (IntPtr) ((int) dest + 4);
+ Marshal.WriteInt32 (dest, (int) rangeend[i]);
+ dest = (IntPtr) ((int) dest + 4);
+ }
+ }
+
+ public EncoderParameter (Encoder encoder, int numberOfValues, int type, int value)
+ {
+ this.encoder = encoder;
+ this.valuePtr = (IntPtr) value;
+ this.valuesCount = numberOfValues;
+ this.type = (EncoderParameterValueType) type;
+ }
+
+ public EncoderParameter (Encoder encoder, int numerator1, int denominator1, int numerator2, int denominator2)
+ {
+ this.encoder = encoder;
+ this.valuesCount = 1;
+ this.type = EncoderParameterValueType.ValueTypeRationalRange;
+ this.valuePtr = Marshal.AllocHGlobal (4 * 4);
+ int [] valuearray = { numerator1, denominator1, numerator2, denominator2 };
+ Marshal.Copy (valuearray, 0, this.valuePtr, 4);
+ }
+
+ public EncoderParameter (Encoder encoder, int[] numerator1, int[] denominator1, int[] numerator2, int[] denominator2)
+ {
+ if (numerator1.Length != denominator1.Length ||
+ numerator2.Length != denominator2.Length ||
+ numerator1.Length != numerator2.Length)
+ throw new ArgumentException ("Invalid parameter used.");
+
+ this.encoder = encoder;
+ this.valuesCount = numerator1.Length;
+ this.type = EncoderParameterValueType.ValueTypeRationalRange;
+
+ this.valuePtr = Marshal.AllocHGlobal (4 * valuesCount * 4);
+ IntPtr dest = this.valuePtr;
+ for (int i = 0; i < valuesCount; i++) {
+ Marshal.WriteInt32 (dest, numerator1[i]);
+ dest = (IntPtr) ((int) dest + 4);
+ Marshal.WriteInt32 (dest, denominator1[i]);
+ dest = (IntPtr) ((int) dest + 4);
+ Marshal.WriteInt32 (dest, numerator2[i]);
+ dest = (IntPtr) ((int) dest + 4);
+ Marshal.WriteInt32 (dest, denominator2[i]);
+ dest = (IntPtr) ((int) dest + 4);
+ }
+ }
+
+ public Encoder Encoder {
+ get {
+ return encoder;
+ }
+
+ set {
+ encoder = value;
+ }
+ }
+
+ public int NumberOfValues {
+ get {
+ return valuesCount;
+ }
+ }
+
+ public EncoderParameterValueType Type {
+ get {
+ return type;
+ }
+ }
+
+ public EncoderParameterValueType ValueType {
+ get {
+ return type;
+ }
+ }
+
+ void Dispose (bool disposing) {
+ if (valuePtr != IntPtr.Zero) {
+ Marshal.FreeHGlobal (valuePtr);
+ valuePtr = IntPtr.Zero;
+ }
+ }
+
+ public void Dispose () {
+ Dispose (true);
+ GC.SuppressFinalize(this);
+ }
+
+ ~EncoderParameter () {
+ Dispose (false);
+ }
+
+ internal static int NativeSize () {
+ return Marshal.SizeOf (typeof(GdipEncoderParameter));
+ }
+
+ internal void ToNativePtr (IntPtr epPtr) {
+ GdipEncoderParameter ep = new GdipEncoderParameter ();
+ ep.guid = this.encoder.Guid;
+ ep.numberOfValues = (uint) this.valuesCount;
+ ep.type = this.type;
+ ep.value = this.valuePtr;
+ Marshal.StructureToPtr (ep, epPtr, false);
+ }
+
+ internal static EncoderParameter FromNativePtr (IntPtr epPtr) {
+ GdipEncoderParameter ep;
+ ep = (GdipEncoderParameter) Marshal.PtrToStructure (epPtr, typeof(GdipEncoderParameter));
+
+ Type valType;
+ uint valCount;
+
+ switch (ep.type) {
+ case EncoderParameterValueType.ValueTypeAscii:
+ case EncoderParameterValueType.ValueTypeByte:
+ case EncoderParameterValueType.ValueTypeUndefined:
+ valType = typeof(byte);
+ valCount = ep.numberOfValues;
+ break;
+ case EncoderParameterValueType.ValueTypeShort:
+ valType = typeof(short);
+ valCount = ep.numberOfValues;
+ break;
+ case EncoderParameterValueType.ValueTypeLong:
+ valType = typeof(int);
+ valCount = ep.numberOfValues;
+ break;
+ case EncoderParameterValueType.ValueTypeLongRange:
+ case EncoderParameterValueType.ValueTypeRational:
+ valType = typeof(int);
+ valCount = ep.numberOfValues * 2;
+ break;
+ case EncoderParameterValueType.ValueTypeRationalRange:
+ valType = typeof(int);
+ valCount = ep.numberOfValues * 4;
+ break;
+ default:
+ return null;
+ }
+
+ EncoderParameter eparam = new EncoderParameter();
+ eparam.encoder = new Encoder(ep.guid);
+ eparam.valuesCount = (int) ep.numberOfValues;
+ eparam.type = ep.type;
+ eparam.valuePtr = Marshal.AllocHGlobal ((int)(valCount * Marshal.SizeOf(valType)));
+
+ /* There's nothing in Marshal to do a memcpy() between two IntPtrs. This sucks. */
+ unsafe {
+ byte *s = (byte *) ep.value;
+ byte *d = (byte *) eparam.valuePtr;
+ for (int i = 0; i < valCount * Marshal.SizeOf(valType); i++)
+ *d++ = *s++;
+ }
+
+ return eparam;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.jvm.cs
new file mode 100755
index 00000000000..0f9d42b85f1
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.jvm.cs
@@ -0,0 +1,189 @@
+//
+// System.Drawing.Imaging.EncoderParameter.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+// Vladimir Vukicevic (vladimir@pobox.com)
+//
+// (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging {
+
+ [MonoTODO]
+ public sealed class EncoderParameter : IDisposable {
+
+ private Encoder encoder;
+ private int valuesCount;
+ private EncoderParameterValueType type;
+
+ internal EncoderParameter ()
+ {
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, byte value)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, byte[] value)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, short value)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, short[] value)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, long value)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, long[] value)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, string value)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, byte value, bool undefined)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, byte[] value, bool undefined)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, int numerator, int denominator)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, int[] numerator, int[] denominator)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, long rangebegin, long rangeend)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, long[] rangebegin, long[] rangeend)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, int numberOfValues, int type, int value)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, int numerator1, int denominator1, int numerator2, int denominator2)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public EncoderParameter (Encoder encoder, int[] numerator1, int[] denominator1, int[] numerator2, int[] denominator2)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Encoder Encoder {
+ get {
+ return encoder;
+ }
+
+ set {
+ encoder = value;
+ }
+ }
+
+ public int NumberOfValues {
+ get {
+ return valuesCount;
+ }
+ }
+
+ public EncoderParameterValueType Type {
+ get {
+ return type;
+ }
+ }
+
+ public EncoderParameterValueType ValueType {
+ get {
+ return type;
+ }
+ }
+
+ void Dispose (bool disposing) {
+ throw new NotImplementedException();
+ }
+
+ public void Dispose () {
+ Dispose (true);
+ }
+
+ ~EncoderParameter () {
+ Dispose (false);
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameterValueType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameterValueType.cs
new file mode 100644
index 00000000000..e1b72c937ab
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameterValueType.cs
@@ -0,0 +1,44 @@
+//
+// System.Drawing.Imaging.EncoderParameterValueType.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum EncoderParameterValueType : int {
+ ValueTypeAscii = 2,
+ ValueTypeByte = 1,
+ ValueTypeLong = 4,
+ ValueTypeLongRange = 6,
+ ValueTypeRational = 5,
+ ValueTypeRationalRange = 8,
+ ValueTypeShort = 3,
+ ValueTypeUndefined = 7
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameters.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameters.cs
new file mode 100644
index 00000000000..dd5dada5f8c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameters.cs
@@ -0,0 +1,115 @@
+//
+// System.Drawing.Imaging.EncoderParameters.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+// Vladimir Vukicevic (vladimir@pobox.com)
+//
+// (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging
+{
+ public sealed class EncoderParameters : IDisposable
+ {
+ private EncoderParameter[] parameters;
+
+ public EncoderParameters () {
+ parameters = new EncoderParameter[1];
+ }
+
+ public EncoderParameters (int count) {
+ parameters = new EncoderParameter[count];
+ }
+
+ public EncoderParameter[] Param {
+ get {
+ return parameters;
+ }
+
+ set {
+ parameters = value;
+ }
+ }
+
+ public void Dispose () {
+ // Nothing
+ GC.SuppressFinalize(this);
+ }
+#if !TARGET_JVM
+ internal IntPtr ToNativePtr () {
+ IntPtr result;
+ IntPtr ptr;
+
+ // 4 is the initial int32 "count" value
+ result = Marshal.AllocHGlobal (4 + parameters.Length * EncoderParameter.NativeSize());
+
+ ptr = result;
+ Marshal.WriteInt32 (ptr, parameters.Length);
+
+ ptr = (IntPtr) ((int) ptr + 4);
+ for (int i = 0; i < parameters.Length; i++) {
+ parameters[i].ToNativePtr (ptr);
+ ptr = (IntPtr) ((int) ptr + EncoderParameter.NativeSize());
+ }
+
+ return result;
+ }
+
+ /* The IntPtr passed in here is a blob returned from
+ * GdipImageGetEncoderParameterList. Its internal pointers
+ * (i.e. the Value pointers in the EncoderParameter entries)
+ * point to areas within this block of memeory; this means
+ * that we need to free it as a whole, and also means that
+ * we can't Marshal.PtrToStruct our way to victory.
+ */
+ internal static EncoderParameters FromNativePtr (IntPtr epPtr) {
+ if (epPtr == IntPtr.Zero)
+ return null;
+
+ IntPtr ptr = epPtr;
+
+ int count = Marshal.ReadInt32 (ptr);
+ ptr = (IntPtr) ((int) ptr + 4);
+
+ if (count == 0)
+ return null;
+
+ EncoderParameters result = new EncoderParameters (count);
+
+ for (int i = 0; i < count; i++) {
+ result.parameters[i] = EncoderParameter.FromNativePtr (ptr);
+ ptr = (IntPtr) ((int) ptr + EncoderParameter.NativeSize());
+ }
+
+ return result;
+ }
+#endif
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderValue.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderValue.cs
new file mode 100644
index 00000000000..6f054fe5af3
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderValue.cs
@@ -0,0 +1,60 @@
+//
+// System.Drawing.Imaging.EncoderValue.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum EncoderValue {
+ ColorTypeCMYK = 0,
+ ColorTypeYCCK = 1,
+ CompressionCCITT3 = 3,
+ CompressionCCITT4 = 4,
+ CompressionLZW = 2,
+ CompressionNone = 6,
+ CompressionRle = 5,
+ Flush = 20,
+ FrameDimensionPage = 23,
+ FrameDimensionResolution = 22,
+ FrameDimensionTime = 21,
+ LastFrame = 19,
+ MultiFrame = 18,
+ RenderNonProgressive = 12,
+ RenderProgressive = 11,
+ ScanMethodInterlaced = 7,
+ ScanMethodNonInterlaced = 8,
+ TransformFlipHorizontal = 16,
+ TransformFlipVertical = 17,
+ TransformRotate180 = 14,
+ TransformRotate270 = 15,
+ TransformRotate90 = 13,
+ VersionGif87 = 9,
+ VersionGif89 = 10
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/FrameDimension.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/FrameDimension.cs
new file mode 100644
index 00000000000..ad6f7feb37a
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/FrameDimension.cs
@@ -0,0 +1,93 @@
+// created on 21.02.2002 at 17:06
+//
+// FrameDimension.cs
+//
+// Author: Christian Meyer
+// eMail: Christian.Meyer@cs.tum.edu
+// Dennis Hayes (dennish@raytek.com)
+// Sanjay Gupta <gsanjay@novell.com>
+// Jordi Mas i Hernanez (jordi@ximian.com)
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Drawing.Imaging {
+
+using System;
+
+public sealed class FrameDimension {
+
+ readonly Guid guid;
+
+ // constructor
+ public FrameDimension(Guid guid)
+ {
+ this.guid = guid;
+ }
+
+ //properties
+ public Guid Guid {
+ get {
+ return guid;
+ }
+ }
+
+ public static FrameDimension Page {
+ get {
+ return new FrameDimension (new Guid ("7462dc86-6180-4c7e-8e3f-ee7333a7a483"));
+ }
+ }
+
+ public static FrameDimension Resolution {
+ get {
+ return new FrameDimension (new Guid ("84236f7b-3bd3-428f-8dab-4ea1439ca315" ));
+ }
+ }
+
+ public static FrameDimension Time {
+ get {
+ return new FrameDimension (new Guid ("6aedbd6d-3fb5-418a-83a6-7f45229dc872" ));
+ }
+ }
+
+ //methods
+ public override bool Equals(object o)
+ {
+ if (!(o is FrameDimension))
+ return false;
+
+ return (guid == ((FrameDimension)o).guid);
+ }
+
+ public override int GetHashCode()
+ {
+ return guid.GetHashCode ();
+ }
+
+ public override string ToString()
+ {
+ return "FrameDimension :" + guid;
+ }
+
+}
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs
new file mode 100644
index 00000000000..380756f17e0
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs
@@ -0,0 +1,433 @@
+//
+// System.Drawing.Imaging.ImageAttributes.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com) (stubbed out)
+// Jordi Mas i Hernàndez (jmas@softcatala.org)
+// Sanjay Gupta (gsanjay@novell.com)
+//
+// (C) 2002-4 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging
+{
+ /// <summary>
+ /// Summary description for ImageAttributes.
+ /// </summary>
+ [StructLayout(LayoutKind.Sequential)]
+ public sealed class ImageAttributes : ICloneable, IDisposable {
+
+ private IntPtr nativeImageAttr = IntPtr.Zero;
+
+ internal IntPtr NativeObject{
+ get{
+ return nativeImageAttr;
+ }
+ }
+
+ internal ImageAttributes(IntPtr native)
+ {
+ nativeImageAttr = native;
+ }
+
+ public ImageAttributes() {
+
+ Status status = GDIPlus.GdipCreateImageAttributes(out nativeImageAttr);
+
+ if (status != Status.Ok)
+ throw new Exception ("Error calling GDIPlus.GdipCreateImageAttributes:" +status);
+
+ }
+
+ public void ClearBrushRemapTable()
+ {
+ ClearRemapTable (ColorAdjustType.Brush);
+ }
+
+ //Clears the color keys for all GDI+ objects
+ public void ClearColorKey()
+ {
+ ClearColorKey (ColorAdjustType.Default);
+ }
+
+ public void ClearColorKey(ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesColorKeys (nativeImageAttr,
+ type, false, 0, 0);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ClearColorMatrix()
+ {
+ ClearColorMatrix (ColorAdjustType.Default);
+ }
+
+ public void ClearColorMatrix(ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesColorMatrix (nativeImageAttr,
+ type, false, null, null, ColorMatrixFlag.Default);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ClearGamma()
+ {
+ ClearGamma (ColorAdjustType.Default);
+ }
+
+ public void ClearGamma(ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesGamma (nativeImageAttr, type, false, 0);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ClearNoOp()
+ {
+ ClearNoOp (ColorAdjustType.Default);
+ }
+
+ public void ClearNoOp(ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesNoOp (nativeImageAttr, type, false);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ClearOutputChannel()
+ {
+ ClearOutputChannel (ColorAdjustType.Default);
+ }
+
+ public void ClearOutputChannel(ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesOutputChannel (nativeImageAttr,
+ type, false, ColorChannelFlag.ColorChannelLast);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ClearOutputChannelColorProfile()
+ {
+ ClearOutputChannelColorProfile (ColorAdjustType.Default);
+ }
+
+ public void ClearOutputChannelColorProfile(ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesOutputChannelColorProfile (nativeImageAttr,
+ type, false, null);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ClearRemapTable()
+ {
+ ClearRemapTable (ColorAdjustType.Default);
+ }
+
+ public void ClearRemapTable(ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesRemapTable (nativeImageAttr,
+ type, false, 0, IntPtr.Zero);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ClearThreshold()
+ {
+ ClearThreshold (ColorAdjustType.Default);
+ }
+
+ public void ClearThreshold(ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesThreshold (nativeImageAttr,
+ type, false, 0);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ //Sets the color keys for all GDI+ objects
+ public void SetColorKey(Color colorLow, Color colorHigh)
+ {
+
+ Status status = GDIPlus.GdipSetImageAttributesColorKeys(nativeImageAttr,
+ ColorAdjustType.Default, true, colorLow.ToArgb(), colorHigh.ToArgb());
+
+ if (status != Status.Ok)
+ throw new Exception ("Error calling GDIPlus.GdipSetImageAttributesColorKeys:" +status);
+ }
+
+ public void SetColorMatrix(ColorMatrix colorMatrix)
+ {
+
+ Status status = GDIPlus.GdipSetImageAttributesColorMatrix(nativeImageAttr, ColorAdjustType.Default,
+ true, colorMatrix, (ColorMatrix)null, ColorMatrixFlag.Default);
+
+ if (status != Status.Ok)
+ throw new Exception ("Error calling GDIPlus.SetColorMatrix:" +status);
+ }
+
+ public void SetColorMatrix(ColorMatrix colorMatrix, ColorMatrixFlag colorMatrixFlag)
+ {
+
+ Status status = GDIPlus.GdipSetImageAttributesColorMatrix(nativeImageAttr, ColorAdjustType.Default,
+ true, colorMatrix, (ColorMatrix)null, colorMatrixFlag);
+ if (status != Status.Ok)
+ throw new Exception ("Error calling GDIPlus.SetColorMatrix:" +status);
+
+ }
+
+ public void SetColorMatrix(ColorMatrix colorMatrix, ColorMatrixFlag colorMatrixFlag, ColorAdjustType colorAdjustType) {
+
+ Status status = GDIPlus.GdipSetImageAttributesColorMatrix(nativeImageAttr,colorAdjustType,
+ true, colorMatrix, (ColorMatrix)null, colorMatrixFlag);
+
+ if (status != Status.Ok)
+ throw new Exception ("Error calling GDIPlus.SetColorMatrix:" +status);
+ }
+
+ public void Dispose()
+ {
+ if (nativeImageAttr != IntPtr.Zero) {
+
+ Status status = GDIPlus.GdipDisposeImageAttributes(nativeImageAttr);
+ GDIPlus.CheckStatus (status);
+ nativeImageAttr = IntPtr.Zero;
+ }
+
+ System.GC.SuppressFinalize (this);
+ }
+
+ ~ImageAttributes()
+ {
+ Dispose ();
+ }
+
+ public object Clone()
+ {
+ IntPtr imgclone;
+
+ Status status = GDIPlus.GdipCloneImageAttributes (nativeImageAttr, out imgclone);
+ GDIPlus.CheckStatus (status);
+
+ return new ImageAttributes (imgclone);
+ }
+
+ public void GetAdjustedPalette(ColorPalette palette, ColorAdjustType type)
+ {
+ IntPtr colorPalette;
+
+ Status status = GDIPlus.GdipGetImageAttributesAdjustedPalette (nativeImageAttr,
+ out colorPalette, type);
+
+ palette.setFromGDIPalette (colorPalette);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetBrushRemapTable(ColorMap[] map)
+ {
+ GdiColorMap gdiclr = new GdiColorMap ();
+ IntPtr clrmap, lpPointer;
+ int mapsize = Marshal.SizeOf (gdiclr);
+ int size = mapsize * map.Length;
+ clrmap = lpPointer = Marshal.AllocHGlobal (size);
+
+ for (int i=0; i < map.Length; i++)
+ {
+ gdiclr.from = map[i].OldColor.ToArgb();
+ gdiclr.to = map[i].NewColor.ToArgb();
+
+ Marshal.StructureToPtr (gdiclr, lpPointer, false);
+ lpPointer = (IntPtr) (lpPointer.ToInt32() + mapsize);
+ }
+
+ Status status = GDIPlus.GdipSetImageAttributesRemapTable (nativeImageAttr,
+ ColorAdjustType.Brush, true, (uint) map.Length, clrmap);
+
+ Marshal.FreeHGlobal (clrmap);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void SetColorKey(Color colorLow, Color colorHigh, ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesColorKeys (nativeImageAttr,
+ type, true, colorLow.ToArgb (), colorHigh.ToArgb ());
+
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesColorMatrix (nativeImageAttr,
+ ColorAdjustType.Default, true, newColorMatrix, grayMatrix, ColorMatrixFlag.Default);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag flags)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesColorMatrix (nativeImageAttr,
+ ColorAdjustType.Default, true, newColorMatrix, grayMatrix, flags);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag mode, ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesColorMatrix (nativeImageAttr,
+ ColorAdjustType.Default, true, newColorMatrix, grayMatrix, mode);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetGamma(float gamma)
+ {
+ SetGamma (gamma, ColorAdjustType.Default);
+ }
+
+ public void SetGamma(float gamma, ColorAdjustType coloradjust)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesGamma (nativeImageAttr, coloradjust, true,
+ gamma);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetNoOp()
+ {
+ SetNoOp (ColorAdjustType.Default);
+ }
+
+ public void SetNoOp(ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesNoOp (nativeImageAttr,
+ type, true);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetOutputChannel(ColorChannelFlag flags)
+ {
+ SetOutputChannel (flags, ColorAdjustType.Default);
+ }
+
+ public void SetOutputChannel(ColorChannelFlag flags, ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesOutputChannel (nativeImageAttr,
+ type, true, flags);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetOutputChannelColorProfile(string colorProfileFilename)
+ {
+ SetOutputChannelColorProfile (colorProfileFilename, ColorAdjustType.Default);
+ }
+
+ public void SetOutputChannelColorProfile(string colorProfileFilename, ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesOutputChannelColorProfile (nativeImageAttr,
+ type, true, colorProfileFilename);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetRemapTable(ColorMap[] map)
+ {
+ SetRemapTable (map, ColorAdjustType.Default);
+ }
+
+
+ public void SetRemapTable(ColorMap[] map, ColorAdjustType type)
+ {
+ GdiColorMap gdiclr = new GdiColorMap ();
+ IntPtr clrmap, lpPointer;
+ int mapsize = Marshal.SizeOf (gdiclr);
+ int size = mapsize * map.Length;
+ clrmap = lpPointer = Marshal.AllocHGlobal (size);
+
+ for (int i=0; i < map.Length; i++)
+ {
+ gdiclr.from = map[i].OldColor.ToArgb();
+ gdiclr.to = map[i].NewColor.ToArgb();
+
+ Marshal.StructureToPtr (gdiclr, lpPointer, false);
+ lpPointer = (IntPtr) (lpPointer.ToInt32() + mapsize);
+ }
+
+ Status status = GDIPlus.GdipSetImageAttributesRemapTable (nativeImageAttr,
+ type, true, (uint) map.Length, clrmap);
+
+ Marshal.FreeHGlobal (clrmap);
+
+ GDIPlus.CheckStatus (status);
+
+ }
+
+ public void SetThreshold(float threshold)
+ {
+ SetThreshold (threshold, ColorAdjustType.Default);
+ }
+
+ public void SetThreshold(float threshold, ColorAdjustType type)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesThreshold (nativeImageAttr,
+ type, true, 0);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetWrapMode(WrapMode mode)
+ {
+ SetWrapMode (mode, Color.Black);
+ }
+
+
+ public void SetWrapMode(WrapMode mode, Color color)
+ {
+ SetWrapMode (mode, color, false);
+ }
+
+
+ public void SetWrapMode(WrapMode mode, Color color, bool clamp)
+ {
+ Status status = GDIPlus.GdipSetImageAttributesWrapMode (nativeImageAttr, mode,
+ color.ToArgb(), clamp);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.jvm.cs
new file mode 100755
index 00000000000..fde74ff8cf0
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.jvm.cs
@@ -0,0 +1,298 @@
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace System.Drawing.Imaging
+{
+ /// <summary>
+ /// Summary description for ImageAttributes.
+ /// </summary>
+ ///
+ [MonoTODO]
+ public sealed class ImageAttributes : ICloneable, IDisposable
+ {
+ [MonoTODO]
+ public ImageAttributes()
+ {
+ }
+
+ public void Dispose()
+ {
+ }
+
+ public Object Clone()
+ {
+ ImageAttributes imgAttr = new ImageAttributes();
+ imgAttr.clrMatrix = clrMatrix;
+ imgAttr.clrMatrixFlag = clrMatrixFlag;
+ imgAttr.clrAdjustType = clrAdjustType;
+ imgAttr.gMatrix = gMatrix;
+ imgAttr.thresh = thresh;
+ imgAttr.gamma = gamma;
+ imgAttr.clrChannelFlags = clrChannelFlags;
+ imgAttr.clrProfileFilename = clrProfileFilename;
+ imgAttr.clrLow = clrLow;
+ imgAttr.clrHigh = clrHigh;
+ imgAttr.clrMap = clrMap;
+ imgAttr.wrapMode = wrapMode;
+ imgAttr.col = col;
+ imgAttr.bClamp = bClamp;
+ imgAttr.clrPalette = clrPalette;
+ imgAttr.bNoOp = bNoOp;
+ return imgAttr;
+ }
+
+
+ public void SetColorMatrix(ColorMatrix newColorMatrix)
+ {
+ SetColorMatrix(newColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default);
+ }
+
+ public void SetColorMatrix(ColorMatrix newColorMatrix, ColorMatrixFlag flags)
+ {
+ SetColorMatrix(newColorMatrix, flags, ColorAdjustType.Default);
+ }
+
+ public void SetColorMatrix(ColorMatrix newColorMatrix, ColorMatrixFlag mode, ColorAdjustType type)
+ {
+ clrMatrix = newColorMatrix;
+ clrMatrixFlag = mode;
+ clrAdjustType = type;
+ }
+
+ public void ClearColorMatrix()
+ {
+ ClearColorMatrix(ColorAdjustType.Default);
+ }
+
+ public void ClearColorMatrix(ColorAdjustType type)
+ {
+ ColorMatrix cm = new ColorMatrix();
+ clrMatrix = cm;
+ clrAdjustType = type;
+ }
+
+ public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix gMatrix)
+ {
+ SetColorMatrices(newColorMatrix, gMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default);
+ }
+
+ public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix gMatrix, ColorMatrixFlag flags)
+ {
+ SetColorMatrices(newColorMatrix, gMatrix, flags, ColorAdjustType.Default);
+ }
+
+ public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix gMatrix, ColorMatrixFlag mode, ColorAdjustType type)
+ {
+ clrMatrix = newColorMatrix;
+ this.gMatrix = gMatrix;
+ clrMatrixFlag = mode;
+ clrAdjustType = type;
+ }
+
+ public void SetThreshold(float thresh)
+ {
+ SetThreshold(thresh, ColorAdjustType.Default);
+ }
+
+ public void SetThreshold(float thresh, ColorAdjustType type)
+ {
+ this.thresh = thresh;
+ clrAdjustType = type;
+ }
+
+ public void ClearThreshold()
+ {
+ ClearThreshold(ColorAdjustType.Default);
+ }
+
+ public void ClearThreshold(ColorAdjustType type)
+ {
+ thresh = 1.0F;
+ clrAdjustType = type;
+ }
+
+ public void SetGamma(float gamma)
+ {
+ SetGamma(gamma, ColorAdjustType.Default);
+ }
+
+ public void SetGamma(float gamma, ColorAdjustType type)
+ {
+ this.gamma = gamma;
+ clrAdjustType = type;
+ return;
+ }
+
+ public void ClearGamma()
+ {
+ ClearGamma(ColorAdjustType.Default);
+ }
+
+ public void ClearGamma(ColorAdjustType type)
+ {
+ gamma = 1;
+ clrAdjustType = type;
+ }
+
+ public void SetNoOp()
+ {
+ SetNoOp(ColorAdjustType.Default);
+ }
+
+ public void SetNoOp(ColorAdjustType type)
+ {
+ bNoOp = true;
+ clrAdjustType = type;
+ }
+
+ public void ClearNoOp()
+ {
+ ClearNoOp(ColorAdjustType.Default);
+ }
+
+ public void ClearNoOp(ColorAdjustType type)
+ {
+ bNoOp = false;
+ clrAdjustType = type;
+ }
+
+ public void SetColorKey(Color clrLow, Color clrHigh)
+ {
+ SetColorKey(clrLow, clrHigh, ColorAdjustType.Default);
+ }
+
+ public void SetColorKey(Color clrLow, Color clrHigh, ColorAdjustType type)
+ {
+ this.clrLow = clrLow;
+ this.clrHigh = clrHigh;
+ clrAdjustType = type;
+ }
+
+ public void ClearColorKey()
+ {
+ ClearColorKey(ColorAdjustType.Default);
+ }
+
+ public void ClearColorKey(ColorAdjustType type)
+ {
+ clrAdjustType = type;
+ }
+
+ public void SetOutputChannel(ColorChannelFlag flags)
+ {
+ SetOutputChannel(flags, ColorAdjustType.Default);
+ }
+
+ public void SetOutputChannel(ColorChannelFlag flags, ColorAdjustType type)
+ {
+ clrChannelFlags = flags;
+ clrAdjustType = type;
+ }
+
+ public void ClearOutputChannel()
+ {
+ ClearOutputChannel(ColorAdjustType.Default);
+ }
+
+ public void ClearOutputChannel(ColorAdjustType type)
+ {
+ clrAdjustType = type;
+ }
+
+ public void SetOutputChannelColorProfile(String clrProfileFilename)
+ {
+ SetOutputChannelColorProfile(clrProfileFilename, ColorAdjustType.Default);
+ }
+
+ public void SetOutputChannelColorProfile(String clrProfileFilename, ColorAdjustType type)
+ {
+ this.clrProfileFilename = clrProfileFilename;
+ clrAdjustType = type;
+ }
+
+ public void ClearOutputChannelColorProfile()
+ {
+ ClearOutputChannel(ColorAdjustType.Default);
+ }
+
+ public void ClearOutputChannelColorProfile(ColorAdjustType type)
+ {
+ clrProfileFilename = null;
+ clrAdjustType = type;
+ }
+
+ public void SetRemapTable(ColorMap[] map)
+ {
+ SetRemapTable(map, ColorAdjustType.Default);
+ }
+
+ public void SetRemapTable(ColorMap[] map, ColorAdjustType type)
+ {
+ clrMap = map;
+ clrAdjustType = type;
+ }
+
+ public void ClearRemapTable()
+ {
+ ClearRemapTable(ColorAdjustType.Default);
+ }
+
+ public void ClearRemapTable(ColorAdjustType type)
+ {
+ clrMap = null;
+ clrAdjustType = type;
+ }
+
+ public void SetBrushRemapTable(ColorMap []map)
+ {
+ SetRemapTable(map, ColorAdjustType.Brush);
+ }
+
+ public void ClearBrushRemapTable()
+ {
+ ClearRemapTable(ColorAdjustType.Brush);
+ }
+
+ public void SetWrapMode(WrapMode mode)
+ {
+ SetWrapMode(mode, new Color(), false);
+ }
+
+ public void SetWrapMode(WrapMode mode, Color clr)
+ {
+ SetWrapMode(mode, clr, false);
+ }
+
+ public void SetWrapMode(WrapMode mode, Color clr, bool bClamp)
+ {
+ wrapMode = mode;
+ col = clr;
+ this.bClamp = bClamp;
+ }
+
+ public void GetAdjustedPalette(ColorPalette palette, ColorAdjustType type)
+ {
+ clrPalette = palette;
+ clrAdjustType = type;
+ }
+
+ public ColorMatrix clrMatrix;
+ public ColorMatrixFlag clrMatrixFlag;
+ public ColorAdjustType clrAdjustType;
+ public ColorMatrix gMatrix;
+ public float thresh;
+ public float gamma;
+ public ColorChannelFlag clrChannelFlags;
+ public string clrProfileFilename;
+ public Color clrLow;
+ public Color clrHigh;
+ public ColorMap[] clrMap;
+ public WrapMode wrapMode;
+ public Color col;
+ public bool bClamp;
+ public ColorPalette clrPalette;
+ public bool bNoOp;
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodec.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodec.jvm.cs
new file mode 100644
index 00000000000..2eff947138a
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodec.jvm.cs
@@ -0,0 +1,700 @@
+using System;
+using System.Configuration;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Drawing.Imaging;
+using System.Xml;
+using Mainsoft.Drawing.Configuration;
+
+using imageio = javax.imageio;
+using stream = javax.imageio.stream;
+using awt = java.awt;
+using image = java.awt.image;
+using spi = javax.imageio.spi;
+using dom = org.w3c.dom;
+
+namespace Mainsoft.Drawing.Imaging {
+ /// <summary>
+ /// Summary description for ImageCodec.
+ /// </summary>
+ public class ImageCodec : IDisposable {
+
+ #region Members
+
+ imageio.ImageReader _nativeReader = null;
+ imageio.ImageWriter _nativeWriter = null;
+ stream.ImageInputStream _nativeStream = null;
+
+ ImageFormat _imageFormat = null;
+
+ int _currentFrame = 0;
+
+ #endregion
+
+ #region Constructros
+
+ protected ImageCodec() {
+ }
+
+ static ImageCodec() {
+ }
+
+ #endregion
+
+ #region Internal properties
+
+ internal imageio.ImageReader NativeReader {
+ get { return _nativeReader; }
+ set {
+ _nativeReader = value;
+ if (value == null)
+ return;
+ _imageFormat = MimeTypesToImageFormat( value.getOriginatingProvider().getMIMETypes() );
+ }
+ }
+ internal imageio.ImageWriter NativeWriter {
+ get { return _nativeWriter; }
+ set {
+ _nativeWriter = value;
+ if (value == null)
+ return;
+ _imageFormat = MimeTypesToImageFormat( value.getOriginatingProvider().getMIMETypes() );
+ }
+ }
+
+ internal stream.ImageInputStream NativeStream {
+ get { return _nativeStream; }
+ set {
+ _nativeStream = value;
+ if (value == null)
+ return;
+
+ if (NativeReader != null)
+ NativeReader.setInput( value );
+
+ if (NativeWriter != null)
+ NativeWriter.setOutput( value );
+ }
+ }
+
+ #endregion
+
+ #region ImageCodec factory methods
+
+ public static ImageCodec CreateReader(stream.ImageInputStream inputStream) {
+ java.util.Iterator iter = imageio.ImageIO.getImageReaders( inputStream );
+ return CreateReader(iter);
+ }
+
+ public static ImageCodec CreateReader(ImageFormat imageFormat) {
+ return CreateReader( ImageFormatToClsid( imageFormat ) );
+ }
+
+ public static ImageCodec CreateReader(Guid clsid) {
+ ImageCodec codec = null;
+ try {
+ ImageCodecInfo codecInfo = FindDecoder(clsid);
+ java.util.Iterator iter = imageio.ImageIO.getImageReadersByMIMEType( codecInfo.MimeType );
+ codec = CreateReader(iter);
+ }
+ catch {}
+
+ if (codec == null) {
+ ImageFormat format = ClsidToImageFormat(clsid);
+ string name = (format != null) ? format.ToString() : clsid.ToString();
+ throw new NotSupportedException(String.Format("The '{0}' format decoder is not installed.", name));
+ }
+
+ return codec;
+ }
+
+ private static ImageCodec CreateReader(java.util.Iterator iter) {
+ if ( !iter.hasNext() )
+ return null;
+
+ ImageCodec imageCodec = new ImageCodec();
+ imageCodec.NativeReader = (imageio.ImageReader) iter.next();
+ return imageCodec;
+ }
+
+ public static ImageCodec CreateWriter(ImageFormat imageFormat) {
+ return CreateWriter( ImageFormatToClsid( imageFormat ) );
+ }
+
+ public static ImageCodec CreateWriter(Guid clsid) {
+ ImageCodec codec = null;
+ try {
+ ImageCodecInfo codecInfo = FindEncoder(clsid);
+ java.util.Iterator iter = imageio.ImageIO.getImageWritersByMIMEType( codecInfo.MimeType );
+ codec = CreateWriter(iter);
+ }
+ catch {}
+
+ if (codec == null) {
+ ImageFormat format = ClsidToImageFormat(clsid);
+ string name = (format != null) ? format.ToString() : clsid.ToString();
+ throw new NotSupportedException(String.Format("The '{0}' format encoder is not installed.", name));
+ }
+
+ return codec;
+ }
+
+ private static ImageCodec CreateWriter(java.util.Iterator iter) {
+ if ( !iter.hasNext() )
+ return null;
+
+ ImageCodec imageCodec = new ImageCodec();
+ imageCodec.NativeWriter = (imageio.ImageWriter) iter.next();
+ return imageCodec;
+ }
+
+ #endregion
+
+ #region Codec enumerations
+
+ internal static Hashtable Decoders {
+ get {
+ const string MYNAME = "System.Drawing.Imaging.ImageCodecInfo.decoders";
+ Hashtable o = (Hashtable) AppDomain.CurrentDomain.GetData (MYNAME);
+ if (o != null)
+ return o;
+ o = new ReaderSpiIterator().Iterate();
+ AppDomain.CurrentDomain.SetData(MYNAME, o);
+ return o;
+ }
+ }
+
+ internal static Hashtable Encoders {
+ get {
+ const string MYNAME = "System.Drawing.Imaging.ImageCodecInfo.encoders";
+ Hashtable o = (Hashtable) AppDomain.CurrentDomain.GetData (MYNAME);
+ if (o != null)
+ return o;
+ o = new WriterSpiIterator().Iterate();
+ AppDomain.CurrentDomain.SetData(MYNAME, o);
+ return o;
+ }
+ }
+
+ internal static ImageCodecInfo FindEncoder (Guid clsid) {
+ ImageCodecInfo codec = (ImageCodecInfo) Encoders[clsid];
+ if (codec == null) {
+ // .net saves in png if cannot find requested encoder. atc id 316563
+ codec = (ImageCodecInfo) Encoders[ ImageCodec.PngClsid ];
+ }
+ return codec;
+ }
+
+ internal static ImageCodecInfo FindDecoder (Guid clsid) {
+ ImageCodecInfo codec = (ImageCodecInfo) Decoders[clsid];
+ if (codec == null) {
+ ImageFormat format = ClsidToImageFormat(clsid);
+ string name = (format != null) ? format.ToString() : clsid.ToString();
+ throw new NotSupportedException(String.Format("The '{0}' format decoder is not installed.", name));
+ }
+ return codec;
+ }
+
+ #endregion
+
+ #region SpiIterators
+
+ abstract class BaseSpiIterator {
+ protected abstract java.util.Iterator GetIterator (string mimeType);
+ protected abstract spi.ImageReaderWriterSpi GetNext (java.util.Iterator iter);
+
+ #region ProcessOneCodec
+ private ImageCodecInfo ProcessOneCodec (Guid clsid, Guid formatID, string mimeType) {
+ ImageCodecInfo ici = new ImageCodecInfo ();
+ ici.Clsid = clsid;
+ ici.FormatID = formatID;
+ ici.MimeType = mimeType;
+ java.util.Iterator iter = null;
+ try {
+ iter = GetIterator (mimeType);
+ }
+ catch(Exception) {
+ return null;
+ }
+ while (iter.hasNext ()) {
+ spi.ImageReaderWriterSpi rw = GetNext (iter);
+
+ ici.CodecName = rw.getDescription (java.util.Locale.getDefault ());
+ //ici.DllName = null;
+ foreach (string suffix in rw.getFileSuffixes ()) {
+ if (ici.FilenameExtension != null)
+ ici.FilenameExtension += ";";
+ ici.FilenameExtension += "*."+suffix;
+ }
+ ici.Flags = ImageCodecFlags.Builtin|ImageCodecFlags.SupportBitmap;
+ if (rw is spi.ImageReaderSpi)
+ ici.Flags |= ImageCodecFlags.Decoder;
+
+ if (rw is spi.ImageWriterSpi)
+ ici.Flags |= ImageCodecFlags.Encoder;
+
+ ici.FormatDescription = string.Join(";",
+ rw.getFormatNames());
+ try {
+ ici.Version = (int)Convert.ToDouble(rw.getVersion ());
+ }
+ catch (Exception) {
+ ici.Version = 1;
+ }
+ break;
+ }
+ return ici;
+ }
+ #endregion
+
+ internal Hashtable Iterate () {
+ // TBD: Insert Exception handling here
+ NameValueCollection nvc = (NameValueCollection) System.Configuration.ConfigurationSettings
+ .GetConfig ("system.drawing/codecs");
+ Hashtable codecs = new Hashtable (10);
+
+ for (int i=0; i<nvc.Count; i++) {
+ Guid clsid = new Guid (nvc.GetKey (i));
+ ImageFormat format = ClsidToImageFormat (clsid);
+ ImageCodecInfo codec = ProcessOneCodec (clsid, format.Guid, nvc[i]);
+ if ((codec != null) && (codec.FilenameExtension != null))
+ codecs [clsid] = codec;
+ }
+ return codecs;
+ }
+ }
+
+ class ReaderSpiIterator: BaseSpiIterator {
+ protected override java.util.Iterator GetIterator(string mimeType) {
+ return imageio.ImageIO.getImageReadersByMIMEType (mimeType);
+ }
+ protected override javax.imageio.spi.ImageReaderWriterSpi GetNext(java.util.Iterator iter) {
+ imageio.ImageReader r = (imageio.ImageReader) iter.next ();
+ return r.getOriginatingProvider ();
+ }
+ }
+
+ class WriterSpiIterator: BaseSpiIterator {
+ protected override java.util.Iterator GetIterator(string mimeType) {
+ return imageio.ImageIO.getImageWritersByMIMEType (mimeType);
+ }
+ protected override javax.imageio.spi.ImageReaderWriterSpi GetNext(java.util.Iterator iter) {
+ imageio.ImageWriter w = (imageio.ImageWriter) iter.next ();
+ return w.getOriginatingProvider ();
+ }
+ }
+ #endregion
+
+ #region Clsid and FormatID
+ static Guid BmpClsid = new Guid ("557cf400-1a04-11d3-9a73-0000f81ef32e");
+ static Guid JpegClsid = new Guid ("557cf401-1a04-11d3-9a73-0000f81ef32e");
+ static Guid GifClsid = new Guid ("557cf402-1a04-11d3-9a73-0000f81ef32e");
+ static Guid EmfClsid = new Guid ("557cf403-1a04-11d3-9a73-0000f81ef32e");
+ static Guid WmfClsid = new Guid ("557cf404-1a04-11d3-9a73-0000f81ef32e");
+ static Guid TiffClsid = new Guid ("557cf405-1a04-11d3-9a73-0000f81ef32e");
+ static Guid PngClsid = new Guid ("557cf406-1a04-11d3-9a73-0000f81ef32e");
+ static Guid IconClsid = new Guid ("557cf407-1a04-11d3-9a73-0000f81ef32e");
+
+ private static ImageFormat MimeTypesToImageFormat (string [] mimeTypes) {
+ foreach (ImageCodecInfo codec in Decoders.Values)
+ for (int i=0; i<mimeTypes.Length; i++)
+ if (codec.MimeType == mimeTypes [i])
+ return new ImageFormat (codec.FormatID);
+ return null;
+ }
+
+ internal static ImageFormat ClsidToImageFormat (Guid clsid) {
+ if (clsid.Equals (BmpClsid))
+ return ImageFormat.Bmp;
+ else if (clsid.Equals (JpegClsid))
+ return ImageFormat.Jpeg;
+ else if (clsid.Equals (GifClsid))
+ return ImageFormat.Gif;
+ else if (clsid.Equals (EmfClsid))
+ return ImageFormat.Emf;
+ else if (clsid.Equals (WmfClsid))
+ return ImageFormat.Wmf;
+ else if (clsid.Equals (TiffClsid))
+ return ImageFormat.Tiff;
+ else if (clsid.Equals (PngClsid))
+ return ImageFormat.Png;
+ else if (clsid.Equals (IconClsid))
+ return ImageFormat.Icon;
+ else
+ return null;
+ }
+
+ internal static Guid ImageFormatToClsid (ImageFormat format) {
+ if (format == null)
+ return Guid.Empty;
+
+ if (format.Guid.Equals (ImageFormat.Bmp.Guid))
+ return BmpClsid;
+ else if (format.Guid.Equals (ImageFormat.Jpeg.Guid))
+ return JpegClsid;
+ else if (format.Guid.Equals (ImageFormat.Gif))
+ return GifClsid;
+ else if (format.Guid.Equals (ImageFormat.Emf.Guid))
+ return EmfClsid;
+ else if (format.Guid.Equals (ImageFormat.Wmf.Guid))
+ return WmfClsid;
+ else if (format.Guid.Equals (ImageFormat.Tiff.Guid))
+ return TiffClsid;
+ else if (format.Guid.Equals (ImageFormat.Png.Guid))
+ return PngClsid;
+ else if (format.Guid.Equals (ImageFormat.Icon.Guid))
+ return IconClsid;
+ else
+ return Guid.Empty;
+ }
+
+ private FrameDimension FormatFrameDimesion {
+ get {
+ if (ImageFormat == null)
+ return FrameDimension.Page;
+
+ if (ImageFormat.Guid.Equals (ImageFormat.Bmp.Guid))
+ return FrameDimension.Page;
+ else if (ImageFormat.Guid.Equals (ImageFormat.Jpeg.Guid))
+ return FrameDimension.Page;
+ else if (ImageFormat.Guid.Equals (ImageFormat.Gif))
+ return FrameDimension.Time;
+ else if (ImageFormat.Guid.Equals (ImageFormat.Emf.Guid))
+ return FrameDimension.Page;
+ else if (ImageFormat.Guid.Equals (ImageFormat.Wmf.Guid))
+ return FrameDimension.Page;
+ else if (ImageFormat.Guid.Equals (ImageFormat.Tiff.Guid))
+ return FrameDimension.Page;
+ else if (ImageFormat.Guid.Equals (ImageFormat.Png.Guid))
+ return FrameDimension.Page;
+ else if (ImageFormat.Guid.Equals (ImageFormat.Icon.Guid))
+ return FrameDimension.Resolution;
+ else
+ return FrameDimension.Page;
+ }
+ }
+
+ #endregion
+
+ #region Image read/write methods
+
+ internal PlainImage ReadPlainImage() {
+ awt.Image img = ReadImage( _currentFrame );
+ if (img == null)
+ return null;
+
+ // its possible to fail to load thumbnails and metadata, but image is ok.
+ awt.Image [] th = null;
+#if THUMBNAIL_SUPPORTED
+ try {
+ th = ReadThumbnails( _currentFrame );
+ }
+ catch (Exception) {}
+#endif
+
+ XmlDocument md = null;
+ imageio.metadata.IIOMetadata nativeMd = null;
+ try {
+ nativeMd = ReadImageMetadata( _currentFrame );
+ md = ConvertImageMetadata( nativeMd );
+ }
+ catch (Exception) {}
+
+ float [] resolution = GetResolution( md );
+
+ PlainImage pi = new PlainImage( img, th, ImageFormat, resolution[0], resolution[1], FormatFrameDimesion );
+ pi.NativeMetadata = nativeMd;
+ return pi;
+ }
+
+ internal PlainImage ReadNextPlainImage() {
+ _currentFrame++;
+ return ReadPlainImage();
+ }
+
+ private awt.Image ReadImage(int frame) {
+ if (NativeStream == null)
+ throw new Exception("Input stream not specified");
+
+ try {
+ return NativeReader.read (frame);
+ }
+ catch (java.lang.IndexOutOfBoundsException) {
+ return null;
+ }
+ catch (java.io.IOException ex) {
+ throw new System.IO.IOException(ex.Message, ex);
+ }
+ }
+
+#if THUMBNAIL_SUPPORTED
+ private awt.Image [] ReadThumbnails(int frameIndex) {
+ awt.Image [] thArray = null;
+
+ try {
+ if (NativeReader.readerSupportsThumbnails()) {
+ int tmbNumber = NativeReader.getNumThumbnails(frameIndex);
+
+ if (tmbNumber > 0) {
+ thArray = new awt.Image[ tmbNumber ];
+
+ for (int i = 0; i < tmbNumber; i++) {
+ thArray[i] = NativeReader.readThumbnail(frameIndex, i);
+ }
+ }
+ }
+ return thArray;
+ }
+ catch (java.io.IOException ex) {
+ throw new System.IO.IOException(ex.Message, ex);
+ }
+ }
+#endif
+ internal void WritePlainImage(PlainImageCollection pic) {
+ if ((pic == null) || (pic.Count == 0))
+ return;
+
+ if (pic.Count == 1) {
+ WritePlainImage( pic[0] );
+ return;
+ }
+
+ try {
+ if (NativeWriter.canWriteSequence ()) {
+ NativeWriter.prepareWriteSequence (null);
+ for (int i=0; i < pic.Count; i++) {
+ imageio.IIOImage iio = GetIIOImageContainer( pic[i] );
+ NativeWriter.writeToSequence (iio, null);
+ }
+ NativeWriter.endWriteSequence ();
+ }
+ else
+ WritePlainImage( pic[0] );
+ }
+ catch (java.io.IOException ex) {
+ throw new System.IO.IOException(ex.Message, ex);
+ }
+ }
+
+ internal void WritePlainImage(PlainImage pi) {
+ try {
+ imageio.IIOImage iio = GetIIOImageContainer( pi );
+ WriteImage( iio );
+ }
+ catch (java.io.IOException ex) {
+ throw new System.IO.IOException(ex.Message, ex);
+ }
+ }
+
+ private void WriteImage(imageio.IIOImage iio) {
+ if (NativeStream == null)
+ throw new Exception("Output stream not specified");
+
+ NativeWriter.write( iio );
+ }
+
+ private imageio.IIOImage GetIIOImageContainer(PlainImage pi) {
+ java.util.ArrayList al = null;
+
+ // prepare thumbnails list
+ if (pi.Thumbnails != null) {
+ al = new java.util.ArrayList( pi.Thumbnails.Length );
+ for (int i=0; i < pi.Thumbnails.Length; i++)
+ al.add(pi.Thumbnails[i]);
+ }
+
+ // prepare IIOImage container
+ if (pi.NativeImage is image.BufferedImage) {
+ imageio.IIOImage iio = new javax.imageio.IIOImage(
+ (image.BufferedImage)pi.NativeImage, al, null /*pi.NativeMetadata*/);
+ return iio;
+ }
+ else
+ // TBD: This codec is for raster formats only
+ throw new NotSupportedException("Only raster formats are supported");
+ }
+
+
+ private imageio.metadata.IIOMetadata ReadImageMetadata(int frameIndex) {
+ if (NativeStream == null)
+ throw new Exception("Input stream not specified");
+
+ try {
+ imageio.metadata.IIOMetadata md = NativeReader.getImageMetadata( frameIndex );
+ return md;
+ }
+ catch (java.io.IOException ex) {
+ throw new System.IO.IOException(ex.Message, ex);
+ }
+ }
+
+ #endregion
+
+ #region Extra properties
+
+ public ImageFormat ImageFormat {
+ get { return _imageFormat; }
+ }
+
+ #endregion
+
+ #region Metadata parse
+
+ private float [] GetResolution(XmlDocument metaData) {
+ if (metaData == null)
+ return new float[]{0, 0};
+
+ ResolutionConfigurationCollection rcc =
+ (ResolutionConfigurationCollection)
+ ConfigurationSettings.GetConfig("system.drawing/codecsmetadata");
+
+ if (rcc == null)
+ throw new ConfigurationException("Configuration section codecsmetadata not found");
+
+ ResolutionConfiguration rc = rcc[ ImageFormat.ToString() ];
+
+ if (rc == null)
+ return new float[]{0, 0};
+
+ // Horizontal resolution
+ string xResPath = rc.XResPath;
+ string xRes;
+
+ if (xResPath == string.Empty)
+ xRes = rc.XResDefault;
+ else
+ xRes = GetValueFromMetadata(metaData, xResPath);
+
+ if ((xRes == null) || (xRes == string.Empty))
+ xRes = rc.XResDefault;
+
+ // Vertical resolution
+ string yResPath = rc.YResPath;
+ string yRes;
+
+ if (yResPath == string.Empty)
+ yRes = rc.YResDefault;
+ else
+ yRes = GetValueFromMetadata(metaData, yResPath);
+
+ if ((yRes == null) || (yRes == string.Empty))
+ yRes = rc.YResDefault;
+
+ // Resolution units
+ string resUnitsPath = rc.UnitsTypePath;
+ string resUnitsType;
+
+ if (resUnitsPath == string.Empty)
+ resUnitsType = rc.UnitsTypeDefault;
+ else
+ resUnitsType = GetValueFromMetadata(metaData, resUnitsPath);
+
+ if (resUnitsType == null)
+ resUnitsType = rc.UnitsTypeDefault;
+
+ // Unit scale
+ string unitScale = rc.UnitsScale[resUnitsType].ToString();
+
+ // Adjust resolution to its units
+ float [] res = new float[2];
+ res[0] = ParseFloatValue(xRes) * ParseFloatValue(unitScale);
+ res[1] = ParseFloatValue(yRes) * ParseFloatValue(unitScale);
+
+ return res;
+ }
+
+ private string GetValueFromMetadata(XmlDocument metaData, string path) {
+ XmlNode n = metaData.SelectSingleNode(path);
+ if (n == null)
+ return null;
+
+ return n.InnerText;
+ }
+
+ private XmlDocument ConvertImageMetadata(imageio.metadata.IIOMetadata metaData) {
+ string [] formatNames = metaData.getMetadataFormatNames();
+ dom.Element rootNode = (dom.Element) metaData.getAsTree(formatNames[0]);
+
+ XmlDocument _metadataDocument = new XmlDocument();
+ XmlConvert(rootNode, _metadataDocument);
+
+ return _metadataDocument;
+ }
+
+ private void XmlConvert(dom.Node jNode, XmlNode nNode) {
+ XmlDocument document = nNode.OwnerDocument;
+ if (document == null)
+ document = (XmlDocument)nNode;
+
+ XmlNode n = null;
+ switch (jNode.getNodeType()) {
+ case 1 :
+ n = document.CreateNode(XmlNodeType.Element, jNode.getNodeName(), jNode.getNamespaceURI());
+ break;
+
+ case 4 :
+ n = document.CreateNode(XmlNodeType.CDATA, jNode.getNodeName(), jNode.getNamespaceURI());
+ break;
+
+ default:
+ return;
+ }
+ //set value
+ n.InnerText = jNode.getNodeValue();
+ nNode.AppendChild( n );
+
+ //copy attributes
+ org.w3c.dom.NamedNodeMap nm = jNode.getAttributes();
+ for (int i=0; i<nm.getLength(); i++) {
+ XmlAttribute a = document.CreateAttribute( nm.item(i).getNodeName() );
+ a.Value = nm.item(i).getNodeValue();
+ n.Attributes.Append( a );
+ }
+
+ //copy childs
+ org.w3c.dom.NodeList nl = jNode.getChildNodes();
+ for (int i=0; i<nl.getLength(); i++) {
+ XmlConvert(nl.item(i), n);
+ }
+ }
+
+ protected virtual float ParseFloatValue(string strValue) {
+ try {
+ if ((strValue != null) && (strValue != "")) {
+ int dividerPos = strValue.IndexOf("/");
+
+ if (dividerPos < 0) {
+ return float.Parse(strValue);
+ }
+ else {
+ return float.Parse(strValue.Substring( 0, dividerPos )) /
+ float.Parse(strValue.Substring( dividerPos + 1 ));
+ }
+ }
+ return float.NaN;
+ }
+ catch (Exception) {
+ return float.NaN;
+ }
+ }
+
+ #endregion
+
+ #region IDisposable members
+
+ public void Dispose() {
+ if (NativeReader != null) {
+ NativeReader.dispose();
+ NativeReader = null;
+ }
+
+ if (NativeWriter != null) {
+ NativeWriter.dispose();
+ NativeWriter = null;
+ }
+ }
+
+ #endregion
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs
new file mode 100644
index 00000000000..671afe49689
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs
@@ -0,0 +1,46 @@
+//
+// System.Drawing.Imaging.ImageCodecFlags.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Flags]
+ [Serializable]
+ public enum ImageCodecFlags {
+ BlockingDecode = 32,
+ Builtin = 65536,
+ Decoder = 2,
+ Encoder = 1,
+ SeekableEncode = 16,
+ SupportBitmap = 4,
+ SupportVector = 8,
+ System = 131072,
+ User = 262144
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs
new file mode 100644
index 00000000000..9acb4236407
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs
@@ -0,0 +1,217 @@
+//
+// System.Drawing.Imaging.ImageCodecInfo.cs
+//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections;
+using System.IO;
+
+namespace System.Drawing.Imaging {
+
+ [ComVisible (false)]
+ public sealed class ImageCodecInfo
+ {
+ private Guid clsid;
+ private string codecName;
+ private string dllName;
+ private string filenameExtension;
+ private ImageCodecFlags flags;
+ private string formatDescription;
+ private Guid formatID;
+ private string mimeType;
+ private byte[][] signatureMasks;
+ private byte[][] signaturePatterns;
+ private int version;
+
+ internal ImageCodecInfo()
+ {
+
+ }
+
+ // methods
+ public static ImageCodecInfo[] GetImageDecoders()
+ {
+ int decoderNums, arraySize, decoder_size;
+ IntPtr decoders, decoder_ptr;
+ ImageCodecInfo[] result;
+ GdipImageCodecInfo gdipdecoder = new GdipImageCodecInfo();
+ Status status;
+
+ status = GDIPlus.GdipGetImageDecodersSize (out decoderNums, out arraySize);
+ GDIPlus.CheckStatus (status);
+
+ result = new ImageCodecInfo [decoderNums];
+
+ if (decoderNums == 0)
+ return result;
+
+ /* Get decoders list*/
+ decoders = Marshal.AllocHGlobal (arraySize);
+ status = GDIPlus.GdipGetImageDecoders (decoderNums, arraySize, decoders);
+ GDIPlus.CheckStatus (status);
+
+ decoder_size = Marshal.SizeOf (gdipdecoder);
+ decoder_ptr = decoders;
+
+ for (int i = 0; i < decoderNums; i++, decoder_ptr = new IntPtr (decoder_ptr.ToInt64 () + decoder_size))
+ {
+ gdipdecoder = (GdipImageCodecInfo) Marshal.PtrToStructure (decoder_ptr, typeof (GdipImageCodecInfo));
+ result[i] = new ImageCodecInfo ();
+ GdipImageCodecInfo.MarshalTo (gdipdecoder, result[i]);
+ }
+
+ Marshal.FreeHGlobal (decoders);
+ return result;
+ }
+
+
+ public static ImageCodecInfo[] GetImageEncoders()
+ {
+ int encoderNums, arraySize, encoder_size;
+ IntPtr encoders, encoder_ptr;
+ ImageCodecInfo[] result;
+ GdipImageCodecInfo gdipencoder = new GdipImageCodecInfo();
+ Status status;
+
+ status = GDIPlus.GdipGetImageEncodersSize (out encoderNums, out arraySize);
+ GDIPlus.CheckStatus (status);
+
+ result = new ImageCodecInfo [encoderNums];
+
+ if (encoderNums == 0)
+ return result;
+
+ /* Get encoders list*/
+ encoders = Marshal.AllocHGlobal (arraySize);
+
+ status = GDIPlus.GdipGetImageEncoders (encoderNums, arraySize, encoders);
+ GDIPlus.CheckStatus (status);
+
+ encoder_size = Marshal.SizeOf (gdipencoder);
+ encoder_ptr = encoders;
+
+ for (int i = 0; i < encoderNums; i++, encoder_ptr = new IntPtr (encoder_ptr.ToInt64 () + encoder_size))
+ {
+ gdipencoder = (GdipImageCodecInfo) Marshal.PtrToStructure (encoder_ptr, typeof (GdipImageCodecInfo));
+ result[i] = new ImageCodecInfo ();
+ GdipImageCodecInfo.MarshalTo (gdipencoder, result[i]);
+ }
+
+ Marshal.FreeHGlobal (encoders);
+ return result;
+ }
+
+ // properties
+
+ public Guid Clsid
+ {
+ get { return clsid; }
+ set { clsid = value; }
+ }
+
+
+ public string CodecName
+ {
+ get { return codecName; }
+ set { codecName = value; }
+ }
+
+
+ public string DllName
+ {
+ get { return dllName; }
+ set { dllName = value; }
+ }
+
+
+ public string FilenameExtension
+ {
+ get { return filenameExtension; }
+ set { filenameExtension = value; }
+ }
+
+
+ public ImageCodecFlags Flags
+ {
+ get { return flags; }
+ set { flags = value; }
+ }
+
+ public string FormatDescription
+ {
+ get { return formatDescription; }
+ set { formatDescription = value; }
+ }
+
+ public Guid FormatID
+ {
+ get { return formatID; }
+ set { formatID = value; }
+ }
+
+
+ public string MimeType
+ {
+ get { return mimeType; }
+ set { mimeType = value; }
+ }
+
+
+ [CLSCompliant(false)]
+ public byte[][] SignatureMasks
+ {
+ get { return signatureMasks; }
+ set { signatureMasks = value; }
+ }
+
+ [MonoTODO]
+ [CLSCompliant(false)]
+ public byte[][] SignaturePatterns
+ {
+ get { return signaturePatterns; }
+ set { signaturePatterns = value; }
+ }
+
+ public int Version
+ {
+ get { return version; }
+ set { version = value; }
+ }
+
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.jvm.cs
new file mode 100755
index 00000000000..0ab16b81f6a
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.jvm.cs
@@ -0,0 +1,181 @@
+//
+// System.Drawing.Imaging.ImageCodecInfo.cs
+//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Configuration;
+using System.IO;
+using Mainsoft.Drawing.Imaging;
+
+using imageio = javax.imageio;
+using spi = javax.imageio.spi;
+
+namespace System.Drawing.Imaging {
+
+ [ComVisible (false)]
+ public sealed class ImageCodecInfo
+ {
+ private Guid clsid;
+ private string codecName;
+ private string dllName;
+ private string filenameExtension;
+ private ImageCodecFlags flags;
+ private string formatDescription;
+ private Guid formatID;
+ private string mimeType;
+ private byte[][] signatureMasks;
+ private byte[][] signaturePatterns;
+ private int version;
+
+ public static ImageCodecInfo[] GetImageDecoders ()
+ {
+ Hashtable oldInfo = ImageCodec.Decoders;
+ ImageCodecInfo [] newInfo = new ImageCodecInfo [oldInfo.Count];
+ int i=0;
+ foreach (ImageCodecInfo codec in oldInfo.Values) {
+ newInfo [i++] = (ImageCodecInfo) codec.MemberwiseClone ();
+ }
+ return newInfo;
+ }
+
+ internal ImageCodecInfo () {
+ }
+
+ public static ImageCodecInfo[] GetImageEncoders ()
+ {
+ Hashtable oldInfo = ImageCodec.Encoders;
+ ImageCodecInfo [] newInfo = new ImageCodecInfo [oldInfo.Count];
+ int i=0;
+ foreach (ImageCodecInfo codec in oldInfo.Values) {
+ //newInfo [i++] = (ImageCodecInfo) codec.MemberwiseClone ();
+ newInfo [i] = new ImageCodecInfo ();
+ newInfo [i].clsid = codec.clsid;
+ newInfo [i].formatID = codec.formatID;
+ newInfo [i].codecName = codec.codecName;
+ newInfo [i].dllName = codec.dllName;
+ newInfo [i].flags = codec.flags;
+ newInfo [i].filenameExtension = codec.filenameExtension;
+ newInfo [i].formatDescription = codec.formatDescription;
+ newInfo [i].mimeType = codec.mimeType;
+ newInfo [i].signatureMasks = codec.signatureMasks;
+ newInfo [i].signaturePatterns = codec.signaturePatterns;
+ newInfo [i++].version = codec.version;
+ }
+ return newInfo;
+ }
+
+ // properties
+
+ public Guid Clsid
+ {
+ get { return clsid; }
+ set { clsid = value; }
+ }
+
+
+ public string CodecName
+ {
+ get { return codecName; }
+ set { codecName = value; }
+ }
+
+
+ public string DllName
+ {
+ get { return dllName; }
+ set { throw new NotSupportedException(); }
+ }
+
+
+ public string FilenameExtension
+ {
+ get { return filenameExtension; }
+ set { filenameExtension = value; }
+ }
+
+
+ public ImageCodecFlags Flags
+ {
+ get { return flags; }
+ set { flags = value; }
+ }
+
+ public string FormatDescription
+ {
+ get { return formatDescription; }
+ set { formatDescription = value; }
+ }
+
+ public Guid FormatID
+ {
+ get { return formatID; }
+ set { formatID = value; }
+ }
+
+
+ public string MimeType
+ {
+ get { return mimeType; }
+ set { mimeType = value; }
+ }
+
+
+ [CLSCompliant(false)]
+ public byte[][] SignatureMasks
+ {
+ get { return signatureMasks; }
+ set { signatureMasks = value; }
+ }
+
+ [CLSCompliant(false)]
+ public byte[][] SignaturePatterns
+ {
+ get { return signaturePatterns; }
+ set { signaturePatterns = value; }
+ }
+
+ public int Version
+ {
+ get { return version; }
+ set { version = value; }
+ }
+
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs
new file mode 100644
index 00000000000..bc00d1bd168
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs
@@ -0,0 +1,51 @@
+//
+// System.Drawing.Imaging.ImageFlags.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Flags]
+ [Serializable]
+ public enum ImageFlags {
+ Caching = 131072,
+ ColorSpaceCmyk = 32,
+ ColorSpaceGray = 64,
+ ColorSpaceRgb = 16,
+ ColorSpaceYcbcr = 128,
+ ColorSpaceYcck = 256,
+ HasAlpha = 2,
+ HasRealDpi = 4096,
+ HasRealPixelSize = 8192,
+ HasTranslucent = 4,
+ None = 0,
+ PartiallyScalable = 8,
+ ReadOnly = 65536,
+ Scalable = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFormat.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFormat.cs
new file mode 100644
index 00000000000..1a7e94043b4
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFormat.cs
@@ -0,0 +1,187 @@
+//
+// System.Drawing.Imaging.ImageFormat.cs
+//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+// (C) 2002-4 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+
+namespace System.Drawing.Imaging {
+
+ [TypeConverter (typeof (ImageFormatConverter))]
+ public sealed class ImageFormat
+ {
+ private Guid guid;
+ private static ImageFormat BmpImageFormat = new ImageFormat (new Guid ("b96b3cab-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat EmfImageFormat = new ImageFormat (new Guid ("b96b3cac-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat ExifImageFormat = new ImageFormat (new Guid ("b96b3cb2-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat GifImageFormat = new ImageFormat (new Guid ("b96b3cb0-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat TiffImageFormat = new ImageFormat (new Guid ("b96b3cb1-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat PngImageFormat = new ImageFormat(new Guid("b96b3caf-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat MemoryBmpImageFormat = new ImageFormat (new Guid ("b96b3caa-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat IconImageFormat = new ImageFormat (new Guid ("b96b3cb5-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat JpegImageFormat = new ImageFormat(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat WmfImageFormat = new ImageFormat (new Guid ("b96b3cad-0728-11d3-9d7b-0000f81ef32e"));
+
+
+ // constructors
+ public ImageFormat (Guid guid)
+ {
+ this.guid = guid;
+ }
+
+
+ // methods
+ public override bool Equals(object o) {
+
+ if (o is ImageFormat)
+ if ( ((ImageFormat)o).Guid.Equals(this.Guid))
+ return true;
+ return false;
+
+ }
+
+
+ public override int GetHashCode()
+ {
+ return guid.GetHashCode();
+ }
+
+
+ public override string ToString()
+ {
+ if (this.Equals (Bmp))
+ return "Bmp";
+
+ if (this.Equals (Emf))
+ return "Emf";
+
+ if (this.Equals (Exif))
+ return "Exif";
+
+ if (this.Equals (Gif))
+ return "Gif";
+
+ if (this.Equals (Tiff))
+ return "Tiff";
+
+ if (this.Equals (Png))
+ return "Png";
+
+ if (this.Equals (MemoryBmp))
+ return "MemoryBmp";
+
+ if (this.Equals (Icon))
+ return "Icon";
+
+ if (this.Equals (Jpeg))
+ return "Jpeg";
+
+ if (this.Equals (Wmf))
+ return "Wmf";
+
+ // Default
+ return ("[ImageFormat: " + Guid.ToString () + "]");
+
+
+ }
+
+ // properties
+ public Guid Guid
+ {
+ get { return guid; }
+ }
+
+
+ public static ImageFormat Bmp
+ {
+ get { return BmpImageFormat; }
+ }
+
+
+ public static ImageFormat Emf
+ {
+ get { return EmfImageFormat; }
+ }
+
+
+ public static ImageFormat Exif
+ {
+ get { return ExifImageFormat; }
+ }
+
+
+ public static ImageFormat Gif
+ {
+ get { return GifImageFormat; }
+ }
+
+
+ public static ImageFormat Icon
+ {
+ get { return IconImageFormat; }
+ }
+
+
+ public static ImageFormat Jpeg
+ {
+ get { return JpegImageFormat; }
+ }
+
+
+ public static ImageFormat MemoryBmp
+ {
+ get { return MemoryBmpImageFormat; }
+ }
+
+
+ public static ImageFormat Png
+ {
+ get { return PngImageFormat; }
+ }
+
+
+ public static ImageFormat Tiff
+ {
+ get { return TiffImageFormat; }
+ }
+
+
+ public static ImageFormat Wmf
+ {
+ get { return WmfImageFormat; }
+ }
+
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageLockMode.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageLockMode.cs
new file mode 100644
index 00000000000..0f810254199
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageLockMode.cs
@@ -0,0 +1,40 @@
+//
+// System.Drawing.Imaging.ImageLockMode.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum ImageLockMode {
+ ReadOnly = 1,
+ ReadWrite = 3,
+ UserInputBuffer = 4,
+ WriteOnly = 2
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs
new file mode 100644
index 00000000000..61af60d417b
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/MetaHeader.cs
@@ -0,0 +1,94 @@
+//
+// System.Drawing.Imaging.MetaHeader.cs
+//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging {
+
+ [StructLayout(LayoutKind.Sequential)]
+ public sealed class MetaHeader {
+
+ private short headerSize;
+ private int maxRecord;
+ private short noObjects;
+ private short noParameters;
+ private int size;
+ private short type;
+ private short version;
+
+ // constructors
+ public MetaHeader()
+ {
+ }
+
+ // properties
+ public short HeaderSize {
+ get { return headerSize; }
+ set { headerSize = value; }
+ }
+
+ public int MaxRecord {
+ get { return maxRecord; }
+ set { maxRecord = value; }
+ }
+
+ public short NoObjects {
+ get { return noObjects; }
+ set { noObjects = value; }
+ }
+
+ public short NoParameters {
+ get { return noParameters; }
+ set { noParameters = value; }
+ }
+
+ public int Size {
+ get { return size; }
+ set { size = value; }
+ }
+
+ public short Type {
+ get { return type; }
+ set { type = value; }
+ }
+
+ public short Version {
+ get { return version; }
+ set { version = value; }
+ }
+
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/Metafile.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/Metafile.cs
new file mode 100644
index 00000000000..711d80509ed
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/Metafile.cs
@@ -0,0 +1,328 @@
+//
+// System.Drawing.Imaging.Metafile.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Christian Meyer
+// eMail: Christian.Meyer@cs.tum.edu
+// Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Reflection;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging {
+
+ [Serializable]
+ [ComVisible (false)]
+ [Editor ("System.Drawing.Design.MetafileEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ public sealed class Metafile : Image {
+
+ // constructors
+ [MonoTODO]
+ public Metafile (Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string filename)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr henhmetafile, bool deleteEmf)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHtc, EmfType emfType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHtc, Rectangle frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHtc, RectangleF frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHtc)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (String fileName, IntPtr referenceHtc)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, EmfType emfType, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader, bool deleteWmf)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, Rectangle frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, RectangleF frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, Rectangle frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, RectangleF frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHtc, EmfType type, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, EmfType type, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type,
+ string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type,
+ string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type,
+ string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type,
+ string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ // methods
+ [MonoTODO]
+ public IntPtr GetHenhmetafile()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public MetafileHeader GetMetafileHeader()
+ {
+ return GetMetafileHeader (GetHenhmetafile () );
+ }
+
+ [MonoTODO]
+ public static MetafileHeader GetMetafileHeader(IntPtr henhmetafile)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static MetafileHeader GetMetafileHeader(Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static MetafileHeader GetMetafileHeader(string fileName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static MetafileHeader GetMetafileHeader(IntPtr henhmetafile, WmfPlaceableFileHeader wmfHeader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void PlayRecord(EmfPlusRecordType recordType, int flags, int dataSize, byte[] datawmfHeader)
+ {
+ throw new NotImplementedException ();
+ }
+ // properties
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/Metafile.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/Metafile.jvm.cs
new file mode 100644
index 00000000000..78a28c40755
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/Metafile.jvm.cs
@@ -0,0 +1,362 @@
+//
+// System.Drawing.Imaging.Metafile.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Christian Meyer
+// eMail: Christian.Meyer@cs.tum.edu
+// Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Reflection;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging {
+
+ [Serializable]
+ [ComVisible (false)]
+#if SYSTEM_DRAWING_DESIGN_SUPPORT
+ [Editor ("System.Drawing.Design.MetafileEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+#endif
+ [MonoTODO]
+ public sealed class Metafile : Image {
+
+ // constructors
+ [MonoTODO]
+ public Metafile (Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string filename)
+ {
+ throw new NotImplementedException ();
+ }
+
+#if INTPTR_SUPPORT
+
+ [MonoTODO]
+ public Metafile (IntPtr henhmetafile, bool deleteEmf)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHtc, EmfType emfType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHtc, Rectangle frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHtc, RectangleF frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHtc)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (String fileName, IntPtr referenceHtc)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, EmfType emfType, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader, bool deleteWmf)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, Rectangle frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, RectangleF frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, Rectangle frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, RectangleF frameRect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHtc, EmfType type, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, EmfType type, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type,
+ string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type,
+ string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type,
+ string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public Metafile (string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type,
+ string description)
+ {
+ throw new NotImplementedException ();
+ }
+
+ // methods
+ [MonoTODO]
+ public IntPtr GetHenhmetafile()
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
+ [MonoTODO]
+ public MetafileHeader GetMetafileHeader()
+ {
+ throw new NotFiniteNumberException();
+ }
+
+#if INTPTR_SUPPORT
+ [MonoTODO]
+ public static MetafileHeader GetMetafileHeader(IntPtr henhmetafile)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+ [MonoTODO]
+ public static MetafileHeader GetMetafileHeader(Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static MetafileHeader GetMetafileHeader(string fileName)
+ {
+ throw new NotImplementedException ();
+ }
+
+#if INTPTR_SUPPORT
+ [MonoTODO]
+ public static MetafileHeader GetMetafileHeader(IntPtr henhmetafile, WmfPlaceableFileHeader wmfHeader)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+ [MonoTODO]
+ public void PlayRecord(EmfPlusRecordType recordType, int flags, int dataSize, byte[] datawmfHeader)
+ {
+ throw new NotImplementedException ();
+ }
+ // properties
+
+ [MonoTODO]
+ protected override void InternalSave (javax.imageio.stream.ImageOutputStream output, Guid clsid) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override PixelFormat InternalPixelFormat {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO]
+ protected override java.awt.Image[] CloneNativeObjects(java.awt.Image[] src) {
+ throw new NotImplementedException ();
+ }
+
+ #region Clone
+ [MonoTODO]
+ public override object Clone() {
+ throw new NotImplementedException ();
+ }
+ #endregion
+
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileFrameUnit.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileFrameUnit.cs
new file mode 100644
index 00000000000..2635952099d
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileFrameUnit.cs
@@ -0,0 +1,42 @@
+//
+// System.Drawing.Imaging.MetafileFrameUnit.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum MetafileFrameUnit {
+ Document = 5,
+ GdiCompatible = 7,
+ Inch = 4,
+ Millimeter = 6,
+ Pixel = 2,
+ Point = 3
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileHeader.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileHeader.cs
new file mode 100644
index 00000000000..a248d74cc39
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileHeader.cs
@@ -0,0 +1,144 @@
+//
+// System.Drawing.Imaging.MetafileHeader.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Everaldo Canuto
+// eMail: everaldo.canuto@bol.com.br
+// Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging {
+
+ [MonoTODO]
+#if !TARGET_JVM
+ [StructLayout(LayoutKind.Sequential)]
+#endif
+ public sealed class MetafileHeader
+ {
+
+ //constructor
+ internal MetafileHeader()
+ {
+ //Nothing to be done here
+ }
+
+ // methods
+ [MonoTODO]
+ public bool IsDisplay() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsEmf() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsEmfOrEmfPlus() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsEmfPlus() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsEmfPlusDual() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsEmfPlusOnly() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsWmf() {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public bool IsWmfPlaceable() {
+ throw new NotImplementedException ();
+ }
+
+ // properties
+ [MonoTODO]
+ public Rectangle Bounds {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public float DpiX {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public float DpiY {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int EmfPlusHeaderSize {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int LogicalDpiX {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int LogicalDpiY {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int MetafileSize {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MetafileType Type {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int Version {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public MetaHeader WmfHeader {
+ get { throw new NotImplementedException (); }
+ }
+
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileType.cs
new file mode 100644
index 00000000000..24415c002ee
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileType.cs
@@ -0,0 +1,46 @@
+//
+// System.Drawing.Imaging.MetafileType
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum MetafileType
+ {
+ Invalid = 0,
+ Wmf = 1,
+ WmfPlaceable = 2,
+ Emf = 3,
+ EmfPlusOnly = 4,
+ EmfPlusDual = 5
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/PaletteFlags.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/PaletteFlags.cs
new file mode 100644
index 00000000000..11b968b47af
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/PaletteFlags.cs
@@ -0,0 +1,39 @@
+//
+// System.Drawing.Imaging.PaletteFlags.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Imaging
+{
+ [Serializable]
+ public enum PaletteFlags {
+ GrayScale = 2,
+ Halftone = 4,
+ HasAlpha = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/PixelFormat.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/PixelFormat.cs
new file mode 100644
index 00000000000..44a69aa6ebf
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/PixelFormat.cs
@@ -0,0 +1,63 @@
+// created on 20.02.2002 at 21:18
+//
+// Image.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Christian Meyer
+// eMail: Christian.Meyer@cs.tum.edu
+// Dennis Hayes
+// dennish@raytek.com
+//
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+namespace System.Drawing.Imaging {
+
+ [Serializable]
+ public enum PixelFormat {
+ Alpha = 262144,
+ Canonical = 2097152,
+ DontCare = 0,
+ Extended = 1048576,
+ Format16bppArgb1555 = 397319,
+ Format16bppGrayScale = 1052676,
+ Format16bppRgb555 = 135173,
+ Format16bppRgb565 = 135174,
+ Format1bppIndexed = 196865,
+ Format24bppRgb = 137224,
+ Format32bppArgb = 2498570,
+ Format32bppPArgb = 925707,
+ Format32bppRgb = 139273,
+ Format48bppRgb = 1060876,
+ Format4bppIndexed = 197634,
+ Format64bppArgb = 3424269,
+ Format64bppPArgb = 1851406,
+ Format8bppIndexed = 198659,
+ Gdi = 131072,
+ Indexed = 65536,
+ Max = 15,
+ PAlpha = 524288,
+ Undefined = 0 //shows up in enumcheck as second "dontcare".
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/PlayRecordCallback.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/PlayRecordCallback.cs
new file mode 100644
index 00000000000..7d7ac421726
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/PlayRecordCallback.cs
@@ -0,0 +1,42 @@
+//
+// System.Drawing.Imaging.PlayRecordCallback.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Everaldo Canuto
+// eMail: everaldo.canuto@bol.com.br
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Imaging {
+
+ [Serializable]
+ public delegate void PlayRecordCallback(
+ EmfPlusRecordType recordType,
+ int flags,
+ int dataSize,
+ IntPtr recordData
+ );
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs
new file mode 100644
index 00000000000..46b6ac51061
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs
@@ -0,0 +1,77 @@
+//
+// System.Drawing.Imaging.PropertyItem.cs
+//
+// Authors:
+// Everaldo Canuto (everaldo.canuto@bol.com.br)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Imaging {
+
+ public sealed class PropertyItem
+ {
+
+ private int id;
+ private int len;
+ private short type;
+ private byte[] value;
+
+ //constructor
+ internal PropertyItem()
+ {
+ //Nothing to be done here
+ }
+
+
+ // properties
+ public int Id {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public int Len {
+ get { return len; }
+ set { len = value; }
+ }
+
+ public short Type {
+ get { return type; }
+ set { type = value; }
+ }
+
+ public byte[] Value {
+ get { return this.value; }
+ set { this.value = value; }
+ }
+
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/WmfPlaceableFileHeader.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/WmfPlaceableFileHeader.cs
new file mode 100644
index 00000000000..b9c896313a3
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Imaging/WmfPlaceableFileHeader.cs
@@ -0,0 +1,103 @@
+//
+// System.Drawing.Imaging.WmfPlaceableFileHeader.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Everaldo Canuto
+// eMail: everaldo.canuto@bol.com.br
+// Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Imaging {
+
+ [StructLayout(LayoutKind.Sequential)]
+ public sealed class WmfPlaceableFileHeader {
+
+ // constructors
+ [MonoTODO]
+ public WmfPlaceableFileHeader() {
+ throw new NotImplementedException ();
+ }
+
+ // properties
+ [MonoTODO]
+ public short BboxBottom {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public short BboxLeft {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public short BboxRight {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public short BboxTop {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public short Checksum {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public short Hmf {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public short Inch {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int Key {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public int Reserved {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/ChangeLog b/mcs/class/System.Drawing/System.Drawing.Printing/ChangeLog
new file mode 100644
index 00000000000..34b32630033
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/ChangeLog
@@ -0,0 +1,54 @@
+2006-01-15 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * PrintingServicesUnix.cs: Allow setting the dpy's for the surface
+
+2005-12-22 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * PrintingServices.cs: Printing services abstration class
+ * PrintingServicesWin32.cs: Win32 printer driver
+ * PrintingServicesUnix.cs: Unix printer driver
+ * Margins.cs: Fixes exceptions error messages
+ * PrinterResolution.cs: Fixes
+ * PrintEventArgs.cs: New internal method
+ * PrintPageEventArgs.cs: New internal method
+ * StandardPrintController.cs: Fixes
+ * PrinterUnitConvert.cs: Fixes conversion errors
+ * PrintDocument.cs: Fixes to make it print
+ * PageSettings.cs: Take margains into account
+ * PrintController.cs: Fixes
+ * PaperSize.cs: Method to set paper Kind
+ * PrinterSettings.cs: Implements settings and fixes
+ *
+
+2005-12-07 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * PrinterResolutionKind.cs: Fixes signature for .Net 2.0
+ * PaperKind.cs: Fixes signature for .Net 2.0
+ * PaperSource.cs: Fixes signature for .Net 2.0
+ * Margins.cs: Fixes signature for .Net 2.0
+ * PrinterResolution.cs: Fixes signature for .Net 2.0
+ * PrintEventArgs.cs: Fixes signature for .Net 2.0
+ * PrintAction.cs: New enum in .Net 2.0
+ * PageSettings.cs: Fixes signature for .Net 2.0
+ * PaperSourceKind.cs: Fixes signature for .Net 2.0
+ * PrintController.cs: Fixes signature for .Net 2.0
+ * Duplex.cs: Fixes signature for .Net 2.0
+ * PaperSize.cs: Fixes signature for .Net 2.0
+ * PreviewPrintController.cs: Fixes signature for .Net 2.0
+ * PrinterSettings.cs: Fixes signature for .Net 2.0
+ * PrintRange.cs: Fixes signature for .Net 2.0
+
+2005-09-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * InvalidPrinterException.cs: Removed NotImplementedException (not
+ required) and added a demand for SerializationFormatter on the
+ GetObjectData method.
+ * PrintingPermission.cs: Throw ArgumentException if the class or
+ version attributes are missing in the supplied XML (only in 1.x).
+
+2005-03-23 Jordi Mas i Hernandez <jordi@ximian.com>
+ * PaperKind.cs: fixes wrong enum values
+
+2005-01-27 Lluis Sanchez Gual <lluis@novell.com>
+
+ * MarginsConverter.cs: Implemented support for InstanceDescriptor.
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/Duplex.cs b/mcs/class/System.Drawing/System.Drawing.Printing/Duplex.cs
new file mode 100644
index 00000000000..2eaf3452f02
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/Duplex.cs
@@ -0,0 +1,42 @@
+//
+// System.Drawing.Duplex.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Printing
+{
+#if NET_2_0
+ [Serializable]
+#endif
+ public enum Duplex {
+ Default = -1,
+ Horizontal = 3,
+ Simplex = 1,
+ Vertical = 2
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs b/mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs
new file mode 100644
index 00000000000..9ee8b733b7f
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs
@@ -0,0 +1,64 @@
+//
+// System.Drawing.InvalidPrinterExecption.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Runtime.Serialization;
+using System.Security.Permissions;
+
+namespace System.Drawing.Printing {
+
+#if NET_2_0
+ [Serializable]
+#endif
+ public class InvalidPrinterException : SystemException {
+
+ private PrinterSettings settings;
+
+ public InvalidPrinterException (PrinterSettings settings)
+ {
+ this.settings = settings;
+ }
+
+ protected InvalidPrinterException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
+
+ [SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ if (info == null)
+ throw new ArgumentNullException ("info");
+
+ base.GetObjectData (info, context);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/Margins.cs b/mcs/class/System.Drawing/System.Drawing.Printing/Margins.cs
new file mode 100644
index 00000000000..20b49572926
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/Margins.cs
@@ -0,0 +1,151 @@
+//
+// System.Drawing.Margins.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+
+namespace System.Drawing.Printing
+{
+#if NET_2_0
+ [Serializable]
+#endif
+ [TypeConverter (typeof (MarginsConverter))]
+ public class Margins : ICloneable
+ {
+ int left;
+ int right;
+ int top;
+ int bottom;
+
+ public Margins()
+ {
+ left = 100;
+ right = 100;
+ top = 100;
+ bottom = 100;
+ }
+
+ public Margins(int left, int right, int top, int bottom)
+ {
+ //Verify parameters
+ if (left < 0)
+ throw new System.ArgumentException("All Margins must be greater than 0", "left");
+ if (right < 0)
+ throw new System.ArgumentException("All Margins must be greater than 0", "right");
+ if (top < 0)
+ throw new System.ArgumentException("All Margins must be greater than 0", "top");
+ if (bottom < 0)
+ throw new System.ArgumentException("All Margins must be greater than 0", "bottom");
+
+ //Set proprities
+ this.left = left;
+ this.right = right;
+ this.top = top;
+ this.bottom = bottom;
+ }
+
+ public int Left {
+ get {
+ return left;
+ }
+ set {
+ if (left < 0)
+ throw new System.ArgumentException("All Margins must be greater than 0", "left");
+ left = value;
+ }
+ }
+
+ public int Right {
+ get {
+ return right;
+ }
+ set {
+ if (right < 0)
+ throw new System.ArgumentException("All Margins must be greater than 0", "right");
+ right = value;
+ }
+ }
+
+ public int Top {
+ get {
+ return top;
+ }
+ set {
+ if (top < 0)
+ throw new System.ArgumentException("All Margins must be greater than 0", "top");
+ top = value;
+ }
+ }
+
+ public int Bottom {
+ get {
+ return bottom;
+ }
+ set {
+ if (bottom < 0)
+ throw new System.ArgumentException("All Margins must be greater than 0", "bottom");
+ bottom = value;
+ }
+ }
+
+ public object Clone()
+ {
+ return new Margins (this.Left, this.Right, this.Top, this.Bottom);
+ }
+
+ public override bool Equals (object obj)
+ {
+ Margins m = obj as Margins;
+
+ if (m == null)
+ return false;
+ if (m.Left == left && m.Right == right && m.Top == top && m.Bottom == bottom)
+ return true;
+
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ // Try to create a somewhat meaningful hash
+ int hash = left + right * 2^8 + top * 2^16 + bottom * 2^24;
+ return hash;
+ }
+
+ public override string ToString()
+ {
+ string ret = "[Margins Left={0} Right={1} Top={2} Bottom={3}]";
+ return String.Format (ret, this.Left, this.Right, this.Top, this.Bottom);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/MarginsConverter.cs b/mcs/class/System.Drawing/System.Drawing.Printing/MarginsConverter.cs
new file mode 100644
index 00000000000..c437a1c4b68
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/MarginsConverter.cs
@@ -0,0 +1,137 @@
+//
+// System.Drawing.MarginsConverter.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Herve Poussineau (hpoussineau@fr.st)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Text.RegularExpressions;
+using System.ComponentModel.Design.Serialization;
+using System.Reflection;
+
+namespace System.Drawing.Printing {
+ /// <summary>
+ /// Summary description for MarginsConverter.
+ /// </summary>
+ public class MarginsConverter : ExpandableObjectConverter {
+ public MarginsConverter() {
+ }
+ #region Methods
+ public override bool CanConvertFrom(ITypeDescriptorContext context,Type sourceType) {
+ if (sourceType == typeof(string))
+ return true;
+
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override bool CanConvertTo(ITypeDescriptorContext context,Type destinationType) {
+ if (destinationType == typeof(string))
+ return true;
+
+ if (destinationType == typeof (InstanceDescriptor))
+ return true;
+
+ return base.CanConvertTo(context, destinationType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context,CultureInfo culture,object value) {
+ if (value is string)
+ {
+ if (value == null)
+ return new Margins();
+
+ // format [left];[right];[top];[bottom]
+ string separator = @"( |\t)*";
+ separator = separator + ";" + separator;
+ string regex = @"(?<left>\d+)" + separator + @"(?<right>\d+)" + separator + @"(?<top>\d+)" + separator + @"(?<bottom>\d+)";
+
+ Match match = new Regex(regex).Match(value as string);
+ if (!match.Success)
+ throw new ArgumentException("value");
+
+ int left, right, top, bottom;
+ try
+ {
+ left = int.Parse(match.Groups["left"].Value);
+ right = int.Parse(match.Groups["right"].Value);
+ top = int.Parse(match.Groups["top"].Value);
+ bottom = int.Parse(match.Groups["bottom"].Value);
+ }
+ catch (Exception e)
+ {
+ throw new ArgumentException("value", e);
+ }
+ return new Margins(left, right, top, bottom);
+ } else
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context,CultureInfo culture,object value,Type destinationType) {
+ if (destinationType == typeof(string) && value is Margins)
+ {
+ Margins source = value as Margins;
+ string ret = "{0}; {1}; {2}; {3}";
+ return String.Format(ret, source.Left, source.Right, source.Top, source.Bottom);
+ }
+ if (destinationType == typeof (InstanceDescriptor) && value is Margins) {
+ Margins c = (Margins) value;
+ ConstructorInfo ctor = typeof(Margins).GetConstructor (new Type[] {typeof(int), typeof(int), typeof(int), typeof(int)} );
+ return new InstanceDescriptor (ctor, new object[] {c.Left, c.Right, c.Top, c.Bottom});
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ public override bool GetCreateInstanceSupported(ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues)
+ {
+ try
+ {
+ Margins margins = new Margins();
+ margins.Left = int.Parse(propertyValues["Left"].ToString());
+ margins.Right = int.Parse(propertyValues["Right"].ToString());
+ margins.Top = int.Parse(propertyValues["Top"].ToString());
+ margins.Bottom = int.Parse(propertyValues["Bottom"].ToString());
+ return margins;
+ }
+ catch (Exception)
+ {
+ // in case of error, return null
+ return null;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PageSettings.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PageSettings.cs
new file mode 100644
index 00000000000..c962f00d8bb
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PageSettings.cs
@@ -0,0 +1,216 @@
+//
+// System.Drawing.PageSettings.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Herve Poussineau (hpoussineau@fr.st)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Printing
+{
+#if NET_2_0
+ [Serializable]
+#else
+ [ComVisible (false)]
+#endif
+ public class PageSettings : ICloneable
+ {
+ bool _Color;
+ bool _Landscape;
+ float _HardMarginX;
+ float _HardMarginY;
+ RectangleF _PrintableArea;
+ // create a new default Margins object (is 1 inch for all margins)
+ Margins _Margins = new Margins();
+ PaperSize _PaperSize;
+ PaperSource _PaperSource;
+ PrinterResolution _PrinterResolution;
+ PrinterSettings _PrinterSettings;
+
+ public PageSettings() : this(new PrinterSettings())
+ {
+ }
+
+ public PageSettings(PrinterSettings printerSettings)
+ {
+ PrinterSettings = printerSettings;
+
+ Color = printerSettings.DefaultPageSettings.Color;
+ Landscape = printerSettings.DefaultPageSettings.Landscape;
+ PaperSize = printerSettings.DefaultPageSettings.PaperSize;
+ PaperSource = printerSettings.DefaultPageSettings.PaperSource;
+ PrinterResolution = printerSettings.DefaultPageSettings.PrinterResolution;
+ }
+
+ // used by PrinterSettings.DefaultPageSettings
+ internal PageSettings(PrinterSettings printerSettings, bool color, bool landscape, PaperSize paperSize, PaperSource paperSource, PrinterResolution printerResolution)
+ {
+ PrinterSettings = printerSettings;
+
+ Color = color;
+ Landscape = landscape;
+ PaperSize = paperSize;
+ PaperSource = paperSource;
+ PrinterResolution = printerResolution;
+ }
+
+ //props
+ public Rectangle Bounds{
+ get{
+ int width = this.PaperSize.Width;
+ int height = this.PaperSize.Height;
+
+ width -= this.Margins.Left + this.Margins.Right;
+ height -= this.Margins.Top + this.Margins.Bottom;
+
+ if (this.Landscape) {
+ // swap width and height
+ int tmp = width;
+ width = height;
+ height = tmp;
+ }
+ return new Rectangle (Margins.Left, Margins.Top, width, height);
+ }
+ }
+
+ public bool Color{
+ get{
+ return _Color;
+ }
+ set{
+ _Color = value;
+ }
+ }
+
+ public bool Landscape {
+ get{
+ return _Landscape;
+ }
+ set{
+ _Landscape = value;
+ }
+ }
+
+ public Margins Margins{
+ get{
+ return _Margins;
+ }
+ set{
+ _Margins = value;
+ }
+ }
+
+ public PaperSize PaperSize{
+ get{
+ return _PaperSize;
+ }
+ set{
+ _PaperSize = value;
+ }
+ }
+
+ public PaperSource PaperSource{
+ get{
+ return _PaperSource;
+ }
+ set{
+ _PaperSource = value;
+ }
+ }
+
+ public PrinterResolution PrinterResolution{
+ get{
+ return _PrinterResolution;
+ }
+ set{
+ _PrinterResolution = value;
+ }
+ }
+
+ public PrinterSettings PrinterSettings{
+ get{
+ return _PrinterSettings;
+ }
+ set{
+ _PrinterSettings = value;
+ }
+ }
+#if NET_2_0
+ public float HardMarginX {
+ get {
+ return _HardMarginX;
+ }
+ }
+
+ public float HardMarginY {
+ get {
+ return _HardMarginY;
+ }
+ }
+
+ public RectangleF PrintableArea {
+ get {
+ return _PrintableArea;
+ }
+ }
+#endif
+
+
+ public object Clone(){
+ return new PageSettings(this.PrinterSettings);
+ }
+
+
+ [MonoTODO("PageSettings.CopyToHdevmode")]
+ public void CopyToHdevmode (IntPtr hdevmode){
+ throw new NotImplementedException ();
+ }
+
+
+ [MonoTODO("PageSettings.SetHdevmode")]
+ public void SetHdevmode (IntPtr hdevmode){
+ throw new NotImplementedException ();
+ }
+
+ public override string ToString(){
+ string ret = "[PageSettings: Color={0}";
+ ret += ", Landscape={1}";
+ ret += ", Margins={2}";
+ ret += ", PaperSize={3}";
+ ret += ", PaperSource={4}";
+ ret += ", PrinterResolution={5}";
+ ret += "]";
+
+ return String.Format(ret, this.Color, this.Landscape, this.Margins, this.PaperSize, this.PaperSource, this.PrinterResolution);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PaperKind.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PaperKind.cs
new file mode 100644
index 00000000000..d379f1ef5d3
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PaperKind.cs
@@ -0,0 +1,157 @@
+//
+// System.Drawing.PaperKind.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Printing
+{
+#if NET_2_0
+ [Serializable]
+#endif
+ public enum PaperKind
+ {
+ A2 = 66,
+ A3 = 8,
+ A3Extra = 63,
+ A3ExtraTransverse = 68,
+ A3Rotated = 76,
+ A3Transverse = 67,
+ A4 = 9,
+ A4Extra = 53,
+ A4Plus = 60,
+ A4Rotated = 77,
+ A4Small = 10,
+ A4Transverse = 55,
+ A5 = 11,
+ A5Extra = 64,
+ A5Rotated = 78,
+ A5Transverse = 61,
+ A6 = 70,
+ A6Rotated = 83,
+ APlus = 57,
+ B4 = 12,
+ B4Envelope = 33,
+ B4JisRotated = 79,
+ B5 = 13,
+ B5Envelope = 34,
+ B5Extra = 65,
+ B5JisRotated = 80,
+ B5Transverse = 62,
+ B6Envelope = 35,
+ B6Jis = 88,
+ B6JisRotated = 89,
+ BPlus = 58,
+ C3Envelope = 29,
+ C4Envelope = 30,
+ C5Envelope = 28,
+ C65Envelope = 32,
+ C6Envelope = 31,
+ CSheet = 24,
+ Custom = 0,
+ DLEnvelope = 27,
+ DSheet = 25,
+ ESheet = 26,
+ Executive = 7,
+ Folio = 14,
+ GermanLegalFanfold = 41,
+ GermanStandardFanfold = 40,
+ InviteEnvelope = 47,
+ IsoB4 = 42,
+ ItalyEnvelope = 36,
+ JapaneseDoublePostcard = 69,
+ JapaneseDoublePostcardRotated = 82,
+ JapaneseEnvelopeChouNumber3 = 73,
+ JapaneseEnvelopeChouNumber3Rotated = 86,
+ JapaneseEnvelopeChouNumber4 = 74,
+ JapaneseEnvelopeChouNumber4Rotated = 87,
+ JapaneseEnvelopeKakuNumber2 = 71,
+ JapaneseEnvelopeKakuNumber2Rotated = 84,
+ JapaneseEnvelopeKakuNumber3 = 72,
+ JapaneseEnvelopeKakuNumber3Rotated = 85,
+ JapaneseEnvelopeYouNumber4 = 91,
+ JapaneseEnvelopeYouNumber4Rotated = 92,
+ JapanesePostcard = 43,
+ JapanesePostcardRotated = 81,
+ Ledger = 4,
+ Legal = 5,
+ LegalExtra = 51,
+ Letter = 1,
+ LetterExtra = 50,
+ LetterExtraTransverse = 56,
+ LetterPlus = 59,
+ LetterRotated = 75,
+ LetterSmall = 2,
+ LetterTransverse = 54,
+ MonarchEnvelope = 37,
+ Note = 18,
+ Number10Envelope = 20,
+ Number11Envelope = 21,
+ Number12Envelope = 22,
+ Number14Envelope = 23,
+ Number9Envelope = 19,
+ PersonalEnvelope = 38,
+ Prc16K = 93,
+ Prc16KRotated = 106,
+ Prc32K = 94,
+ Prc32KBig = 95,
+ Prc32KBigRotated = 108,
+ Prc32KRotated = 107,
+ PrcEnvelopeNumber1 = 96,
+ PrcEnvelopeNumber10 = 105,
+ PrcEnvelopeNumber10Rotated = 118,
+ PrcEnvelopeNumber1Rotated = 109,
+ PrcEnvelopeNumber2 = 97,
+ PrcEnvelopeNumber2Rotated = 110,
+ PrcEnvelopeNumber3 = 98,
+ PrcEnvelopeNumber3Rotated = 111,
+ PrcEnvelopeNumber4 = 99,
+ PrcEnvelopeNumber4Rotated = 112,
+ PrcEnvelopeNumber5 = 100,
+ PrcEnvelopeNumber5Rotated = 113,
+ PrcEnvelopeNumber6 = 101,
+ PrcEnvelopeNumber6Rotated = 114,
+ PrcEnvelopeNumber7 = 102,
+ PrcEnvelopeNumber7Rotated = 115,
+ PrcEnvelopeNumber8 = 103,
+ PrcEnvelopeNumber8Rotated = 116,
+ PrcEnvelopeNumber9 = 104,
+ PrcEnvelopeNumber9Rotated = 117,
+ Quarto = 15,
+ Standard10x11 = 45,
+ Standard10x14 = 16,
+ Standard11x17 = 17,
+ Standard12x11 = 90,
+ Standard15x11 = 46,
+ Standard9x11 = 44,
+ Statement = 6,
+ Tabloid = 3,
+ TabloidExtra = 52,
+ USStandardFanfold = 39
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PaperSize.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PaperSize.cs
new file mode 100644
index 00000000000..8ded0d59eaf
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PaperSize.cs
@@ -0,0 +1,115 @@
+//
+// System.Drawing.PaperSize.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Herve Poussineau (hpoussineau@fr.st)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Printing
+{
+ /// <summary>
+ /// Summary description for PaperSize.
+ /// </summary>
+#if NET_2_0
+ [Serializable]
+#endif
+ public class PaperSize
+ {
+ string name;
+ int width;
+ int height;
+ PaperKind kind;
+#if NET_2_0
+ public PaperSize ()
+ {
+
+ }
+#endif
+ public PaperSize(string name, int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ this.name = name;
+ this.kind = PaperKind.Custom;
+ }
+
+ public int Width{
+ get{
+ return width;
+ }set
+ {
+ if (Kind != PaperKind.Custom)
+ throw new ArgumentException();
+ width = value;
+ }
+ }
+ public int Height{
+ get{
+ return height;
+ }set
+ {
+ if (Kind != PaperKind.Custom)
+ throw new ArgumentException();
+ height = value;
+ }
+ }
+
+ public string PaperName{
+ get{
+ return name;
+ }
+ set{
+ if (Kind != PaperKind.Custom)
+ throw new ArgumentException();
+ name = value;
+ }
+ }
+
+ public PaperKind Kind{
+ get{
+ return kind;
+ }
+ }
+ internal void SetKind (PaperKind k) {kind = k;}
+#if NET_2_0
+ [MonoTODO]
+ public int RawKind {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+#endif
+
+ public override string ToString(){
+ string ret = "[PaperSize {0} Kind={1} Height={2} Width={3}]";
+ return String.Format(ret, this.PaperName, this.Kind, this.Height, this.Width);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PaperSource.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PaperSource.cs
new file mode 100644
index 00000000000..9523f304977
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PaperSource.cs
@@ -0,0 +1,95 @@
+//
+// System.Drawing.PaperSource.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Herve Poussineau (hpoussineau@fr.st)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Printing
+{
+ /// <summary>
+ /// Summary description for PaperSource.
+ /// </summary>
+#if NET_2_0
+ [Serializable]
+#endif
+ public class PaperSource
+ {
+ PaperSourceKind _Kind;
+ string _SourceName;
+
+#if NET_2_0
+ public PaperSource ()
+ {
+
+ }
+#endif
+ // NOTE:how to construct this class?
+ // I have added a constructor, but I am not sure of me...
+ internal PaperSource(string sourceName, PaperSourceKind kind)
+ {
+ _SourceName = sourceName;
+ _Kind = kind;
+ }
+
+ public PaperSourceKind Kind{
+ get {
+ return _Kind;
+ }
+ }
+ public string SourceName{
+ get {
+ return _SourceName;
+ }
+#if NET_2_0
+ set {
+ _SourceName = value;
+ }
+#endif
+ }
+
+#if NET_2_0
+ [MonoTODO]
+ public int RawKind {
+ get {
+ throw new NotImplementedException ();
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+#endif
+
+ public override string ToString(){
+ string ret = "[PaperSource {0} Kind={1}]";
+ return String.Format(ret, this.SourceName, this.Kind);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PaperSourceKind.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PaperSourceKind.cs
new file mode 100644
index 00000000000..3312630ef5a
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PaperSourceKind.cs
@@ -0,0 +1,52 @@
+//
+// System.Drawing.PaperSourceKind.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Printing
+{
+#if NET_2_0
+ [Serializable]
+#endif
+ public enum PaperSourceKind {
+ AutomaticFeed = 7,
+ Cassette = 14,
+ Custom = 257,
+ Envelope = 5,
+ FormSource = 15,
+ LargeCapacity = 11,
+ LargeFormat = 10,
+ Lower = 2,
+ Manual = 4,
+ ManualFeed = 6,
+ Middle = 3,
+ SmallFormat = 9,
+ TractorFeed = 8,
+ Upper = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PreviewPageInfo.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PreviewPageInfo.cs
new file mode 100644
index 00000000000..4242b054e11
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PreviewPageInfo.cs
@@ -0,0 +1,57 @@
+//
+// System.Drawing.PreviewPageInfo.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Printing
+{
+ /// <summary>
+ /// Summary description for PreviewPageInfo.
+ /// </summary>
+ public sealed class PreviewPageInfo {
+ Image image;
+ Size physicalSize;
+ public PreviewPageInfo(Image image, Size physicalSize) {
+ this.image = image;
+ this.physicalSize = physicalSize;
+ }
+ public Image Image {
+ get{
+ return image;
+ }
+ }
+ public Size PhysicalSize{
+ get{
+ return physicalSize;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PreviewPrintController.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PreviewPrintController.cs
new file mode 100644
index 00000000000..63d26f5d89c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PreviewPrintController.cs
@@ -0,0 +1,87 @@
+//
+// System.Drawing.PreviewPrintController.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Printing
+{
+ public class PreviewPrintController : PrintController
+ {
+ private bool useantialias;
+
+ public PreviewPrintController()
+ {
+ useantialias = false;
+ }
+#if NET_2_0
+ [MonoTODO]
+ public virtual bool IsPreview {
+ get { throw new NotImplementedException(); }
+ }
+#endif
+
+ [MonoTODO]
+ public override void OnEndPage(PrintDocument document, PrintPageEventArgs e){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void OnStartPrint(PrintDocument document, PrintEventArgs e){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void OnEndPrint(PrintDocument document, PrintEventArgs e){
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e){
+ throw new NotImplementedException ();
+ }
+
+ public virtual bool UseAntiAlias {
+ get{
+ return useantialias;
+ }
+ set{
+ useantialias = value;
+ }
+ }
+
+ [MonoTODO]
+ public PreviewPageInfo [] GetPreviewPageInfo(){
+ throw new NotImplementedException ();
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintAction.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintAction.cs
new file mode 100644
index 00000000000..efe7aaef663
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintAction.cs
@@ -0,0 +1,45 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+//
+// Jordi Mas i Hernandez <jordimash@gmail.com>
+//
+//
+
+#if NET_2_0
+
+using System;
+
+namespace System.Drawing.Printing
+{
+ public enum PrintAction
+ {
+ PrintToFile = 0,
+ PrintToPreview = 1,
+ PrintToPrinter = 2
+ }
+
+}
+
+#endif
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintController.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintController.cs
new file mode 100644
index 00000000000..5855e3faaec
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintController.cs
@@ -0,0 +1,65 @@
+//
+// System.Drawing.PrintController.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Printing
+{
+ public abstract class PrintController
+ {
+ public PrintController ()
+ {
+ }
+#if NET_2_0
+ public virtual bool IsPreview {
+ get { return false; }
+ }
+#endif
+ public virtual void OnEndPage (PrintDocument document, PrintPageEventArgs e)
+ {
+ }
+
+ public virtual void OnStartPrint (PrintDocument document, PrintEventArgs e)
+ {
+ }
+
+ public virtual void OnEndPrint (PrintDocument document, PrintEventArgs e)
+ {
+ }
+
+
+ public virtual Graphics OnStartPage (PrintDocument document, PrintPageEventArgs e)
+ {
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintDocument.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintDocument.cs
new file mode 100644
index 00000000000..8c9c6d550e2
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintDocument.cs
@@ -0,0 +1,209 @@
+//
+// System.Drawing.PrintDocument.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Herve Poussineau (hpoussineau@fr.st)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+
+namespace System.Drawing.Printing
+{
+ [DefaultEvent ("PrintPage"), DefaultProperty ("DocumentName")]
+ [ToolboxItemFilter ("System.Drawing.Printing", ToolboxItemFilterType.Allow)]
+ public class PrintDocument : System.ComponentModel.Component
+ {
+ private PageSettings defaultpagesettings;
+ private PrinterSettings printersettings;
+ private PrintController printcontroller;
+ private string documentname;
+#if !(NET_1_0)
+ private bool originAtMargins = false; // .NET V1.1 Beta
+#endif
+
+ public PrintDocument() {
+ documentname = "document"; //offical default.
+ defaultpagesettings = new PageSettings(); // use default values of default printer
+ printersettings = new PrinterSettings(); // use default values
+ printcontroller = new StandardPrintController();
+ }
+
+ // properties
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [Browsable (false)]
+ [SRDescription ("The settings for the current page.")]
+ public PageSettings DefaultPageSettings{
+ get{
+ return defaultpagesettings;
+ }
+ set{
+ defaultpagesettings = value;
+ }
+ }
+
+ // Name of the document, not the file!
+ [DefaultValue ("document")]
+ [SRDescription ("The name of the document.")]
+ public string DocumentName{
+ get{
+ return documentname;
+ }
+ set{
+ documentname = value;
+ }
+ }
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [Browsable (false)]
+ [SRDescription ("The print controller object.")]
+ public PrintController PrintController{
+ get{
+ return printcontroller;
+ }
+ set{
+ printcontroller = value;
+ }
+ }
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [Browsable (false)]
+ [SRDescription ("The current settings for the active printer.")]
+ public PrinterSettings PrinterSettings{
+ get{
+ return printersettings;
+ }
+ set{
+ printersettings = value;
+ }
+ }
+
+#if !(NET_1_0)
+ [DefaultValue (false)]
+ [SRDescription ("Determines if the origin is set at the specified margins.")]
+ public bool OriginAtMargins{
+ get{
+ return originAtMargins;
+ }
+ set{
+ originAtMargins = value;
+ }
+ }
+#endif
+
+ // methods
+ public void Print(){
+ PrintEventArgs printArgs = new PrintEventArgs();
+ this.OnBeginPrint(printArgs);
+ if (printArgs.Cancel)
+ return;
+ PrintController.OnStartPrint(this, printArgs);
+ if (printArgs.Cancel)
+ return;
+
+ Graphics g = null;
+
+ // while there are more pages
+ PrintPageEventArgs printPageArgs;
+ do
+ {
+ PageSettings pageSettings = DefaultPageSettings.Clone() as PageSettings;
+ this.OnQueryPageSettings(new QueryPageSettingsEventArgs(pageSettings));
+
+ printPageArgs = new PrintPageEventArgs(
+ null,
+ pageSettings.Bounds,
+ new Rectangle(0, 0, pageSettings.PaperSize.Width, pageSettings.PaperSize.Height),
+ pageSettings);
+
+ if (g == null) {
+ g = Graphics.FromHdc (printArgs.GraphicsContext.Hdc);
+ printArgs.GraphicsContext.Graphics = g;
+ }
+
+ printPageArgs.GraphicsContext = printArgs.GraphicsContext;
+ PrintController.OnStartPage(this, printPageArgs);
+ // assign Graphics in printPageArgs
+ printPageArgs.SetGraphics(g);
+
+ if (!printPageArgs.Cancel)
+ this.OnPrintPage(printPageArgs);
+
+ PrintController.OnEndPage(this, printPageArgs);
+ if (printPageArgs.Cancel)
+ break;
+ } while (printPageArgs.HasMorePages);
+
+ this.OnEndPrint(printArgs);
+ PrintController.OnEndPrint(this, printArgs);
+ }
+
+ public override string ToString(){
+ return "[PrintDocument " + this.DocumentName + "]";
+ }
+
+ // events
+ protected virtual void OnBeginPrint(PrintEventArgs e){
+ //fire the event
+ if (BeginPrint != null)
+ BeginPrint(this, e);
+ }
+
+ protected virtual void OnEndPrint(PrintEventArgs e){
+ //fire the event
+ if (EndPrint != null)
+ EndPrint(this, e);
+ }
+
+ protected virtual void OnPrintPage(PrintPageEventArgs e){
+ //fire the event
+ if (PrintPage != null)
+ PrintPage(this, e);
+ }
+
+ protected virtual void OnQueryPageSettings(QueryPageSettingsEventArgs e){
+ //fire the event
+ if (QueryPageSettings != null)
+ QueryPageSettings(this, e);
+ }
+
+ [SRDescription ("Raised when printing begins")]
+ public event PrintEventHandler BeginPrint;
+
+ [SRDescription ("Raised when printing ends")]
+ public event PrintEventHandler EndPrint;
+
+ [SRDescription ("Raised when printing of a new page begins")]
+ public event PrintPageEventHandler PrintPage;
+
+ [SRDescription ("Raised before printing of a new page begins")]
+ public event QueryPageSettingsEventHandler QueryPageSettings;
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintEventArgs.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintEventArgs.cs
new file mode 100644
index 00000000000..94a4491b469
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintEventArgs.cs
@@ -0,0 +1,60 @@
+//
+// System.Drawing.PrintEventArgs.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+//NOTE: Complete! Aparently just a redifiniton of CancleEventArgs specific to Printing.
+namespace System.Drawing.Printing
+{
+ /// <summary>
+ /// Summary description for PrintEventArgs.
+ /// </summary>
+ public class PrintEventArgs : System.ComponentModel.CancelEventArgs
+ {
+ private GraphicsPrinter graphics_context;
+#if NET_2_0
+ internal PrintAction action;
+#endif
+
+ public PrintEventArgs()
+ {
+ }
+#if NET_2_0
+ public PrintAction PrintAction {
+ get { return action; }
+ }
+#endif
+
+ internal GraphicsPrinter GraphicsContext {
+ get { return graphics_context; }
+ set { graphics_context = value; }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintEventHandler.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintEventHandler.cs
new file mode 100644
index 00000000000..2cff92bcff1
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintEventHandler.cs
@@ -0,0 +1,40 @@
+//
+// System.Drawing.PrintEventHandler.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Printing
+{
+ /// <summary>
+ /// Summary description for PrintEventHandler.
+ /// </summary>
+ public delegate void PrintEventHandler(object sender, PrintEventArgs e);
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventArgs.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventArgs.cs
new file mode 100644
index 00000000000..859d5e38bf0
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventArgs.cs
@@ -0,0 +1,103 @@
+//
+// System.Drawing.PrintPageEventArgs.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Herve Poussineau (hpoussineau@fr.st)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+namespace System.Drawing.Printing {
+ /// <summary>
+ /// Summary description for PrintPageEventArgs.
+ /// </summary>
+ public class PrintPageEventArgs : EventArgs {
+ bool cancel;
+ Graphics graphics;
+ bool hasmorePages;
+ Rectangle marginBounds;
+ Rectangle pageBounds;
+ PageSettings pageSettings;
+ GraphicsPrinter graphics_context;
+
+ public PrintPageEventArgs(Graphics graphics, Rectangle marginBounds,
+ Rectangle pageBounds, PageSettings pageSettings) {
+ this.graphics = graphics;
+ this.marginBounds = marginBounds;
+ this.pageBounds = pageBounds;
+ this.pageSettings = pageSettings;
+ }
+ public bool Cancel {
+ get{
+ return cancel;
+ }
+ set{
+ cancel = value;
+ }
+ }
+ public Graphics Graphics {
+ get{
+ return graphics;
+ }
+ }
+ public bool HasMorePages {
+ get{
+ return hasmorePages;
+ }
+ set{
+ hasmorePages = value;
+ }
+ }
+ public Rectangle MarginBounds {
+ get{
+ return marginBounds;
+ }
+ }
+ public Rectangle PageBounds {
+ get{
+ return pageBounds;
+ }
+ }
+ public PageSettings PageSettings {
+ get{
+ return pageSettings;
+ }
+ }
+
+ // used in PrintDocument.Print()
+ internal void SetGraphics(Graphics g)
+ {
+ graphics = g;
+ }
+
+ internal GraphicsPrinter GraphicsContext {
+ get { return graphics_context; }
+ set { graphics_context = value; }
+ }
+}
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventHandler.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventHandler.cs
new file mode 100644
index 00000000000..e60998de74c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventHandler.cs
@@ -0,0 +1,40 @@
+//
+// System.Drawing.PrintPageEventHandler.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Printing
+{
+ /// <summary>
+ /// Summary description for PrintPageEventHandler.
+ /// </summary>
+ public delegate void PrintPageEventHandler(object sender, PrintPageEventArgs e);
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintRange.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintRange.cs
new file mode 100644
index 00000000000..a13e3eb9514
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintRange.cs
@@ -0,0 +1,44 @@
+//
+// System.Drawing.PrintRange.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Printing
+{
+#if NET_2_0
+ [Serializable]
+#endif
+ public enum PrintRange {
+ AllPages = 0,
+ Selection = 1,
+ SomePages = 2,
+#if NET_2_0
+ CurrentPage = 0x400000
+#endif
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolution.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolution.cs
new file mode 100644
index 00000000000..f6b20ecdba9
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolution.cs
@@ -0,0 +1,106 @@
+//
+// System.Drawing.Printing.PrinterResolution.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002 Ximian, Inc
+// (C) 2003 Andreas Nahr
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Printing
+{
+
+#if NET_2_0
+ [Serializable]
+#endif
+ public class PrinterResolution
+ {
+ private PrinterResolutionKind kind = PrinterResolutionKind.Custom;
+ private int x;
+ private int y;
+
+#if NET_2_0
+ public PrinterResolution ()
+ {
+ }
+#else
+ private PrinterResolution ()
+ {
+ }
+#endif
+
+ internal PrinterResolution (int x, int y, PrinterResolutionKind kind)
+ {
+ this.x = x;
+ this.y = y;
+ this.kind = kind;
+ }
+
+ public int X {
+ get {
+ return x;
+ }
+#if NET_2_0
+ set {
+ x = value;
+ }
+#endif
+ }
+
+ public int Y {
+ get {
+ return y;
+ }
+#if NET_2_0
+ set {
+ y = value;
+ }
+#endif
+ }
+
+ public PrinterResolutionKind Kind {
+ get {
+ return kind;
+ }
+#if NET_2_0
+ set {
+ kind = value;
+ }
+#endif
+ }
+
+ public override string ToString ()
+ {
+ if (kind != PrinterResolutionKind.Custom)
+ return "[PrinterResolution " + kind.ToString () + "]";
+
+ return "[PrinterResolution X=" + x + " Y=" + y + "]";
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolutionKind.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolutionKind.cs
new file mode 100644
index 00000000000..4b4b514f39f
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolutionKind.cs
@@ -0,0 +1,43 @@
+//
+// System.Drawing.PrinterResolutionKind.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Printing
+{
+#if NET_2_0
+ [Serializable]
+#endif
+ public enum PrinterResolutionKind {
+ Custom = 0,
+ Draft = -1,
+ High = -4,
+ Low = -2,
+ Medium = -3
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrinterSettings.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterSettings.cs
new file mode 100644
index 00000000000..d4deb296336
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterSettings.cs
@@ -0,0 +1,541 @@
+//
+// System.Drawing.PrinterSettings.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Herve Poussineau (hpoussineau@fr.st)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+using System.Collections;
+using System.Drawing.Printing;
+using System.ComponentModel;
+using System.Drawing.Imaging;
+
+namespace System.Drawing.Printing
+{
+ [Serializable]
+#if ! NET_2_0
+ [ComVisible(false)]
+#endif
+ public class PrinterSettings : ICloneable
+ {
+ private string printer_name;
+ private string print_filename;
+ private short copies;
+ private int maximum_page;
+ private int minimum_page;
+ private int from_page;
+ private int to_page;
+ private bool collate;
+ private PrintRange print_range;
+ internal int maximum_copies;
+ internal bool can_duplex;
+ internal bool supports_color;
+ internal int landscape_angle;
+ internal PrinterSettings.PrinterResolutionCollection printer_resolutions;
+ internal PrinterSettings.PaperSizeCollection paper_sizes;
+
+ public PrinterSettings() : this (SysPrn.Service.DefaultPrinter)
+ {
+ }
+
+ internal PrinterSettings (string printer)
+ {
+ printer_name = printer;
+ ResetToDefaults ();
+ SysPrn.Service.LoadPrinterSettings (printer_name, this);
+ }
+
+ private void ResetToDefaults ()
+ {
+ printer_resolutions = null;
+ paper_sizes = null;
+ maximum_page = 9999;
+ }
+
+ // Public subclasses
+
+ public class PaperSourceCollection : ICollection, IEnumerable
+ {
+ ArrayList _PaperSources = new ArrayList();
+
+ public PaperSourceCollection(PaperSource[] array) {
+ foreach (PaperSource ps in array)
+ _PaperSources.Add(ps);
+ }
+
+ public int Count { get { return _PaperSources.Count; } }
+ int ICollection.Count { get { return _PaperSources.Count; } }
+ bool ICollection.IsSynchronized { get { return false; } }
+ object ICollection.SyncRoot { get { return this; } }
+#if NET_2_0
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int Add (PaperSource paperSource) {throw new NotImplementedException (); }
+ public void CopyTo (PaperSource[] paperSources, int index) {throw new NotImplementedException (); }
+#endif
+
+ public virtual PaperSource this[int index] {
+ get { return _PaperSources[index] as PaperSource; }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return _PaperSources.GetEnumerator();
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return _PaperSources.GetEnumerator();
+ }
+
+ void ICollection.CopyTo(Array array, int index)
+ {
+ _PaperSources.CopyTo(array, index);
+ }
+ }
+
+ public class PaperSizeCollection : ICollection, IEnumerable
+ {
+ ArrayList _PaperSizes = new ArrayList();
+
+ public PaperSizeCollection(PaperSize[] array) {
+ foreach (PaperSize ps in array)
+ _PaperSizes.Add(ps);
+ }
+
+ public int Count { get { return _PaperSizes.Count; } }
+ int ICollection.Count { get { return _PaperSizes.Count; } }
+ bool ICollection.IsSynchronized { get { return false; } }
+ object ICollection.SyncRoot { get { return this; } }
+#if NET_2_0
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int Add (PaperSize paperSize) {return _PaperSizes.Add (paperSize); }
+ public void CopyTo (PaperSize[] paperSizes, int index) {throw new NotImplementedException (); }
+#else
+ internal int Add (PaperSize paperSize) {return _PaperSizes.Add (paperSize); }
+#endif
+
+ public virtual PaperSize this[int index] {
+ get { return _PaperSizes[index] as PaperSize; }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return _PaperSizes.GetEnumerator();
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return _PaperSizes.GetEnumerator();
+ }
+
+ void ICollection.CopyTo(Array array, int index)
+ {
+ _PaperSizes.CopyTo(array, index);
+ }
+
+ internal void Clear ()
+ {
+ _PaperSizes.Clear ();
+ }
+ }
+
+ public class PrinterResolutionCollection : ICollection, IEnumerable
+ {
+ ArrayList _PrinterResolutions = new ArrayList();
+
+ public PrinterResolutionCollection(PrinterResolution[] array) {
+ foreach (PrinterResolution pr in array)
+ _PrinterResolutions.Add(pr);
+ }
+
+ public int Count { get { return _PrinterResolutions.Count; } }
+ int ICollection.Count { get { return _PrinterResolutions.Count; } }
+ bool ICollection.IsSynchronized { get { return false; } }
+ object ICollection.SyncRoot { get { return this; } }
+#if NET_2_0
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int Add (PrinterResolution printerResolution) { return _PrinterResolutions.Add (printerResolution); }
+ public void CopyTo (PrinterResolution[] printerResolutions, int index) {throw new NotImplementedException (); }
+#else
+ internal int Add (PrinterResolution printerResolution) { return _PrinterResolutions.Add (printerResolution); }
+#endif
+
+ public virtual PrinterResolution this[int index] {
+ get { return _PrinterResolutions[index] as PrinterResolution; }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return _PrinterResolutions.GetEnumerator();
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return _PrinterResolutions.GetEnumerator();
+ }
+
+ void ICollection.CopyTo(Array array, int index)
+ {
+ _PrinterResolutions.CopyTo(array, index);
+ }
+
+ internal void Clear ()
+ {
+ _PrinterResolutions.Clear ();
+ }
+ }
+
+ public class StringCollection : ICollection, IEnumerable
+ {
+ ArrayList _Strings = new ArrayList();
+
+ public StringCollection(string[] array) {
+ foreach (string s in array)
+ _Strings.Add(s);
+ }
+
+ public int Count { get { return _Strings.Count; } }
+ int ICollection.Count { get { return _Strings.Count; } }
+ bool ICollection.IsSynchronized { get { return false; } }
+ object ICollection.SyncRoot { get { return this; } }
+
+ public virtual string this[int index] {
+ get { return _Strings[index] as string; }
+ }
+#if NET_2_0
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int Add (string value) { return _Strings.Add (value); }
+ public void CopyTo (string[] strings, int index) {throw new NotImplementedException (); }
+#else
+ internal int Add (string value) { return _Strings.Add (value); }
+#endif
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return _Strings.GetEnumerator();
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return _Strings.GetEnumerator();
+ }
+
+ void ICollection.CopyTo(Array array, int index)
+ {
+ _Strings.CopyTo(array, index);
+ }
+ }
+
+ //properties
+
+ public bool CanDuplex
+ {
+ get { return can_duplex; }
+ }
+
+ public bool Collate
+ {
+ get { return collate; }
+ set { collate = value; }
+ }
+
+ public short Copies
+ {
+ get { return copies; }
+ set {
+ if (value < 0)
+ throw new ArgumentException ("The value of the Copies property is less than zero.");
+
+ copies = value;
+ }
+ }
+
+ [MonoTODO("PrinterSettings.DefaultPageSettings")]
+ public PageSettings DefaultPageSettings
+ {
+ get
+ {
+ return new PageSettings(
+ this,
+ // TODO: get default color mode for this printer
+ false,
+ // TODO: get default orientation for this printer
+ false,
+ // TODO: get default paper size for this printer
+ new PaperSize("A4", 827, 1169),
+ // TODO: get default paper source for this printer
+ new PaperSource("default", PaperSourceKind.FormSource),
+ // TODO: get default resolution for this printer
+ new PrinterResolution(300, 300, PrinterResolutionKind.Medium)
+ );
+ }
+ }
+
+ [MonoTODO("PrinterSettings.Duplex")]
+ public Duplex Duplex
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ public int FromPage
+ {
+ get { return from_page; }
+ set {
+ if (value < 0)
+ throw new ArgumentException ("The value of the FromPage property is less than zero");
+
+ from_page = value;
+ }
+ }
+
+ public static PrinterSettings.StringCollection InstalledPrinters
+ {
+ get { return SysPrn.Service.InstalledPrinters; }
+ }
+
+ public bool IsDefaultPrinter
+ {
+ get { return (printer_name == SysPrn.Service.DefaultPrinter); }
+ }
+
+ [MonoTODO("PrinterSettings.IsPlotter")]
+ public bool IsPlotter
+ {
+ get { return false; }
+ }
+
+ [MonoTODO("PrinterSettings.IsValid")]
+ public bool IsValid
+ {
+ get { return true; }
+ }
+
+ public int LandscapeAngle
+ {
+ get { return landscape_angle; }
+ }
+
+ public int MaximumCopies
+ {
+ get { return maximum_copies; }
+ }
+
+ public int MaximumPage
+ {
+ get { return maximum_page; }
+ set {
+ // This not documented but behaves like MinimumPage
+ if (value < 0)
+ throw new ArgumentException ("The value of the MaximumPage property is less than zero");
+
+ maximum_page = value;
+ }
+ }
+
+ public int MinimumPage
+ {
+ get { return minimum_page; }
+ set {
+ if (value < 0)
+ throw new ArgumentException ("The value of the MaximumPage property is less than zero");
+
+ minimum_page = value;
+ }
+ }
+
+ public PrinterSettings.PaperSizeCollection PaperSizes
+ {
+ get {
+ if (paper_sizes == null) {
+ paper_sizes = new PrinterSettings.PaperSizeCollection (new PaperSize [] {});
+ SysPrn.Service.LoadPrinterPaperSizes (printer_name, this);
+ }
+ return paper_sizes;
+ }
+ }
+
+ [MonoTODO("PrinterSettings.PaperSources")]
+ public PrinterSettings.PaperSourceCollection PaperSources
+ {
+ get { throw new NotImplementedException(); }
+ }
+#if NET_2_0
+
+ public string PrintFileName
+ {
+ get { return print_filename; }
+ set { print_filename = value; }
+ }
+#endif
+ public string PrinterName
+ {
+ get { return printer_name; }
+ set {
+ if (printer_name == value)
+ return;
+
+ printer_name = value;
+ SysPrn.Service.LoadPrinterSettings (printer_name, this);
+ }
+ }
+
+ public PrinterSettings.PrinterResolutionCollection PrinterResolutions
+ {
+ get {
+ if (printer_resolutions == null) {
+ printer_resolutions = new PrinterSettings.PrinterResolutionCollection (new PrinterResolution[] {});
+ SysPrn.Service.LoadPrinterResolutions (printer_name, this);
+ }
+ return printer_resolutions;
+ }
+ }
+
+ public PrintRange PrintRange
+ {
+ get { return print_range; }
+ set {
+ if (value != PrintRange.AllPages && value != PrintRange.Selection &&
+ value != PrintRange.SomePages)
+ throw new InvalidEnumArgumentException ("The value of the PrintRange property is not one of the PrintRange values");
+
+ print_range = value;
+ }
+ }
+
+ [MonoTODO("PrinterSettings.PrintToFile")]
+ public bool PrintToFile
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ public bool SupportsColor
+ {
+ get { return supports_color; }
+ }
+
+ public int ToPage
+ {
+ get { return to_page; }
+ set {
+ if (value < 0)
+ throw new ArgumentException ("The value of the ToPage property is less than zero");
+
+ to_page = value;
+ }
+ }
+
+ //methods
+ public virtual object Clone()
+ {
+ PrinterSettings ps = new PrinterSettings (printer_name);
+ return ps;
+ }
+
+ [MonoTODO("PrinterSettings.CreateMeasurementGraphics")]
+ public Graphics CreateMeasurementGraphics()
+ {
+ throw new NotImplementedException();
+ }
+#if NET_2_0
+ [MonoTODO("PrinterSettings.CreateMeasurementGraphics")]
+ public Graphics CreateMeasurementGraphics(bool honorOriginAtMargins)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO("PrinterSettings.CreateMeasurementGraphics")]
+ public Graphics CreateMeasurementGraphics(PageSettings pageSettings)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO("PrinterSettings.CreateMeasurementGraphics")]
+ public Graphics CreateMeasurementGraphics (PageSettings pageSettings, bool honorOriginAtMargins)
+ {
+ throw new NotImplementedException();
+ }
+#endif
+
+ [MonoTODO("PrinterSettings.GetHdevmode")]
+ public IntPtr GetHdevmode()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO("PrinterSettings.GetHdevmode")]
+ public IntPtr GetHdevmode(PageSettings pageSettings)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO("PrinterSettings.GetHdevname")]
+ public IntPtr GetHdevnames()
+ {
+ throw new NotImplementedException();
+ }
+
+#if NET_2_0
+
+ [MonoTODO("IsDirectPrintingSupported")]
+ public bool IsDirectPrintingSupported (Image image)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO("IsDirectPrintingSupported")]
+ public bool IsDirectPrintingSupported (ImageFormat imageFormat)
+ {
+ throw new NotImplementedException();
+ }
+#endif
+
+ [MonoTODO("PrinterSettings.SetHdevmode")]
+ public void SetHdevmode(IntPtr hdevmode)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO("PrinterSettings.SetHdevnames")]
+ public void SetHdevnames(IntPtr hdevnames)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO("PrinterSettings.ToString")]
+ public override string ToString()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnit.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnit.cs
new file mode 100644
index 00000000000..ff9264c7bef
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnit.cs
@@ -0,0 +1,39 @@
+//
+// System.Drawing.PrinterUnit.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Printing
+{
+ public enum PrinterUnit {
+ Display = 0,
+ HundredthsOfAMillimeter = 2,
+ TenthsOfAMillimeter = 3,
+ ThousandthsOfAnInch = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnitConvert.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnitConvert.cs
new file mode 100644
index 00000000000..00452060da0
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnitConvert.cs
@@ -0,0 +1,139 @@
+//
+// System.Drawing.Printing.PrinterUnitConvert.cs
+//
+// Authors:
+// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Herve Poussineau (hpoussineau@fr.st)
+//
+// (C) 2003 Martin Willemoes Hansen
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Drawing.Printing
+{
+ public sealed class PrinterUnitConvert
+ {
+ private PrinterUnitConvert ()
+ {
+ }
+
+ public static double Convert (double value,
+ PrinterUnit fromUnit,
+ PrinterUnit toUnit)
+ {
+ switch (fromUnit)
+ {
+ case PrinterUnit.Display:
+ switch (toUnit)
+ {
+ case PrinterUnit.Display: return value;
+ case PrinterUnit.ThousandthsOfAnInch: return value * 10;
+ case PrinterUnit.HundredthsOfAMillimeter: return value * 25.4;
+ case PrinterUnit.TenthsOfAMillimeter: return value * 2.54;
+ }
+ break;
+ case PrinterUnit.ThousandthsOfAnInch:
+ switch (toUnit)
+ {
+ case PrinterUnit.Display: return value / 10;
+ case PrinterUnit.ThousandthsOfAnInch: return value;
+ case PrinterUnit.HundredthsOfAMillimeter: return value * 2.54;
+ case PrinterUnit.TenthsOfAMillimeter: return value * 0.254;
+ }
+ break;
+ case PrinterUnit.HundredthsOfAMillimeter:
+ switch (toUnit)
+ {
+ case PrinterUnit.Display: return value / 25.4;
+ case PrinterUnit.ThousandthsOfAnInch: return value / 2.54;
+ case PrinterUnit.HundredthsOfAMillimeter: return value;
+ case PrinterUnit.TenthsOfAMillimeter: return value / 10;
+ }
+ break;
+ case PrinterUnit.TenthsOfAMillimeter:
+ switch (toUnit)
+ {
+ case PrinterUnit.Display: return value / 2.54;
+ case PrinterUnit.ThousandthsOfAnInch: return value / 0.254;
+ case PrinterUnit.HundredthsOfAMillimeter: return value * 10;
+ case PrinterUnit.TenthsOfAMillimeter: return value;
+ }
+ break;
+ }
+ // should never happen
+ throw new NotImplementedException();
+ }
+
+ public static int Convert (int value,
+ PrinterUnit fromUnit,
+ PrinterUnit toUnit)
+ {
+ double rslt;
+ rslt = Convert ((double) value, fromUnit, toUnit);
+ return (int) Math.Round (rslt);
+
+ }
+
+ public static Margins Convert (Margins value,
+ PrinterUnit fromUnit,
+ PrinterUnit toUnit)
+ {
+ return new Margins(
+ Convert(value.Left, fromUnit, toUnit),
+ Convert(value.Right, fromUnit, toUnit),
+ Convert(value.Top, fromUnit, toUnit),
+ Convert(value.Bottom, fromUnit, toUnit));
+ }
+
+ public static Point Convert (Point value,
+ PrinterUnit fromUnit,
+ PrinterUnit toUnit)
+ {
+ return new Point(
+ Convert(value.X, fromUnit, toUnit),
+ Convert(value.Y, fromUnit, toUnit));
+ }
+
+ public static Rectangle Convert (Rectangle value,
+ PrinterUnit fromUnit,
+ PrinterUnit toUnit)
+ {
+ return new Rectangle(
+ Convert(value.X, fromUnit, toUnit),
+ Convert(value.Y, fromUnit, toUnit),
+ Convert(value.Width, fromUnit, toUnit),
+ Convert(value.Height, fromUnit, toUnit));
+ }
+
+ public static Size Convert (Size value,
+ PrinterUnit fromUnit,
+ PrinterUnit toUnit)
+ {
+ return new Size(
+ Convert(value.Width, fromUnit, toUnit),
+ Convert(value.Height, fromUnit, toUnit));
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermission.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermission.cs
new file mode 100644
index 00000000000..8aee6ce95cd
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermission.cs
@@ -0,0 +1,259 @@
+//
+// System.Drawing.PrintingPermission.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Herve Poussineau (hpoussineau@fr.st)
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// (C) 2002 Ximian, Inc
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Globalization;
+using System.Security;
+using System.Security.Permissions;
+
+namespace System.Drawing.Printing {
+
+ [Serializable]
+ public sealed class PrintingPermission : CodeAccessPermission, IUnrestrictedPermission {
+
+ private const int version = 1;
+
+ private PrintingPermissionLevel _Level;
+
+ public PrintingPermission (PermissionState state)
+ {
+ if (CheckPermissionState (state, true) == PermissionState.Unrestricted)
+ _Level = PrintingPermissionLevel.AllPrinting;
+ else
+ _Level = PrintingPermissionLevel.NoPrinting;
+ }
+
+ public PrintingPermission (PrintingPermissionLevel printingLevel)
+ {
+ Level = printingLevel;
+ }
+
+ // properties
+
+ public PrintingPermissionLevel Level{
+ get { return _Level; }
+ set {
+ if (!Enum.IsDefined (typeof (PrintingPermissionLevel), value)) {
+ string msg = Locale.GetText ("Invalid enum {0}");
+ throw new ArgumentException (String.Format (msg, value), "Level");
+ }
+ _Level = value;
+ }
+ }
+
+ // methods
+
+ public override IPermission Copy ()
+ {
+ return new PrintingPermission (this.Level);
+ }
+
+ public override void FromXml (SecurityElement esd)
+ {
+ CheckSecurityElement (esd, "esd", version, version);
+ // Note: we do not (yet) care about the return value
+ // as we only accept version 1 (min/max values)
+
+ if (IsUnrestricted (esd))
+ _Level = PrintingPermissionLevel.AllPrinting;
+ else {
+ string level = esd.Attribute ("Level");
+ if (level != null) {
+ _Level = (PrintingPermissionLevel) Enum.Parse (
+ typeof (PrintingPermissionLevel), level);
+ }
+ else
+ _Level = PrintingPermissionLevel.NoPrinting;
+ }
+ }
+
+ public override IPermission Intersect (IPermission target)
+ {
+ PrintingPermission pp = Cast (target);
+ if ((pp == null) || IsEmpty () || pp.IsEmpty ())
+ return null;
+
+ PrintingPermissionLevel level = (_Level <= pp.Level) ? _Level : pp.Level;
+ return new PrintingPermission (level);
+ }
+
+ public override bool IsSubsetOf (IPermission target)
+ {
+ PrintingPermission pp = Cast (target);
+ if (pp == null)
+ return IsEmpty ();
+
+ return (_Level <= pp.Level);
+ }
+
+ public bool IsUnrestricted ()
+ {
+ return (_Level == PrintingPermissionLevel.AllPrinting);
+ }
+
+ public override SecurityElement ToXml ()
+ {
+ SecurityElement se = Element (version);
+ if (IsUnrestricted ())
+ se.AddAttribute ("Unrestricted", "true");
+ else
+ se.AddAttribute ("Level", _Level.ToString ());
+ return se;
+ }
+
+ public override IPermission Union (IPermission target)
+ {
+ PrintingPermission pp = Cast (target);
+ if (pp == null)
+ return new PrintingPermission (_Level);
+ if (IsUnrestricted () || pp.IsUnrestricted ())
+ return new PrintingPermission (PermissionState.Unrestricted);
+ if (IsEmpty () && pp.IsEmpty ())
+ return null;
+
+ PrintingPermissionLevel level = (_Level > pp.Level) ? _Level : pp.Level;
+ return new PrintingPermission (level);
+ }
+
+ // Internal helpers methods
+
+ private bool IsEmpty ()
+ {
+ return (_Level == PrintingPermissionLevel.NoPrinting);
+ }
+
+ private PrintingPermission Cast (IPermission target)
+ {
+ if (target == null)
+ return null;
+
+ PrintingPermission pp = (target as PrintingPermission);
+ if (pp == null) {
+ ThrowInvalidPermission (target, typeof (PrintingPermission));
+ }
+
+ return pp;
+ }
+
+ // NOTE: The following static methods should be moved out to a (static?) class
+ // if (ever) System.Drawing.dll gets more than one permission in it's assembly.
+
+ // snippet moved from FileIOPermission (nickd) to be reused in all derived classes
+ internal SecurityElement Element (int version)
+ {
+ SecurityElement se = new SecurityElement ("IPermission");
+ Type type = this.GetType ();
+ se.AddAttribute ("class", type.FullName + ", " + type.Assembly.ToString ().Replace ('\"', '\''));
+ se.AddAttribute ("version", version.ToString ());
+ return se;
+ }
+
+ internal static PermissionState CheckPermissionState (PermissionState state, bool allowUnrestricted)
+ {
+ string msg;
+ switch (state) {
+ case PermissionState.None:
+ break;
+ case PermissionState.Unrestricted:
+ if (!allowUnrestricted) {
+ msg = Locale.GetText ("Unrestricted isn't not allowed for identity permissions.");
+ throw new ArgumentException (msg, "state");
+ }
+ break;
+ default:
+ msg = String.Format (Locale.GetText ("Invalid enum {0}"), state);
+ throw new ArgumentException (msg, "state");
+ }
+ return state;
+ }
+
+ // logic isn't identical to CodeAccessPermission.CheckSecurityElement - see unit tests
+ internal static int CheckSecurityElement (SecurityElement se, string parameterName, int minimumVersion, int maximumVersion)
+ {
+ if (se == null)
+ throw new ArgumentNullException (parameterName);
+
+ string c = se.Attribute ("class");
+#if NET_2_0
+ if (c == null) {
+ string msg = Locale.GetText ("Missing 'class' attribute.");
+ throw new ArgumentException (msg, parameterName);
+ }
+#else
+ if ((c == null) || (String.Compare (c, 0, "System.Drawing.Printing.PrintingPermission", 0, 42) != 0)) {
+ string msg = Locale.GetText ("Wrong 'class' attribute.");
+ throw new ArgumentException (msg, parameterName);
+ }
+#endif
+ // we assume minimum version if no version number is supplied
+ int version = minimumVersion;
+ string v = se.Attribute ("version");
+ if (v != null) {
+ try {
+ version = Int32.Parse (v);
+ }
+ catch (Exception e) {
+ string msg = Locale.GetText ("Couldn't parse version from '{0}'.");
+ msg = String.Format (msg, v);
+ throw new ArgumentException (msg, parameterName, e);
+ }
+ }
+#if !NET_2_0
+ else {
+ string msg = Locale.GetText ("Missing 'version' attribute.");
+ throw new ArgumentException (msg, parameterName);
+ }
+#endif
+
+ if ((version < minimumVersion) || (version > maximumVersion)) {
+ string msg = Locale.GetText ("Unknown version '{0}', expected versions between ['{1}','{2}'].");
+ msg = String.Format (msg, version, minimumVersion, maximumVersion);
+ throw new ArgumentException (msg, parameterName);
+ }
+ return version;
+ }
+
+ // must be called after CheckSecurityElement (i.e. se != null)
+ internal static bool IsUnrestricted (SecurityElement se)
+ {
+ string value = se.Attribute ("Unrestricted");
+ if (value == null)
+ return false;
+ return (String.Compare (value, Boolean.TrueString, true, CultureInfo.InvariantCulture) == 0);
+ }
+
+ internal static void ThrowInvalidPermission (IPermission target, Type expected)
+ {
+ string msg = Locale.GetText ("Invalid permission type '{0}', expected type '{1}'.");
+ msg = String.Format (msg, target.GetType (), expected);
+ throw new ArgumentException (msg, "target");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionAttribute.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionAttribute.cs
new file mode 100644
index 00000000000..da6623c14eb
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionAttribute.cs
@@ -0,0 +1,69 @@
+//
+// System.Drawing.PrintingPermissionAttribute.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Herve Poussineau (hpoussineau@fr.st)
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// (C) 2002 Ximian, Inc
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Security;
+using System.Security.Permissions;
+
+namespace System.Drawing.Printing {
+
+ [AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
+ // strangely this class isn't [Serializable] like other permission classes
+ public sealed class PrintingPermissionAttribute : CodeAccessSecurityAttribute {
+
+ private PrintingPermissionLevel _level;
+
+ public PrintingPermissionAttribute (SecurityAction action)
+ : base (action)
+ {
+ // seems to always assign PrintingPermissionLevel.NoPrinting ...
+ _level = PrintingPermissionLevel.NoPrinting;
+ }
+
+ public PrintingPermissionLevel Level {
+ get { return _level; }
+ set {
+ if (!Enum.IsDefined (typeof (PrintingPermissionLevel), value)) {
+ string msg = Locale.GetText ("Invalid enum {0}");
+ throw new ArgumentException (String.Format (msg, value), "Level");
+ }
+ _level = value;
+ }
+ }
+
+ public override IPermission CreatePermission ()
+ {
+ if (base.Unrestricted)
+ return new PrintingPermission (PermissionState.Unrestricted);
+ else
+ return new PrintingPermission (_level);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionLevel.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionLevel.cs
new file mode 100644
index 00000000000..16e3ad80f4b
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionLevel.cs
@@ -0,0 +1,41 @@
+//
+// System.Drawing.PrintingPermissionLevel.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Drawing.Printing {
+
+#if NET_2_0
+ [Serializable]
+#endif
+ public enum PrintingPermissionLevel {
+ AllPrinting = 3,
+ DefaultPrinting = 2,
+ NoPrinting = 0,
+ SafePrinting = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServices.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServices.cs
new file mode 100644
index 00000000000..aac6dff9e84
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServices.cs
@@ -0,0 +1,102 @@
+//
+// Copyright (C) 2005 Novell, Inc. http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Author:
+//
+// Jordi Mas i Hernandez, jordimash@gmail.com
+//
+
+using System.Runtime.InteropServices;
+using System.Collections;
+using System.Drawing.Printing;
+using System.ComponentModel;
+using System.Drawing.Imaging;
+
+namespace System.Drawing.Printing
+{
+ internal abstract class PrintingServices
+ {
+ // Properties
+ internal abstract PrinterSettings.StringCollection InstalledPrinters { get; }
+ internal abstract string DefaultPrinter { get; }
+
+
+ // Methods
+ internal abstract bool StartDoc (GraphicsPrinter gr, string doc_name, string output_file);
+ internal abstract IntPtr CreateGraphicsContext (PrinterSettings settings);
+ internal abstract bool StartPage (GraphicsPrinter gr);
+ internal abstract bool EndPage (GraphicsPrinter gr);
+ internal abstract bool EndDoc (GraphicsPrinter gr);
+
+ internal abstract void LoadPrinterSettings (string printer, PrinterSettings settings);
+ internal abstract void LoadPrinterResolutions (string printer, PrinterSettings settings);
+ internal abstract void LoadPrinterPaperSizes (string printer, PrinterSettings settings);
+
+ internal void LoadDefaultResolutions (PrinterSettings.PrinterResolutionCollection col)
+ {
+ col.Add (new PrinterResolution ((int) PrinterResolutionKind.High, -1, PrinterResolutionKind.High));
+ col.Add (new PrinterResolution ((int) PrinterResolutionKind.Medium, -1, PrinterResolutionKind.Medium));
+ col.Add (new PrinterResolution ((int) PrinterResolutionKind.Low, -1, PrinterResolutionKind.Low));
+ col.Add (new PrinterResolution ((int) PrinterResolutionKind.Draft, -1, PrinterResolutionKind.Draft));
+ }
+ }
+
+ internal class SysPrn
+ {
+ static PrintingServices service;
+
+ static SysPrn ()
+ {
+ int platform = (int) Environment.OSVersion.Platform;
+
+ if (platform == 4 || platform == 128) {
+ service = new PrintingServicesUnix ();
+ } else {
+ service = new PrintingServicesWin32 ();
+ }
+ }
+
+ static internal PrintingServices Service {
+ get { return service; }
+ }
+ }
+
+ internal class GraphicsPrinter
+ {
+ private Graphics graphics;
+ private IntPtr hDC;
+
+ internal GraphicsPrinter (Graphics gr, IntPtr dc)
+ {
+ graphics = gr;
+ hDC = dc;
+ }
+
+ internal Graphics Graphics {
+ get { return graphics; }
+ set { graphics = value; }
+ }
+ internal IntPtr Hdc { get { return hDC; }}
+ }
+}
+
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesUnix.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesUnix.cs
new file mode 100644
index 00000000000..ce4af5dc18d
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesUnix.cs
@@ -0,0 +1,354 @@
+//
+// Copyright (C) 2005 Novell, Inc. http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Author:
+//
+// Jordi Mas i Hernandez, jordimash@gmail.com
+//
+
+using System.Runtime.InteropServices;
+using System.Collections;
+using System.Drawing.Printing;
+using System.ComponentModel;
+using System.Drawing.Imaging;
+using System.Text;
+
+namespace System.Drawing.Printing
+{
+ internal class PrintingServicesUnix : PrintingServices
+ {
+ private Hashtable doc_info = new Hashtable ();
+
+ internal PrintingServicesUnix ()
+ {
+
+ }
+
+ // Methods
+ internal override void LoadPrinterSettings (string printer, PrinterSettings settings)
+ {
+ IntPtr ptr, ppd_handle;
+ string ppd_filename;
+ PPD_FILE ppd;
+
+ ptr = cupsGetPPD (printer);
+ ppd_filename = Marshal.PtrToStringAnsi (ptr);
+ ppd_handle = ppdOpenFile (ppd_filename);
+ //Console.WriteLine ("File: {0}", ppd_filename);
+
+ ppd = (PPD_FILE) Marshal.PtrToStructure (ppd_handle, typeof (PPD_FILE));
+ settings.landscape_angle = ppd.landscape;
+ settings.supports_color = (ppd.color_device == 0) ? false : true;
+ ppdClose (ppd_handle);
+ }
+
+ internal override void LoadPrinterResolutions (string printer, PrinterSettings settings)
+ {
+ settings.PrinterResolutions.Clear ();
+ LoadDefaultResolutions (settings.PrinterResolutions);
+ }
+
+ internal override void LoadPrinterPaperSizes (string printer, PrinterSettings settings)
+ {
+ IntPtr ptr, ppd_handle;
+ string ppd_filename, real_name;
+ PPD_FILE ppd;
+ PPD_SIZE size;
+ PaperSize ps;
+ PaperKind kind = PaperKind.Custom;
+
+ settings.PaperSizes.Clear ();
+
+ ptr = cupsGetPPD (printer);
+ ppd_filename = Marshal.PtrToStringAnsi (ptr);
+ ppd_handle = ppdOpenFile (ppd_filename);
+
+ ppd = (PPD_FILE) Marshal.PtrToStructure (ppd_handle, typeof (PPD_FILE));
+ ptr = ppd.sizes;
+ float w, h;
+ for (int i = 0; i < ppd.num_sizes; i++) {
+ size = (PPD_SIZE) Marshal.PtrToStructure (ptr, typeof (PPD_SIZE));
+ real_name = GetPaperSizeName (ppd, size.name);
+ ptr = new IntPtr (ptr.ToInt64 () + Marshal.SizeOf (size));
+
+ w = size.width * 100 / 72;
+ h = size.length * 100 / 72;
+ ps = new PaperSize (real_name, (int) w, (int) h);
+ // TODO: Convert from name to paper kind enum
+ ps.SetKind (kind);
+ settings.PaperSizes.Add (ps);
+ }
+
+ ppdClose (ppd_handle);
+ }
+
+ internal override bool StartPage (GraphicsPrinter gr)
+ {
+ return true;
+ }
+
+ internal override bool EndPage (GraphicsPrinter gr)
+ {
+ GdipGetPostScriptSavePage (gr.Hdc);
+ return true;
+ }
+
+ internal override bool EndDoc (GraphicsPrinter gr)
+ {
+ DOCINFO doc = (DOCINFO) doc_info[gr.Hdc];
+
+ gr.Graphics.Dispose (); // Dispose object to force surface finish
+ cupsPrintFile (doc.settings.PrinterName, doc.filename, doc.title, 0, IntPtr.Zero);
+ doc_info.Remove (gr.Hdc);
+ //TODO: Delete temporary file created
+ return true;
+ }
+
+ internal override bool StartDoc (GraphicsPrinter gr, string doc_name, string output_file)
+ {
+ DOCINFO doc = (DOCINFO) doc_info[gr.Hdc];
+ doc.title = doc_name;
+ return true;
+ }
+
+ internal override IntPtr CreateGraphicsContext (PrinterSettings settings)
+ {
+ IntPtr graphics = IntPtr.Zero;
+ StringBuilder name = new StringBuilder (1024);
+ int length = name.Capacity;
+ cupsTempFile (name, length);
+
+ GdipGetPostScriptGraphicsContext (name.ToString(),
+ settings.DefaultPageSettings.PaperSize.Width / 100 * 72,
+ settings.DefaultPageSettings.PaperSize.Height / 100 * 72,
+ // Harcoded dpy's
+ 300, 300, ref graphics);
+
+ DOCINFO doc = new DOCINFO ();
+ doc.filename = name.ToString();
+ doc.settings = settings;
+ doc_info.Add (graphics, doc);
+
+ return graphics;
+ }
+
+ // Properties
+
+ internal override PrinterSettings.StringCollection InstalledPrinters {
+ get {
+ int n_printers;
+ IntPtr printers = IntPtr.Zero, ptr_printers, ptr_printer;
+ string str;
+ PrinterSettings.StringCollection col = new PrinterSettings.StringCollection (new string[] {});
+
+ n_printers = cupsGetPrinters (ref printers);
+
+ ptr_printers = printers;
+ for (int i = 0; i < n_printers; i++) {
+ ptr_printer = (IntPtr) Marshal.ReadInt32 (ptr_printers);
+ str = Marshal.PtrToStringAnsi (ptr_printer);
+ ptr_printers = new IntPtr (ptr_printers.ToInt64 () + 4);
+ col.Add (str);
+ }
+ Marshal.FreeHGlobal (printers);
+ return col;
+ }
+ }
+
+ internal override string DefaultPrinter {
+ get {
+ IntPtr str;
+ str = cupsGetDefault ();
+ return Marshal.PtrToStringAnsi (str);
+ }
+ }
+
+ // Private functions
+
+ private string GetPaperSizeName (PPD_FILE ppd, string name)
+ {
+ string rslt = name;
+ PPD_GROUP group;
+ PPD_OPTION option;
+ PPD_CHOICE choice;
+ IntPtr ptr, ptr_opt, ptr_choice;
+
+ ptr = ppd.groups;
+ for (int i = 0; i < ppd.num_groups; i++) {
+ group = (PPD_GROUP) Marshal.PtrToStructure (ptr, typeof (PPD_GROUP));
+ //Console.WriteLine ("Size text:{0} name:{1} opts {2}", group.text, group.name, group.num_options);
+ ptr = new IntPtr (ptr.ToInt64 () + Marshal.SizeOf (group));
+
+ ptr_opt = group.options;
+ for (int n = 0; n < group.num_options; n++) {
+ option = (PPD_OPTION) Marshal.PtrToStructure (ptr_opt, typeof (PPD_OPTION));
+ ptr_opt = new IntPtr (ptr_opt.ToInt64 () + Marshal.SizeOf (option));
+ //Console.WriteLine (" key:{0} def:{1} text: {2}", option.keyword, option.defchoice, option.text);
+
+ if (!option.keyword.Equals ("PageSize"))
+ continue;
+
+ ptr_choice = option.choices;
+ for (int c = 0; c < option.num_choices; c++) {
+ choice = (PPD_CHOICE) Marshal.PtrToStructure (ptr_choice, typeof (PPD_CHOICE));
+ ptr_choice = new IntPtr (ptr_choice.ToInt64 () + Marshal.SizeOf (choice));
+ //Console.WriteLine (" choice:{0} - text: {1}", choice.choice, choice.text);
+ if (name.Equals (choice.choice)) {
+ rslt = choice.text;
+ break;
+ }
+ }
+ }
+ }
+
+ return rslt;
+ }
+
+
+ //
+ // DllImports
+ //
+
+ [DllImport("libcups", CharSet=CharSet.Ansi)]
+ static extern int cupsGetPrinters (ref IntPtr printers);
+
+ [DllImport("libcups", CharSet=CharSet.Ansi)]
+ static extern IntPtr cupsTempFile (StringBuilder sb, int len);
+
+ [DllImport("libcups", CharSet=CharSet.Ansi)]
+ static extern IntPtr cupsGetDefault ();
+
+ [DllImport("libcups", CharSet=CharSet.Ansi)]
+ static extern int cupsPrintFile (string printer, string filename, string title, int num_options, IntPtr options);
+
+ [DllImport("libcups", CharSet=CharSet.Ansi)]
+ static extern IntPtr cupsGetPPD (string printer);
+
+ [DllImport("libcups", CharSet=CharSet.Ansi)]
+ static extern IntPtr ppdOpenFile (string filename);
+
+ [DllImport("libcups")]
+ static extern void ppdClose (IntPtr ppd);
+
+ [DllImport("libgdiplus", CharSet=CharSet.Ansi)]
+ static extern int GdipGetPostScriptGraphicsContext (string filename, int with, int height, double dpix, double dpiy, ref IntPtr graphics);
+
+ [DllImport("libgdiplus")]
+ static extern int GdipGetPostScriptSavePage (IntPtr graphics);
+
+
+ //Struct
+ public struct DOCINFO
+ {
+ public PrinterSettings settings;
+ public string title;
+ public string filename;
+ }
+
+ public struct PPD_SIZE
+ {
+ public int marked;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=42)]
+ public string name;
+ public float width;
+ public float length;
+ public float left;
+ public float bottom;
+ public float right;
+ public float top;
+ }
+
+ public struct PPD_GROUP
+ {
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=40)]
+ public string text;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=42)]
+ public string name;
+ public int num_options;
+ public IntPtr options;
+ public int num_subgroups;
+ public IntPtr subgrups;
+ }
+
+ public struct PPD_OPTION
+ {
+ public byte conflicted;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=41)]
+ public string keyword;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=41)]
+ public string defchoice;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=81)]
+ public string text;
+ public int ui;
+ public int section;
+ public float order;
+ public int num_choices;
+ public IntPtr choices;
+ }
+
+ public struct PPD_CHOICE
+ {
+ public byte marked;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=41)]
+ public string choice;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=81)]
+ public string text;
+ public IntPtr code;
+ public IntPtr option;
+ }
+
+ public struct PPD_FILE
+ {
+ public int language_level;
+ public int color_device;
+ public int variable_sizes;
+ public int accurate_screens;
+ public int contone_only;
+ public int landscape;
+ public int model_number;
+ public int manual_copies;
+ public int throughput;
+ public int colorspace;
+ public IntPtr patches;
+ public int num_emulations;
+ public IntPtr emulations;
+ public IntPtr jcl_begin;
+ public IntPtr jcl_ps;
+ public IntPtr jcl_end;
+ public IntPtr lang_encoding;
+ public IntPtr lang_version;
+ public IntPtr modelname;
+ public IntPtr ttrasterizer;
+ public IntPtr manufacturer;
+ public IntPtr product;
+ public IntPtr nickname;
+ public IntPtr shortnickname;
+ public int num_groups;
+ public IntPtr groups;
+ public int num_sizes;
+ public IntPtr sizes;
+
+ /* There is more data after this that we are not using*/
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesWin32.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesWin32.cs
new file mode 100644
index 00000000000..52f7ef55b91
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesWin32.cs
@@ -0,0 +1,339 @@
+//
+// Copyright (C) 2005 Novell, Inc. http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Author:
+//
+// Jordi Mas i Hernandez, jordimash@gmail.com
+//
+
+using System.Runtime.InteropServices;
+using System.Collections;
+using System.Drawing.Printing;
+using System.ComponentModel;
+using System.Text;
+
+namespace System.Drawing.Printing
+{
+ internal class PrintingServicesWin32 : PrintingServices
+ {
+ internal PrintingServicesWin32 ()
+ {
+
+ }
+
+ internal override void LoadPrinterSettings (string printer, PrinterSettings settings)
+ {
+ int ret;
+
+ settings.maximum_copies = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_COPIES, IntPtr.Zero, IntPtr.Zero);
+
+ ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_DUPLEX, IntPtr.Zero, IntPtr.Zero);
+ settings.can_duplex = (ret == 1) ? true : false;
+
+ ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_COLORDEVICE, IntPtr.Zero, IntPtr.Zero);
+ settings.supports_color = (ret == 1) ? true : false;
+
+ ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_ORIENTATION, IntPtr.Zero, IntPtr.Zero);
+ if (ret != -1)
+ settings.landscape_angle = ret;
+ }
+
+ internal override void LoadPrinterResolutions (string printer, PrinterSettings settings)
+ {
+ int ret;
+ IntPtr ptr, buff = IntPtr.Zero;
+
+ settings.PrinterResolutions.Clear ();
+ LoadDefaultResolutions (settings.PrinterResolutions);
+ ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_ENUMRESOLUTIONS, IntPtr.Zero, IntPtr.Zero);
+
+ if (ret == -1)
+ return;
+
+ ptr = buff = Marshal.AllocHGlobal (ret * 2 * Marshal.SizeOf (buff));
+ ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_ENUMRESOLUTIONS, buff, IntPtr.Zero);
+ int x, y;
+ if (ret != -1) {
+ for (int i = 0; i < ret; i++) {
+ x = Marshal.ReadInt32 (ptr);
+ ptr = new IntPtr (ptr.ToInt64 () + Marshal.SizeOf (x));
+ y = Marshal.ReadInt32 (ptr);
+ ptr = new IntPtr (ptr.ToInt64 () + Marshal.SizeOf (y));
+ settings.PrinterResolutions.Add (new PrinterResolution
+ (x,y, PrinterResolutionKind.Custom));
+ }
+ }
+ Marshal.FreeHGlobal (buff);
+ }
+
+ internal override void LoadPrinterPaperSizes (string printer, PrinterSettings settings)
+ {
+ int items, ret;
+ IntPtr ptr_names, buff_names = IntPtr.Zero;
+ IntPtr ptr_sizes, buff_sizes = IntPtr.Zero;
+ IntPtr ptr_sizes_enum, buff_sizes_enum = IntPtr.Zero;
+ string name;
+
+ settings.PaperSizes.Clear ();
+ items = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERSIZE, IntPtr.Zero, IntPtr.Zero);
+
+ if (items == -1)
+ return;
+
+ ptr_sizes = buff_sizes = Marshal.AllocHGlobal (items * 2 * 4);
+ ptr_names = buff_names = Marshal.AllocHGlobal (items * 64 * 2);
+ ptr_sizes_enum = buff_sizes_enum = Marshal.AllocHGlobal (items * 2);
+ ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERSIZE, buff_sizes, IntPtr.Zero);
+
+ if (ret == -1)
+ return;
+
+ ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERS, buff_sizes_enum, IntPtr.Zero);
+ ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERNAMES, buff_names, IntPtr.Zero);
+
+ int x, y;
+ PaperSize ps;
+ PaperKind kind;
+ for (int i = 0; i < ret; i++) {
+ x = Marshal.ReadInt32 (ptr_sizes);
+ ptr_sizes = new IntPtr (ptr_sizes.ToInt64 () + 4);
+ y = Marshal.ReadInt32 (ptr_sizes);
+ ptr_sizes = new IntPtr (ptr_sizes.ToInt64 () + 4);
+
+ x = PrinterUnitConvert.Convert (x, PrinterUnit.TenthsOfAMillimeter,
+ PrinterUnit.Display);
+
+ y = PrinterUnitConvert.Convert (y, PrinterUnit.TenthsOfAMillimeter,
+ PrinterUnit.Display);
+
+ name = Marshal.PtrToStringUni (ptr_names);
+ ptr_names = new IntPtr (ptr_names.ToInt64 () + 64 * 2);
+
+ kind = (PaperKind) Marshal.ReadInt16 (ptr_sizes_enum);
+ ptr_sizes_enum = new IntPtr (ptr_sizes_enum.ToInt64 () + 2);
+
+ ps = new PaperSize (name, x,y);
+ ps.SetKind (kind);
+ settings.PaperSizes.Add (ps);
+ }
+ Marshal.FreeHGlobal (buff_names);
+ Marshal.FreeHGlobal (buff_sizes);
+ Marshal.FreeHGlobal (buff_sizes_enum);
+ }
+
+ internal override bool StartDoc (GraphicsPrinter gr, string doc_name, string output_file)
+ {
+ DOCINFO di = new DOCINFO ();
+ int ret;
+
+ di.cbSize = Marshal.SizeOf (di);
+ di.lpszDocName = Marshal.StringToHGlobalUni (doc_name);
+ di.lpszOutput = IntPtr.Zero;
+ di.lpszDatatype = IntPtr.Zero;
+ di.fwType = 0;
+
+ ret = Win32StartDoc (gr.Hdc, ref di);
+ Marshal.FreeHGlobal (di.lpszDocName);
+ return (ret > 0) ? true : false;
+ }
+
+ internal override bool StartPage (GraphicsPrinter gr)
+ {
+ int ret = Win32StartPage (gr.Hdc);
+ return (ret > 0) ? true : false;
+ }
+
+ internal override bool EndPage (GraphicsPrinter gr)
+ {
+ int ret = Win32EndPage (gr.Hdc);
+ return (ret > 0) ? true : false;
+ }
+
+ internal override bool EndDoc (GraphicsPrinter gr)
+ {
+ int ret = Win32EndDoc (gr.Hdc);
+ Win32DeleteDC (gr.Hdc);
+ gr.Graphics.Dispose ();
+ return (ret > 0) ? true : false;
+ }
+
+ internal override IntPtr CreateGraphicsContext (PrinterSettings settings)
+ {
+ IntPtr dc = IntPtr.Zero;
+ dc = Win32CreateDC (null, settings.PrinterName, null, IntPtr.Zero /* DEVMODE */);
+ return dc;
+ }
+
+ // Properties
+ internal override string DefaultPrinter {
+ get {
+ StringBuilder name = new StringBuilder (1024);
+ int length = name.Capacity;
+
+ Win32GetDefaultPrinter (name, ref length);
+ return name.ToString ();
+ }
+ }
+
+ internal override PrinterSettings.StringCollection InstalledPrinters {
+ get {
+ PrinterSettings.StringCollection col = new PrinterSettings.StringCollection (new string[] {});
+ PRINTER_INFO printer_info;
+ uint cbNeeded = 0, printers = 0;
+ IntPtr ptr, buff;
+ string s;
+
+ // Determine space need it
+ Win32EnumPrinters (2 /* PRINTER_ENUM_LOCAL */,
+ null, 2, IntPtr.Zero, 0, ref cbNeeded, ref printers);
+
+ ptr = buff = Marshal.AllocHGlobal ((int) cbNeeded);
+
+ // Give us the printer list
+ Win32EnumPrinters (2 /* PRINTER_ENUM_LOCAL */,
+ null, 2, buff, (uint)cbNeeded, ref cbNeeded, ref printers);
+
+ for (int i = 0; i < printers; i++) {
+ printer_info = (PRINTER_INFO) Marshal.PtrToStructure (ptr, typeof (PRINTER_INFO));
+ s = Marshal.PtrToStringUni (printer_info.pPrinterName);
+ col.Add (s);
+ ptr = new IntPtr (ptr.ToInt64 () + Marshal.SizeOf (printer_info));
+ }
+
+ Marshal.FreeHGlobal (buff);
+ return col;
+ }
+ }
+
+ //
+ // DllImports
+ //
+
+ [DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="DeviceCapabilities", SetLastError=true)]
+ static extern int Win32DeviceCapabilities (string device, string port, DCCapabilities cap, IntPtr outputBuffer, IntPtr deviceMode);
+
+ [DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="EnumPrinters", SetLastError=true)]
+ static extern int Win32EnumPrinters (int Flags, string Name, uint Level, IntPtr pPrinterEnum, uint cbBuf,
+ ref uint pcbNeeded, ref uint pcReturned);
+
+ [DllImport("winspool.drv", EntryPoint="GetDefaultPrinter", CharSet=CharSet.Unicode, SetLastError=true)]
+ private static extern int Win32GetDefaultPrinter (StringBuilder buffer, ref int bufferSize);
+
+ [DllImport("gdi32.dll", EntryPoint="CreateDC")]
+ static extern IntPtr Win32CreateDC (string lpszDriver, string lpszDevice,
+ string lpszOutput, IntPtr lpInitData);
+
+ [DllImport("gdi32.dll", CharSet=CharSet.Unicode, EntryPoint="StartDoc")]
+ static extern int Win32StartDoc (IntPtr hdc, [In] ref DOCINFO lpdi);
+
+ [DllImport("gdi32.dll", EntryPoint="StartPage")]
+ static extern int Win32StartPage (IntPtr hDC);
+
+ [DllImport("gdi32.dll", EntryPoint="EndPage")]
+ static extern int Win32EndPage (IntPtr hdc);
+
+ [DllImport("gdi32.dll", EntryPoint="EndDoc")]
+ static extern int Win32EndDoc (IntPtr hdc);
+
+ [DllImport("gdi32.dll", EntryPoint="DeleteDC")]
+ public static extern IntPtr Win32DeleteDC (IntPtr hDc);
+
+ //
+ // Structs
+ //
+ [StructLayout (LayoutKind.Sequential)]
+ internal struct PRINTER_INFO
+ {
+ public IntPtr pServerName;
+ public IntPtr pPrinterName;
+ public IntPtr pShareName;
+ public IntPtr pPortName;
+ public IntPtr pDriverName;
+ public IntPtr pComment;
+ public IntPtr pLocation;
+ public IntPtr pDevMode;
+ public IntPtr pSepFile;
+ public IntPtr pPrintProcessor;
+ public IntPtr pDatatype;
+ public IntPtr pParameters;
+ public IntPtr pSecurityDescriptor;
+ public uint Attributes;
+ public uint Priority;
+ public uint DefaultPriority;
+ public uint StartTime;
+ public uint UntilTime;
+ public uint Status;
+ public uint cJobs;
+ public uint AveragePPM;
+ }
+
+ [StructLayout (LayoutKind.Sequential)]
+ internal struct DOCINFO
+ {
+ public int cbSize;
+ public IntPtr lpszDocName;
+ public IntPtr lpszOutput;
+ public IntPtr lpszDatatype;
+ public int fwType;
+ }
+
+ // Enums
+ internal enum DCCapabilities : short
+ {
+ DC_FIELDS = 1,
+ DC_PAPERS = 2,
+ DC_PAPERSIZE = 3,
+ DC_MINEXTENT = 4,
+ DC_MAXEXTENT = 5,
+ DC_BINS = 6,
+ DC_DUPLEX = 7,
+ DC_SIZE = 8,
+ DC_EXTRA = 9,
+ DC_VERSION = 10,
+ DC_DRIVER = 11,
+ DC_BINNAMES = 12,
+ DC_ENUMRESOLUTIONS = 13,
+ DC_FILEDEPENDENCIES = 14,
+ DC_TRUETYPE = 15,
+ DC_PAPERNAMES = 16,
+ DC_ORIENTATION = 17,
+ DC_COPIES = 18,
+ DC_BINADJUST = 19,
+ DC_EMF_COMPLIANT = 20,
+ DC_DATATYPE_PRODUCED = 21,
+ DC_COLLATE = 22,
+ DC_MANUFACTURER = 23,
+ DC_MODEL = 24,
+ DC_PERSONALITY = 25,
+ DC_PRINTRATE = 26,
+ DC_PRINTRATEUNIT = 27,
+ DC_PRINTERMEM = 28,
+ DC_MEDIAREADY = 29,
+ DC_STAPLE = 30,
+ DC_PRINTRATEPPM = 31,
+ DC_COLORDEVICE = 32,
+ DC_NUP = 33
+ }
+ }
+}
+
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventArgs.cs b/mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventArgs.cs
new file mode 100644
index 00000000000..2e9215076e5
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventArgs.cs
@@ -0,0 +1,57 @@
+//
+// System.Drawing.QueryPageSettingsEventArgs.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Printing
+{
+ /// <summary>
+ /// Summary description for QueryPageSettingEventArgs.
+ /// </summary>
+ public class QueryPageSettingsEventArgs : PrintEventArgs
+ {
+ private PageSettings pageSettings;
+
+ public QueryPageSettingsEventArgs(PageSettings pageSettings)
+ {
+ this.pageSettings = pageSettings;
+ }
+ public PageSettings PageSettings {
+ get{
+ return pageSettings;
+ }
+ set{
+ pageSettings = value;
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventHandler.cs b/mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventHandler.cs
new file mode 100644
index 00000000000..373eeb85ff4
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventHandler.cs
@@ -0,0 +1,40 @@
+//
+// System.Drawing.QueryPageSettingsEventHandler.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing.Printing
+{
+ /// <summary>
+ /// Summary description for QueryPageSettingsEventHandler.
+ /// </summary>
+ public delegate void QueryPageSettingsEventHandler(object sender, QueryPageSettingsEventArgs e);
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/StandardPrintController.cs b/mcs/class/System.Drawing/System.Drawing.Printing/StandardPrintController.cs
new file mode 100644
index 00000000000..0e1e533b072
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Printing/StandardPrintController.cs
@@ -0,0 +1,68 @@
+//
+// System.Drawing.StandardPrintController.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Herve Poussineau (hpoussineau@fr.st)
+// Jordi Mas i Hernandez (jordimash@gmail.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing.Printing
+{
+ public class StandardPrintController : PrintController
+ {
+ public StandardPrintController()
+ {
+ }
+
+ public override void OnEndPage (PrintDocument document, PrintPageEventArgs e)
+ {
+ SysPrn.Service.EndPage (e.GraphicsContext);
+ }
+
+ public override void OnStartPrint (PrintDocument document, PrintEventArgs e)
+ {
+ IntPtr dc = SysPrn.Service.CreateGraphicsContext (document.PrinterSettings);
+ e.GraphicsContext = new GraphicsPrinter (null, dc);
+ SysPrn.Service.StartDoc (e.GraphicsContext, document.DocumentName, string.Empty);
+ }
+
+ public override void OnEndPrint (PrintDocument document, PrintEventArgs e)
+ {
+ SysPrn.Service.EndDoc (e.GraphicsContext);
+ }
+
+ public override Graphics OnStartPage (PrintDocument document, PrintPageEventArgs e)
+ {
+ SysPrn.Service.StartPage (e.GraphicsContext);
+ return e.Graphics;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs b/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs
new file mode 100644
index 00000000000..81d6ed771e3
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs
@@ -0,0 +1,100 @@
+//
+// System.Drawing.Text.FontCollection.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Everaldo Canuto everaldo.canuto@bol.com.br
+// Sanjay Gupta (gsanjay@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Text {
+
+ public abstract class FontCollection : IDisposable {
+
+ internal IntPtr nativeFontCollection = IntPtr.Zero;
+
+ internal FontCollection ()
+ {
+ }
+
+ internal FontCollection (IntPtr ptr)
+ {
+ nativeFontCollection = ptr;
+ }
+
+ // methods
+ public void Dispose()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (true);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ }
+
+ // properties
+ public FontFamily[] Families
+ {
+ get {
+ int found;
+ int returned;
+ Status status;
+ FontFamily[] families;
+
+ status = GDIPlus.GdipGetFontCollectionFamilyCount (nativeFontCollection, out found);
+ GDIPlus.CheckStatus (status);
+
+ int nSize = Marshal.SizeOf (IntPtr.Zero);
+ IntPtr dest = Marshal.AllocHGlobal (nSize * found);
+
+ status = GDIPlus.GdipGetFontCollectionFamilyList(nativeFontCollection, found, dest, out returned);
+
+ IntPtr[] ptrAr = new IntPtr [returned];
+ int pos = dest.ToInt32 ();
+ for ( int i = 0; i < returned ; i++, pos+=nSize)
+ ptrAr[i] = (IntPtr)Marshal.PtrToStructure ((IntPtr)pos, typeof(IntPtr));
+
+ Marshal.FreeHGlobal (dest);
+
+ families = new FontFamily [returned];
+ for ( int i = 0; i < returned; i++ )
+ families[i] = new FontFamily (ptrAr[i]);
+
+ return families;
+ }
+ }
+
+ ~FontCollection()
+ {
+ Dispose (false);
+ }
+
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.jvm.cs
new file mode 100644
index 00000000000..15af2c798e3
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.jvm.cs
@@ -0,0 +1,89 @@
+//
+// System.Drawing.Text.FontCollection.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Everaldo Canuto everaldo.canuto@bol.com.br
+// Sanjay Gupta (gsanjay@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using awt = java.awt;
+
+namespace System.Drawing.Text
+{
+ /// <summary>
+ /// Summary description for FontCollection.
+ /// </summary>
+ public abstract class FontCollection : IDisposable
+ {
+ private readonly Hashtable _fonts;
+
+ protected FontCollection()
+ {
+ _fonts = CollectionsUtil.CreateCaseInsensitiveHashtable( new Hashtable() );
+ }
+
+ protected FontCollection(Hashtable fonts) {
+ _fonts = fonts;
+ }
+
+ public FontFamily[] Families {
+ get {
+ ICollection values = _fonts.Keys;
+ FontFamily[] families = new FontFamily[values.Count];
+
+ string [] keys = new string[_fonts.Count];
+ _fonts.Keys.CopyTo(keys, 0);
+
+ for (int i = 0; i < _fonts.Count; i++)
+ families[i] = new FontFamily( keys[i] );
+
+ return families;
+ }
+ }
+
+ internal virtual awt.Font GetInitialFont(string familyName) {
+ return (awt.Font)_fonts[familyName];
+ }
+
+ internal virtual bool Contains(string familyName) {
+ return _fonts.ContainsKey( familyName );
+ }
+
+ protected void AddFont(awt.Font font) {
+ _fonts.Add(font.getFamily(), font);
+ }
+
+ #region IDisposable Members
+
+ public void Dispose() {
+ // TODO: Add FontCollection.Dispose implementation
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/GenericFontFamilies.cs b/mcs/class/System.Drawing/System.Drawing.Text/GenericFontFamilies.cs
new file mode 100644
index 00000000000..e58731ac6a3
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/GenericFontFamilies.cs
@@ -0,0 +1,39 @@
+//
+// System.Drawing.GenericFontFamilies.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Text
+{
+ [Serializable]
+ public enum GenericFontFamilies {
+ Monospace = 2,
+ SansSerif = 1,
+ Serif = 0
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/HotkeyPrefix.cs b/mcs/class/System.Drawing/System.Drawing.Text/HotkeyPrefix.cs
new file mode 100644
index 00000000000..be833c7b2fd
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/HotkeyPrefix.cs
@@ -0,0 +1,39 @@
+//
+// System.Drawing.HotkeyPrefix.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Text
+{
+ [Serializable]
+ public enum HotkeyPrefix {
+ Hide = 2,
+ None = 0,
+ Show = 1
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.cs b/mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.cs
new file mode 100644
index 00000000000..c7414581162
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.cs
@@ -0,0 +1,49 @@
+//
+// System.Drawing.Text.InstalledFontCollection.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Everaldo Canuto everaldo.canuto@bol.com.br
+// Alexandre Pigolkine ( pigolkine@gmx.de)
+// Sanjay Gupta (gsanjay@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+
+namespace System.Drawing.Text {
+
+ public sealed class InstalledFontCollection : FontCollection {
+
+ internal InstalledFontCollection(IntPtr ptr): base (ptr)
+ {}
+
+ public InstalledFontCollection()
+ {
+ Status status = GDIPlus.GdipNewInstalledFontCollection (out nativeFontCollection);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.jvm.cs
new file mode 100644
index 00000000000..8e93ca8cfda
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.jvm.cs
@@ -0,0 +1,57 @@
+//
+// System.Drawing.InstalledFontCollection.cs
+//
+// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+// Author: Konstantin Triger (kostat@mainsoft.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using awt = java.awt;
+
+namespace System.Drawing.Text
+{
+ /// <summary>
+ /// Summary description for InstalledFontCollection.
+ /// </summary>
+ public sealed class InstalledFontCollection : FontCollection
+ {
+ static readonly Hashtable _installedFonts;
+
+ static InstalledFontCollection()
+ {
+ _installedFonts = CollectionsUtil.CreateCaseInsensitiveHashtable( new Hashtable() );
+ java.awt.Font [] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
+ for (int i = 0; i < fonts.Length; i++) {
+ string fontFamilyName = fonts[i].getFamily();
+ if (!_installedFonts.ContainsKey( fontFamilyName ))
+ _installedFonts.Add(fontFamilyName, fonts[i]);
+ }
+ }
+
+ public InstalledFontCollection() : base( _installedFonts ) {
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/LineLayout.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Text/LineLayout.jvm.cs
new file mode 100755
index 00000000000..4771f028751
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/LineLayout.jvm.cs
@@ -0,0 +1,187 @@
+//
+// System.Drawing.Test.LineLayout.jvm.cs
+//
+// Author:
+// Konstantin Triger <kostat@mainsoft.com>
+//
+// Copyright (C) 2005 Mainsoft Corporation, (http://www.mainsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Drawing2D;
+
+using font = java.awt.font;
+using text = java.text;
+using awt = java.awt;
+using geom = java.awt.geom;
+
+namespace System.Drawing.Text {
+
+ internal sealed class LineLayout {
+
+ #region Fields
+
+ readonly font.TextLayout _layout;
+
+ readonly float _accumulatedHeight;
+ readonly TextLineIterator _lineIter;
+
+ #endregion
+
+ #region ctor
+
+ internal LineLayout(font.TextLayout layout,
+ TextLineIterator lineIter,
+ float accumulatedHeight) {
+
+ _layout = layout;
+ _lineIter = lineIter;
+ _accumulatedHeight = accumulatedHeight;
+ }
+
+ #endregion
+
+ #region Properties
+
+ internal float AccumulatedHeight {
+ get { return _accumulatedHeight; }
+ }
+
+ internal float MeasureWidth {
+ get {
+ return Width + (_lineIter.Margin*2);
+ }
+ }
+
+ internal int CharacterCount {
+ get { return _layout.getCharacterCount(); }
+ }
+
+ internal float Ascent {
+ get { return _layout.getAscent(); }
+ }
+
+ internal float Descent {
+ get { return _layout.getDescent(); }
+ }
+
+ public float Leading {
+ get { return _layout.getLeading(); }
+ }
+
+ internal float NativeY {
+ get {
+ if (_lineIter.Format.IsVertical) {
+ float height = _lineIter.Height;
+ if (float.IsPositiveInfinity(height))
+ height = 0;
+ switch (_lineIter.Format.Alignment) {
+ case StringAlignment.Center:
+ return (height - Width) / 2;
+ case StringAlignment.Far:
+ return height - _layout.getVisibleAdvance() - _lineIter.Margin;
+ default:
+ return _lineIter.Margin;
+ }
+ }
+ else
+ return AccumulatedHeight + Ascent;
+ }
+ }
+
+ internal float NativeX {
+ get {
+ float width = _lineIter.Width;
+ if (float.IsPositiveInfinity(width))
+ width = 0;
+ if (_lineIter.Format.IsVertical)
+ return (_lineIter.Format.IsRightToLeft) ?
+ width - AccumulatedHeight - Ascent :
+ AccumulatedHeight + Leading + Descent;
+ else {
+ float xOffset;
+ switch ( _lineIter.Format.Alignment) {
+ case StringAlignment.Center:
+ xOffset = (width - Width) / 2;
+ break;
+ case StringAlignment.Far:
+ if (_lineIter.Format.IsRightToLeft)
+ xOffset = _lineIter.Margin;
+ else
+ xOffset = width - _layout.getVisibleAdvance() - _lineIter.Margin;
+ break;
+ default:
+ if (_lineIter.Format.IsRightToLeft)
+ xOffset = width - _layout.getVisibleAdvance() - _lineIter.Margin;
+ else
+ xOffset = _lineIter.Margin;
+ break;
+ }
+
+ return xOffset;
+ }
+ }
+ }
+
+ internal float Height {
+ get {
+ return Ascent + Descent + Leading;
+ }
+ }
+
+ internal float Width {
+ get {
+ if (_lineIter.Format.MeasureTrailingSpaces)
+ if (!(_lineIter.Format.IsRightToLeft ^
+ (_lineIter.Format.Alignment == StringAlignment.Far)))
+ return _layout.getAdvance();
+
+ return _layout.getVisibleAdvance();
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ internal void Draw(awt.Graphics2D g2d, float x, float y) {
+ if (_lineIter.Format.IsVertical)
+ _layout.draw(g2d, y + NativeY, -(x + NativeX) );
+ else
+ _layout.draw(g2d, x + NativeX, y + NativeY );
+ }
+
+ internal awt.Shape GetOutline(float x, float y) {
+ geom.AffineTransform t = (geom.AffineTransform)_lineIter.Transform.clone();
+
+ if (_lineIter.Format.IsVertical)
+ t.translate(y + NativeY, -(x + NativeX));
+ else
+ t.translate(x + NativeX, y + NativeY);
+
+ return _layout.getOutline(t);
+ }
+
+ #endregion
+ }
+
+} \ No newline at end of file
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.cs b/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.cs
new file mode 100644
index 00000000000..919a5dde5c1
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.cs
@@ -0,0 +1,86 @@
+//
+// System.Drawing.Text.PrivateFontCollection.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Everaldo Canuto everaldo.canuto@bol.com.br
+// Sanjay Gupta (gsanjay@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Text {
+
+#if !NET_2_0
+ [ComVisible(false)]
+#endif
+ public sealed class PrivateFontCollection : FontCollection {
+
+ // constructors
+ internal PrivateFontCollection (IntPtr ptr): base (ptr)
+ {}
+
+ public PrivateFontCollection()
+ {
+ Status status = GDIPlus.GdipNewPrivateFontCollection (out nativeFontCollection);
+ GDIPlus.CheckStatus (status);
+ }
+
+ // methods
+ public void AddFontFile(string filename)
+ {
+ if ( filename == null )
+ throw new Exception ("Value cannot be null, Parameter name : filename");
+ bool exists = File.Exists(filename);
+ if (!exists)
+ throw new Exception ("The path is not of a legal form");
+
+ Status status = GDIPlus.GdipPrivateAddFontFile (nativeFontCollection, filename);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void AddMemoryFont(IntPtr memory, int length)
+ {
+ Status status = GDIPlus.GdipPrivateAddMemoryFont (nativeFontCollection, memory, length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ // methods
+ protected override void Dispose(bool disposing)
+ {
+ if (nativeFontCollection!=IntPtr.Zero){
+ GDIPlus.GdipDeletePrivateFontCollection (nativeFontCollection);
+ nativeFontCollection = IntPtr.Zero;
+ }
+
+ base.Dispose (true);
+ }
+
+
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.jvm.cs
new file mode 100644
index 00000000000..1f67bc1a326
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/PrivateFontCollection.jvm.cs
@@ -0,0 +1,58 @@
+//
+// System.Drawing.PrivateFontCollection.cs
+//
+// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+// Author: Konstantin Triger (kostat@mainsoft.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using awt = java.awt;
+using io = java.io;
+using vmw.common;
+
+namespace System.Drawing.Text
+{
+ /// <summary>
+ /// Summary description for PrivateFontCollection.
+ /// </summary>
+ public sealed class PrivateFontCollection : FontCollection
+ {
+ public PrivateFontCollection()
+ {
+ }
+
+ public void AddFontFile(string filename) {
+ using(FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) {
+ io.InputStream stream = vmw.common.IOUtils.ToInputStream (fs);
+ awt.Font font = awt.Font.createFont(awt.Font.TRUETYPE_FONT, stream);
+ AddFont(font);
+ }
+ }
+#if INTPTR_SUPPORT
+ public void AddMemoryFont(IntPtr memory, int length) {
+ }
+#endif
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/TextLineIterator.jvm.cs b/mcs/class/System.Drawing/System.Drawing.Text/TextLineIterator.jvm.cs
new file mode 100755
index 00000000000..1928f51ed92
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/TextLineIterator.jvm.cs
@@ -0,0 +1,242 @@
+//
+// System.Drawing.Test.TextLineIterator.jvm.cs
+//
+// Author:
+// Konstantin Triger <kostat@mainsoft.com>
+//
+// Copyright (C) 2005 Mainsoft Corporation, (http://www.mainsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Drawing2D;
+
+using font = java.awt.font;
+using text = java.text;
+using awt = java.awt;
+using geom = java.awt.geom;
+
+namespace System.Drawing.Text {
+ internal sealed class TextLineIterator {
+
+ #region Fields
+
+ readonly float _width;
+ readonly float _height;
+ readonly StringFormat _format;
+ readonly font.FontRenderContext _frc;
+ readonly string _s;
+ readonly Font _font;
+ readonly float _margin;
+
+ static readonly string NewLine;
+
+ static readonly geom.AffineTransform Rotate90Transform =
+ geom.AffineTransform.getRotateInstance(Math.PI/2);
+
+ font.TextMeasurer _measurer;
+ int _charsConsumed = 0;
+ int _currentPos = 0;
+ int _currentRun = 0;
+ float _accumulatedHeight = 0;
+
+ #endregion
+
+ #region ctors
+
+ static TextLineIterator() {
+ string newLine = Environment.NewLine;
+ if (newLine == null || newLine.Length == 0 || newLine[newLine.Length - 1] == '\n')
+ newLine = "\n";
+
+ NewLine = newLine;
+ }
+
+ internal TextLineIterator(string s, Font font, font.FontRenderContext frc, StringFormat format, float width, float height) {
+ _format = (format != null) ? format : new StringFormat();
+ _font = font;
+ _s = (s != null) ? s : String.Empty;
+ _frc = frc;
+ FontFamily ff = font.FontFamily;
+ _margin = font.Size*ff.GetDrawMargin(font.Style)/ff.GetEmHeight(font.Style);
+
+ _width = width;
+ _height = height;
+ }
+
+ #endregion
+
+ #region Properties
+
+ float WrapWidth {
+ get { return (_format.IsVertical ? Height : Width) - (Margin * 2); }
+ }
+
+ internal float WrapHeight {
+ get { return (_format.IsVertical ? Width : Height); }
+ }
+
+ internal float Width {
+ get { return _width; }
+ }
+
+ internal float Height {
+ get { return _height; }
+ }
+
+ internal StringFormat Format {
+ get { return _format; }
+ }
+
+ internal float Margin {
+ get { return _margin; }
+ }
+
+ internal int CharsConsumed {
+ get { return _charsConsumed; }
+ }
+
+ internal int CurrentRun {
+ get { return _currentRun; }
+ }
+
+ internal int CurrentPosition {
+ get { return _currentPos; }
+ }
+
+ internal float AccumulatedHeight {
+ get { return _accumulatedHeight; }
+ }
+
+ internal float GetAdvanceBetween(int start, int limit) {
+ return _measurer.getAdvanceBetween(start, limit);
+ }
+
+ internal geom.AffineTransform Transform {
+ get { return Format.IsVertical ? Rotate90Transform : Matrix.IdentityTransform.NativeObject; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ LineLayout NextTextLayoutFromMeasurer() {
+ if (_accumulatedHeight >= WrapHeight) {
+ _charsConsumed += _currentPos;
+ return null;
+ }
+
+ int limit = _measurer.getLineBreakIndex(_currentPos, WrapWidth);
+
+ int wordBreak = limit;
+ if (wordBreak < _currentRun) {
+ while (wordBreak >= _currentPos && char.IsLetterOrDigit(_s, _charsConsumed + wordBreak))
+ wordBreak--;
+
+ if (wordBreak > _currentPos)
+ limit = wordBreak + 1;
+ }
+ font.TextLayout layout = _measurer.getLayout(_currentPos, limit);
+
+ LineLayout lineLayout = new LineLayout(
+ layout,
+ this,
+ _accumulatedHeight);
+
+ float lineHeight = lineLayout.Ascent + lineLayout.Descent;
+
+ if (Format.LineLimit && (_accumulatedHeight + lineHeight > WrapHeight)) {
+ _charsConsumed += _currentPos;
+ return null;
+ }
+
+ _accumulatedHeight += lineHeight + lineLayout.Leading;
+
+ _currentPos = limit;
+
+ while (_currentPos < _currentRun) {
+ if (char.IsWhiteSpace(_s, _charsConsumed + _currentPos))
+ _currentPos++;
+ else
+ break;
+ }
+ return lineLayout;
+ }
+
+ internal LineLayout NextLine() {
+ if (_currentPos < _currentRun && !Format.NoWrap)
+ return NextTextLayoutFromMeasurer();
+
+ _charsConsumed += _currentRun;
+ if (_charsConsumed >= _s.Length)
+ return null;
+
+ string s;
+ int lineBreakIndex = _s.IndexOf(NewLine, _charsConsumed);
+ if (lineBreakIndex >= 0) {
+ s = _s.Substring(_charsConsumed, lineBreakIndex - _charsConsumed + NewLine.Length);
+ }
+ else
+ s = _s.Substring(_charsConsumed);
+
+ _currentRun = s.Length;
+ _currentPos = 0;
+
+ text.AttributedString aS = new text.AttributedString(s);
+
+ // TODO: add more attribs according to StringFormat
+ aS.addAttribute(font.TextAttribute.FONT, _font.NativeObject);
+ if((_font.Style & FontStyle.Underline) != FontStyle.Regular)
+ aS.addAttribute(font.TextAttribute.UNDERLINE, font.TextAttribute.UNDERLINE_ON);
+ if((_font.Style & FontStyle.Strikeout) != FontStyle.Regular)
+ aS.addAttribute(font.TextAttribute.STRIKETHROUGH, font.TextAttribute.STRIKETHROUGH_ON);
+
+ text.AttributedCharacterIterator charIter = aS.getIterator();
+
+ _measurer = new font.TextMeasurer(charIter, _frc);
+ return NextTextLayoutFromMeasurer();
+ }
+
+ internal geom.AffineTransform CalcLineAlignmentTransform() {
+ if (Format.LineAlignment == StringAlignment.Near)
+ return null;
+ float height = WrapHeight;
+ if (float.IsPositiveInfinity(height))
+ height = 0;
+
+ float shift = height - AccumulatedHeight;
+ if (height > 0 && shift <= 0)
+ return null;
+
+ if (Format.LineAlignment == StringAlignment.Center)
+ shift /= 2;
+ else
+ if (Format.IsVertical && Format.IsRightToLeft)
+ return null;
+
+ return Format.IsVertical ?
+ geom.AffineTransform.getTranslateInstance(shift, 0) :
+ geom.AffineTransform.getTranslateInstance(0, shift);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/TextRenderingHint.cs b/mcs/class/System.Drawing/System.Drawing.Text/TextRenderingHint.cs
new file mode 100644
index 00000000000..0a2cc394378
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/TextRenderingHint.cs
@@ -0,0 +1,42 @@
+//
+// System.Drawing.TextRenderingHint.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing.Text
+{
+ [Serializable]
+ public enum TextRenderingHint {
+ AntiAlias = 4,
+ AntiAliasGridFit = 3,
+ ClearTypeGridFit = 5,
+ SingleBitPerPixel = 2,
+ SingleBitPerPixelGridFit = 1,
+ SystemDefault = 0
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/changelog b/mcs/class/System.Drawing/System.Drawing.Text/changelog
new file mode 100644
index 00000000000..39cea553748
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.Text/changelog
@@ -0,0 +1,91 @@
+2005-12-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * TextLineIterator.jvm.cs: handle null string.
+
+2005-11-16 Konstantin Triger <kostat@mainsoft.com>
+
+ * PrivateFontCollection.jvm.cs: open a correct stream.
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * Added LineLayout.jvm.cs, TextLineIterator.jvm.cs for text support
+
+2005-11-10 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * FontCollection.jvm.cs: refactoring, added GetInitialFont()
+ * InstalledFontCollection.jvm.cs: refactoring, removed GetFamilyName
+ * PrivateFontCollection.jvm.cs: refactoring
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * FontCollection.jvm.cs, InstalledFontCollection.jvm.cs,
+ PrivateFontCollection.jvm.cs: added TARGET_JVM implementation
+
+2005-04-04 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * PrivateFontCollection.cs: nativeFontCollection equals IntPtr.Zero to
+ avoid errors on multiple disposes
+
+ * FontCollection.cs: implements dispose
+
+2004-11-25 Marek Safar <marek.safar@seznam.cz>
+
+ * Image.cs: Add CheckStatus to Families.
+
+2004-02-25 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * PrivateFontCollection.cs: Removed excess attributes
+
+2004-02-25 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * FontCollection.cs: Remove console
+
+2004-02-06 Sanjay Gupta <gsanjay@novell.com>
+ * CheckStatus(): Used method of GDIPlus for error checking
+ in FontCollection.cs, InstalledFontCollection.cs and
+ PrivateFontCollection.cs
+
+2004-01-29 Sanjay Gupta <gsanjay@novell.com>
+ * FontCollection.cs: Implemented Dispose method.
+ * InstalledFontCollection.cs: Removed Console.WriteLine calls.
+ * PrivateFontCollection.cs: Implemented AddMemoryFont method.
+
+2004-01-28 Jordi Mas <jordi@ximian.com>
+ * FontCollection.cs: fixed marshalling issues
+
+2004-01-28 Sanjay Gupta <gsanjay@novell.com>
+
+ * FontCollection.cs: Implemented missing functionalities.
+ * InstalledFontCollection.css: Implemented missing functionalities.
+ * PrivateFontCollection.cs: Implemented few methods.
+
+2004-01-10 Ravindra <rkumar@novell.com>
+
+ * All Enums: Made serializable.
+
+2003-10-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * InstalledFontCollection.cs factory removed
+
+2003-06-22 Alexandre Pigolkine <pigolkine@gmx.de>
+ * FontCollection.cs
+ * InstalledFontCollection.cs
+ calls to implementation added
+
+2002-09-16 Nick Drochak <ndrochak@gol.com>
+
+ * PrivateFontCollection.cs: Fix build error. Cannot put ComVisible on
+ constructors.
+
+2003-09-14 Piers Haken <piersh@friskit.com>
+
+ * PrivateFontCollection.cs: import interop for ComVisible attribute
+
+2002-09-13 Dennis Hayes (dennish@raytek.com)
+* checked in for Everaldo Canuto everaldo.canuto@bol.com.br
+
+* FontCollection.cs
+* GenericFontFamilies.cs
+* HotkeyPrefix.cs
+* InstalledFontCollection.cs
+* PrivateFontCollection.cs
+* TextRenderingHint.cs
diff --git a/mcs/class/System.Drawing/System.Drawing.dll.sources b/mcs/class/System.Drawing/System.Drawing.dll.sources
new file mode 100755
index 00000000000..9286b50d2df
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.dll.sources
@@ -0,0 +1,192 @@
+Assembly/AssemblyInfo.cs
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+System.Drawing/Bitmap.cs
+System.Drawing/Brush.cs
+System.Drawing/Brushes.cs
+System.Drawing/BufferedGraphics.cs
+System.Drawing/BufferedGraphicsManager.cs
+System.Drawing/BufferedGraphicsContext.cs
+System.Drawing/CharacterRange.cs
+System.Drawing/carbonFunctions.cs
+System.Drawing/ColorConverter.cs
+System.Drawing/Color.cs
+System.Drawing/ColorTranslator.cs
+System.Drawing/ComIStreamMarshaler.cs
+System.Drawing/ComIStreamWrapper.cs
+System.Drawing/ContentAlignment.cs
+System.Drawing/CopyPixelOperation.cs
+System.Drawing/Font.cs
+System.Drawing/FontConverter.cs
+System.Drawing/FontFamily.cs
+System.Drawing/FontStyle.cs
+System.Drawing/Graphics.cs
+System.Drawing/GraphicsUnit.cs
+System.Drawing/gdipEnums.cs
+System.Drawing/gdipFunctions.cs
+System.Drawing/gdipStructs.cs
+System.Drawing/KnownColor.cs
+System.Drawing/IconConverter.cs
+System.Drawing/Icon.cs
+System.Drawing/IDeviceContext.cs
+System.Drawing/ImageAnimator.cs
+System.Drawing/ImageConverter.cs
+System.Drawing/Image.cs
+System.Drawing/ImageFormatConverter.cs
+System.Drawing/Pen.cs
+System.Drawing/Pens.cs
+System.Drawing/PointConverter.cs
+System.Drawing/Point.cs
+System.Drawing/PointF.cs
+System.Drawing/RectangleConverter.cs
+System.Drawing/Rectangle.cs
+System.Drawing/RectangleF.cs
+System.Drawing/Region.cs
+System.Drawing/RotateFlipType.cs
+System.Drawing/SizeConverter.cs
+System.Drawing/Size.cs
+System.Drawing/SizeF.cs
+System.Drawing/SizeFConverter.cs
+System.Drawing/SolidBrush.cs
+System.Drawing/SRDescriptionAttribute.cs
+System.Drawing/StringAligment.cs
+System.Drawing/StringDigitSubstitute.cs
+System.Drawing/StringFormat.cs
+System.Drawing/StringFormatFlags.cs
+System.Drawing/StringTrimming.cs
+System.Drawing/StringUnit.cs
+System.Drawing/SystemBrushes.cs
+System.Drawing/SystemColors.cs
+System.Drawing/SystemFonts.cs
+System.Drawing/SystemIcons.cs
+System.Drawing/SystemPens.cs
+System.Drawing/TextureBrush.cs
+System.Drawing/ToolboxBitmapAttribute.cs
+System.Drawing.Design/UITypeEditorEditStyle.cs
+System.Drawing.Design/IPropertyValueUIService.cs
+System.Drawing.Design/IToolboxItemProvider.cs
+System.Drawing.Design/PropertyValueItem.cs
+System.Drawing.Design/PropertyValueUIHandler.cs
+System.Drawing.Design/PropertyValueUIItemInvokeHandler.cs
+System.Drawing.Design/CategoryNameCollection.cs
+System.Drawing.Design/IToolboxService.cs
+System.Drawing.Design/IToolboxUser.cs
+System.Drawing.Design/PaintValueEventArgs.cs
+System.Drawing.Design/ToolboxComponentsCreatedEventArgs.cs
+System.Drawing.Design/ToolboxComponentsCreatedEventHandler.cs
+System.Drawing.Design/ToolboxComponentsCreatingEventArgs.cs
+System.Drawing.Design/ToolboxComponentsCreatingEventHandler.cs
+System.Drawing.Design/ToolboxItemCreatorCallback.cs
+System.Drawing.Design/ToolboxItem.cs
+System.Drawing.Design/UITypeEditor.cs
+System.Drawing.Design/ToolboxItemCollection.cs
+System.Drawing.Drawing2D/AdjustableArrowCap.cs
+System.Drawing.Drawing2D/Blend.cs
+System.Drawing.Drawing2D/ColorBlend.cs
+System.Drawing.Drawing2D/CombineMode.cs
+System.Drawing.Drawing2D/CompostingMode.cs
+System.Drawing.Drawing2D/CompostingQuality.cs
+System.Drawing.Drawing2D/CoordinateSpace.cs
+System.Drawing.Drawing2D/CustomLineCap.cs
+System.Drawing.Drawing2D/DashCap.cs
+System.Drawing.Drawing2D/DashStyle.cs
+System.Drawing.Drawing2D/FillMode.cs
+System.Drawing.Drawing2D/FlushIntention.cs
+System.Drawing.Drawing2D/GraphicsContainer.cs
+System.Drawing.Drawing2D/GraphicsPath.cs
+System.Drawing.Drawing2D/GraphicsPathIterator.cs
+System.Drawing.Drawing2D/GraphicsState.cs
+System.Drawing.Drawing2D/HatchBrush.cs
+System.Drawing.Drawing2D/HatchStyle.cs
+System.Drawing.Drawing2D/InterpolationMode.cs
+System.Drawing.Drawing2D/LinearGradientBrush.cs
+System.Drawing.Drawing2D/LinearGradientMode.cs
+System.Drawing.Drawing2D/LineCap.cs
+System.Drawing.Drawing2D/LineJoin.cs
+System.Drawing.Drawing2D/Matrix.cs
+System.Drawing.Drawing2D/MatrixOrder.cs
+System.Drawing.Drawing2D/PathData.cs
+System.Drawing.Drawing2D/PathGradientBrush.cs
+System.Drawing.Drawing2D/PathPointType.cs
+System.Drawing.Drawing2D/PenAlignment.cs
+System.Drawing.Drawing2D/PenType.cs
+System.Drawing.Drawing2D/PixelOffsetMode.cs
+System.Drawing.Drawing2D/QualityMode.cs
+System.Drawing.Drawing2D/RegionData.cs
+System.Drawing.Drawing2D/SmoothingMode.cs
+../../build/common/MonoTODOAttribute.cs
+System.Drawing.Drawing2D/WarpMode.cs
+System.Drawing.Drawing2D/WrapMode.cs
+System.Drawing.Imaging/BitmapData.cs
+System.Drawing.Imaging/ColorAdjustType.cs
+System.Drawing.Imaging/ColorChannelFlag.cs
+System.Drawing.Imaging/ColorMap.cs
+System.Drawing.Imaging/ColorMapType.cs
+System.Drawing.Imaging/ColorMatrix.cs
+System.Drawing.Imaging/ColorMatrixFlag.cs
+System.Drawing.Imaging/ColorMode.cs
+System.Drawing.Imaging/ColorPalette.cs
+System.Drawing.Imaging/EmfPlusRecordType.cs
+System.Drawing.Imaging/EmfType.cs
+System.Drawing.Imaging/Encoder.cs
+System.Drawing.Imaging/EncoderParameter.cs
+System.Drawing.Imaging/EncoderParameters.cs
+System.Drawing.Imaging/EncoderParameterValueType.cs
+System.Drawing.Imaging/EncoderValue.cs
+System.Drawing.Imaging/FrameDimension.cs
+System.Drawing.Imaging/ImageAttributes.cs
+System.Drawing.Imaging/ImageCodecFlags.cs
+System.Drawing.Imaging/ImageCodecInfo.cs
+System.Drawing.Imaging/ImageFlags.cs
+System.Drawing.Imaging/ImageFormat.cs
+System.Drawing.Imaging/ImageLockMode.cs
+System.Drawing.Imaging/Metafile.cs
+System.Drawing.Imaging/MetafileFrameUnit.cs
+System.Drawing.Imaging/MetafileHeader.cs
+System.Drawing.Imaging/MetafileType.cs
+System.Drawing.Imaging/MetaHeader.cs
+System.Drawing.Imaging/PaletteFlags.cs
+System.Drawing.Imaging/PixelFormat.cs
+System.Drawing.Imaging/PlayRecordCallback.cs
+System.Drawing.Imaging/PropertyItem.cs
+System.Drawing.Imaging/WmfPlaceableFileHeader.cs
+System.Drawing.Printing/Duplex.cs
+System.Drawing.Printing/InvalidPrinterException.cs
+System.Drawing.Printing/MarginsConverter.cs
+System.Drawing.Printing/Margins.cs
+System.Drawing.Printing/PrintingServices.cs
+System.Drawing.Printing/PrintingServicesWin32.cs
+System.Drawing.Printing/PrintingServicesUnix.cs
+System.Drawing.Printing/PageSettings.cs
+System.Drawing.Printing/PaperKind.cs
+System.Drawing.Printing/PaperSize.cs
+System.Drawing.Printing/PaperSource.cs
+System.Drawing.Printing/PaperSourceKind.cs
+System.Drawing.Printing/PreviewPageInfo.cs
+System.Drawing.Printing/PreviewPrintController.cs
+System.Drawing.Printing/PrintController.cs
+System.Drawing.Printing/PrintDocument.cs
+System.Drawing.Printing/PrinterResolution.cs
+System.Drawing.Printing/PrinterResolutionKind.cs
+System.Drawing.Printing/PrinterSettings.cs
+System.Drawing.Printing/PrinterUnit.cs
+System.Drawing.Printing/PrinterUnitConvert.cs
+System.Drawing.Printing/PrintEventArgs.cs
+System.Drawing.Printing/PrintEventHandler.cs
+System.Drawing.Printing/PrintingPermissionAttribute.cs
+System.Drawing.Printing/PrintingPermission.cs
+System.Drawing.Printing/PrintingPermissionLevel.cs
+System.Drawing.Printing/PrintAction.cs
+System.Drawing.Printing/PrintPageEventArgs.cs
+System.Drawing.Printing/PrintPageEventHandler.cs
+System.Drawing.Printing/PrintRange.cs
+System.Drawing.Printing/QueryPageSettingsEventArgs.cs
+System.Drawing.Printing/QueryPageSettingsEventHandler.cs
+System.Drawing.Printing/StandardPrintController.cs
+System.Drawing.Text/FontCollection.cs
+System.Drawing.Text/PrivateFontCollection.cs
+System.Drawing.Text/GenericFontFamilies.cs
+System.Drawing.Text/HotkeyPrefix.cs
+System.Drawing.Text/InstalledFontCollection.cs
+System.Drawing.Text/TextRenderingHint.cs
+
diff --git a/mcs/class/System.Drawing/System.Drawing.sln b/mcs/class/System.Drawing/System.Drawing.sln
new file mode 100644
index 00000000000..3b05edfd090
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.sln
@@ -0,0 +1,21 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{83B010C7-76FC-4FAD-A26C-00D7EFE60256}") = "System.Drawing", "System.Drawing.vmwcsproj", "{33E3C30E-1978-4FBD-A743-AF0885938266}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug_Java = Debug_Java
+ Release_Java = Release_Java
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {33E3C30E-1978-4FBD-A743-AF0885938266}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {33E3C30E-1978-4FBD-A743-AF0885938266}.Debug_Java.Build.0 = Debug_Java|.NET
+ {33E3C30E-1978-4FBD-A743-AF0885938266}.Release_Java.ActiveCfg = Release_Java|.NET
+ {33E3C30E-1978-4FBD-A743-AF0885938266}.Release_Java.Build.0 = Release_Java|.NET
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/mcs/class/System.Drawing/System.Drawing.vmwcsproj b/mcs/class/System.Drawing/System.Drawing.vmwcsproj
new file mode 100644
index 00000000000..3c4478b53dd
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing.vmwcsproj
@@ -0,0 +1,170 @@
+<VisualStudioProject>
+ <CSHARP ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{33E3C30E-1978-4FBD-A743-AF0885938266}">
+ <Build>
+ <Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="System.Drawing" AssemblyOriginatorKeyFile="" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" PreBuildEvent="" PostBuildEvent="" RootNamespace="System.Drawing" RunPostBuildEvent="OnBuildSuccess" StartupObject="">
+ <Config Name="Debug_Java" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE;TARGET_JVM" DocumentationFile="" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="1595" Optimize="false" OutputPath="bin\Debug_Java\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ <Config Name="Release_Java" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="TRACE;TARGET_JVM" DocumentationFile="" DebugSymbols="false" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="1595" Optimize="true" OutputPath="bin\Release_Java\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ </Settings>
+ <References>
+ <Reference Name="System" AssemblyName="System" HintPath="..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"/>
+ <Reference Name="rt" AssemblyName="rt" HintPath="..\lib\j2sdk1.4.1\rt.dll" Private="False"/>
+ <Reference Name="J2SE.Helpers" AssemblyName="J2SE.Helpers" HintPath="..\lib\J2SE.Helpers.dll" Private="False"/>
+ <Reference Name="System.Xml" AssemblyName="System.Xml" HintPath="..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Xml.dll" Private="False"/>
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File RelPath="Locale.cs" Link="..\..\build\common\Locale.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="MonoTODOAttribute.cs" Link="..\..\build\common\MonoTODOAttribute.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="Assembly\AssemblyInfo.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="Assembly\Consts.cs.in" Link="..\..\build\common\Consts.cs.in" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="Assembly\Application.ico" BuildAction="EmbeddedResource"/>
+ <File RelPath="Assembly\Asterisk.ico" BuildAction="EmbeddedResource"/>
+ <File RelPath="Assembly\Error.ico" BuildAction="EmbeddedResource"/>
+ <File RelPath="Assembly\Exclamation.ico" BuildAction="EmbeddedResource"/>
+ <File RelPath="Assembly\Hand.ico" BuildAction="EmbeddedResource"/>
+ <File RelPath="Assembly\Information.ico" BuildAction="EmbeddedResource"/>
+ <File RelPath="Assembly\Question.ico" BuildAction="EmbeddedResource"/>
+ <File RelPath="Assembly\Warning.ico" BuildAction="EmbeddedResource"/>
+ <File RelPath="Assembly\WinLogo.ico" BuildAction="EmbeddedResource"/>
+ <File RelPath="Mainsoft.Drawing.Configuration.jvm\ResolutionConfiguration.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="Mainsoft.Drawing.Configuration.jvm\ResolutionConfigurationCollection.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="Mainsoft.Drawing.Configuration.jvm\ResolutionConfigurationHandler.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\AdvancedStroke.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\BasicShape.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Bitmap.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Brush.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Brushes.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\CharacterRange.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Color.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\ColorConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\ColorTranslator.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\ContentAlignment.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Font.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\FontConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\FontFamily.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\FontStyle.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Graphics.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\GraphicsUnit.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Icon.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\IconConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Image.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\ImageAnimator.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\ImageConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\ImageFormatConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\KnownColor.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Pen.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Pens.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\PlainImage.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\PlainImageCollection.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Point.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\PointConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\PointF.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Rectangle.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\RectangleConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\RectangleF.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Region.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\RotateFlipType.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\Size.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\SizeConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\SizeF.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\SolidBrush.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\StringAligment.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\StringDigitSubstitute.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\StringFormat.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\StringFormatFlags.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\StringTrimming.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\StringUnit.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\StrokeFactory.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\SystemBrushes.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\SystemColors.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\SystemIcons.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\SystemPens.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TextureBrush.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\ToolboxBitmapAttribute.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Design\UITypeEditor.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Design\UITypeEditorEditStyle.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\AdjustableArrowCap.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\Blend.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\ColorBlend.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\CombineMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\CompostingMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\CompostingQuality.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\CoordinateSpace.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\CustomLineCap.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\DashCap.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\DashStyle.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\ExtendedGeneralPath.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\FillMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\FlushIntention.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\GeneralPathIterator.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\GraphicsContainer.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\GraphicsPath.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\GraphicsPathIterator.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\GraphicsState.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\HatchBrush.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\HatchStyle.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\InterpolationMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\LinearGradientBrush.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\LinearGradientMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\LineCap.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\LineJoin.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\Matrix.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\MatrixOrder.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\PathData.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\PathGradientBrush.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\PathPointType.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\PenAlignment.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\PenType.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\PixelOffsetMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\QualityMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\RegionData.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\SmoothingMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\WarpMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\WrapMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\BitmapData.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ColorAdjustType.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ColorChannelFlag.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ColorMap.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ColorMapType.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ColorMatrix.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ColorMatrixFlag.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ColorMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ColorPalette.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\EmfPlusRecordType.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\EmfType.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\Encoder.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\EncoderParameter.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\EncoderParameters.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\EncoderParameterValueType.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\EncoderValue.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\FrameDimension.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ImageAttributes.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ImageCodec.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ImageCodecFlags.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ImageCodecInfo.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ImageFlags.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ImageFormat.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\ImageLockMode.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\Metafile.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\MetafileFrameUnit.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\MetafileHeader.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\MetafileType.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\MetaHeader.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\PaletteFlags.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\PixelFormat.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\PropertyItem.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\WmfPlaceableFileHeader.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Text\FontCollection.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Text\GenericFontFamilies.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Text\HotkeyPrefix.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Text\InstalledFontCollection.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Text\LineLayout.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Text\PrivateFontCollection.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Text\TextLineIterator.jvm.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Text\TextRenderingHint.cs" SubType="Code" BuildAction="Compile"/>
+ </Include>
+ </Files>
+ <UserProperties jarserver="ip2" project.JDKType="1.4.2_05" REFS.JarPath.rt="..\Program Files\Mainsoft\Visual MainWin for J2EE\j2sdk1.4\lib\rt.jar" REFS.JarPath.system="..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.jar" REFS.JarPath.j2se.helpers="..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\J2SE.Helpers.jar"/>
+ </CSHARP>
+ <VisualMainWin><Project Prop2023="1.4.2_05" Prop2024="" Prop2026="" Prop2015="" Version="1.6.0" ProjectType="1"/><References/><Configs><Config Prop2000="0" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="0" Prop2006="" Prop2007="" Prop2008="" Prop2009="" Prop2010="" Prop2011="-1" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="0" Name="Debug_Java"/><Config Prop2000="0" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="0" Prop2006="" Prop2007="" Prop2008="" Prop2009="" Prop2010="" Prop2011="-1" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="0" Name="Release_Java"/></Configs></VisualMainWin></VisualStudioProject>
diff --git a/mcs/class/System.Drawing/System.Drawing/AdvancedStroke.jvm.cs b/mcs/class/System.Drawing/System.Drawing/AdvancedStroke.jvm.cs
new file mode 100755
index 00000000000..769312d708a
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/AdvancedStroke.jvm.cs
@@ -0,0 +1,550 @@
+using System;
+using System.Drawing.Drawing2D;
+using java.lang;
+
+using java.awt;
+using java.awt.geom;
+using sun.dc.path;
+using sun.dc.pr;
+
+namespace System.Drawing {
+
+ internal enum PenFit {
+ NotThin,
+ Thin,
+ ThinAntiAlias
+ }
+
+ internal class AdvancedStroke : Stroke {
+
+ public const float PenUnits = 0.01f;
+ public const int MinPenUnits = 100;
+ public const int MinPenUnitsAA = 20;
+ public const float MinPenSizeAA = PenUnits * MinPenUnitsAA;
+ public const double MinPenSizeAASquared = (MinPenSizeAA * MinPenSizeAA);
+ public const double MinPenSizeSquared = 1.000000001;
+ public const double MinPenSizeNorm = 1.5;
+ public const double MinPenSizeSquaredNorm = (MinPenSizeNorm * MinPenSizeNorm);
+
+ /**
+ * Joins path segments by extending their outside edges until
+ * they meet.
+ */
+ public const int JOIN_MITER = 0;
+
+ /**
+ * Joins path segments by rounding off the corner at a radius
+ * of half the line width.
+ */
+ public const int JOIN_ROUND = 1;
+
+ /**
+ * Joins path segments by connecting the outer corners of their
+ * wide outlines with a straight segment.
+ */
+ public const int JOIN_BEVEL = 2;
+
+ /**
+ * Ends unclosed subpaths and dash segments with no added
+ * decoration.
+ */
+ public const int CAP_BUTT = 0;
+
+ /**
+ * Ends unclosed subpaths and dash segments with a round
+ * decoration that has a radius equal to half of the width
+ * of the pen.
+ */
+ public const int CAP_ROUND = 1;
+
+ /**
+ * Ends unclosed subpaths and dash segments with a square
+ * projection that extends beyond the end of the segment
+ * to a distance equal to half of the line width.
+ */
+ public const int CAP_SQUARE = 2;
+
+ float width;
+
+ int join;
+ int cap;
+ float miterlimit;
+
+ float[] dash;
+ float dash_phase;
+
+ AffineTransform _penTransform;
+ AffineTransform _outputTransform;
+ PenFit _penFit;
+
+ /**
+ * Constructs a new <code>AdvancedStroke</code> with the specified
+ * attributes.
+ * @param width the width of this <code>AdvancedStroke</code>. The
+ * width must be greater than or equal to 0.0f. If width is
+ * set to 0.0f, the stroke is rendered as the thinnest
+ * possible line for the target device and the antialias
+ * hint setting.
+ * @param cap the decoration of the ends of a <code>AdvancedStroke</code>
+ * @param join the decoration applied where path segments meet
+ * @param miterlimit the limit to trim the miter join. The miterlimit
+ * must be greater than or equal to 1.0f.
+ * @param dash the array representing the dashing pattern
+ * @param dash_phase the offset to start the dashing pattern
+ * @throws IllegalArgumentException if <code>width</code> is negative
+ * @throws IllegalArgumentException if <code>cap</code> is not either
+ * CAP_BUTT, CAP_ROUND or CAP_SQUARE
+ * @throws IllegalArgumentException if <code>miterlimit</code> is less
+ * than 1 and <code>join</code> is JOIN_MITER
+ * @throws IllegalArgumentException if <code>join</code> is not
+ * either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER
+ * @throws IllegalArgumentException if <code>dash_phase</code>
+ * is negative and <code>dash</code> is not <code>null</code>
+ * @throws IllegalArgumentException if the length of
+ * <code>dash</code> is zero
+ * @throws IllegalArgumentException if dash lengths are all zero.
+ */
+ public AdvancedStroke(float width, int cap, int join, float miterlimit,
+ float[] dash, float dash_phase, AffineTransform penTransform,
+ AffineTransform outputTransform, PenFit penFit) {
+ if (width < 0.0f) {
+ throw new IllegalArgumentException("negative width");
+ }
+ if (cap != CAP_BUTT && cap != CAP_ROUND && cap != CAP_SQUARE) {
+ throw new IllegalArgumentException("illegal end cap value");
+ }
+ if (join == JOIN_MITER) {
+ if (miterlimit < 1.0f) {
+ throw new IllegalArgumentException("miter limit < 1");
+ }
+ } else if (join != JOIN_ROUND && join != JOIN_BEVEL) {
+ throw new IllegalArgumentException("illegal line join value");
+ }
+ if (dash != null) {
+ if (dash_phase < 0.0f) {
+ throw new IllegalArgumentException("negative dash phase");
+ }
+ bool allzero = true;
+ for (int i = 0; i < dash.Length; i++) {
+ float d = dash[i];
+ if (d > 0.0) {
+ allzero = false;
+ } else if (d < 0.0) {
+ throw new IllegalArgumentException("negative dash length");
+ }
+ }
+ if (allzero) {
+ throw new IllegalArgumentException("dash lengths all zero");
+ }
+ }
+ this.width = width;
+ this.cap = cap;
+ this.join = join;
+ this.miterlimit = miterlimit;
+ if (dash != null) {
+ this.dash = (float []) dash.Clone();
+ }
+ this.dash_phase = dash_phase;
+ this._penTransform = penTransform;
+ this._outputTransform = outputTransform;
+ this._penFit = penFit;
+ }
+
+ /**
+ * Constructs a solid <code>AdvancedStroke</code> with the specified
+ * attributes.
+ * @param width the width of the <code>AdvancedStroke</code>
+ * @param cap the decoration of the ends of a <code>AdvancedStroke</code>
+ * @param join the decoration applied where path segments meet
+ * @param miterlimit the limit to trim the miter join
+ * @throws IllegalArgumentException if <code>width</code> is negative
+ * @throws IllegalArgumentException if <code>cap</code> is not either
+ * CAP_BUTT, CAP_ROUND or CAP_SQUARE
+ * @throws IllegalArgumentException if <code>miterlimit</code> is less
+ * than 1 and <code>join</code> is JOIN_MITER
+ * @throws IllegalArgumentException if <code>join</code> is not
+ * either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER
+ */
+ public AdvancedStroke(float width, int cap, int join, float miterlimit) :
+ this(width, cap, join, miterlimit, null, 0.0f, null, null, PenFit.NotThin) {
+ }
+
+ /**
+ * Constructs a solid <code>AdvancedStroke</code> with the specified
+ * attributes. The <code>miterlimit</code> parameter is
+ * unnecessary in cases where the default is allowable or the
+ * line joins are not specified as JOIN_MITER.
+ * @param width the width of the <code>AdvancedStroke</code>
+ * @param cap the decoration of the ends of a <code>AdvancedStroke</code>
+ * @param join the decoration applied where path segments meet
+ * @throws IllegalArgumentException if <code>width</code> is negative
+ * @throws IllegalArgumentException if <code>cap</code> is not either
+ * CAP_BUTT, CAP_ROUND or CAP_SQUARE
+ * @throws IllegalArgumentException if <code>join</code> is not
+ * either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER
+ */
+ public AdvancedStroke(float width, int cap, int join) :
+ this(width, cap, join, 10.0f, null, 0.0f, null, null, PenFit.NotThin) {
+ }
+
+ /**
+ * Constructs a solid <code>AdvancedStroke</code> with the specified
+ * line width and with default values for the cap and join
+ * styles.
+ * @param width the width of the <code>AdvancedStroke</code>
+ * @throws IllegalArgumentException if <code>width</code> is negative
+ */
+ public AdvancedStroke(float width) :
+ this(width, CAP_SQUARE, JOIN_MITER, 10.0f, null, 0.0f, null, null, PenFit.NotThin) {
+ }
+
+ /**
+ * Constructs a new <code>AdvancedStroke</code> with defaults for all
+ * attributes.
+ * The default attributes are a solid line of width 1.0, CAP_SQUARE,
+ * JOIN_MITER, a miter limit of 10.0.
+ */
+ public AdvancedStroke() :
+ this(1.0f, CAP_SQUARE, JOIN_MITER, 10.0f, null, 0.0f, null, null, PenFit.NotThin) {
+ }
+
+
+ /**
+ * Returns a <code>Shape</code> whose interior defines the
+ * stroked outline of a specified <code>Shape</code>.
+ * @param s the <code>Shape</code> boundary be stroked
+ * @return the <code>Shape</code> of the stroked outline.
+ */
+ public Shape createStrokedShape(Shape s) {
+ FillAdapter filler = new FillAdapter();
+ PathStroker stroker = new PathStroker(filler);
+ PathConsumer consumer;
+
+ stroker.setPenDiameter(width);
+ switch (_penFit) {
+ case PenFit.Thin:
+ stroker.setPenFitting(PenUnits, MinPenUnits);
+ break;
+ case PenFit.ThinAntiAlias:
+ stroker.setPenFitting(PenUnits, MinPenUnitsAA);
+ break;
+ }
+
+ float[] t4 = null;
+ if (PenTransform != null && !PenTransform.isIdentity() && (PenTransform.getDeterminant() > 1e-25)) {
+ t4 = new float[]{
+ (float)PenTransform.getScaleX(), (float)PenTransform.getShearY(),
+ (float)PenTransform.getShearX(), (float)PenTransform.getScaleY()
+ };
+ }
+
+ float[] t6 = null;
+ if (OutputTransform != null && !OutputTransform.isIdentity()) {
+ t6 = new float[] {
+ (float)OutputTransform.getScaleX(), (float)OutputTransform.getShearY(),
+ (float)OutputTransform.getShearX(), (float)OutputTransform.getScaleY(),
+ (float)OutputTransform.getTranslateX(), (float)OutputTransform.getTranslateY()
+ };
+ }
+
+ stroker.setPenT4(t4);
+ stroker.setOutputT6(t6);
+ stroker.setCaps(RasterizerCaps[cap]);
+ stroker.setCorners(RasterizerCorners[join], miterlimit);
+ if (dash != null) {
+ PathDasher dasher = new PathDasher(stroker);
+ dasher.setDash(dash, dash_phase);
+ dasher.setDashT4(t4);
+ consumer = dasher;
+ } else {
+ consumer = stroker;
+ }
+
+ PathIterator pi = s.getPathIterator(null);
+
+ try {
+ consumer.beginPath();
+ bool pathClosed = false;
+ float mx = 0.0f;
+ float my = 0.0f;
+ float[] point = new float[6];
+
+ while (!pi.isDone()) {
+ int type = pi.currentSegment(point);
+ if (pathClosed == true) {
+ pathClosed = false;
+ if (type != PathIterator__Finals.SEG_MOVETO) {
+ // Force current point back to last moveto point
+ consumer.beginSubpath(mx, my);
+ }
+ }
+ switch ((GraphicsPath.JPI)type) {
+ case GraphicsPath.JPI.SEG_MOVETO:
+ mx = point[0];
+ my = point[1];
+ consumer.beginSubpath(point[0], point[1]);
+ break;
+ case GraphicsPath.JPI.SEG_LINETO:
+ consumer.appendLine(point[0], point[1]);
+ break;
+ case GraphicsPath.JPI.SEG_QUADTO:
+ // Quadratic curves take two points
+ consumer.appendQuadratic(point[0], point[1],
+ point[2], point[3]);
+ break;
+ case GraphicsPath.JPI.SEG_CUBICTO:
+ // Cubic curves take three points
+ consumer.appendCubic(point[0], point[1],
+ point[2], point[3],
+ point[4], point[5]);
+ break;
+ case GraphicsPath.JPI.SEG_CLOSE:
+ consumer.closedSubpath();
+ pathClosed = true;
+ break;
+ }
+ pi.next();
+ }
+
+ consumer.endPath();
+ } catch (PathException e) {
+ throw new InternalError("Unable to Stroke shape ("+
+ e.Message+")");
+ }
+
+ return filler.getShape();
+ }
+
+ /**
+ * Returns the line width. Line width is represented in user space,
+ * which is the default-coordinate space used by Java 2D. See the
+ * <code>Graphics2D</code> class comments for more information on
+ * the user space coordinate system.
+ * @return the line width of this <code>AdvancedStroke</code>.
+ * @see Graphics2D
+ */
+ public float getLineWidth() {
+ return width;
+ }
+
+ /**
+ * Returns the end cap style.
+ * @return the end cap style of this <code>AdvancedStroke</code> as one
+ * of the static <code>int</code> values that define possible end cap
+ * styles.
+ */
+ public int getEndCap() {
+ return cap;
+ }
+
+ /**
+ * Returns the line join style.
+ * @return the line join style of the <code>AdvancedStroke</code> as one
+ * of the static <code>int</code> values that define possible line
+ * join styles.
+ */
+ public int getLineJoin() {
+ return join;
+ }
+
+ /**
+ * Returns the limit of miter joins.
+ * @return the limit of miter joins of the <code>AdvancedStroke</code>.
+ */
+ public float getMiterLimit() {
+ return miterlimit;
+ }
+
+ /**
+ * Returns the array representing the lengths of the dash segments.
+ * Alternate entries in the array represent the user space lengths
+ * of the opaque and transparent segments of the dashes.
+ * As the pen moves along the outline of the <code>Shape</code>
+ * to be stroked, the user space
+ * distance that the pen travels is accumulated. The distance
+ * value is used to index into the dash array.
+ * The pen is opaque when its current cumulative distance maps
+ * to an even element of the dash array and transparent otherwise.
+ * @return the dash array.
+ */
+ public float[] getDashArray() {
+ if (dash == null) {
+ return null;
+ }
+
+ return (float[]) dash.Clone();
+ }
+
+ /**
+ * Returns the current dash phase.
+ * The dash phase is a distance specified in user coordinates that
+ * represents an offset into the dashing pattern. In other words, the dash
+ * phase defines the point in the dashing pattern that will correspond to
+ * the beginning of the stroke.
+ * @return the dash phase as a <code>float</code> value.
+ */
+ public float getDashPhase() {
+ return dash_phase;
+ }
+
+ /**
+ * Returns the hashcode for this stroke.
+ * @return a hash code for this stroke.
+ */
+ public override int GetHashCode() {
+ int hash = Float.floatToIntBits(width);
+ hash = hash * 31 + join;
+ hash = hash * 31 + cap;
+ hash = hash * 31 + Float.floatToIntBits(miterlimit);
+ if (dash != null) {
+ hash = hash * 31 + Float.floatToIntBits(dash_phase);
+ for (int i = 0; i < dash.Length; i++) {
+ hash = hash * 31 + Float.floatToIntBits(dash[i]);
+ }
+ }
+ return hash;
+ }
+
+ /**
+ * Returns true if this AdvancedStroke represents the same
+ * stroking operation as the given argument.
+ */
+ /**
+ * Tests if a specified object is equal to this <code>AdvancedStroke</code>
+ * by first testing if it is a <code>AdvancedStroke</code> and then comparing
+ * its width, join, cap, miter limit, dash, and dash phase attributes with
+ * those of this <code>AdvancedStroke</code>.
+ * @param obj the specified object to compare to this
+ * <code>AdvancedStroke</code>
+ * @return <code>true</code> if the width, join, cap, miter limit, dash, and
+ * dash phase are the same for both objects;
+ * <code>false</code> otherwise.
+ */
+ public override bool Equals(object obj) {
+ if (!(obj is AdvancedStroke)) {
+ return false;
+ }
+
+ AdvancedStroke bs = (AdvancedStroke) obj;
+ if (width != bs.width) {
+ return false;
+ }
+
+ if (join != bs.join) {
+ return false;
+ }
+
+ if (cap != bs.cap) {
+ return false;
+ }
+
+ if (miterlimit != bs.miterlimit) {
+ return false;
+ }
+
+ if (dash != null) {
+ if (dash_phase != bs.dash_phase) {
+ return false;
+ }
+
+ if (!java.util.Arrays.equals(dash, bs.dash)) {
+ return false;
+ }
+ }
+ else if (bs.dash != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public AffineTransform PenTransform {
+ get{
+ return _penTransform;
+ }
+ set{
+ _penTransform = value;
+ }
+ }
+
+ public AffineTransform OutputTransform {
+ get {
+ return _outputTransform;
+ }
+ set {
+ _outputTransform = value;
+ }
+ }
+
+ private static readonly int[] RasterizerCaps = {
+ Rasterizer.BUTT, Rasterizer.ROUND, Rasterizer.SQUARE
+ };
+
+ private static readonly int[] RasterizerCorners = {
+ Rasterizer.MITER, Rasterizer.ROUND, Rasterizer.BEVEL
+ };
+
+ #region FillAdapter
+
+ private class FillAdapter : PathConsumer {
+ bool closed;
+ GeneralPath path;
+
+ public FillAdapter() {
+ path = new GeneralPath(GeneralPath.WIND_NON_ZERO);
+ }
+
+ public Shape getShape() {
+ return path;
+ }
+
+ public void beginPath() {}
+
+ public void beginSubpath(float x0, float y0) {
+ if (closed) {
+ path.closePath();
+ closed = false;
+ }
+ path.moveTo(x0, y0);
+ }
+
+ public void appendLine(float x1, float y1) {
+ path.lineTo(x1, y1);
+ }
+
+ public void appendQuadratic(float xm, float ym, float x1, float y1) {
+ path.quadTo(xm, ym, x1, y1);
+ }
+
+ public void appendCubic(float xm, float ym,
+ float xn, float yn,
+ float x1, float y1) {
+ path.curveTo(xm, ym, xn, yn, x1, y1);
+ }
+
+ public void closedSubpath() {
+ closed = true;
+ }
+
+ public void endPath() {
+ if (closed) {
+ path.closePath();
+ closed = false;
+ }
+ }
+
+ public void useProxy(FastPathProducer proxy) {
+ proxy.sendTo(this);
+ }
+
+ public long getCPathConsumer() {
+ return 0;
+ }
+
+ public void dispose() {
+ }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Drawing/System.Drawing/BasicShape.jvm.cs b/mcs/class/System.Drawing/System.Drawing/BasicShape.jvm.cs
new file mode 100755
index 00000000000..5aad895321f
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/BasicShape.jvm.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
+
+using awt = java.awt;
+using geom = java.awt.geom;
+
+namespace System.Drawing
+{
+ /// <summary>
+ /// Summary description for BasicShape.
+ /// </summary>
+ public abstract class BasicShape : MarshalByRefObject, awt.Shape, IDisposable
+ {
+ awt.Shape _shape;
+
+ protected BasicShape(awt.Shape shape)
+ {
+ _shape = shape;
+ }
+
+ protected awt.Shape Shape {
+ get {
+ return _shape;
+ }
+ set {
+ _shape = value;
+ }
+ }
+
+ #region IDisposable
+ public void Dispose () {
+ Dispose (true);
+ }
+
+ void Dispose (bool disposing) {
+ }
+ #endregion
+
+ #region Shape Members
+
+ awt.Rectangle awt.Shape.getBounds() {
+ return Shape.getBounds();
+ }
+
+ bool awt.Shape.contains(double arg_0, double arg_1) {
+ return Shape.contains(arg_0, arg_1);
+ }
+
+ bool awt.Shape.contains(geom.Point2D arg_0) {
+ return Shape.contains(arg_0);
+ }
+
+ bool awt.Shape.contains(double arg_0, double arg_1, double arg_2, double arg_3) {
+ return Shape.contains(arg_0, arg_1, arg_2, arg_3);
+ }
+
+ bool awt.Shape.contains(geom.Rectangle2D arg_0) {
+ return Shape.contains(arg_0);
+ }
+
+ geom.PathIterator awt.Shape.getPathIterator(geom.AffineTransform arg_0) {
+ return Shape.getPathIterator(arg_0);
+ }
+
+ geom.PathIterator awt.Shape.getPathIterator(geom.AffineTransform arg_0, double arg_1) {
+ return Shape.getPathIterator(arg_0, arg_1);
+ }
+
+ geom.Rectangle2D awt.Shape.getBounds2D() {
+ return Shape.getBounds2D();
+ }
+
+ bool awt.Shape.intersects(double arg_0, double arg_1, double arg_2, double arg_3) {
+ return Shape.intersects(arg_0, arg_1, arg_2, arg_3);
+ }
+
+ bool awt.Shape.intersects(geom.Rectangle2D arg_0) {
+ return Shape.intersects(arg_0);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Bitmap.cs b/mcs/class/System.Drawing/System.Drawing/Bitmap.cs
new file mode 100644
index 00000000000..2f082833a13
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Bitmap.cs
@@ -0,0 +1,324 @@
+//
+// System.Drawing.Bitmap.cs
+//
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+// Authors:
+// Alexandre Pigolkine (pigolkine@gmx.de)
+// Christian Meyer (Christian.Meyer@cs.tum.edu)
+// Miguel de Icaza (miguel@ximian.com)
+// Jordi Mas i Hernandez (jmas@softcatala.org)
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.IO;
+using System.Drawing.Imaging;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+using System.Security.Permissions;
+
+namespace System.Drawing
+{
+ [Serializable]
+ [ComVisible (true)]
+ [Editor ("System.Drawing.Design.BitmapEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ public sealed class Bitmap : Image
+ {
+ #region constructors
+ // constructors
+ internal Bitmap (IntPtr ptr)
+ {
+ nativeObject = ptr;
+ }
+
+ public Bitmap (int width, int height) : this (width, height, PixelFormat.Format32bppArgb)
+ {
+
+ }
+
+ public Bitmap (int width, int height, Graphics g)
+ {
+ IntPtr bmp;
+ Status s = GDIPlus.GdipCreateBitmapFromGraphics (width, height, g.nativeObject, out bmp);
+ GDIPlus.CheckStatus (s);
+ nativeObject = (IntPtr)bmp;
+ }
+
+ public Bitmap (int width, int height, PixelFormat format)
+ {
+ IntPtr bmp;
+ Status s = GDIPlus.GdipCreateBitmapFromScan0 (width, height, 0, format, IntPtr.Zero, out bmp);
+ GDIPlus.CheckStatus (s);
+ nativeObject = (IntPtr) bmp;
+
+ }
+
+ public Bitmap (Image original) : this (original, original.Width, original.Height) {}
+
+ public Bitmap (Stream stream) : this (stream, false) {}
+
+ public Bitmap (string filename) : this (filename, false) {}
+
+ public Bitmap (Image original, Size newSize) : this(original, newSize.Width, newSize.Height) {}
+
+ internal Bitmap (int width, int height, PixelFormat pixel, IntPtr bmp)
+ {
+ nativeObject = (IntPtr)bmp;
+ }
+
+ internal Bitmap (float width, float height, PixelFormat pixel, IntPtr bmp)
+ {
+ nativeObject = (IntPtr)bmp;
+
+ }
+
+ public Bitmap (Stream stream, bool useIcm)
+ {
+ if (stream == null)
+ throw new ArgumentNullException ("stream");
+
+ InitFromStream (stream);
+ }
+
+ public Bitmap (string filename, bool useIcm)
+ {
+ IntPtr imagePtr;
+ Status st;
+
+ if (useIcm)
+ st = GDIPlus.GdipCreateBitmapFromFileICM (filename, out imagePtr);
+ else
+ st = GDIPlus.GdipCreateBitmapFromFile (filename, out imagePtr);
+
+ GDIPlus.CheckStatus (st);
+ nativeObject = imagePtr;
+ }
+
+ public Bitmap (Type type, string resource)
+ {
+ using (Stream s = type.Assembly.GetManifestResourceStream (type, resource)){
+ if (s == null)
+ throw new FileNotFoundException ("Resource name was not found: `" + resource + "'");
+
+ InitFromStream (s);
+ }
+ }
+
+ public Bitmap (Image original, int width, int height) : this(width, height, PixelFormat.Format32bppArgb)
+ {
+ Graphics graphics = Graphics.FromImage(this);
+
+ graphics.DrawImage(original, 0, 0, width, height);
+ graphics.Dispose();
+ }
+
+ public Bitmap (int width, int height, int stride, PixelFormat format, IntPtr scan0)
+ {
+ IntPtr bmp;
+
+ Status status = GDIPlus.GdipCreateBitmapFromScan0 (width, height, stride, format, scan0, out bmp);
+ GDIPlus.CheckStatus (status);
+ nativeObject = (IntPtr) bmp;
+ }
+
+ private Bitmap (SerializationInfo info, StreamingContext context)
+ {
+ foreach (SerializationEntry serEnum in info) {
+ if (String.Compare(serEnum.Name, "Data", true) == 0) {
+ byte[] bytes = (byte[]) serEnum.Value;
+
+ if (bytes != null) {
+ InitFromStream(new MemoryStream(bytes));
+ }
+ }
+ }
+ }
+ //The below function is not required. Call should resolve to base
+ //Moreover there is a problem with the declaration. Base class function
+ //is not declared as protected to access in descendent class
+ /*private Bitmap (SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }*/
+
+ #endregion
+ // methods
+ public Color GetPixel (int x, int y) {
+
+ int argb;
+
+ Status s = GDIPlus.GdipBitmapGetPixel(nativeObject, x, y, out argb);
+ GDIPlus.CheckStatus (s);
+
+ return Color.FromArgb(argb);
+ }
+
+ public void SetPixel (int x, int y, Color color)
+ {
+ Status s = GDIPlus.GdipBitmapSetPixel(nativeObject, x, y, color.ToArgb());
+ GDIPlus.CheckStatus (s);
+ }
+
+ public Bitmap Clone (Rectangle rect,PixelFormat format)
+ {
+ IntPtr bmp;
+ Status status = GDIPlus.GdipCloneBitmapAreaI(rect.X, rect.Top, rect.Width, rect.Height,
+ PixelFormat, nativeObject, out bmp);
+
+ GDIPlus.CheckStatus (status);
+
+ Bitmap bmpnew = new Bitmap (rect.Width, rect.Height, PixelFormat, (IntPtr) bmp);
+ return bmpnew;
+ }
+
+ public Bitmap Clone (RectangleF rect, PixelFormat format)
+ {
+ IntPtr bmp;
+ Status status = GDIPlus.GdipCloneBitmapArea (rect.X, rect.Top, rect.Width, rect.Height,
+ PixelFormat, nativeObject, out bmp);
+ GDIPlus.CheckStatus (status);
+
+ Bitmap bmpnew = new Bitmap (rect.Width, rect.Height, PixelFormat, (IntPtr) bmp);
+ return bmpnew;
+ }
+
+ public static Bitmap FromHicon (IntPtr hicon) //TODO: Untested
+ {
+ IntPtr bitmap;
+
+ Status status = GDIPlus.GdipCreateBitmapFromHICON (hicon, out bitmap);
+ GDIPlus.CheckStatus (status);
+
+ return new Bitmap (0,0, PixelFormat.Format32bppArgb, bitmap); // FIXME
+ }
+
+ public static Bitmap FromResource (IntPtr hinstance, string bitmapName) //TODO: Untested
+ {
+ IntPtr bitmap;
+
+ Status status = GDIPlus.GdipCreateBitmapFromResource (hinstance, bitmapName, out bitmap);
+ GDIPlus.CheckStatus (status);
+
+ return new Bitmap (0,0, PixelFormat.Format32bppArgb, bitmap); // FIXME
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
+ public IntPtr GetHbitmap ()
+ {
+ return GetHbitmap(Color.Gray);
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
+ public IntPtr GetHbitmap (Color background)
+ {
+ IntPtr HandleBmp;
+
+ Status status = GDIPlus.GdipCreateHBITMAPFromBitmap (nativeObject, out HandleBmp, background.ToArgb ());
+ GDIPlus.CheckStatus (status);
+
+ return HandleBmp;
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
+ public IntPtr GetHicon ()
+ {
+ IntPtr HandleIcon;
+
+ Status status = GDIPlus.GdipCreateHICONFromBitmap (nativeObject, out HandleIcon);
+ GDIPlus.CheckStatus (status);
+
+ return HandleIcon;
+ }
+
+ public BitmapData LockBits (Rectangle rect, ImageLockMode flags, PixelFormat format)
+ {
+ BitmapData result = new BitmapData();
+
+ if (nativeObject == (IntPtr) 0)
+ throw new Exception ("nativeObject is null");
+
+ Status status = GDIPlus.GdipBitmapLockBits (nativeObject, ref rect, flags, format, result);
+
+ //NOTE: scan0 points to piece of memory allocated in the unmanaged space
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+#if NET_2_0
+ public BitmapData LockBits (Rectangle rect, ImageLockMode flags, PixelFormat format, BitmapData bitmapData)
+ {
+ Status status = GDIPlus.GdipBitmapLockBits (nativeObject, ref rect, flags, format, bitmapData);
+ GDIPlus.CheckStatus (status);
+
+ return bitmapData;
+ }
+#endif
+
+ public void MakeTransparent ()
+ {
+ Color clr = GetPixel(0,0);
+ MakeTransparent (clr);
+ }
+
+ public void MakeTransparent (Color transparentColor)
+ {
+ // We have to draw always over a 32-bitmap surface that supports alpha channel
+ Bitmap bmp = new Bitmap(Width, Height, PixelFormat.Format32bppArgb);
+ Graphics gr = Graphics.FromImage(bmp);
+ Rectangle destRect = new Rectangle(0, 0, Width, Height);
+ ImageAttributes imageAttr = new ImageAttributes();
+
+ imageAttr.SetColorKey(transparentColor, transparentColor);
+
+ gr.DrawImage (this, destRect, 0, 0, Width, Height, GraphicsUnit.Pixel, imageAttr);
+
+ IntPtr oldBmp = nativeObject;
+ nativeObject = bmp.nativeObject;
+ bmp.nativeObject = oldBmp;
+
+ gr.Dispose();
+ bmp.Dispose();
+ imageAttr.Dispose();
+ }
+
+ public void SetResolution (float xDpi, float yDpi)
+ {
+ Status status = GDIPlus.GdipBitmapSetResolution (nativeObject, xDpi, yDpi);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void UnlockBits (BitmapData bitmap_data)
+ {
+ Status status = GDIPlus.GdipBitmapUnlockBits (nativeObject, bitmap_data);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Bitmap.jvm.cs b/mcs/class/System.Drawing/System.Drawing/Bitmap.jvm.cs
new file mode 100644
index 00000000000..90db022df0d
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Bitmap.jvm.cs
@@ -0,0 +1,420 @@
+using System;
+using System.IO;
+using System.Drawing.Imaging;
+using System.Runtime.Serialization;
+using Mainsoft.Drawing.Imaging;
+
+using io = java.io;
+using imageio = javax.imageio;
+using stream = javax.imageio.stream;
+using spi = javax.imageio.spi;
+using BufferedImage = java.awt.image.BufferedImage;
+using JavaImage = java.awt.Image;
+using awt = java.awt;
+using image = java.awt.image;
+
+namespace System.Drawing
+{
+ public sealed class Bitmap : Image {
+
+ # region Static fields
+
+ static readonly image.ColorModel _jpegColorModel = new image.DirectColorModel(24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
+
+ #endregion
+
+ #region constructors
+
+ Bitmap (PlainImage orig) {
+ base.Initialize( orig, false );
+ }
+
+ [MonoTODO]
+ private Bitmap (SerializationInfo info, StreamingContext context) {
+ throw new NotImplementedException ();
+ }
+
+ public Bitmap (int width, int height, Graphics g)
+ :this (width, height, PixelFormat.Format32bppArgb) {
+ CurrentImage.HorizontalResolution = g.DpiX;
+ CurrentImage.VerticalResolution = g.DpiY;
+ }
+
+ public Bitmap (Image original)
+ :this (original, original.Size) {}
+
+ public Bitmap (Image orig, Size newSize)
+ :this (orig, newSize.Width, newSize.Height) {}
+
+ public Bitmap (Image orig, int width, int height)
+ :base (CreateScaledImage (orig, width, height), ImageFormat.MemoryBmp) {}
+
+ internal Bitmap (java.awt.Image nativeObject, ImageFormat format)
+ :base (nativeObject, format) {}
+
+ [MonoTODO]
+ private Bitmap (java.awt.Image nativeObject, ImageFormat format, PixelFormat pixFormat)
+ :this (nativeObject, format) {
+ if (pixFormat != this.PixelFormat)
+ throw new NotImplementedException ("Converting PixelFormat is not implemented yet.");
+ }
+
+ public Bitmap (int width, int height)
+ :this (width, height, PixelFormat.Format32bppArgb) {}
+
+ public Bitmap (int width, int height, PixelFormat format)
+ :base (
+ new java.awt.image.BufferedImage (width, height,
+ ToBufferedImageFormat (format)),
+ ImageFormat.Bmp) {
+ }
+
+ public Bitmap (Stream stream)
+ :this (stream, false) {}
+
+ public Bitmap (string filename)
+ :this (filename, false) {}
+
+ [MonoTODO]
+ public Bitmap (Stream stream, bool useIcm)
+ :this (stream, useIcm, null) {}
+
+ [MonoTODO]
+ public Bitmap (string filename, bool useIcm)
+ :this (filename, useIcm, null) {}
+
+ internal Bitmap (Stream stream, bool useIcm, ImageFormat format) {
+ // TBD: useIcm param
+ io.InputStream jis = vmw.common.IOUtils.ToInputStream (stream);
+ Initialize (new stream.MemoryCacheImageInputStream (jis), format);
+ }
+
+ internal Bitmap (string filename, bool useIcm, ImageFormat format) {
+ using(FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read)) {
+ // TBD: useIcm param
+ io.InputStream jis = vmw.common.IOUtils.ToInputStream (stream);
+ Initialize (new stream.MemoryCacheImageInputStream (jis), format);
+ }
+ }
+
+ public Bitmap (Type type, string resource) {
+ using (Stream s = type.Assembly.GetManifestResourceStream (resource)) {
+ if (s == null)
+ throw new ArgumentException("Resource '" + resource + "' could not be found in class '" + type.ToString() + "'");
+
+ io.InputStream jis = vmw.common.IOUtils.ToInputStream (s);
+ Initialize (new stream.MemoryCacheImageInputStream (jis), null);
+ }
+ }
+#if INTPTR_SUPPORT
+ [MonoTODO]
+ public Bitmap (int width, int height, int stride, PixelFormat format, IntPtr scan0)
+ {
+ throw new NotImplementedException();
+ }
+#endif
+ #endregion
+
+ #region Internal Initialization
+
+ private void Initialize (stream.ImageInputStream input, ImageFormat format) {
+ ImageCodec ic = null;
+
+ if (format == null)
+ ic = ImageCodec.CreateReader(input);
+ else
+ ic = ImageCodec.CreateReader(format);
+
+ try {
+ ic.NativeStream = input;
+ PlainImage pi = ic.ReadPlainImage();
+ base.Initialize( pi, false );
+
+ pi = ic.ReadNextPlainImage();
+ while ( pi != null) {
+ base.Initialize( pi, true );
+ pi = ic.ReadNextPlainImage();
+ }
+
+ _flags |= (int)(ImageFlags.ImageFlagsReadOnly | ImageFlags.ImageFlagsHasRealPixelSize);
+ }
+ catch (IOException ex) {
+ throw ex;
+ }
+ catch (Exception) {
+ throw new OutOfMemoryException ("Out of memory");
+ }
+ finally {
+ ic.Dispose();
+ }
+ }
+
+ #endregion
+
+ #region InternalSave
+ protected override void InternalSave (stream.ImageOutputStream output, Guid clsid) {
+
+ ImageCodec ic = ImageCodec.CreateWriter( clsid );
+ using (ic) {
+
+ PlainImage plainImage = CurrentImage;
+ plainImage.NativeImage.flush();
+
+ if ( ImageCodec.ClsidToImageFormat( clsid ).Equals( ImageFormat.Jpeg ) ) {
+ image.ColorModel cm = ((image.BufferedImage)CurrentImage.NativeImage).getColorModel();
+ if (cm.hasAlpha()) {
+ if (cm is image.DirectColorModel) {
+ image.Raster raster = ((image.BufferedImage)CurrentImage.NativeImage).getRaster();
+ image.DataBuffer db = raster.getDataBuffer();
+ image.DirectColorModel dcm = (image.DirectColorModel)cm;
+ image.SinglePixelPackedSampleModel jpegSampleModel = new image.SinglePixelPackedSampleModel(
+ db.getDataType(), Width, Height,
+ new int[] {dcm.getRedMask(), dcm.getGreenMask(), dcm.getBlueMask()} );
+
+ image.BufferedImage tb = new image.BufferedImage(
+ _jpegColorModel,
+ image.Raster.createWritableRaster( jpegSampleModel, db, null ),
+ false, null );
+
+ plainImage = new PlainImage( tb, plainImage.Thumbnails, ImageFormat.Jpeg, plainImage.HorizontalResolution, plainImage.VerticalResolution, plainImage.Dimension );
+ plainImage.NativeMetadata = plainImage.NativeMetadata;
+ }
+ }
+ }
+
+ ic.NativeStream = output;
+ ic.WritePlainImage( plainImage );
+ }
+ }
+
+ #endregion
+
+ #region private statics: ToBufferedImageFormat, CreateScaledImage
+
+ private static int ToBufferedImageFormat (PixelFormat format) {
+ switch(format) {
+ case PixelFormat.Format16bppGrayScale:
+ return BufferedImage.TYPE_USHORT_GRAY;
+ case PixelFormat.Format1bppIndexed:
+ return BufferedImage.TYPE_BYTE_GRAY;
+ case PixelFormat.Format32bppArgb:
+ return BufferedImage.TYPE_INT_ARGB;
+ case PixelFormat.Format32bppRgb:
+ return BufferedImage.TYPE_INT_RGB;
+ case PixelFormat.Format32bppPArgb:
+ return BufferedImage.TYPE_INT_ARGB_PRE;
+ case PixelFormat.Format16bppRgb555:
+ return BufferedImage.TYPE_USHORT_555_RGB;
+ case PixelFormat.Format16bppRgb565:
+ return BufferedImage.TYPE_USHORT_565_RGB;
+ case PixelFormat.Indexed:
+ return BufferedImage.TYPE_BYTE_INDEXED;
+ default:
+ return BufferedImage.TYPE_INT_ARGB;
+ }
+ }
+
+ private static java.awt.Image CreateScaledImage(Image original, int width, int height) {
+ JavaImage oldscaled = original.CurrentImage.NativeImage.getScaledInstance(width, height,
+ JavaImage.SCALE_DEFAULT);
+ BufferedImage newimage = new BufferedImage(oldscaled.getWidth(null),
+ oldscaled.getHeight(null),
+ BufferedImage.TYPE_INT_ARGB);
+ java.awt.Graphics2D graphics2d = newimage.createGraphics();
+ graphics2d.drawImage(oldscaled, 0, 0, null);
+ graphics2d.dispose();
+ return newimage;
+ }
+ #endregion
+
+ #region Get-SetPixel
+ public Color GetPixel (int x, int y)
+ {
+
+ int argb = NativeObject.getRGB(x,y);
+ return Color.FromArgb(argb);
+ }
+
+ public void SetPixel (int x, int y, Color color)
+ {
+ int rgb = color.ToArgb();
+ NativeObject.setRGB(x,y,rgb);
+ }
+ #endregion
+
+ #region Clone
+ public override object Clone () {
+ return new Bitmap ( (PlainImage)CurrentImage.Clone() );
+ }
+
+ public Bitmap Clone (Rectangle rect, PixelFormat pixFormat)
+ {
+ return Clone(new RectangleF( rect.X, rect.Y, rect.Width, rect.Height ), pixFormat);
+ }
+
+ public Bitmap Clone (RectangleF rect, PixelFormat pixFormat)
+ {
+ PlainImage plainImage = CurrentImage.Clone(false);
+ BufferedImage clone = new BufferedImage( (int)rect.Width, (int)rect.Height, ToBufferedImageFormat( pixFormat ) );
+ awt.Graphics2D g = clone.createGraphics();
+ try {
+ g.drawImage( NativeObject, -(int)rect.X, -(int)rect.Y, null );
+ }
+ finally {
+ g.dispose();
+ }
+
+ plainImage.NativeImage = clone;
+ return new Bitmap(plainImage);
+ }
+ #endregion
+
+ #region LockBits
+ [MonoTODO]
+ public BitmapData LockBits (Rectangle rect, ImageLockMode flags, PixelFormat format) {
+ throw new NotImplementedException();
+ }
+ #endregion
+
+ #region MakeTransparent
+ public void MakeTransparent ()
+ {
+ Color clr = Color.FromArgb(0,0,0);
+ MakeTransparent (clr);
+ }
+
+ public void MakeTransparent (Color transparentColor)
+ {
+ image.WritableRaster raster = NativeObject.getRaster();
+ int numBands = raster.getNumBands();
+ if (numBands != 4)
+ return;
+
+ int maxWidth = raster.getWidth() + raster.getMinX();
+ int maxHeight = raster.getHeight() + raster.getMinY();
+ int[] srcPix = new int[numBands];
+
+ for (int y = raster.getMinY(); y < maxHeight; y++) {
+ for (int x = raster.getMinX(); x < maxWidth; x++) {
+ /*srcPix =*/ raster.getPixel(x, y, srcPix);
+ if (srcPix[0] == transparentColor.R &&
+ srcPix[1] == transparentColor.G &&
+ srcPix[2] == transparentColor.B) {
+ srcPix[3] = 0;
+ raster.setPixel(x, y, srcPix);
+ }
+ }
+ }
+ }
+ #endregion
+
+ #region SetResolution
+ public void SetResolution (float xDpi, float yDpi)
+ {
+ CurrentImage.HorizontalResolution = xDpi;
+ CurrentImage.VerticalResolution = yDpi;
+ }
+ #endregion
+
+ #region UnlockBits
+ [MonoTODO]
+ public void UnlockBits (BitmapData bitmap_data)
+ {
+ throw new NotImplementedException();
+ }
+ #endregion
+
+ #region NativeObject
+ internal new BufferedImage NativeObject {
+ get {
+ return (BufferedImage)base.NativeObject.CurrentImage.NativeImage;
+ }
+ }
+
+ protected override java.awt.Image[] CloneNativeObjects(java.awt.Image[] src) {
+ if (src == null)
+ return null;
+
+ awt.Image[] dst = new awt.Image[src.Length];
+ for (int i = 0; i < dst.Length; i++) {
+ BufferedImage image = src[i] as BufferedImage;
+ if (image == null)
+ throw new ArgumentException(String.Format("Unsupported image type '{0}'", src[i].ToString()), "src");
+
+ dst[i] = new BufferedImage(image.getColorModel(), image.copyData(null), image.isAlphaPremultiplied(), null);
+ }
+
+ return dst;
+ }
+
+ #endregion
+
+ #region InternalPixelFormat
+ protected override PixelFormat InternalPixelFormat {
+ get {
+ int t = NativeObject.getType();
+ switch(t) {
+ case 11://JavaImage.TYPE_USHORT_GRAY:
+ return PixelFormat.Format16bppGrayScale;
+ case 10://JavaImage.TYPE_BYTE_GRAY:
+ return PixelFormat.Format1bppIndexed;
+ case 1: //JavaImage.TYPE_INT_RGB
+ return PixelFormat.Format32bppRgb;
+ case 2: //JavaImage.TYPE_INT_ARGB:
+ return PixelFormat.Format32bppArgb;
+ case 3://JavaImage.TYPE_INT_ARGB_PRE:
+ return PixelFormat.Format32bppPArgb;
+ case 9://JavaImage.TYPE_USHORT_555_RGB:
+ return PixelFormat.Format16bppRgb555;
+ case 8://JavaImage.TYPE_USHORT_565_RGB:
+ return PixelFormat.Format16bppRgb565;
+ case 13://JavaImage.TYPE_BYTE_INDEXED:
+ return PixelFormat.Indexed;
+ //TBD: support this
+ case 12://JavaImage.TYPE_BYTE_BINARY:
+ case 0://JavaImage.TYPE_CUSTOM:
+ case 4://JavaImage.TYPE_INT_BGR:
+ case 5://JavaImage.TYPE_3BYTE_BGR:
+ case 6://JavaImage.TYPE_4BYTE_ABGR:
+ case 7://JavaImage.TYPE_4BYTE_ABGR_PRE:
+ default:
+ return PixelFormat.Undefined;
+ }
+ }
+ }
+ #endregion
+
+#if INTPTR_SUPPORT
+ [MonoTODO]
+ public static Bitmap FromHicon (IntPtr hicon)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public static Bitmap FromResource (IntPtr hinstance, string bitmapName) //TBD: Untested
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public IntPtr GetHbitmap ()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public IntPtr GetHbitmap (Color background)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public IntPtr GetHicon ()
+ {
+ throw new NotImplementedException();
+ }
+#endif
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Brush.cs b/mcs/class/System.Drawing/System.Drawing/Brush.cs
new file mode 100644
index 00000000000..77c758a6ed5
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Brush.cs
@@ -0,0 +1,115 @@
+//
+// System.Drawing.Brush.cs
+//
+// Authors:
+// Miguel de Icaza (miguel@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+// (C) Novell, Inc. Http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Collections;
+
+namespace System.Drawing
+{
+ public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable
+ {
+ internal IntPtr nativeObject;
+ abstract public object Clone ();
+
+ internal Brush (IntPtr ptr)
+ {
+ nativeObject = ptr;
+ }
+
+ internal IntPtr NativeObject {
+ get {
+ return nativeObject;
+ }
+ set {
+ nativeObject = value;
+ }
+ }
+
+#if NET_2_0
+ protected Brush ()
+ {
+
+ }
+
+ protected internal void SetNativeBrush (IntPtr brush)
+ {
+ nativeObject = brush;
+ }
+#else
+ internal Brush ()
+ {
+
+ }
+#endif
+
+ internal Brush CreateBrush (IntPtr brush, System.Drawing.BrushType type)
+ {
+ switch (type) {
+ case BrushType.BrushTypeSolidColor:
+ return new SolidBrush (brush);
+
+ case BrushType.BrushTypeHatchFill:
+ return new HatchBrush (brush);
+
+ case BrushType.BrushTypeTextureFill:
+ return new TextureBrush (brush);
+
+ default:
+ throw new NotImplementedException ();
+ }
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if ((GDIPlus.Display != IntPtr.Zero) && (nativeObject != IntPtr.Zero)) {
+ GDIPlus.GdipDeleteBrush (nativeObject);
+ nativeObject = IntPtr.Zero;
+ }
+ }
+
+ ~Brush ()
+ {
+ Dispose (false);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing/Brush.jvm.cs b/mcs/class/System.Drawing/System.Drawing/Brush.jvm.cs
new file mode 100755
index 00000000000..c7fa4051e08
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Brush.jvm.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Collections;
+
+using awt = java.awt;
+using image = java.awt.image;
+using geom = java.awt.geom;
+
+
+namespace System.Drawing
+{
+ public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable, awt.Paint {
+
+ #region fields
+
+ private Matrix _brushTransform = new Matrix();
+
+ #endregion
+
+ protected abstract java.awt.Paint NativeObject {
+ get;
+ }
+
+ awt.PaintContext awt.Paint.createContext (image.ColorModel cm,
+ awt.Rectangle deviceBounds, geom.Rectangle2D userBounds, geom.AffineTransform xform,
+ awt.RenderingHints hints) {
+
+ return createContextInternal(cm, deviceBounds, userBounds, xform, hints);
+ }
+
+ protected virtual awt.PaintContext createContextInternal (image.ColorModel cm,
+ awt.Rectangle deviceBounds, geom.Rectangle2D userBounds, geom.AffineTransform xform,
+ awt.RenderingHints hints) {
+
+ Matrix.Multiply(xform, _brushTransform.NativeObject, MatrixOrder.Append);
+ return NativeObject.createContext (cm, deviceBounds, userBounds, xform, hints);
+ }
+
+ int awt.Transparency.getTransparency () {
+ return NativeObject.getTransparency ();
+ }
+
+ abstract public object Clone ();
+
+ public void Dispose () {
+ Dispose (true);
+ }
+
+ protected virtual void Dispose (bool disposing) {
+ }
+
+ protected Brush InternalClone() {
+ Brush brush = (Brush)this.MemberwiseClone();
+ brush._brushTransform = this._brushTransform.Clone();
+ return brush;
+ }
+
+ #region Brush transform
+
+ internal Matrix BrushTransform {
+ get { return _brushTransform.Clone(); }
+ set {
+ if (value == null)
+ throw new ArgumentNullException("matrix");
+
+ value.CopyTo( _brushTransform );
+ }
+ }
+
+ protected internal void BrushTranslateTransform (float dx, float dy) {
+ BrushTranslateTransform(dx, dy, MatrixOrder.Prepend);
+ }
+ protected internal void BrushTranslateTransform (float dx, float dy, MatrixOrder order) {
+ _brushTransform.Translate(dx,dy,order);
+ }
+ protected internal void BrushResetTransform () {
+ _brushTransform.Reset();
+ }
+ protected internal void BrushRotateTransform (float angle) {
+ BrushRotateTransform(angle, MatrixOrder.Prepend);
+ }
+ protected internal void BrushRotateTransform (float angle, MatrixOrder order) {
+ _brushTransform.Rotate(angle, order);
+ }
+ protected internal void BrushScaleTransform (float sx, float sy) {
+ BrushScaleTransform(sx, sy, MatrixOrder.Prepend);
+ }
+ protected internal void BrushScaleTransform (float sx, float sy, MatrixOrder order) {
+ _brushTransform.Scale(sx, sy, order);
+ }
+ protected internal void BrushMultiplyTransform (Matrix matrix) {
+ BrushMultiplyTransform(matrix, MatrixOrder.Prepend);
+ }
+ protected internal void BrushMultiplyTransform (Matrix matrix, MatrixOrder order) {
+ if (matrix == null)
+ throw new ArgumentNullException("matrix");
+ _brushTransform.Multiply(matrix, order);
+ }
+
+ #endregion
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing/Brushes.cs b/mcs/class/System.Drawing/System.Drawing/Brushes.cs
new file mode 100644
index 00000000000..98a387c6de1
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Brushes.cs
@@ -0,0 +1,1459 @@
+//
+// System.Windows.Drawing.Brushes.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Suesan Chaney
+// Peter Bartok (pbartok@novell.com)
+//
+// (C) Ximian, Inc., 2002 http://www.ximian.com
+// (C) Novell, Inc., 2004 http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing
+{
+ public sealed class Brushes
+ {
+ static SolidBrush aliceBlue;
+ static SolidBrush antiqueWhite;
+ static SolidBrush aqua;
+ static SolidBrush aquamarine;
+ static SolidBrush azure;
+ static SolidBrush beige;
+ static SolidBrush bisque;
+ static SolidBrush black;
+ static SolidBrush blanchedAlmond;
+ static SolidBrush blue;
+ static SolidBrush blueViolet;
+ static SolidBrush brown;
+ static SolidBrush burlyWood;
+ static SolidBrush cadetBlue;
+ static SolidBrush chartreuse;
+ static SolidBrush chocolate;
+ static SolidBrush coral;
+ static SolidBrush cornflowerBlue;
+ static SolidBrush cornsilk;
+ static SolidBrush crimson;
+ static SolidBrush cyan;
+ static SolidBrush darkBlue;
+ static SolidBrush darkCyan;
+ static SolidBrush darkGoldenrod;
+ static SolidBrush darkGray;
+ static SolidBrush darkGreen;
+ static SolidBrush darkKhaki;
+ static SolidBrush darkMagenta;
+ static SolidBrush darkOliveGreen;
+ static SolidBrush darkOrange;
+ static SolidBrush darkOrchid;
+ static SolidBrush darkRed;
+ static SolidBrush darkSalmon;
+ static SolidBrush darkSeaGreen;
+ static SolidBrush darkSlateBlue;
+ static SolidBrush darkSlateGray;
+ static SolidBrush darkTurquoise;
+ static SolidBrush darkViolet;
+ static SolidBrush deepPink;
+ static SolidBrush deepSkyBlue;
+ static SolidBrush dimGray;
+ static SolidBrush dodgerBlue;
+ static SolidBrush firebrick;
+ static SolidBrush floralWhite;
+ static SolidBrush forestGreen;
+ static SolidBrush fuchsia;
+ static SolidBrush gainsboro;
+ static SolidBrush ghostWhite;
+ static SolidBrush gold;
+ static SolidBrush goldenrod;
+ static SolidBrush gray;
+ static SolidBrush green;
+ static SolidBrush greenYellow;
+ static SolidBrush honeydew;
+ static SolidBrush hotPink;
+ static SolidBrush indianRed;
+ static SolidBrush indigo;
+ static SolidBrush ivory;
+ static SolidBrush khaki;
+ static SolidBrush lavender;
+ static SolidBrush lavenderBlush;
+ static SolidBrush lawnGreen;
+ static SolidBrush lemonChiffon;
+ static SolidBrush lightBlue;
+ static SolidBrush lightCoral;
+ static SolidBrush lightCyan;
+ static SolidBrush lightGoldenrodYellow;
+ static SolidBrush lightGray;
+ static SolidBrush lightGreen;
+ static SolidBrush lightPink;
+ static SolidBrush lightSalmon;
+ static SolidBrush lightSeaGreen;
+ static SolidBrush lightSkyBlue;
+ static SolidBrush lightSlateGray;
+ static SolidBrush lightSteelBlue;
+ static SolidBrush lightYellow;
+ static SolidBrush lime;
+ static SolidBrush limeGreen;
+ static SolidBrush linen;
+ static SolidBrush magenta;
+ static SolidBrush maroon;
+ static SolidBrush mediumAquamarine;
+ static SolidBrush mediumBlue;
+ static SolidBrush mediumOrchid;
+ static SolidBrush mediumPurple;
+ static SolidBrush mediumSeaGreen;
+ static SolidBrush mediumSlateBlue;
+ static SolidBrush mediumSpringGreen;
+ static SolidBrush mediumTurquoise;
+ static SolidBrush mediumVioletRed;
+ static SolidBrush midnightBlue;
+ static SolidBrush mintCream;
+ static SolidBrush mistyRose;
+ static SolidBrush moccasin;
+ static SolidBrush navajoWhite;
+ static SolidBrush navy;
+ static SolidBrush oldLace;
+ static SolidBrush olive;
+ static SolidBrush oliveDrab;
+ static SolidBrush orange;
+ static SolidBrush orangeRed;
+ static SolidBrush orchid;
+ static SolidBrush paleGoldenrod;
+ static SolidBrush paleGreen;
+ static SolidBrush paleTurquoise;
+ static SolidBrush paleVioletRed;
+ static SolidBrush papayaWhip;
+ static SolidBrush peachPuff;
+ static SolidBrush peru;
+ static SolidBrush pink;
+ static SolidBrush plum;
+ static SolidBrush powderBlue;
+ static SolidBrush purple;
+ static SolidBrush red;
+ static SolidBrush rosyBrown;
+ static SolidBrush royalBlue;
+ static SolidBrush saddleBrown;
+ static SolidBrush salmon;
+ static SolidBrush sandyBrown;
+ static SolidBrush seaGreen;
+ static SolidBrush seaShell;
+ static SolidBrush sienna;
+ static SolidBrush silver;
+ static SolidBrush skyBlue;
+ static SolidBrush slateBlue;
+ static SolidBrush slateGray;
+ static SolidBrush snow;
+ static SolidBrush springGreen;
+ static SolidBrush steelBlue;
+ static SolidBrush tan;
+ static SolidBrush teal;
+ static SolidBrush thistle;
+ static SolidBrush tomato;
+ static SolidBrush transparent;
+ static SolidBrush turquoise;
+ static SolidBrush violet;
+ static SolidBrush wheat;
+ static SolidBrush white;
+ static SolidBrush whiteSmoke;
+ static SolidBrush yellow;
+ static SolidBrush yellowGreen;
+
+ // We intentionally do not set the is_modifiable=false flag on
+ // the brushes, to stay Microsoft compatible
+
+ private Brushes () { }
+
+ public static Brush AliceBlue {
+ get {
+ if (aliceBlue==null) {
+ aliceBlue=new SolidBrush(Color.AliceBlue);
+ }
+ return(aliceBlue);
+ }
+ }
+
+ public static Brush AntiqueWhite {
+ get {
+ if (antiqueWhite==null) {
+ antiqueWhite=new SolidBrush(Color.AntiqueWhite);
+ }
+ return(antiqueWhite);
+ }
+ }
+
+ public static Brush Aqua {
+ get {
+ if (aqua==null) {
+ aqua=new SolidBrush(Color.Aqua);
+ }
+ return(aqua);
+ }
+ }
+
+ public static Brush Aquamarine {
+ get {
+ if (aquamarine==null) {
+ aquamarine=new SolidBrush(Color.Aquamarine);
+ }
+ return(aquamarine);
+ }
+ }
+
+ public static Brush Azure {
+ get {
+ if (azure==null) {
+ azure=new SolidBrush(Color.Azure);
+ }
+ return(azure);
+ }
+ }
+
+ public static Brush Beige {
+ get {
+ if (beige==null) {
+ beige=new SolidBrush(Color.Beige);
+ }
+ return(beige);
+ }
+ }
+
+ public static Brush Bisque {
+ get {
+ if (bisque==null) {
+ bisque=new SolidBrush(Color.Bisque);
+ }
+ return(bisque);
+ }
+ }
+
+ public static Brush Black {
+ get {
+ if (black==null) {
+ black=new SolidBrush(Color.Black);
+ }
+ return(black);
+ }
+ }
+
+ public static Brush BlanchedAlmond {
+ get {
+ if (blanchedAlmond==null) {
+ blanchedAlmond=new SolidBrush(Color.BlanchedAlmond);
+ }
+ return(blanchedAlmond);
+ }
+ }
+
+ public static Brush Blue {
+ get {
+ if (blue==null) {
+ blue=new SolidBrush(Color.Blue);
+ }
+ return(blue);
+ }
+ }
+
+ public static Brush BlueViolet {
+ get {
+ if (blueViolet==null) {
+ blueViolet=new SolidBrush(Color.BlueViolet);
+ }
+ return(blueViolet);
+ }
+ }
+
+ public static Brush Brown {
+ get {
+ if (brown==null) {
+ brown=new SolidBrush(Color.Brown);
+ }
+ return(brown);
+ }
+ }
+
+ public static Brush BurlyWood {
+ get {
+ if (burlyWood==null) {
+ burlyWood=new SolidBrush(Color.BurlyWood);
+ }
+ return(burlyWood);
+ }
+ }
+
+ public static Brush CadetBlue {
+ get {
+ if (cadetBlue==null) {
+ cadetBlue=new SolidBrush(Color.CadetBlue);
+ }
+ return(cadetBlue);
+ }
+ }
+
+ public static Brush Chartreuse {
+ get {
+ if (chartreuse==null) {
+ chartreuse=new SolidBrush(Color.Chartreuse);
+ }
+ return(chartreuse);
+ }
+ }
+
+ public static Brush Chocolate {
+ get {
+ if (chocolate==null) {
+ chocolate=new SolidBrush(Color.Chocolate);
+ }
+ return(chocolate);
+ }
+ }
+
+ public static Brush Coral {
+ get {
+ if (coral==null) {
+ coral=new SolidBrush(Color.Coral);
+ }
+ return(coral);
+ }
+ }
+
+ public static Brush CornflowerBlue {
+ get {
+ if (cornflowerBlue==null) {
+ cornflowerBlue=new SolidBrush(Color.CornflowerBlue);
+ }
+ return(cornflowerBlue);
+ }
+ }
+
+ public static Brush Cornsilk {
+ get {
+ if (cornsilk==null) {
+ cornsilk=new SolidBrush(Color.Cornsilk);
+ }
+ return(cornsilk);
+ }
+ }
+
+ public static Brush Crimson {
+ get {
+ if (crimson==null) {
+ crimson=new SolidBrush(Color.Crimson);
+ }
+ return(crimson);
+ }
+ }
+
+ public static Brush Cyan {
+ get {
+ if (cyan==null) {
+ cyan=new SolidBrush(Color.Cyan);
+ }
+ return(cyan);
+ }
+ }
+
+ public static Brush DarkBlue {
+ get {
+ if (darkBlue==null) {
+ darkBlue=new SolidBrush(Color.DarkBlue);
+ }
+ return(darkBlue);
+ }
+ }
+
+ public static Brush DarkCyan {
+ get {
+ if (darkCyan==null) {
+ darkCyan=new SolidBrush(Color.DarkCyan);
+ }
+ return(darkCyan);
+ }
+ }
+
+ public static Brush DarkGoldenrod {
+ get {
+ if (darkGoldenrod==null) {
+ darkGoldenrod=new SolidBrush(Color.DarkGoldenrod);
+ }
+ return(darkGoldenrod);
+ }
+ }
+
+ public static Brush DarkGray {
+ get {
+ if (darkGray==null) {
+ darkGray=new SolidBrush(Color.DarkGray);
+ }
+ return(darkGray);
+ }
+ }
+
+ public static Brush DarkGreen {
+ get {
+ if (darkGreen==null) {
+ darkGreen=new SolidBrush(Color.DarkGreen);
+ }
+ return(darkGreen);
+ }
+ }
+
+ public static Brush DarkKhaki {
+ get {
+ if (darkKhaki==null) {
+ darkKhaki=new SolidBrush(Color.DarkKhaki);
+ }
+ return(darkKhaki);
+ }
+ }
+
+ public static Brush DarkMagenta {
+ get {
+ if (darkMagenta==null) {
+ darkMagenta=new SolidBrush(Color.DarkMagenta);
+ }
+ return(darkMagenta);
+ }
+ }
+
+ public static Brush DarkOliveGreen {
+ get {
+ if (darkOliveGreen==null) {
+ darkOliveGreen=new SolidBrush(Color.DarkOliveGreen);
+ }
+ return(darkOliveGreen);
+ }
+ }
+
+ public static Brush DarkOrange {
+ get {
+ if (darkOrange==null) {
+ darkOrange=new SolidBrush(Color.DarkOrange);
+ }
+ return(darkOrange);
+ }
+ }
+
+ public static Brush DarkOrchid {
+ get {
+ if (darkOrchid==null) {
+ darkOrchid=new SolidBrush(Color.DarkOrchid);
+ }
+ return(darkOrchid);
+ }
+ }
+
+ public static Brush DarkRed {
+ get {
+ if (darkRed==null) {
+ darkRed=new SolidBrush(Color.DarkRed);
+ }
+ return(darkRed);
+ }
+ }
+
+ public static Brush DarkSalmon {
+ get {
+ if (darkSalmon==null) {
+ darkSalmon=new SolidBrush(Color.DarkSalmon);
+ }
+ return(darkSalmon);
+ }
+ }
+
+ public static Brush DarkSeaGreen {
+ get {
+ if (darkSeaGreen==null) {
+ darkSeaGreen=new SolidBrush(Color.DarkSeaGreen);
+ }
+ return(darkSeaGreen);
+ }
+ }
+
+ public static Brush DarkSlateBlue {
+ get {
+ if (darkSlateBlue==null) {
+ darkSlateBlue=new SolidBrush(Color.DarkSlateBlue);
+ }
+ return(darkSlateBlue);
+ }
+ }
+
+ public static Brush DarkSlateGray {
+ get {
+ if (darkSlateGray==null) {
+ darkSlateGray=new SolidBrush(Color.DarkSlateGray);
+ }
+ return(darkSlateGray);
+ }
+ }
+
+ public static Brush DarkTurquoise {
+ get {
+ if (darkTurquoise==null) {
+ darkTurquoise=new SolidBrush(Color.DarkTurquoise);
+ }
+ return(darkTurquoise);
+ }
+ }
+
+ public static Brush DarkViolet {
+ get {
+ if (darkViolet==null) {
+ darkViolet=new SolidBrush(Color.DarkViolet);
+ }
+ return(darkViolet);
+ }
+ }
+
+ public static Brush DeepPink {
+ get {
+ if (deepPink==null) {
+ deepPink=new SolidBrush(Color.DeepPink);
+ }
+ return(deepPink);
+ }
+ }
+
+ public static Brush DeepSkyBlue {
+ get {
+ if (deepSkyBlue==null) {
+ deepSkyBlue=new SolidBrush(Color.DeepSkyBlue);
+ }
+ return(deepSkyBlue);
+ }
+ }
+
+ public static Brush DimGray {
+ get {
+ if (dimGray==null) {
+ dimGray=new SolidBrush(Color.DimGray);
+ }
+ return(dimGray);
+ }
+ }
+
+ public static Brush DodgerBlue {
+ get {
+ if (dodgerBlue==null) {
+ dodgerBlue=new SolidBrush(Color.DodgerBlue);
+ }
+ return(dodgerBlue);
+ }
+ }
+
+ public static Brush Firebrick {
+ get {
+ if (firebrick==null) {
+ firebrick=new SolidBrush(Color.Firebrick);
+ }
+ return(firebrick);
+ }
+ }
+
+ public static Brush FloralWhite {
+ get {
+ if (floralWhite==null) {
+ floralWhite=new SolidBrush(Color.FloralWhite);
+ }
+ return(floralWhite);
+ }
+ }
+
+ public static Brush ForestGreen {
+ get {
+ if (forestGreen==null) {
+ forestGreen=new SolidBrush(Color.ForestGreen);
+ }
+ return(forestGreen);
+ }
+ }
+
+ public static Brush Fuchsia {
+ get {
+ if (fuchsia==null) {
+ fuchsia=new SolidBrush(Color.Fuchsia);
+ }
+ return(fuchsia);
+ }
+ }
+
+ public static Brush Gainsboro {
+ get {
+ if (gainsboro==null) {
+ gainsboro=new SolidBrush(Color.Gainsboro);
+ }
+ return(gainsboro);
+ }
+ }
+
+ public static Brush GhostWhite {
+ get {
+ if (ghostWhite==null) {
+ ghostWhite=new SolidBrush(Color.GhostWhite);
+ }
+ return(ghostWhite);
+ }
+ }
+
+ public static Brush Gold {
+ get {
+ if (gold==null) {
+ gold=new SolidBrush(Color.Gold);
+ }
+ return(gold);
+ }
+ }
+
+ public static Brush Goldenrod {
+ get {
+ if (goldenrod==null) {
+ goldenrod=new SolidBrush(Color.Goldenrod);
+ }
+ return(goldenrod);
+ }
+ }
+
+ public static Brush Gray {
+ get {
+ if (gray==null) {
+ gray=new SolidBrush(Color.Gray);
+ }
+ return(gray);
+ }
+ }
+
+ public static Brush Green {
+ get {
+ if (green==null) {
+ green=new SolidBrush(Color.Green);
+ }
+ return(green);
+ }
+ }
+
+ public static Brush GreenYellow {
+ get {
+ if (greenYellow==null) {
+ greenYellow=new SolidBrush(Color.GreenYellow);
+ }
+ return(greenYellow);
+ }
+ }
+
+ public static Brush Honeydew {
+ get {
+ if (honeydew==null) {
+ honeydew=new SolidBrush(Color.Honeydew);
+ }
+ return(honeydew);
+ }
+ }
+
+ public static Brush HotPink {
+ get {
+ if (hotPink==null) {
+ hotPink=new SolidBrush(Color.HotPink);
+ }
+ return(hotPink);
+ }
+ }
+
+ public static Brush IndianRed {
+ get {
+ if (indianRed==null) {
+ indianRed=new SolidBrush(Color.IndianRed);
+ }
+ return(indianRed);
+ }
+ }
+
+ public static Brush Indigo {
+ get {
+ if (indigo==null) {
+ indigo=new SolidBrush(Color.Indigo);
+ }
+ return(indigo);
+ }
+ }
+
+ public static Brush Ivory {
+ get {
+ if (ivory==null) {
+ ivory=new SolidBrush(Color.Ivory);
+ }
+ return(ivory);
+ }
+ }
+
+ public static Brush Khaki {
+ get {
+ if (khaki==null) {
+ khaki=new SolidBrush(Color.Khaki);
+ }
+ return(khaki);
+ }
+ }
+
+ public static Brush Lavender {
+ get {
+ if (lavender==null) {
+ lavender=new SolidBrush(Color.Lavender);
+ }
+ return(lavender);
+ }
+ }
+
+ public static Brush LavenderBlush {
+ get {
+ if (lavenderBlush==null) {
+ lavenderBlush=new SolidBrush(Color.LavenderBlush);
+ }
+ return(lavenderBlush);
+ }
+ }
+
+ public static Brush LawnGreen {
+ get {
+ if (lawnGreen==null) {
+ lawnGreen=new SolidBrush(Color.LawnGreen);
+ }
+ return(lawnGreen);
+ }
+ }
+
+ public static Brush LemonChiffon {
+ get {
+ if (lemonChiffon==null) {
+ lemonChiffon=new SolidBrush(Color.LemonChiffon);
+ }
+ return(lemonChiffon);
+ }
+ }
+
+ public static Brush LightBlue {
+ get {
+ if (lightBlue==null) {
+ lightBlue=new SolidBrush(Color.LightBlue);
+ }
+ return(lightBlue);
+ }
+ }
+
+ public static Brush LightCoral {
+ get {
+ if (lightCoral==null) {
+ lightCoral=new SolidBrush(Color.LightCoral);
+ }
+ return(lightCoral);
+ }
+ }
+
+ public static Brush LightCyan {
+ get {
+ if (lightCyan==null) {
+ lightCyan=new SolidBrush(Color.LightCyan);
+ }
+ return(lightCyan);
+ }
+ }
+
+ public static Brush LightGoldenrodYellow {
+ get {
+ if (lightGoldenrodYellow==null) {
+ lightGoldenrodYellow=new SolidBrush(Color.LightGoldenrodYellow);
+ }
+ return(lightGoldenrodYellow);
+ }
+ }
+
+ public static Brush LightGray {
+ get {
+ if (lightGray==null) {
+ lightGray=new SolidBrush(Color.LightGray);
+ }
+ return(lightGray);
+ }
+ }
+
+ public static Brush LightGreen {
+ get {
+ if (lightGreen==null) {
+ lightGreen=new SolidBrush(Color.LightGreen);
+ }
+ return(lightGreen);
+ }
+ }
+
+ public static Brush LightPink {
+ get {
+ if (lightPink==null) {
+ lightPink=new SolidBrush(Color.LightPink);
+ }
+ return(lightPink);
+ }
+ }
+
+ public static Brush LightSalmon {
+ get {
+ if (lightSalmon==null) {
+ lightSalmon=new SolidBrush(Color.LightSalmon);
+ }
+ return(lightSalmon);
+ }
+ }
+
+ public static Brush LightSeaGreen {
+ get {
+ if (lightSeaGreen==null) {
+ lightSeaGreen=new SolidBrush(Color.LightSeaGreen);
+ }
+ return(lightSeaGreen);
+ }
+ }
+
+ public static Brush LightSkyBlue {
+ get {
+ if (lightSkyBlue==null) {
+ lightSkyBlue=new SolidBrush(Color.LightSkyBlue);
+ }
+ return(lightSkyBlue);
+ }
+ }
+
+ public static Brush LightSlateGray {
+ get {
+ if (lightSlateGray==null) {
+ lightSlateGray=new SolidBrush(Color.LightSlateGray);
+ }
+ return(lightSlateGray);
+ }
+ }
+
+ public static Brush LightSteelBlue {
+ get {
+ if (lightSteelBlue==null) {
+ lightSteelBlue=new SolidBrush(Color.LightSteelBlue);
+ }
+ return(lightSteelBlue);
+ }
+ }
+
+ public static Brush LightYellow {
+ get {
+ if (lightYellow==null) {
+ lightYellow=new SolidBrush(Color.LightYellow);
+ }
+ return(lightYellow);
+ }
+ }
+
+ public static Brush Lime {
+ get {
+ if (lime==null) {
+ lime=new SolidBrush(Color.Lime);
+ }
+ return(lime);
+ }
+ }
+
+ public static Brush LimeGreen {
+ get {
+ if (limeGreen==null) {
+ limeGreen=new SolidBrush(Color.LimeGreen);
+ }
+ return(limeGreen);
+ }
+ }
+
+ public static Brush Linen {
+ get {
+ if (linen==null) {
+ linen=new SolidBrush(Color.Linen);
+ }
+ return(linen);
+ }
+ }
+
+ public static Brush Magenta {
+ get {
+ if (magenta==null) {
+ magenta=new SolidBrush(Color.Magenta);
+ }
+ return(magenta);
+ }
+ }
+
+ public static Brush Maroon {
+ get {
+ if (maroon==null) {
+ maroon=new SolidBrush(Color.Maroon);
+ }
+ return(maroon);
+ }
+ }
+
+ public static Brush MediumAquamarine {
+ get {
+ if (mediumAquamarine==null) {
+ mediumAquamarine=new SolidBrush(Color.MediumAquamarine);
+ }
+ return(mediumAquamarine);
+ }
+ }
+
+ public static Brush MediumBlue {
+ get {
+ if (mediumBlue==null) {
+ mediumBlue=new SolidBrush(Color.MediumBlue);
+ }
+ return(mediumBlue);
+ }
+ }
+
+ public static Brush MediumOrchid {
+ get {
+ if (mediumOrchid==null) {
+ mediumOrchid=new SolidBrush(Color.MediumOrchid);
+ }
+ return(mediumOrchid);
+ }
+ }
+
+ public static Brush MediumPurple {
+ get {
+ if (mediumPurple==null) {
+ mediumPurple=new SolidBrush(Color.MediumPurple);
+ }
+ return(mediumPurple);
+ }
+ }
+
+ public static Brush MediumSeaGreen {
+ get {
+ if (mediumSeaGreen==null) {
+ mediumSeaGreen=new SolidBrush(Color.MediumSeaGreen);
+ }
+ return(mediumSeaGreen);
+ }
+ }
+
+ public static Brush MediumSlateBlue {
+ get {
+ if (mediumSlateBlue==null) {
+ mediumSlateBlue=new SolidBrush(Color.MediumSlateBlue);
+ }
+ return(mediumSlateBlue);
+ }
+ }
+
+ public static Brush MediumSpringGreen {
+ get {
+ if (mediumSpringGreen==null) {
+ mediumSpringGreen=new SolidBrush(Color.MediumSpringGreen);
+ }
+ return(mediumSpringGreen);
+ }
+ }
+
+ public static Brush MediumTurquoise {
+ get {
+ if (mediumTurquoise==null) {
+ mediumTurquoise=new SolidBrush(Color.MediumTurquoise);
+ }
+ return(mediumTurquoise);
+ }
+ }
+
+ public static Brush MediumVioletRed {
+ get {
+ if (mediumVioletRed==null) {
+ mediumVioletRed=new SolidBrush(Color.MediumVioletRed);
+ }
+ return(mediumVioletRed);
+ }
+ }
+
+ public static Brush MidnightBlue {
+ get {
+ if (midnightBlue==null) {
+ midnightBlue=new SolidBrush(Color.MidnightBlue);
+ }
+ return(midnightBlue);
+ }
+ }
+
+ public static Brush MintCream {
+ get {
+ if (mintCream==null) {
+ mintCream=new SolidBrush(Color.MintCream);
+ }
+ return(mintCream);
+ }
+ }
+
+ public static Brush MistyRose {
+ get {
+ if (mistyRose==null) {
+ mistyRose=new SolidBrush(Color.MistyRose);
+ }
+ return(mistyRose);
+ }
+ }
+
+ public static Brush Moccasin {
+ get {
+ if (moccasin==null) {
+ moccasin=new SolidBrush(Color.Moccasin);
+ }
+ return(moccasin);
+ }
+ }
+
+ public static Brush NavajoWhite {
+ get {
+ if (navajoWhite==null) {
+ navajoWhite=new SolidBrush(Color.NavajoWhite);
+ }
+ return(navajoWhite);
+ }
+ }
+
+ public static Brush Navy {
+ get {
+ if (navy==null) {
+ navy=new SolidBrush(Color.Navy);
+ }
+ return(navy);
+ }
+ }
+
+ public static Brush OldLace {
+ get {
+ if (oldLace==null) {
+ oldLace=new SolidBrush(Color.OldLace);
+ }
+ return(oldLace);
+ }
+ }
+
+ public static Brush Olive {
+ get {
+ if (olive==null) {
+ olive=new SolidBrush(Color.Olive);
+ }
+ return(olive);
+ }
+ }
+
+ public static Brush OliveDrab {
+ get {
+ if (oliveDrab==null) {
+ oliveDrab=new SolidBrush(Color.OliveDrab);
+ }
+ return(oliveDrab);
+ }
+ }
+
+ public static Brush Orange {
+ get {
+ if (orange==null) {
+ orange=new SolidBrush(Color.Orange);
+ }
+ return(orange);
+ }
+ }
+
+ public static Brush OrangeRed {
+ get {
+ if (orangeRed==null) {
+ orangeRed=new SolidBrush(Color.OrangeRed);
+ }
+ return(orangeRed);
+ }
+ }
+
+ public static Brush Orchid {
+ get {
+ if (orchid==null) {
+ orchid=new SolidBrush(Color.Orchid);
+ }
+ return(orchid);
+ }
+ }
+
+ public static Brush PaleGoldenrod {
+ get {
+ if (paleGoldenrod==null) {
+ paleGoldenrod=new SolidBrush(Color.PaleGoldenrod);
+ }
+ return(paleGoldenrod);
+ }
+ }
+
+ public static Brush PaleGreen {
+ get {
+ if (paleGreen==null) {
+ paleGreen=new SolidBrush(Color.PaleGreen);
+ }
+ return(paleGreen);
+ }
+ }
+
+ public static Brush PaleTurquoise {
+ get {
+ if (paleTurquoise==null) {
+ paleTurquoise=new SolidBrush(Color.PaleTurquoise);
+ }
+ return(paleTurquoise);
+ }
+ }
+
+ public static Brush PaleVioletRed {
+ get {
+ if (paleVioletRed==null) {
+ paleVioletRed=new SolidBrush(Color.PaleVioletRed);
+ }
+ return(paleVioletRed);
+ }
+ }
+
+ public static Brush PapayaWhip {
+ get {
+ if (papayaWhip==null) {
+ papayaWhip=new SolidBrush(Color.PapayaWhip);
+ }
+ return(papayaWhip);
+ }
+ }
+
+ public static Brush PeachPuff {
+ get {
+ if (peachPuff==null) {
+ peachPuff=new SolidBrush(Color.PeachPuff);
+ }
+ return(peachPuff);
+ }
+ }
+
+ public static Brush Peru {
+ get {
+ if (peru==null) {
+ peru=new SolidBrush(Color.Peru);
+ }
+ return(peru);
+ }
+ }
+
+ public static Brush Pink {
+ get {
+ if (pink==null) {
+ pink=new SolidBrush(Color.Pink);
+ }
+ return(pink);
+ }
+ }
+
+ public static Brush Plum {
+ get {
+ if (plum==null) {
+ plum=new SolidBrush(Color.Plum);
+ }
+ return(plum);
+ }
+ }
+
+ public static Brush PowderBlue {
+ get {
+ if (powderBlue==null) {
+ powderBlue=new SolidBrush(Color.PowderBlue);
+ }
+ return(powderBlue);
+ }
+ }
+
+ public static Brush Purple {
+ get {
+ if (purple==null) {
+ purple=new SolidBrush(Color.Purple);
+ }
+ return(purple);
+ }
+ }
+
+ public static Brush Red {
+ get {
+ if (red==null) {
+ red=new SolidBrush(Color.Red);
+ }
+ return(red);
+ }
+ }
+
+ public static Brush RosyBrown {
+ get {
+ if (rosyBrown==null) {
+ rosyBrown=new SolidBrush(Color.RosyBrown);
+ }
+ return(rosyBrown);
+ }
+ }
+
+ public static Brush RoyalBlue {
+ get {
+ if (royalBlue==null) {
+ royalBlue=new SolidBrush(Color.RoyalBlue);
+ }
+ return(royalBlue);
+ }
+ }
+
+ public static Brush SaddleBrown {
+ get {
+ if (saddleBrown==null) {
+ saddleBrown=new SolidBrush(Color.SaddleBrown);
+ }
+ return(saddleBrown);
+ }
+ }
+
+ public static Brush Salmon {
+ get {
+ if (salmon==null) {
+ salmon=new SolidBrush(Color.Salmon);
+ }
+ return(salmon);
+ }
+ }
+
+ public static Brush SandyBrown {
+ get {
+ if (sandyBrown==null) {
+ sandyBrown=new SolidBrush(Color.SandyBrown);
+ }
+ return(sandyBrown);
+ }
+ }
+
+ public static Brush SeaGreen {
+ get {
+ if (seaGreen==null) {
+ seaGreen=new SolidBrush(Color.SeaGreen);
+ }
+ return(seaGreen);
+ }
+ }
+
+ public static Brush SeaShell {
+ get {
+ if (seaShell==null) {
+ seaShell=new SolidBrush(Color.SeaShell);
+ }
+ return(seaShell);
+ }
+ }
+
+ public static Brush Sienna {
+ get {
+ if (sienna==null) {
+ sienna=new SolidBrush(Color.Sienna);
+ }
+ return(sienna);
+ }
+ }
+
+ public static Brush Silver {
+ get {
+ if (silver==null) {
+ silver=new SolidBrush(Color.Silver);
+ }
+ return(silver);
+ }
+ }
+
+ public static Brush SkyBlue {
+ get {
+ if (skyBlue==null) {
+ skyBlue=new SolidBrush(Color.SkyBlue);
+ }
+ return(skyBlue);
+ }
+ }
+
+ public static Brush SlateBlue {
+ get {
+ if (slateBlue==null) {
+ slateBlue=new SolidBrush(Color.SlateBlue);
+ }
+ return(slateBlue);
+ }
+ }
+
+ public static Brush SlateGray {
+ get {
+ if (slateGray==null) {
+ slateGray=new SolidBrush(Color.SlateGray);
+ }
+ return(slateGray);
+ }
+ }
+
+ public static Brush Snow {
+ get {
+ if (snow==null) {
+ snow=new SolidBrush(Color.Snow);
+ }
+ return(snow);
+ }
+ }
+
+ public static Brush SpringGreen {
+ get {
+ if (springGreen==null) {
+ springGreen=new SolidBrush(Color.SpringGreen);
+ }
+ return(springGreen);
+ }
+ }
+
+ public static Brush SteelBlue {
+ get {
+ if (steelBlue==null) {
+ steelBlue=new SolidBrush(Color.SteelBlue);
+ }
+ return(steelBlue);
+ }
+ }
+
+ public static Brush Tan {
+ get {
+ if (tan==null) {
+ tan=new SolidBrush(Color.Tan);
+ }
+ return(tan);
+ }
+ }
+
+ public static Brush Teal {
+ get {
+ if (teal==null) {
+ teal=new SolidBrush(Color.Teal);
+ }
+ return(teal);
+ }
+ }
+
+ public static Brush Thistle {
+ get {
+ if (thistle==null) {
+ thistle=new SolidBrush(Color.Thistle);
+ }
+ return(thistle);
+ }
+ }
+
+ public static Brush Tomato {
+ get {
+ if (tomato==null) {
+ tomato=new SolidBrush(Color.Tomato);
+ }
+ return(tomato);
+ }
+ }
+
+ public static Brush Transparent {
+ get {
+ if (transparent==null) {
+ transparent=new SolidBrush(Color.Transparent);
+ }
+ return(transparent);
+ }
+ }
+
+ public static Brush Turquoise {
+ get {
+ if (turquoise==null) {
+ turquoise=new SolidBrush(Color.Turquoise);
+ }
+ return(turquoise);
+ }
+ }
+
+ public static Brush Violet {
+ get {
+ if (violet==null) {
+ violet=new SolidBrush(Color.Violet);
+ }
+ return(violet);
+ }
+ }
+
+ public static Brush Wheat {
+ get {
+ if (wheat==null) {
+ wheat=new SolidBrush(Color.Wheat);
+ }
+ return(wheat);
+ }
+ }
+
+ public static Brush White {
+ get {
+ if (white==null) {
+ white=new SolidBrush(Color.White);
+ }
+ return(white);
+ }
+ }
+
+ public static Brush WhiteSmoke {
+ get {
+ if (whiteSmoke==null) {
+ whiteSmoke=new SolidBrush(Color.WhiteSmoke);
+ }
+ return(whiteSmoke);
+ }
+ }
+
+ public static Brush Yellow {
+ get {
+ if (yellow==null) {
+ yellow=new SolidBrush(Color.Yellow);
+ }
+ return(yellow);
+ }
+ }
+
+ public static Brush YellowGreen {
+ get {
+ if (yellowGreen==null) {
+ yellowGreen=new SolidBrush(Color.YellowGreen);
+ }
+ return(yellowGreen);
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/BufferedGraphics.cs b/mcs/class/System.Drawing/System.Drawing/BufferedGraphics.cs
new file mode 100644
index 00000000000..383242b95f2
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/BufferedGraphics.cs
@@ -0,0 +1,118 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+//
+// Jordi Mas i Hernadez <jordimash@gmail.com>
+//
+//
+
+#if NET_2_0
+
+using System;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ public sealed class BufferedGraphics : IDisposable
+ {
+ private Rectangle size;
+ private Bitmap membmp = null;
+ private Graphics target = null;
+ private Graphics source = null;
+
+ private BufferedGraphics ()
+ {
+
+ }
+
+ internal BufferedGraphics (Graphics targetGraphics, Rectangle targetRectangle)
+ {
+ size = targetRectangle;
+ target = targetGraphics;
+ membmp = new Bitmap (size.Width, size.Height);
+ }
+
+ ~BufferedGraphics ()
+ {
+ Dispose (false);
+ }
+
+ public Graphics Graphics {
+ get {
+ if (source == null) {
+ source = Graphics.FromImage (membmp);
+ }
+
+ return source;
+ }
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ private void Dispose (bool disposing)
+ {
+ if (disposing == false)
+ return;
+
+ if (membmp != null) {
+ membmp.Dispose ();
+ membmp = null;
+ }
+
+ if (source != null) {
+ source.Dispose ();
+ source = null;
+ }
+
+ target = null;
+ }
+
+ public void Render ()
+ {
+ Render (target);
+ }
+
+ public void Render (Graphics target)
+ {
+ if (target == null)
+ return;
+
+ target.DrawImage (membmp, size);
+ }
+
+ [MonoTODO]
+ public void Render (IntPtr targetDC)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
+#endif
+
diff --git a/mcs/class/System.Drawing/System.Drawing/BufferedGraphicsContext.cs b/mcs/class/System.Drawing/System.Drawing/BufferedGraphicsContext.cs
new file mode 100644
index 00000000000..a36531a43a9
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/BufferedGraphicsContext.cs
@@ -0,0 +1,89 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+//
+// Jordi Mas i Hernandez <jordimash@gmail.com>
+//
+//
+
+#if NET_2_0
+
+using System;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ public sealed class BufferedGraphicsContext : IDisposable
+ {
+ private Size max_buffer;
+
+ public BufferedGraphicsContext ()
+ {
+ max_buffer = Size.Empty;
+ }
+
+ ~BufferedGraphicsContext ()
+ {
+
+ }
+
+ public BufferedGraphics Allocate (Graphics targetGraphics, Rectangle targetRectangle)
+ {
+ BufferedGraphics graphics = new BufferedGraphics (targetGraphics, targetRectangle);
+ return graphics;
+ }
+
+ [MonoTODO]
+ public BufferedGraphics Allocate (IntPtr targetDC, Rectangle targetRectangle)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Dispose ()
+ {
+ System.GC.SuppressFinalize (this);
+ }
+
+ public void Invalidate ()
+ {
+
+ }
+
+ public Size MaximumBuffer {
+ get {return max_buffer; }
+ set {
+ if (value.Width <= 0 || value.Height <= 0) {
+ throw new ArgumentException ("The height or width of the size is less than or equal to zero.");
+ }
+
+ max_buffer = value;
+ }
+ }
+
+ }
+}
+
+#endif
+
diff --git a/mcs/class/System.Drawing/System.Drawing/BufferedGraphicsManager.cs b/mcs/class/System.Drawing/System.Drawing/BufferedGraphicsManager.cs
new file mode 100644
index 00000000000..156fa141308
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/BufferedGraphicsManager.cs
@@ -0,0 +1,52 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+//
+// Jordi Mas i Hernadez <jordimash@gmail.com>
+//
+//
+
+#if NET_2_0
+
+namespace System.Drawing
+{
+ public sealed class BufferedGraphicsManager
+ {
+ private static BufferedGraphicsContext graphics_context;
+
+ static BufferedGraphicsManager ()
+ {
+ graphics_context = new BufferedGraphicsContext ();
+ }
+
+ private BufferedGraphicsManager ()
+ {
+ }
+
+ public static BufferedGraphicsContext Current {
+ get { return graphics_context; }
+ }
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Drawing/System.Drawing/ChangeLog b/mcs/class/System.Drawing/System.Drawing/ChangeLog
new file mode 100644
index 00000000000..8d2a04f7f94
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ChangeLog
@@ -0,0 +1,2471 @@
+2006-01-19 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Icon.cs: The code wrongly assumed that the stride for the icon
+ would be the same as the stride for the bitmap. This was causing
+ memory corruption.
+
+2006-01-18 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Icon.cs: Reworked ToBitmap() method to not use Bitmap(Stream)
+ which when calling down to MS GDI+ will create an image
+ where neither GetPixel or Save can be used on.
+
+2006-01-18 Sebastien Pouliot <sebastien@ximian.com>
+
+ * gdipFunctions.cs: Added declaration for GdipCreateRegionRgnData.
+ * Region.cs: Implemented .ctor(RegionData)
+
+2006-01-13 Miguel de Icaza <miguel@novell.com>
+
+ * Region.cs: Revert the Region.cs check in GetHrgn as it was used
+ by our Windows.Forms implementation.
+
+2006-01-11 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Graphics.cs: Avoid creating bitmaps two times if both X and Y
+ default DPI are required (i.e. init both value in both cases).
+ * Region.cs: Added null check to match MS behaviour (exception type)
+ and avoid NRE (before CheckStatus is called). Added security demands
+ for unmanaged code on both FromHrgn and ReleaseHrgn (2.0) methods.
+
+2005-12-22 Jonathan Chambers <jonathan.chambers@ansys.com>
+
+ * gdipFunctions.cs: Do not call GdiplusShutdown for
+ now as it causes a crash on MS GDI+.
+
+2005-12-20 Konstantin Triger <kostat@mainsoft.com>
+
+ * Font.jvm.cs: charset support.
+
+2005-12-19 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Graphics.cs (Flush): Make sure nativeObject is not null
+
+2005-12-14 Konstantin Triger <kostat@mainsoft.com>
+
+ * StrokeFactory.jvm.cs: create AdvancedStroke when have penTransform.
+
+2005-12-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * Bitmap.jvm.cs: Fix MakeTransparent.
+
+2005-12-07 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * Graphics.cs: Add new deephs support to CopyFromScreen
+
+2005-12-07 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * BufferedGraphicsManager.cs: Fixes signature
+
+2005-12-05 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Font.cs:
+ - Implemented FromLogFont
+ - Implemented ToLogFont
+ - Whitespace fixes
+ * gdipFunctions.cs:
+ - Added GdipGetLogFontW method
+ - Specified charset for GdipGetLogFontA method
+ * gdipStructs.cs: Added LOGFONTW structure
+
+2005-12-05 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * BufferedGraphics.cs: Removed duplicate class. Set eol-style to
+ native.
+ * BufferedGraphicsManager.cs: Removed duplicate class. Set eol-style
+ to native.
+
+2005-12-05 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * gdipFunctions.cs: DllExports need it to implement
+ new Graphics.CopyFromScreen .Net 2.0 methods
+ * IDeviceContext.cs: New .Net 2.0 interface
+ * Color.cs: Fixes for new .Net 2.0 KnowColors
+ * PointF.cs: New .Net 2.0 Add/Subtract methods
+ * gdipStructs.cs: Structs need it for Graphics.CopyFromScreen
+ * SystemBrushes.cs: New standard SystemBrushes for .Net 2.0
+ * SizeF.cs: New .Net 2.0 Add/Subtract methods
+ * FontConverter.cs: New .Net 2.0 fixes
+ * SystemColors.cs: New standard SystemColors for .Net 2.0
+ * SizeFConverter.cs: New .Net 2.0 class (based on SizeConverter)
+ * CharacterRange.cs: : New .Net 2.0 methods
+ * Size.cs: New .Net 2.0 Add/Subtract methods
+ * SystemPens.cs: New standard SystemPens for .Net 2.0
+ * Bitmap.cs: New .Net 2.0 methods
+ * Region.cs: New .Net 2.0 methods
+ * Brush.cs: New .Net 2.0 constructor
+ * Icon.cs: New .Net 2.0 Constructors and methods
+ * Point.cs: New .Net 2.0 Add/Subtract methods
+ * BufferedGraphicsManager.cs: New .Net 2.0 class
+ * Graphics.cs: New methods for .Net 2.0 and fixes
+ * BufferedGraphics.cs: New .Net 2.0 class
+ * Font.cs: New .Net 2.0 properties
+ * Image.cs: New .Net 2.0 tag property
+ * KnownColor.cs: New .Net 2.0 know colors
+ * CopyPixelOperation.cs: New .Net 2.0 enum
+ * SystemFonts.cs: New .Net 2.0 class
+ * BufferedGraphicsContext.cs: New .Net 2.0 class
+
+2005-11-28 Konstantin Triger <kostat@mainsoft.com>
+
+ * SystemIcons.jvm.cs: refactoring.
+
+2005-11-28 Konstantin Triger <kostat@mainsoft.com>
+
+ * Icon.cs: TARGET_JVM changes.
+
+2005-11-17 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Image.jvm.cs: fixed Save, flush output stream
+
+2005-11-17 Konstantin Triger <kostat@mainsoft.com>
+
+ * StrokeFactory.jvm.cs, Pen.jvm.cs, Graphics.jvm.cs: performance - use BasicStroke when possible.
+
+2005-11-17 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ColorConverter.cs: fixed ConvertFrom, to be able
+ to convert from three digit notation color (#abc)
+
+2005-11-16 Konstantin Triger <kostat@mainsoft.com>
+
+ * Bitmap.jvm.cs: open a correct stream.
+
+2005-11-16 Konstantin Triger <kostat@mainsoft.com>
+
+ * FontFamily.jvm.cs, Font.jvm.cs: throw exception if invalid params.
+
+2005-11-16 Konstantin Triger <kostat@mainsoft.com>
+
+ * FontFamily.jvm.cs: fix for custom font collection
+
+2005-11-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * FontFamily.jvm.cs: fixed GetName
+
+2005-11-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Bitmap.jvm.cs: fixed InternalSave() error handling
+ * Image.jvm.cs: fixed Save() error handling
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * FontFamily.jvm.cs: Refactoring.
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * Font.jvm.cs: Refactoring.
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * StringFormat.jvm.cs, Graphics.jvm.cs: DrawString,
+ MeasureString support
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * FontFamily.jvm.cs: correctly initialize fontcollection
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * FontFamily.jvm.cs: DrawMargin, refactoring.
+
+2005-11-13 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs, Pen.jvm.cs, AdvancedStroke.jvm.cs:
+ Differentiate standard and AntiAlias stroking
+
+2005-11-10 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: added UnitConversion property
+ * FontFamily.jvm.cs: refactoring
+ * Font.jvm.cs: refactoring
+
+2005-11-03 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Font.cs:
+ - Implemented serialization constructor
+ - Implemented GetObjectData()
+
+2005-11-01 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * StringFormat.jvm.cs: Refactoring
+
+2005-10-31 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Image.cs: Default format for MemoryBMP should be Png
+
+2005-10-27 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Bitmap.jvm.cs: fixed InternalSave
+ * Image.jvm.cs: fixed Save
+
+2005-10-27 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Image.jvm.cs: fixed redolution properties
+
+2005-10-27 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Bitmap.jvm.cs: fixed InternalSave, to remove alpha channel of saved jpeg
+ fixed clone, Initialize
+
+2005-10-24 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Brush.cs: Don't delete the brush if the display handle is no longer
+ valid, otherwise cairo will try to use the handle and crash and burn
+
+2005-10-23 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: DrawImage refactoring
+
+2005-10-23 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: Clipping refactoring
+ fixed FillScaledShape, DrawShape, MeasureDraw, BeginContainer,
+ ExcludeClip, IntersectClip, ResetClip, CombineClipArea, RestoreBaseClip,
+ TranslateClip, VisibleClipBounds
+
+2005-10-21 Miguel de Icaza <miguel@novell.com>
+
+ * Pen.cs: Add support for returning the Brush from Pens created
+ with a color constructor.
+
+ Plus: code style police, else does not go on its own line.
+
+ * Graphics.cs: Add various ArgumentNull checks.
+
+2005-10-20 Konstantin Triger <kostat@mainsoft.com>
+
+ * Image.jvm.cs: make Clone abstract
+
+2005-10-20 Konstantin Triger <kostat@mainsoft.com>
+
+ * Font.jvm.cs: make fallbacks for GdiCharSet, GdiVerticalFont
+
+2005-10-19 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Bitmap.jvm.cs: fixed InternalSave, ToBufferedImageFormat, Clone
+ * PlainImage.jvm.cs: fixed Clone
+ * Graphics.jvm.cs: fixed FillShape, Clear, FillScaledShape
+
+2005-10-19 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Brush.jvm.cs: added InternalClone() method
+ changed transformation methods access level
+ * TextureBrush.jvm.cs: refactoring, fixed clone()
+
+2005-10-19 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * AdvancedStroke.jvm.cs: fixed createStrokedShape, check for transform
+ matrix singularity added
+ * Font.jvm.cs: implemetated ISerializable
+ * Pen.jvm.cs: fixed DashPattern property,
+ fixed GetNativeObject() dash pattern calculation
+
+2005-10-14 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * SystemColors.cs: Fixes the Win32 light and lightlight colours
+
+2005-10-11 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * SystemColors.cs: Fixes the Win32 system colors including the color
+ name and the knownColor properties.
+
+2005-10-07 Peter Dennis Bartok <pbartok@novell.com>
+
+ * FontFamily.cs: Use Marshal.PtrToStringUni to do the string
+ conversion, it's less overhead than StringBuilder. (Part of the
+ bugfix for #74871 and #75534)
+
+ * gdipFunctions: Changed signature for GdipGetFamilyName to just
+ have an IntPtr for the buffer
+
+2005-10-04 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Graphics.cs, FontFamily.cs: Calling GC.SuppressFinalize from Dispose,
+ fixes bug #76329
+
+2005-09-29 Peter Dennis Bartok <pbartok@novell.com>
+
+ * SystemColor.cs: Added code used to generate properties, updated with
+ Windows XP colors
+
+2005-09-29 Peter Dennis Bartok <pbartok@novell.com>
+
+ * SystemColor.cs: Make internal names predictable to allow scripted
+ generation of color table
+
+2005-09-28 Peter Dennis Bartok <pbartok@novell.com>
+
+ * Color.cs(UpdateKnownColor): Ensure knownColors exists before trying
+ to update it.
+
+2005-09-27 Peter Dennis Bartok <pbartok@novell.com>
+
+ * SystemColor.cs:
+ - Changed properties to return colors from fields. This allows
+ updating the colors via reflection, for example from MWF themes.
+ - Added code to retrieve system colors via Win32 GetSysColors if
+ running on Win32, this makes us compatible with Microsoft instead
+ of returning static colors on Win32. Unix platforms still will
+ use the static colors
+ * Color.cs: Added UpdateKnownColor() method to allow updating of
+ the KnownColors array
+
+2005-09-26 Kornél Pál <kornelpal@hotmail.com>
+
+ * Graphics.cs: DrawImage: imageAttr can be null. Fixed to pass IntPtr.Zero
+ when imageAttr is null.
+
+2005-09-26 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Brush.jvm.cs: fixed transform methods, createContext
+ * TextureBrush.jvm.cs: implemetated transform, WrapMode, ctors
+
+2005-09-21 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Bitmap.jvm.cs: fixed Clone, InternalSave, Initialize, ctor refactoring, remarks refactoring
+ * Image.jvm.cs: fixed GetFrameCount, GetThumbnailImage, SelectActiveFrame, remarks refactoring
+ * PlainImage.jvm.cs: added metadata props, fixed ctor
+ * PlainImageCollection.jvm.cs: fixed class access
+
+2005-09-21 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Graphics.cs: Fixes exception type at FromImage method
+
+2005-09-20 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: bitmap resolution fix in DrawImage
+
+2005-09-20 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: fixed DrawImage
+
+2005-09-19 Miguel de Icaza <miguel@novell.com>
+
+ * Graphics.cs: Removed restriction on the images that can be
+ loaded. Indexed images *can* be loaded
+
+2005-09-18 Miguel de Icaza <miguel@novell.com>
+
+ * Image.cs: introduce a workaround that catches errors on systems
+ that lack GDI+ as this is being triggered too easily when we
+ enumerate attributes on loaded classes.
+
+ The real bug to fix is #76062.
+
+2005-09-17 Kornél Pál <kornelpal@hotmail.com>
+
+ * Image.cs: Implemented FromHbitmap.
+
+2005-09-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * gdipFunctions.cs: Add [SuppressUnmanagedCodeSecurity] attributes so
+ the JIT won't add demands for UnmanagedCode.
+ * carbonFunctions.cs: Add [SuppressUnmanagedCodeSecurity] attributes
+ so the JIT won't add demands for UnmanagedCode on Mac OSX.
+ * Bitmap.cs: Added LinkDemand for UnmanagedCode on GetHbitmap
+ (+ overloads) and GetHicon methods.
+ * Graphics.cs: Added LinkDemand for UnmanagedCode on FromHdcInternal,
+ FromHwndInternal and ReleaseHdcInternal methods (which are all public
+ despite their names).
+
+2005-09-15 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: text transform, headless session
+
+2005-09-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Bitmap.jvm.cs: native object refactoring
+ * Image.jvm.cs: native object refactoring
+ * Graphics.jvm.cs: fixed access to image native object
+ * TextureBrush.jvm.cs: fixed access to image native object
+ * Added PlainImage.jvm.cs, PlainImageCollection.jvm.cs
+
+2005-09-14 Geoff Norton <gnorton@customerdna.com>
+
+ * carbonFunctions.cs: Add GetCGContextForNSView for Cocoa# integration
+ * Graphics.cs: Check GDIPlus.UseCocoaDrawable for Cocoa# integration
+ * gdipFunctions.cs: Set UseCocoaDrawable depending on the environment variable MONO_GDIP_USE_COCOA_BACKEND
+
+2005-09-14 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: transform, container, thin pen
+
+2005-09-12 Konstantin Triger <kostat@mainsoft.com>
+
+ * AdvancedStroke.jvm.cs: constants for pen fitting calculations
+ * Pen.jvm.cs: fixing transform, pen fitting
+
+2005-09-12 Konstantin Triger <kostat@mainsoft.com>
+
+ * Region.jvm.cs: IsVisible is about intersection
+
+2005-09-12 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * ImageConverter.cs: Use default TypeDescriptor implementation of
+ GetProperties.
+
+2005-09-11 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: fixing clipping with rotate transform
+
+2005-09-11 Konstantin Triger <kostat@mainsoft.com>
+
+ * Region.jvm.cs: default region is infinite
+
+2005-09-10 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: fixing clipping stuff
+
+2005-09-07 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Bitmap.jvm.cs: fixed bitamp accessors
+ * Image.jvm.cs: fixed image accessors
+
+2005-09-07 Konstantin Triger <kostat@mainsoft.com>
+ * AdvancedStroke.jvm.cs: fix matrix translate
+ * Graphics.jvm.cs: fix matrix concatenation order
+
+2005-09-07 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Brush.jvm.cs: added transform methods
+
+2005-09-06 Konstantin Triger <kostat@mainsoft.com>
+
+ * StrokeFactory.jvm.cs, AdvancedStroke.jvm.cs, Pen.jvm.cs:
+ implementing fitting, output transform
+ * Graphics.jvm.cs: fixing DrawXXX, Fill, Clipping, Containers
+
+2005-09-06 Konstantin Triger <kostat@mainsoft.com>
+
+ * ColorTranslator.cs: perform case insensitive check
+
+2005-09-05 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * gdipFunctions.cs: define new functions
+ * Bitmap.cs: fixes image loading and exceptions
+ * Image.cs: fixes image loading and exceptions
+
+ Thanks Kornél Pál for its help
+
+2005-08-30 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Brush.jvm.cs: added brush transform field
+
+2005-08-28 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: fixed .ctor (InterpolationMode)
+
+2005-08-28 Konstantin Triger <kostat@mainsoft.com>
+
+ * StrokeFactory.jvm.cs, AdvancedStroke.jvm.cs, Pen.jvm.cs
+ Graphics.jvm.cs: adjust stroke before widening
+
+2005-08-28 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: Implemented BeginContainer, EndContainer,
+ Save, Restore
+
+2005-08-26 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * PointConverter.cs: Use Int32Converter instead of Int32.Parse. First
+ convert string to int before checking number of components.
+ * RectangleConverter.cs: same.
+ * SizeConverter.cs: same.
+
+2005-08-26 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * ColorConverter.cs: Use Int32Converter instead of Int32.Parse to
+ convert individual components. Special case string containing hex
+ prefix. Convert components before checking count.
+
+2005-08-25 Marek Safar <marek.safar@seznam.cz>
+
+ * gdipFunctions.cs: GetIconInfo new user32 method.
+ GdipGetDC uses IntPtr.
+
+ * gdipStructs.cs: Defined IconInfo struct.
+
+ * Graphics.cs: FromImage throws exception when image has an indexed format.
+ GetHdc fixed.
+
+ * Icon.cs: Implemented FromHandle, Dispose.
+
+2005-05-24 Michael Hutchinson <m.j.hutchinson@gmail.com>
+
+ * ToolboxBitmapAttribute.cs: Implemented retrieving the image
+
+2005-08-23 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: Fixed ResetTransform, TransfromPoints
+ Fixed SmoothingMode property
+
+2005-08-23 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Brushes: Do not create the objects every time that they are requested
+ as in Pens we create and cache them only once when need it. This also
+ fixes the Equals method between two objects requested to Brushes
+
+2005-08-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * SolidBrush.cs: Fixes Dispose to avoid non-disposing some objects
+ * Brush.cs Fixes Dispose to avoid non-disposing some objects
+ * Pen.cs: Fixes Dispose to avoid non-disposing some objects
+ * Region.cs: Dipose always frees if the resource was allocated
+
+2005-08-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * gdipFunctions.cs: Before calling GdiplusShutdown we make that all of handles
+ from gdiplus have been released
+
+2005-08-18 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Pen.jvm.cs: Fixed DashSpacing in createStrokedShape
+ * Color.cs: Fixed java NativeObject property
+ * Image.jvm.cs: Fixed Save method
+
+2005-08-16 Andrew Skiba <andrews@mainsoft.com>
+
+ * Icon.jvm.cs: match Bitmap internal constructor change
+ * Image.jvm.cs: use ImageCodecInfo.Clsid as primary format id, not ImageFormat
+ * Bitmap.jvm.cs: started changes for supporting ImageCodecInfo
+
+2005-08-16 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * Color.cs: To match MS.NET, throw ArgumentException instead of
+ ArgumentOutOfRangeException when color is not between 0 and 255.
+ * RectangleConverter.cs: Take culture into account when converting
+ to/from string. Use culture's ListSeparator as separator character.
+
+2005-08-16 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * Color.cs: Fixed line endings. Set eol-style to native.
+ * ColorConverter.cs: Fixed line endings. Set eol-style to native.
+ * Size.cs: Set eol-style to native.
+ * SizeF.cs: Use current culture in ToString(), set eol-style to native.
+ * SizeConverter.cs: Take culture into account when converting to/from
+ string. Set eol-style to native.
+ * Point.cs: Fixed line endings. Set eol-style to native.
+ * PointF.cs: Use current culture in ToString(), set eol-style to native.
+ * PointConverter.cs: Take culture into account when converting to/from
+ string. Set eol-style to native.
+ * ImageFormatConverter.cs: Fixed line endings. Set eol-style to
+ native.
+ * RectangleConverter.cs: Fixed line endings. Set eol-style to native.
+
+2005-08-16 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: Fixed InterpolationMode property
+
+2005-08-15 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: Fixed DrawImage
+
+2005-08-14 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * ColorConverter.cs: Use TextInfo.ListSeparator as separator, as this
+ appears to be what MS.NET uses.
+
+2005-08-14 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * Point.cs: Use invariant culture for converting numbers to string.
+ * PointF.cs: same
+ * SizeF.cs: same
+
+2005-08-14 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * Color.cs: Fixed ToString for uninitialized color.
+ * ColorConverter.cs: Support conversion from whitespace-only string to
+ Color.Empty. Fixed conversion from Color.Empty and known colors to
+ string.
+
+2005-08-14 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: Initial properties implementation
+
+2005-08-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: DrawImage refactoring
+
+2005-08-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: Implemented PageUnit, PageScale.
+ Added UpdateInternalTransform
+ Fixed DrawImage, Transform, ConcatenateTransform
+
+2005-08-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Icon.jvm.cs: Internal constructor from bitmap
+ * Added SystemIcons.jvm.cs with implementation of SystemIcons
+
+2005-08-14 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Region.jvm.cs: Fixed GetBounds, IsVisible, IsEmpty, IsInfinite, Equals
+ (all methods that use Graphics object)
+
+2005-08-11 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: Refactoring
+
+2005-08-11 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: Fixed Clear, Refactoring
+
+2005-08-11 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: Fixed FillClosedCurve
+
+2005-08-10 Zoltan Varga <vargaz@freemail.hu>
+
+ * Rectangle.cs (Intersect): Return a non-empty rectangle if the two
+ rectangles touch each other.
+
+2005-08-09 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: Fixed DrawCurve.
+
+2005-08-09 Konstantin Triger <kostat@mainsoft.com>
+
+ * StrokeFactory.jvm.cs: use correct stroke
+
+2005-08-09 Konstantin Triger <kostat@mainsoft.com>
+
+ * Added AdvancedStoke.jvm.cs and StrokeFactory.jvm.cs
+ * Pen refactoring.
+
+2005-08-09 Andrew Skiba <andrews@mainsoft.com>
+
+ * FontConverter.cs: exclude not implemented destructor from TARGET_JVM
+
+2005-08-09 Andrew Skiba <andrews@mainsoft.com>
+
+ * ColorConverter.cs, ColorTranslator.cs: fixes to pass tests
+ committed in r48150
+
+2005-08-08 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: Refactoring
+
+2005-08-08 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: Fixed DrawPolygon
+
+2005-08-08 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: Refactoring
+ * Pen.jvm.cs: setting awt.Stroke as a base
+
+2005-08-07 Konstantin Triger <kostat@mainsoft.com>
+
+ * Graphics.jvm.cs: Refactoring
+
+2005-08-07 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: Fixed DrawLines, DrawPolygon to use GraphicsPath
+
+2005-08-07 Andrew Skiba <andrews@mainsoft.com>
+
+ * Rectangle.cs: Intersect fixed
+ * RectandleF.cs: Intersect and Inflate fixed
+
+2005-08-07 Andrew Skiba <andrews@mainsoft.com>
+
+ * Point.cs: Produce same ToString result as dotnet
+
+2005-08-07 Andrew Skiba <andrews@mainsoft.com>
+
+ * Color.cs: GetHashCode is affected by Name, too
+
+2005-08-07 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Pen.jvm.cs: Fixed ctor, LineCap, SetLineCap
+
+2005-08-07 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.jvm.cs: Fixed DrawLines, DrawPolygon
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * SolidBrush.jvm.cs: fix a typo
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * Image.jvm.cs, StringFormat.jvm.cs, FontFamily.jvm.cs, Bitmap.jvm.cs,
+ Pen.jvm.cs, Region.jvm.cs, Brush.jvm.cs, Graphics.jvm.cs, TextureBrush.jvm.cs,
+ Font.jvm.cs: Added TARGET_JVM implementation
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * Rectangle.cs, RectangleF.cs: TARGET_JVM - Add NativeObect property
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * BasicShape.jvm.cs: Added TARGET_JVM specific class
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * Icon.jvm.cs, SystemColors.jvm.cs: Added TARGET_JVM implementations
+
+2005-08-03 Andrew Skiba <andrews@mainsoft.com>
+
+ * ColorTranslator.cs: (GH merge) recognise HTML system colors
+
+2005-08-02 Andrew Skiba <andrews@mainsoft.com>
+
+ * SolidBrush.jvm.cs: added TARGET_JVM implementation of this class
+
+2005-08-02 Andrew Skiba <andrews@mainsoft.com>
+
+ * Color.cs: TARGET_JVM - NativeObject property
+
+2005-07-27 Andrew Skiba <andrews@mainsoft.com>
+
+ * Color.cs: Fixes equality operators, change isXXXcolor booleans into flags enum.
+
+2005-07-27 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * RectangleF.cs: Fixes IsEmpty logic
+
+2005-06-23 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Graphics.cs: implements FromHwndInternal
+
+
+2005-06-13 Peter Bartok <pbartok@novell.com>
+
+ * Icon.cs(ToBitmap): If the icon is not 32bits, create the bitmap
+ through an intermediary step, which turns it into a 32bit version.
+ Fixes #75254
+
+2005-06-13 Kornél Pál <kornelpal@hotmail.com>
+
+ * ComIStreamMarshaler.cs: Dispose releases managed objects as well,
+ removed some unnecessary code
+ * ComIStreamWrapper.cs: Reworked Seek method to proper support of
+ positions beyond the size of stream
+
+2005-06-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Font.cs: fix platform checks.
+
+2005-06-08 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Rectangle.cs:
+ - Fixes is empty method IsEmpty logic
+ - Fixes Contains method logic
+ - Fixes IntersectsWith logic
+
+ * RectangleF.cs:
+ - Fixes is empty method IsEmpty logic
+ - Fixes Contains method logic
+ - Fixes IntersectsWith logic
+
+2005-05-28 Kornél Pál <kornelpal@hotmail.com>
+
+ * ComIStreamMarshaler.cs: GC.SuppressFinalize(this) is not called in
+ destructors. Some methods renamed. Removed unnecessary variables.
+
+2005-05-25 Jonathan Gilbert <logic@deltaq.org>
+
+ * Image.cs: Added retrieveGDIPalette () and storeGDIPalette ()
+ and modified the Palette property to call them. This non-
+ persistent behaviour was discovered by trial and error with
+ Microsoft's implementation. In fact, the Palette property
+ does not behave like a property at all! It is the only way an
+ instance of System.Drawing.Imaging.ColorPalette can be created,
+ and it reflects a backing store that is only updated when the
+ property 'set' method is called. Also updated Clone () since
+ the palette is no longer cached at image load time.
+ * Image.cs: Added IsIndexedPixelFormat () in the same vein as
+ Image::IsAlphaPixelFormat and Image::IsCanonicalPixelFormat.
+ As such a function is not listed in MSDN nor given in
+ Microsoft's implementation, I have made it a private function
+ within the class that uses it.
+
+2005-05-24 Kornél Pál <kornelpal@hotmail.com>
+
+ * Graphics.cs: Revised DrawString methods
+
+2005-03-22 Peter Bartok <pbartok@novell.com>
+
+ * Graphics.cs: Fixed bug #74762, DrawString was crashing on s.Length
+ if s was null.
+
+2005-05-20 Kornél Pál <kornelpal@hotmail.com>
+
+ * Image.cs: Uses MemoryStream wrapping on all platforms if needed
+ * gdipFunctions.cs: Modified conditional compilation syntax
+ * ComIStreamWrapper.cs: Modified conditional compilation syntax
+ * ComIStreamMarshaler.cs: Modified conditional compilation syntax
+
+2005-05-18 Marek Safar <marek.safar@seznam.cz>
+
+ * Bitmap.cs: Add null check into ctor.
+
+2005-05-16 Jordi Mas i Hernandez <jordi@ximian.com> <kornelpal@hotmail.com>
+
+ * gdipFunctions.cs: Kornél Pál's IStream bug fixing
+ * ComIStreamWrapper.cs: Kornél Pál's IStream bug fixing
+ * ComIStreamMarshaler.cs: Kornél Pál's IStream bug fixing
+
+2005-05-14 Jordi Mas i Hernandez <jordi@ximian.com> <kornelpal@hotmail.com>
+
+ * Bitmap.cs: Kornél Pál's Bitmap class ctor and MakeTransparent leak fixes
+
+2005-05-11 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * gdipFunctions.cs: add GdipLoadImageFromStream and GdipSaveImageToStream
+ * ComIStreamWrapper.cs: Kornel Pal COM Stream for Win32
+ * ComIStreamMarshaler.cs: Kornel Pal COM Stream for Win32
+ * Image.cs: uses new Win32 Stream functions when need it
+
+2005-05-10 Juraj Skripsky <juraj@hotfeet.ch>
+
+ * Color.cs: Fix GetSaturation() again and remove
+ obsolete constants.
+
+2005-05-10 Juraj Skripsky <juraj@hotfeet.ch>
+
+ * Color.cs: New, correct implementations for GetHue(),
+ GetBrightness() and GetSaturation().
+
+2005-05-09 Sebastien Pouliot <sebastien@ximian.com>
+
+ * gdipFunctions.cs: Use PlatformID.Unix under NET_2_0.
+ * Graphics.cs: Use PlatformID.Unix under NET_2_0.
+ * Image.cs: Use PlatformID.Unix under NET_2_0.
+
+2005-05-05 Miguel de Icaza <miguel@novell.com>
+
+ * Bitmap.cs, Icon.cs (constructor): Use
+ GetManifestResourceStream(Type,string) in the constructor that
+ takes a type.
+
+2005-04-27 Lluis Sanchez Gual <lluis@novell.com>
+
+ * PointF.cs: Make serialization compatible with MS.
+
+2005-04-10 Geoff Norton <gnorton@customerdna.com>
+
+ * Graphics.cs:
+ carbonFunctions.cs:
+ Use CGContextSynchronize instead of CGContextFlush. This saves
+ on average 20000 ticks per drawing operation.
+
+2005-04-04 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Color.cs: take into account the name color in == and != operators
+ * Font.cs: Use Equals instead of == to compare the family name
+ * FontFamily.cs:
+ - Removes generic fontfamilies cache (done at libgdiplus level)
+ - Fixes Equals method
+
+2005-03-30 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Pen.cs: remove locks. They are done at gdiplus level
+ * Brush.cs: remove locks. They are done at gdiplus level
+ * Image.cs: remove locks. They are done at gdiplus level
+
+2005-03-30 Rogério Pereira Araújo <rogerio.araujo@gmail.com>
+
+ * Icon.cs: Finished Icon(Type, String) ctor
+
+2005-03-23 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * gdipFunctions.cs: fixes GdipGetImagePalette signature
+ * Image.cs: Implements Palette property using gdiplus
+
+2005-03-17 Peter Bartok <pbartok@novell.com>
+
+ * gdipFunctions.cs:
+ - Changed P/Invoke signature for GdipLoadImageFromDelegate_linux()
+ method, now includes a get header delegate
+ - Added StreamGetHeaderImpl method, to allow libgdiplus to determine
+ the image type even on non-seekable streams
+ - Fixed StreamGetBytesImpl to consider the bytes already retrieved
+ via StreamGetHeaderImpl
+ * Image.cs: Fixed call to GdipLoadImageFromDelegate_linux() to include
+ the new StreamGetHeader delegate
+
+2005-03-15 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Pen.cs: Fixes dispose method to allow to be called multiple times
+ * Graphics.cs: matrix are saved and restored at gdiplus level
+
+2005-02-24 Geoff Norton <gnorton@customerdna.com>
+
+ * gdipFunctions.cs: Cache the delegates in the GdiPlusStreamHelper
+ so they dont get garbage collected before use.
+
+2005-02-11 Peter Bartok <pbartok@novell.com>
+
+ * gdipFunctions.cs: Fixed prototype to match previous checkin
+
+2005-02-11 Peter Bartok <pbartok@novell.com>
+
+ * Graphics.cs (FromImage): Fixed type of graphics to be IntPtr (since
+ it really is a pointer)
+
+2005-02-10 Geoff Norton <gnorton@customerdna.com>
+
+ * Icon.cs: Implement GetObjectData ()
+ * Image.cs: Implement GetObjectData ()
+
+2005-02-09 Geoff Norton <gnorton@customerdna.com>
+
+ * Icon.cs: Implement deserializer
+ * Bitmap.cs: Implement deserializer
+
+2005-02-06 Ben Maurer <bmaurer@ximian.com>
+
+ * Brushes.cs: Kill the static ctor here, it has tons of code bloat.
+
+2005-02-03 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Region.cs: revert Jackson's patch and fix this at libgdiplus level
+
+2005-02-02 Jackson Harper <jackson@ximian.com>
+
+ * Region.cs: The default region constructor creates and infinite
+ region, not an empty one.
+
+2005-01-27 Peter Bartok <pbartok@novell.com>
+
+ * Color.cs (GetBrightness, GetSaturation, GetHue): Fixed calculations
+ of HSV numbers. Previous implementation returned wrong numbers and NaN
+ on achromatic colors
+
+2005-01-27 Lluis Sanchez Gual <lluis@novell.com>
+
+ * PointConverter.cs, ImageFormatConverter.cs, RectangleConverter.cs,
+ SizeConverter.cs, ColorConverter.cs, FontConverter.cs
+ : Implemented support for InstanceDescriptor.
+
+2005-01-26 Peter Bartok <pbartok@novell.com>
+
+ * Icon.cs (ToBitmap): Now sets transparency in according to
+ icon AND mask
+
+2004-01-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * gdipFunctions.cs: Fixes GdipGet* function signatures
+ * FontFamily.cs: Fixes GdipGet* function calls
+ * Font.cs: Fixes ToString method
+
+2004-01-17 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Graphics.cs: calls XCloseDisplay on X11 when need it
+ * gdipFunctions.cs: calls XCloseDisplay on X11 when need it
+
+2004-12-27 Zoltan Varga <vargaz@freemail.hu>
+
+ * gdipFunctions.cs Image.cs: Fix marshalling of arrays on amd64.
+
+2004-12-16 Peter Bartok <pbartok@novell.com>
+
+ * Graphics.cs (GetHdc): Removed Wine assumptions, the handle is now
+ equivalent to the gdi+ native object
+
+ * Font.cs (GetHfont): Removed Wine assumptions, the handle is now
+ equivalent to the gdi+ native object
+
+2004-12-09 Geoff Norton <gnorton@customerdna.com>
+
+ * carbonFunctions.cs: New carbon functions/structures
+ * Graphics.cs: Update FromHwnd to work without being in the carbon eventing loop
+
+2004-12-08 Geoff Norton <gnorton@customerdna.com>
+
+ * Graphics.cs: Drop FromHwndWithSize; we can't change the public API
+ Add Quartz support to FromHwnd marshalling a struct back with the ptr/width/height.
+
+2004-12-07 Geoff Norton <gnorton@customerdna.com>
+
+ * Graphics.cs: Add FromHwndWithSize for the MWF/Quartz backend
+ * gdipFunctions.cs: Add the quartz dllimport into libgdiplus
+
+2004-12-06 Miguel de Icaza <miguel@ximian.com>
+
+ * FontFamily.cs: This one is static.
+
+2004-11-25 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs (GdipCreateFontFromLogfontA): Changed return
+ type from int to Status type.
+
+2004-11-25 Marek Safar <marek.safar@seznam.cz>
+
+ * Image.cs: Add CheckStatus to SaveAdd.
+
+2004-11-22 Ravindra <rkumar@novell.com>
+
+ * Graphics.cs: Fixed null values handling in all overloads of
+ MeasureString method.
+
+2004-11-18 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Removed the .so extension from a DllImport
+ that hooks to X11.
+
+2004-10-27 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * gdipFunctions.cs: calls GdiplusShutdown to propery signal GDI+
+ termination
+
+2004-11-03 Miguel de Icaza <miguel@ximian.com>
+
+ * TextureBrush.cs (Clone): While cloning, it is not enough to let
+ GDIPlus clone the underlying data, we must alos clone the managed
+ information.
+
+ * Pen.cs (Dispose): Set the nativeObject to IntPtr.Zero to catch
+ errors in the future, set the lock on the object before doing any
+ other tests, not after.
+
+ (Clone): While cloning, it is not enough to let
+ GDIPlus clone the underlying data, we must alos clone the managed
+ information.
+
+ * Brush.cs (Dispose): Set the nativeObject to IntPtr.Zero to catch
+ errors in the future.
+
+ Set the lock in the object before checkign disposed.
+
+ * SolidBrush.cs (Clone): While cloning, it is not enough to let
+ GDIPlus clone the underlying data, we must alos clone the managed
+ information.
+
+ (Dispose): Set the nativeObject to IntPtr.Zero to catch
+ errors in the future.
+
+2004-10-28 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Added checks for null stream in the
+ StreamHelper internal class.
+ * Icon.cs: Removed an ugly hack that used temp files in
+ ToBitmap () method. We use MemoryStream instead.
+
+2004-10-27 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Font.cs: fixes bug 66533
+
+2004-10-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Bitmap.cs, Font.cs FontFamily.cs Graphics.cs Region.cs
+ SolidBrush.cs StringFormat.cs TextureBrush.cs: removes the
+ lock operations after conversation with Miguel. Do not really
+ need it.
+
+2004-10-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Bitmap.cs: Fixes MakeTransparent problem with 24bbps
+
+2004-10-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Bitmap.cs: Fixes MakeTransparent method
+
+2004-10-13 Ravindra <rkumar@novell.com>
+
+ * Graphics.cs: Moved the initialization of 'use_x_drawable'
+ member out of private constructor to class initialization.
+ So that, we get it right even if Graphics is not instantiated.
+ This fixes the problem we face (otherwise) when we make first
+ call to Graphics.FromHwnd () method.
+
+2004-10-08 Ravindra <rkumar@novell.com>
+
+ * Image.cs: Suppress finalization in Dispose () method.
+
+2004-10-04 Ravindra <rkumar@novell.com>
+
+ * gdipFunctioncs.cs: Fix from Alois for bug #67383.
+
+2004-09-29 Jackson Harper <jackson@ximian.com>
+
+ * Graphics.cs: Use FromHdcInternal to set the X display
+ handle. Add a flag to check if we are on unix so we aren't calling
+ Environment.OSVersion.Platform all the time. Mad props to Peter
+ Bartok for this.
+
+2004-09-17 Marek Safar <marek.safar@seznam.cz>
+
+ * Font.cs (FromHfont, ToHfont): Fixed windows implementation.
+ ToLogFont: Implemented.
+
+ * gdipFunctions.cs: GdipCreateFromHDC changed int to IntPtr to
+ avoid casts.
+ GdipCreateFontFromLogfontA: A new extern call.
+
+2004-09-13 Ravindra <rkumar@novell.com>
+
+ * Graphics.cs: MSDN says that using image width and height gives
+ better performance, hence we are using image width and height to
+ avoid autoscaling in DrawImageUnscaled.
+
+2004-09-10 Ravindra <rkumar@novell.com>
+
+ * Graphics.cs: Implemented DrawIcon methods and fixed
+ DrawImageUnscaled method implementation.
+
+2004-08-21 Jackson Harper <jackson@ximian.com>
+
+ * ImageAnimator.cs: Run animator as a background thread so we do
+ not hang on exit.
+
+2004-08-21 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Modified exception message to include the case
+ of missing required libraries for different formats.
+
+2004-08-10 Jackson Harper <jackson@ximian.com>
+
+ * SystemColors.cs: Make Highlight colour match colour from windows
+ classic color scheme.
+
+2004-07-30 Ravindra <rkumar@novell.com>
+
+ * Font.cs: Fixed Height property implementation and implemented
+ GetHeight method and its overloads.
+
+2004-07-29 Sanjay Gupta <gsanjay@novell.com>
+
+ * gdipFunctions.cs: Corrected signature of GdipGetPropertyItem
+ P/Invoke function for Image.
+ * Image.cs: Implemented GetPropertyItem() and SetPropertyItem() method.
+
+2004-07-29 Sanjay Gupta <gsanjay@novell.com>
+
+ * gdipFunctions.cs: Corrected signatures of GdipGetPropertySize and
+ GdipGetAllPropertyItems P/Invoke function for Image.
+ * gdipStructs.cs: Corrected MarshalTo() method of GdipPropertyItem.
+ * Image.cs: Corrected implementation of PropertyItems property.
+
+2004-07-29 Sanjay Gupta <gsanjay@novell.com>
+
+ * gdipFunctions.cs: Corrected signature of GdipGetPropertyIdList
+ P/Invoke function for Image.
+ * Image.cs: Changed implementation of PropertyIdList property.
+
+2004-07-28 Sanjay Gupta <gsanjay@novell.com>
+
+ * gdipStructs.cs: Implementing PropertyItem property in Image.cs.
+ * Image.cs: Implemented PropertyItems and PropertyIdList properties.
+
+2004-07-21 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Corrected signatures of GdipPathIterCopyData and
+ GdipPathIterEnumerate P/Invoke functions for GraphicsPathIterator.
+
+2004-07-21 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Graphics.cs: fixes MeasureCharacterRanges function. It was completely wrong.
+ * StringFormat.cs: MeasurableCharacterRanges should be passed to GDI+
+ * gdipFunctions.cs: new GDI function calls
+
+2004-07-16 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Added P/Invokes for GraphicsPathIterator.
+
+2004-07-15 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Removed GdipGetPathData P/Invoke. It is redundant.
+
+2004-07-13 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Removed GdipGetPathGradientRectI P/Invoke.
+ This was redundant. It was kept in previous checkin to avoid
+ build breakage.
+
+2004-07-13 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Added some P/Invokes for PathGradientBrush.
+
+2004-07-09 Peter Bartok <pbartok@novell.com>
+ * Graphics.cs: Added support required for new managed SWF library
+ * gdipFunctions.cs: Added XOpenDisplay definition/import
+
+2004-07-02 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * gdipFunctions.cs: fixes bug 61050
+
+2004-06-24 Sanjay Gupta <gsanjay@novell.com>
+
+ * ImageAnimator.cs: Rewrote complete implementation.
+
+2004-06-24 Sanjay Gupta <gsanjay@novell.com>
+
+ * gdipFunctions.cs: Corrected issue in GdiPlusStreamHelper class.
+ If read function was called after seek function call, the
+ implementation was returning data from bytes already peeked and
+ not from the new position in stream, which we have seeked.
+
+2004-06-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Graphics.cs: added MeasureString wrappers
+
+2004-06-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Graphics.cs, gdipFunctions.cs: define and use GdipSetVisibleClip_linux
+
+2004-06-20 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Graphics.cs, gdipFunctions.cs: added missing clip function wrappers
+
+2004-06-18 Ravindra <rkumar@novell.com>
+
+ * FontConverter.cs: Implemented the missing functions.
+ * Font.cs: Added some notes.
+
+2004-06-16 Sanjay Gupta <gsanjay@novell.com>
+
+ * gdipFunctions.cs: Modified Function signature for
+ GdipSaveImageToDelegate_linux() method for saving tiff images
+ to streams.
+ * image.cs: Modified function call GdipSaveImageToDelegate_linux()
+ with new signature.
+
+2004-06-15 Sanjay Gupta <gsanjay@novell.com>
+
+ * gdipFunctions.cs: Added delegate and StreamHelper functions, Close
+ and Size, required by TIFFCodec. Modifed Function signature for
+ GdipLoadImageFromDelegate_linux() method.
+ * image.cs: Modified function call GdipLoadImageFromDelegate_linux()
+ with new signature.
+
+2004-06-11 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: (GdipCreateSolidFill): Changed one argument
+ from out int to out IntPtr.
+ * SolidBrush.cs: Same.
+
+2004-06-10 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * Image.cs: API signature fixes, meaning DisposeResources is now
+ private and marked InitFromStream internal
+
+2004-05-12 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * FontFamily.cs: simplifies object destruction and fixes
+
+2004-05-12 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * FontFamily.cs: added destructor
+ * Graphics.cs: added destructor to stop leaking, remove debugging code
+
+
+2004-05-12 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * gdipFunctions.cs: added GdipSaveAddImage
+ * Image.cs: added SaveAdd methods
+
+2004-06-02 Peter Bartok <pbartok@novell.com>
+ * gdipFunctions.cs: Fixed reference to wrong DLLs for GetDC/ReleaseDC
+ (This fixes bug #59479)
+
+2004-06-01 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * Font.cs: Added missing Browsable attribute on SizeInPoints.
+ * Region.cs: Removed extra ComVisible attribute from Clone().
+
+2004-06-01 Ravindra <rkumar@novell.com>
+
+ * Pen.cs: Added a note on Dispose method.
+ * Brush.cs: Fixed Dispose method.
+ * SolidBrush.cs: Fixed Dispose method.
+
+2004-05-28 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Added some P/Invoke calls for Draw/Fill
+ rectangles.
+ * Graphics.cs: Implemented Dispose method and changed Draw/Fill
+ rectangles implementation (This is basically done to avoid lots
+ of brush and pen setup happening in libgdiplus.)
+
+2004-05-27 Ravindra <rkumar@novell.com>
+
+ * Color.cs: Changed Color.Green to what MS.NET has. Conforming to MS.
+
+2004-05-26 Sanjay Gupta <gsanjay@novell.com>
+
+ * ImageFormatConverter.cs: Fixed issues discovered from nunit
+ test cases.
+
+2004-05-26 Ravindra <rkumar@novell.com>
+
+ * Color.cs: Corrected Color.Green property.
+
+2004-05-24 Jordi Mas i Hernandez <jordi@ximian.com>
+ * gdipStructs.cs: remove unnecessary code, since bug 57706 is fixed
+
+2004-05-20 Sanjay Gupta <gsanjay@novell.com>
+
+ * Icon.cs: Fixed issue with size property.
+
+2004-05-18 Ravindra <rkumar@novell.com>
+
+ * Pen.cs: Added value checks in DashPattern and CompoundArray
+ properties.
+
+2004-05-16 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * Graphics.cs: fixed warning
+ * ImageAnimator.cs: fixed warning
+ * FontConverter.cs: fixed public API
+
+2004-05-14 Vladimir Vukicevic <vladimir@pobox.com>
+
+ * gdipFunctions.cs: Fixed prototype for
+ GdipGetEncoderParameterList
+
+ * Image.cs: Reworked Save functions to handle EncoderParameters.
+ Implemented GetEncoderParameterList
+ Also removed unused setGDIPalette internal method.
+
+2004-05-14 Peter Bartok <pbartok@novell.com>
+ * StringFormat.cs: Added CharacterRange handling
+ * Graphics.cs: Implemented MeasureCharacterRanges method
+
+2004-05-14 Peter Bartok <pbartok@novell.com>
+ * Graphics.cs: Added error check
+
+2004-05-14 Duncan Mak <duncan@ximian.com>
+ * gdipFunctions.cs (GdipCreatePath2I, GdipAddPathPieI):
+ (GdipFlattenPath, GdipWarpPath, GdipWidenPath):
+ (GdipGetPathWorldBounds, GdipGetPathWorldBoundsI): Imported.
+
+2004-05-14 Sanjay Gupta <gsanjay@novell.com>
+ * ImageFormatConverter.cs: Modified implementation of ConvertFrom() method.
+
+2004-05-13 Sanjay Gupta <gsanjay@novell.com>
+ * ImageFormatConverter.cs: Implemented GetStandardValuesSupported () method.
+
+2004-05-13 Peter Bartok <pbartok@novell.com>
+ * Bitmap.cs: Fixed bug #52868, Bitmap(Image, Size) did not
+ resize the image.
+
+2004-05-12 Peter Bartok <pbartok@novell.com>
+ * Image.cs: Implemented GetThumbnailImage
+
+2004-05-13 Sanjay Gupta <gsanjay@novell.com>
+ * Graphics.cs: Made method DrawRectangle (Pen , RectangleF) and
+ FromXDrawable(IntPtr, IntPtr) internal.
+
+2004-05-12 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Color.cs: work for API compatibilty: private date, todos
+ * Font.cs: work for API compatibilty: private date, todos
+ * FontFamily.cs: work for API compatibilty: private date, todos
+ * Graphics.cs: work for API compatibilty: private date, todos
+ * Icon.cs: work for API compatibilty: private date, todos
+ * Image.cs: work for API compatibilty: private date, todos
+ * ImageAnimator.cs: work for API compatibilty: private date, todos
+ * Point.cs: work for API compatibilty: private date, todos
+ * PointF.cs: work for API compatibilty: private date, todos
+ * Rectangle.cs: work for API compatibilty: private date, todos
+ * RectangleF.cs: work for API compatibilty: private date, todos
+ * Region.cs: work for API compatibilty: private date, todos
+ * Size.cs: work for API compatibilty: private date, todos
+ * SizeF.cs: work for API compatibilty: private date, todos
+ * SolidBrush.cs: work for API compatibilty: private date, todos
+ * StringFormat.cs: work for API compatibilty: private date, todos
+ * SystemPens.cs: work for API compatibilty: private date, todos
+ * TextureBrush.cs: work for API compatibilty: private date, todos
+ * gdipStructs.cs: work for API compatibilty: private date, todos
+
+2004-05-12 Ravindra <rkumar@novell.com>
+
+ * Bitmap.cs, Font.cs, FontConverter.cs, Graphics.cs, Icon.cs, Image.cs
+ ImageAnimator.cs, Point.cs, PointF.cs, Rectangle.cs, RectangleF.cs
+ Region.cs, Size.cs, SizeF.cs, ToolboxBitmapAttribute.cs, gdipFunctions.cs:
+ Added missing attributes and some coding style fixes.
+ * Pen.cs: Implementing CustomStartCap and CustomEndCap properties and
+ some fixes.
+
+2004-05-11 Sanjay Gupta <gsanjay@novell.com>
+
+ * ImageAnimator.cs: Implemented first version.
+
+2004-05-11 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Implementing AdjustableArrowCap. Added P/Invokes
+ for the same.
+
+2004-05-10 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Implementing CustomLineCap. Added P/Invokes
+ for the same. Added few related P/Invokes for Pen also.
+
+2004-05-06 Sanjay Gupta <gsanjay@novell.com>
+
+ * ImageAnimator.cs: Corrected implementation of CanAnimate() method.
+
+2004-05-06 Ravindra <rkumar@novell.com>
+
+ * RectangleConverter.cs: Implemented GetProperties () method.
+ * SizeConverter.cs: Implemented GetProperties () method.
+ * PointConverter.cs: Implemented GetProperties () method.
+ * FontConverter.cs: Implemented some of the methods.
+
+2004-05-06 Ravindra <rkumar@novell.com>
+
+ * Color.cs: Fixed Name property.
+ * ColorTranslator.cs: Fixed the existing methods and implemented
+ the missing methods.
+ * ColorConverter.cs: Fixed the existing methods and implemented
+ the missing methods. Also, fixed coding style.
+
+2004-05-05 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Bitmap.cs: Let GDI+ calculate the strides, as it does in Win32.
+
+2004-05-05 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Image.cs: raw_format should be handled by GDI+
+ * Bitmap.cs: raw_format should be handled by GDI+
+
+2004-05-04 Ravindra <rkumar@novell.com>
+
+ * Pen.cs: Modified exception message. Fixed Transform, DashPattern,
+ and DashCap properties. Implementing CoumpoundArray, StartCap, EndCap
+ properties and SetLineCap method. In constructors use IntPtr instead
+ of int.
+ * SolidBrush.cs: Modified exception message.
+ * TextureBrush.cs: Fixed Transform property.
+ * gdipFunctions.cs: Fixed P/Invokes for Pen.cs, TextureBrush.cs and
+ LinearGradientBrush.cs.
+
+2004-04-30 Sanjay Gupta <gsanjay@novell.com>
+
+ * Image.cs: Implemented FrameDimensionsList property.
+
+2004-04-30 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Added few more P/Invoke calls for
+ lineargradient brush and added one case statement in
+ CheckStatus method.
+
+2004-04-30 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Image.cs: takes into account MemoryBmp format when saving
+
+2004-04-30 Ravindra <rkumar@novell.com>
+
+ * StringFormat.cs: Added checks for status.
+
+2004-04-30 Sanjay Gupta <gsanjay@novell.com>
+
+ * Image.cs: Removed calls which passes byte[] for Guid parameter.
+ * gdipFunctions.cs: Removed unwanted unix specific function calls.
+
+2004-04-30 Ravindra <rkumar@novell.com>
+
+ * Graphics.cs: Added checks for status.
+ * Image.cs: Added a check for status.
+ * FontFamily.cs: Added checks for status.
+
+2004-04-29 Peter Bartok <pbartok@novell.com>
+
+ * Brushes.cs: Fixed bug #52695. No longer creates a new
+ brush for every request and behaves Microsoft compatible
+
+2004-04-29 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * Image.cs: fixes Save method. It now retrieves the proper encoder and uses
+ its ClsID instead of the formatID (as GDI+ expects)
+
+2004-04-29 Ravindra <rkumar@novell.com>
+
+ * Font.cs: Added checks for status.
+ * Bitmap.cs: Added checks for status.
+ * Pen.cs: Added checks for status.
+
+2004-04-28 Sanjay Gupta <gsanjay@novell.com>
+
+ * ColorTranslator.cs, StringFormat.cs, SystemIcons.cs, ToolBoxBitmapAttributes.cs:
+ Converted to unix format from dos format.
+
+2004-04-28 Sanjay Gupta <gsanjay@novell.com>
+
+ * ImageConverter.cs: Implemented GetProperties() and GetPropertiesSupported () methods.
+
+2004-04-28 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * gdipStructs.cs: added GdipImageCodecInfo struct
+
+2004-04-28 Sanjay Gupta <gsanjay@novell.com>
+
+ * ImageFormatConverter.cs: Corrected ConvertFrom method.
+
+2004-04-27 Sanjay Gupta <gsanjay@novell.com>
+
+ * ImageConverter.cs: Added exception message.
+ * IconConverter.cs: Added exception message.
+ * ImageFormatConverter.cs: Implemented first version.
+
+2004-04-27 Sanjay Gupta <gsanjay@novell.com>
+
+ * ImageConverter.cs: Implemented first version.
+
+2004-04-27 Sanjay Gupta <gsanjay@novell.com>
+
+ * IconConverter.cs: Implemented first version.
+
+2004-04-26 Sanjay Gupta <gsanjay@novell.com>
+
+ * Image.cs: Corrected implementation of Property RawFormat.
+ * gdipFunctions.cs: Corrected declaration of GdipGetImageRawFormat.
+
+2004-04-25 Sanjay Gupta <gsanjay@novell.com>
+
+ * Bitmap.cs: Resolved a compile time error.
+ * Image.cs: Changed the implementation of few methods to progress
+ with ImageAnimator class.
+ * gdipFunctions.cs: Added few linux only function calls.
+ * Icon.cs: Removed unused variable from code.
+
+2004-04-25 Vladimir Vukicevic <vladimir@pobox.com>
+
+ * Graphics.cs, gdipFunctions.cs: Added CreateFromXDrawable_linux.
+
+2004-04-23 Vladimir Vukicevic <vladimir@pobox.com>
+
+ * Commited patch from pcgod@gmx.net (Bnehamin Jemlich) for
+ serialization for Bitmaps. (Bugzilla #52568)
+
+2004-04-23 Ravindra <rkumar@novell.com>
+
+ * RectangleConverter.cs: Fixed ConvertTo () method.
+ * SizeConverter.cs: Fixed ConvertTo () method.
+ * PointConverter.cs: Fixed ConvertTo () method.
+
+2004-04-23 Sanjay Gupta <gsanjay@novell.com>
+ * ImageAnimator.cs: Implemented CanAnimate() method.
+
+2004-04-22 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Image.cs: added RotateFlip and RemovePropertyItem calls
+
+2004-04-22 Ravindra <rkumar@novell.com>
+
+ * RectangleConverter.cs: Implemented. Also changed file format
+ dos2unix.
+ * Rectangle.cs: Fixed ToString method.
+ * RectangleF.cs: Fixed ToString method.
+
+2004-04-22 Ravindra <rkumar@novell.com>
+
+ * SizeConverter.cs: Implemented some of the functions.
+ * PointConveter.cs: Implemented.
+ * gdipFunctions.cs: Corrected one typo.
+ * Brushes.cs: Added a comment.
+
+2004-04-22 Vladimir Vukicevic <vladimir@pobox.com>
+
+ * gdipFunctions.cs: Fix StreamGetBytesImpl to handle
+ returning portions of the peek buffer back. Fixes #57379.
+
+2004-04-21 Peter Bartok <pbartok@novell.com>
+ * Font.cs: Implemented Font.FromHfont method
+ * gdipStructs.cs: fixed sign for LOGFONTA lfHeight member
+ * gdipFunctions.cs: Added imports for functions required to support
+ Font.FromHfont method
+
+2004-04-21 Jordi Mas i Hernandez <jordi@ximian.com>
+ * RectangleConverter.cs: stubbed out
+ * Font.cs : added missing members
+
+2004-04-19 Sanjay Gupta <gsanjay@novell.com>
+ * Icon.cs: Fixed problem in extracting bitmap from Icon.
+
+2004-04-16 Ravindra <rkumar@novell.com>
+
+ * Pen.cs: GC should be allowed to collect any pen including
+ system pens.
+ * SolidBrush.cs: GC should be allowed to collect any SolidBrush
+ including system brushes.
+ * Brushes.cs: Coding style.
+ * Pens.cs: Objects created by Pens are not modifiable on
+ MS.NET, so we are now. Also, coding style fixes.
+ * SystemPens.cs: Removed static constructor and changed file
+ format dos2unix.
+ * SystemBrushes.cs: Some cosmetic changes.
+
+2004-04-15 Sanjay Gupta <gsanjay@novell.com>
+ * Icon.cs: Implemented more missing bits and fixed the problem
+ of icon not getting saved in proper format
+
+2004-04-14 Sanjay Gupta <gsanjay@novell.com>
+ * Icon.cs: Implemented more missing bits
+
+2004-04-13 Sanjay Gupta <gsanjay@novell.com>
+ * Icon.cs: Implemented few more missing bits
+
+2004-04-12 Sanjay Gupta <gsanjay@novell.com>
+ * Icon.cs: Implemented first version
+
+2004-04-11 Peter Bartok <pbartok@novell.com>
+ * Font.cs: Implemented Font.ToHfont method; used Jordi's suggestion of splitting
+ the code and using our own private gdiplus function when on Unix and using Win32
+ functions when running on Windows
+ * gdipStructs.cs: Added LOGFONTA structure
+ * gdipFunctions.cs: Added various DllImports required for Font.ToHfont
+
+2004-04-10 Vladimir Vukicevic <vladimir@pobox.com>
+
+ * Image.cs: Save should use encoder.FormatID, not Clsid
+
+2004-04-06 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Region.cs: fixes GdipCombineRegionRect and GdipCombineRegionRectI signature
+ * gdipFunctions.cs: fixes GdipCombineRegionRect and GdipCombineRegionRectI signature
+
+2004-04-06 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs (GdipCreatePath2): Fixed signature.
+
+2004-04-06 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Region.cs: fixes GetRegionScans
+ * gdipFunctions.cs: fixes GetRegionScans
+
+2004-04-06 Vladimir Vukicevic <vladimir@pobox.com>
+
+ * gdipFunctions.cs: Added stream delegate helpers for
+ stream loading/saving on linux
+
+ * Image.cs, Bitmap.cs: Converted to call into GDIPlus for
+ loading/saving image data.
+
+2004-04-05 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Region.cs: implemented new methods
+ * Graphics.cs: implemented new methods
+
+2004-04-02 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Region.cs: implemented
+
+2004-04-01 Duncan Mak <duncan@ximian.com>
+
+ * Graphics.cs (DrawCurve): Call the correct GDI+ wrappers.
+
+ * gdipFunctions.cs (GdipAddPathCurveI):
+ (GdipAddPathCurve2, GdipAddPathCurve2I):
+ (GdipAddPathCurve3, GdipAddPathCurve3I):
+ (GdipAddPathClosedCurve, GdipAddPathClosedCurveI):
+ (GdipAddPathClosedCurve2, GdipAddPathClosedCurve2I): Added new
+ wrappers from GDI+.
+
+2004-03-30 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Image.cs: implemented a few GDI+ wrapper calls
+
+2004-03-30 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Bitmap.cs: remove redundant data already present at Image.cs
+ * Image.cs: use GDI+ functions to get image details
+ * StringFormat.cs: missing constructor and property
+
+2004-03-24 Jordi Mas i Hernandez <jordi@ximian.com>
+ * FontFamily.cs: added missing members and style clean
+ * Graphics.cs: fixed signature of DrawArc and DrawPie
+ * Image.cs: added missing members, fixes
+ * StringFormat.cs: missing constructor and property
+
+2004-03-24 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Graphics.cs: Added missing DrawImage GDI+ calls
+ * gdipFunctions.cs: Added missing DrawImage GDI+ calls
+
+2004-03-23 Ravindra <rkumar@novell.com>
+ * gdipFunctions.cs: Added few more P/Invoke calls for
+ LinearGradientBrush.
+
+2004-03-22 Ravindra <rkumar@novell.com>
+ * gdipFunctions.cs: Added P/Invoke calls for LinearGradientBrush
+ and did few coding style fixes.
+
+2004-03-18 Ravindra <rkumar@novell.com>
+ * Brush.cs: Fixed Dispose method.
+ * SolidBrush.cs: Fixed clone method.
+ * TextureBrush.cs: Fixed clone method.
+ * gdipFunctions.cs: Fixed P/Invokes for PathGradientBrush.
+
+2004-03-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * SizeConverter.cs: fixd typo in ConvertFrom that made height be wrong.
+
+2004-03-10 Ravindra <rkumar@novell.com>
+ * Pen.cs: Implemented PenType property.
+ * Brush.cs: Coding style.
+
+2004-03-06 Ravindra <rkumar@novell.com>
+ * gdipFunctions.cs: Added few more GDI+ P/Invoke calls
+ for PathGradientBrush.
+
+2004-03-06 Ravindra <rkumar@novell.com>
+ * gdipFunctions.cs: Added GDI+ P/Invoke calls for
+ PathGradientBrush.
+
+2004-03-04 Duncan Mak <duncan@ximian.com>
+
+ * Region.cs: Indentation.
+
+ * RectangleF.cs: Changed the internal structure from a PointF,
+ SizeF to floats in order to match the layout from the C API.
+
+2004-03-04 Jordi Mas i Hernandez <jordi@ximian.com>
+ * StringFormat.cs: DigitSubstitution and TabStob methods, coding-style
+
+2004-03-03 Sanjay Gupta <gsanjay@novell.com>
+ * gdipFunctions.cs: Added functions for ImageAttributes
+
+2004-03-03 Sanjay Gupta <gsanjay@novell.com>
+ * Icon.cs: Missing function stubs added
+ * Icon.cs: Missing function stubs added
+ * IconConverter.cs: Missing function stubs added
+ * ImageAnimator.cs: Missing function stubs added
+ * ImageConverter.cs: Missing function stubs added
+ * ImageFormatConverter.cs: Missing function stubs added
+
+2004-03-02 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Font.cs: Allow multiple styles
+
+2004-02-25 Jordi Mas i Hernandez <jordi@ximian.com>
+ * StringFormat.cs: Clone method
+
+2004-02-24 Jordi Mas i Hernandez <jordi@ximian.com>
+ * font.cs: fixes, Clone, and ToString
+
+2004-02-21 Jordi Mas i Hernandez <jordi@ximian.com>
+ * gdipFunctions.cs: MeasureString
+ * Graphics.cs : MeasureString
+
+2004-02-17 Jordi Mas i Hernandez <jordi@ximian.com>
+ * Font.cs: destructor and unit conversion
+ * Graphics.cs : system dpi support
+
+2004-02-13 Ravindra <rkumar@novell.com>
+ * Pen.cs: Fixed some bugs.
+ * TextureBrush.cs: Fixed some bugs.
+
+2004-02-13 Sanjay Gupta <gsanjay@novell.com>
+ * gdipFunctions.cs: Added ImageCodecInfo functions
+ * Image.cs: Added few methods
+
+2004-02-13 Jordi Mas i Hernandez <jordi@ximian.com>
+ * FontFamily.cs: remove hardcoded font names, a few bug fixes
+
+2004-02-12 Sanjay Gupta <gsanjay@novell.com>
+ * gdipFunctions.cs: Added Image class functions
+ * Image.cs: Added few methods
+
+2004-02-10 Jordi Mas i Hernandez <jordi@ximian.com>
+ * graphics.cs: fixes parameters for DrawStrings functions
+
+2004-02-07 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * SRDescriptionAttribute.cs: Added and implemented
+ * ToolboxBitmapAttribute.cs: Implemented a few members
+ * SystemIcons.cs: Stubbed
+ * StringFormat.cs: Implemented method
+ * Region.cs: Added Todo, fixed attribute
+ * Size.cs: Added attribute
+ * SizeF.cs: Added attribute
+ * RectangleF.cs: Added attributes
+ * Rectangle.cs: Added attributes
+ * PointF.cs: Added attribute
+ * Point.cs: Added attribute
+
+2004-02-06 Ravindra <rkumar@novell.com>
+
+ * Brush.cs: Renamed GetException method to CheckStatus
+ and moved it to gdipFunctions.cs.
+ * gdipFunctions.cs: Added CheckStatus method.
+ * SolidBrush.cs: Using CheckStatus method.
+ * TextureBrush.cs: Using CheckStatus method.
+ * gdipEnums.cs: Added a missing value.
+
+2004-02-05 Ravindra <rkumar@novell.com>
+
+ * Brush.cs: Added a missing namespace.
+
+2004-02-05 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Added methods for HatchBrush and
+ SolidBrush.
+ * SolidBrush.cs: Added checks for status.
+ * Brush.cs: Added support for HatchBrush and TextureBrush
+ types in internal CreateBrush() method.
+
+2004-02-03 Jordi Mas <jordi@ximian.com>
+ * Font.cs: Setup font properties
+
+2004-02-03 Ravindra <rkumar@novell.com>
+
+ * TextureBrush.cs and Brush.cs: Moved GetException (Status)
+ method from TextureBrush.cs to Brush.cs.
+ * Brush.cs: Made GetException (Status) method internal.
+
+2004-02-03 Sanjay Gupta <gsanjay@novell.com>
+
+ * gdipFunctions.cs: Added methods for Image class.
+
+2004-01-30 Ravindra <rkumar@novell.com>
+
+ * TextureBrush.cs: Added more methods to complete it.
+ * gdipFunctions.cs: Added methods for TextureBrush class.
+
+2004-01-30 Ravindra <rkumar@novell.com>
+
+ * gdipFunctions.cs: Added methods for TextureBrush class.
+
+2004-01-30 Ravindra <rkumar@novell.com>
+
+ * Pen.cs: Modified to handle TextureBrush also.
+ * Bitmap.cs: Added one internal constructor.
+ * TextureBrush.cs: Implemented.
+
+2004-01-29 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs
+ * Graphics.cs: Indentation fixes, removed long dangling lines and
+ extra spaces.
+
+ * Graphics.cs (IsVisible): Renamed variable to not use hungarian
+ notation.
+
+2004-01-29 Sanjay Gupta <gsanjay@novell.com>
+
+ * FontFamily.cs: Implemented few methods and a constructor
+
+2004-01-28 Sanjay Gupta <gsanjay@novell.com>
+
+ * gdipFunctions.cs: Added FontFamily and FontCollection functions.
+ * FontFamily.cs: Implemented missing functionalities.
+
+2004-01-24 Duncan Mak <duncan@ximian.com>
+
+ * Graphics.cs (DrawPath): Implemented.
+
+2004-01-23 Ravindra <rkumar@novell.com>
+
+ * Point.cs: ToString modified.
+ * PointF.cs: ToString modified.
+ * Size.cs: ToString modified.
+ * SizeF.cs: ToString modified. ToPoint and ToSize methods
+ are added.
+
+2004-01-21 Jordi Mas i Hernàndez
+ * Bitmap.cs: Several new methods added.
+
+2004-01-21 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs (GdipGetPathTypes, GdipGetPathPoints): Add
+ OutAttribute to the array argument. This fixes the PathPoints
+ property in System.Drawing.Drawing2D.GraphicsPath.
+
+2004-01-20 Ravindra <rkumar@novell.com>
+
+ * Pen.cs: Fixed bug #52811 in Pen.Transform property. Setting
+ this property was hanging and getting was throwing a NullRef
+ Exception. Earlier we were passing Matrix object to and fro
+ which was causing the problem. Now, we are using IntPtr.
+ Thanks to Duncan for helping me.
+ Also, .NET behavior is to maintain Pen.Color and Pen.Brush
+ together. If color is set, a SolidBrush automatically gets
+ set with the same color, Pen loses the old brush object.
+ If a SolidBrush is set, Pen.Color gets the value same as that
+ of brush color losing the old value. Pen shows this behavior
+ now.
+ * gdipFunctions.cs: Changed the signature of GdipGetPenTransform
+ and GdipSetPenTransform methods to use IntPtr instead of Matrix.
+
+2004-01-19 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs: Import functions for GraphicsPath.
+
+2004-01-14 Ravindra <rkumar@novell.com>
+
+ * SolidBrush.cs: Made SolidBrush to initialize its color
+ from IntPtr.
+
+ * gdipFunctions.cs: Added call to GdipGetSolidFillColor GDI+ API.
+
+2004-01-11 Duncan Mak <duncan@ximian.com>
+
+ * Bitmap.cs (LockBits):
+ * Graphics.cs (DrawString): Removed reference to GpRectF.
+
+2004-01-09 Duncan Mak <duncan@ximian.com>
+
+ * gdipStructs.cs (GpRectF, GpRect, GpPointF, GpPoint):
+ Removed. Didn't know that structs are laid out sequentially by
+ default. We don't need these anymore.
+
+2004-01-12 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * Color.cs: Keep KnownColors in an array so that we avoid ht lookup.
+
+2004-01-11 Daniel Morgan <danielmorgan@verizon.net>
+
+ * Graphics.cs: fix compile error on Windows builds for out
+ parameter state in call to GdipSaveGraphics
+
+2004-01-10 Ravindra <rkumar@novell.com>
+
+ * All Enums: Made serializable.
+
+ * Image.cs: Corrected signature of Dispose(bool) method.
+
+ * Pen.cs, SolidBrush.cs, SystemPens.cs, SystemBrushes.cs:
+ Corrected coding style mistakes of my previous commit.
+
+ * PointConverter.cs, RectangleConverter.cs: Inherit TypeConverter.
+
+ * PointF.cs, RectangleF.cs, SizeF.cs: Made serializable.
+
+ * StringFormat.cs: Inherits MarshalByRefObject.
+
+ * ToolboxBitmapAttribute.cs: Added missing attribute [AttributeUsage].
+
+2004-01-08 Ravindra <rkumar@novell.com>
+
+ * Pen.cs: Added isModifiable (bool) variable. It is required to
+ make Pens created by SystemPens.cs unmodifiable. All property
+ setters are modified for this.
+
+ * SolidBrush.cs: Added isModifiable variable (bool). It is
+ required to make Brushes created by SystemBrushes.cs unmodifiable.
+ All property setters are modified for this.
+
+ * SystemBrushes.cs: Modified all the properties as per the .NET
+ specs, so that Brushes are not created every time. Also, missing
+ properties are added.
+
+ * SystemPens.cs: Modified all the properties as per the .NET
+ specs, so that Brushes are not created every time. Also, missing
+ properties are added.
+
+2003-12-12 Miguel de Icaza <miguel@ximian.com>
+
+ * Rectangle.cs: Patch from Bryan Bulten, fixes Inflate and makes
+ it serializable
+
+2004-01-06 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs: Import GraphicsPath functions from GDI+.
+
+2003-12-21 Duncan Mak <duncan@ximian.com>
+
+ * Graphics.cs (DrawArc): Fixed the method signature and hooked it
+ up to the GDI+ implementation.
+ (RotateTransform): Uncommented.
+
+ * gdipFunctions.cs (DrawArc, DrawArcI): Import from
+ libgdiplus.so.dll.
+
+2003-12-13 Todd Berman <tberman@sevenl.net>
+
+ * Font.cs: Implementing a couple things for porting purposes
+ * SystemBrushes.cs: ^
+ * StringFormat.cs: ^^
+
+2003-11-28 Duncan Mak <duncan@ximian.com>
+
+ * Pen.cs (CompoundArray): Hide this for now.
+
+2003-11-28 Duncan Mak <duncan@ximian.com>
+
+ * Brush.cs (CreateBrush): new internal factory method for creating
+ specific brushes based on the internal (GDI+ C API) BrushType
+ enum.
+ (Brush (IntPtr)): new internal constructor.
+
+ * Pen.cs: Removed all the C# fields. We are using GDI+ completely
+ now.
+ (Pen (IntPtr)): new internal constructor.
+ (Pen (Brush, float)): Use GdipCreateBrush2.
+ (Clone): Implemented using GdipClonePen.
+ (Alignment, Brush, Color, Width): Use GDI+ implementations
+ instead.
+ (CompoundArray, DashCap, DashOffset, DashPattern, DashStyle):
+ Implemented these properties.
+ (CustomStartCap, CustomEndCap, StartCap, EndCap, SetLineCap): Stubbed.
+ (MultiplyTransform, ResetTransform, RotateTransform):
+ (ScaleTransform, TranslateTransform): Implemented these methods.
+
+ * SolidBrush.cs (SolidBrush (IntPtr)): new internal constructor.
+
+ * gdipEnums.cs (BrushType): Added new GDI+ enum.
+
+ * gdipFunctions.cs: Imported new Brush and Pen functions.
+
+2003-11-22 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs
+ (GdipResetWorldTransform, GdipSetWorldTransform):
+ (GdipGetWorldTransform, GdipScaleWorldTransform): Imported.
+
+ * Graphics.cs: Remove unnecessary TODO, and reformatted the code.
+ (transform): Removed this field. Always use the
+ matrix associated in the GpGraphics ptr.
+ (DrawBeziers): Implemented.
+ (DrawLine): Don't need to manually invoke the transform now.
+ (MultiplyTransform, ResetTransform):
+ (ScaleTransform, TranslateTransform): Use GDI+ implementation.
+ (Transform): Instead of storing a Matrix in managed code, use
+ equivalent GDI+ functions.
+
+2003-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * SizeConverter.cs: fixed class signature and implemented some methods.
+
+2003-11-17 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs (GdipGetMatrixElements): Fix signature.
+
+ * Graphics.cs (MultiplyTransform): Commented out until my Matrix commit.
+
+2003-11-17 Duncan Mak <duncan@ximian.com>
+
+ * Bitmap.cs (LockBits):
+ * Graphics.cs (DrawString): Use GpRectF.
+
+ * gdipFunctions.cs: Updated method signatures.
+
+ * Graphics.cs (MultiplyTransform): Implemented using
+ GdipMultiplyWorldTransform from GDI+.
+
+ * gdipStructs.cs (GdipRectF, GdipRect): Renamed to GpRectF and
+ GpRect, to be more consistent with the C naming.
+
+2003-11-16 Miguel de Icaza <miguel@ximian.com>
+
+ * Graphics.cs: Implement the other DrawString overloads .
+
+2003-11-16 Miguel de Icaza <miguel@ximian.com>
+
+ * gdipStructs.cs (GdipRectF): Added utility constructor
+
+2003-11-15 Duncan Mak <duncan@ximian.com>
+
+ * gdipFunctions.cs: Imported matrix functions.
+
+2003-11-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Bitmap.cs: Added Attributes
+ * ColorTranslator.cs: Added private constructor
+ * Font.cs: Added Attributes
+ * FontFamily.cs: sealed
+ * Icon.cs: Added Attributes
+ * IconConverter.cs: Fixed signature
+ * Image.cs: Added attributes
+ * ImageAnimator.cs:
+ * ImageConverter.cs:
+ * ImageFormatConverter.cs:
+ * SolidBrush.cs:
+ * StringFormat.cs:
+ * SystemBrushes.cs:
+ * SystemColors.cs:
+ * SystemIcons.cs:
+ * SystemPens.cs:
+ * TextureBrush.cs: Fixed signature
+ * Color.cs: Added attributes
+ * Point.cs:
+ * PointF.cs:
+ * Rectangle.cs:
+ * Size.cs:
+ * SizeF.cs: Added attributes
+ * ContentAlignment.cs: Added attribute
+
+2003-11-13 Duncan Mak <duncan@ximian.com>
+
+ * Pen.cs (LineCap, LineJoin, MiterLimit, Transform): implemented.
+
+ * gdipFunctions.cs
+ (GdipSetPenMiterLimit, GdipGetPenMiterLimit):
+ (GdipSetPenLineJoin, GdipGetPenLineJoin):
+ (GdipSetPenLineJoin, GdipGetPenTransform): imported.
+
+2003-11-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Bitmap.cs
+ * gdipFunctions.cs copy image in Bitmap constructor
+
+2003-11-06 Duncan Mak <duncan@ximian.com>
+ * Graphics.cs (DrawPie): Use DrawPieI instead of DrawPie and fix
+ angle parameters for the integer case.
+ (DrawBezier): Hook it up with GdipDrawBezier.
+ (DrawEllipse): Fix Width, Height ordering.
+
+2003-11-05 Duncan Mak <duncan@ximian.com>
+
+ * Graphics.cs (DrawPie):
+ * gdipFunctions.cs (GdipDrawPie): Add hooks to the implementation
+ in graphics.c.
+
+2003-10-28 Duncan Mak <duncan@ximian.com>
+
+ * Graphics.cs (DrawEllipse, DrawLine, DrawPolygon):
+ (FillEllipse, FillPolygon): implemented.
+ (RenderingOrigin): implemented.
+
+ * gdipFunctions.cs: Added new GDI+ equivalents.
+
+2003-10-25 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Bitmap.cs
+ * Image.cs small fixes
+
+2003-10-25 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * Image.cs : renamed 'pallete' to 'colorPallete' for CLS compliance.
+
+2003-10-24 Miguel de Icaza <miguel@ximian.com>
+
+ * SystemBrushes.cs: Some more brushe3s.
+
+ * SystemPens.cs: More pens.
+
+ * Pen.cs: Implement IDisposable, ICloneable.
+
+ * Region.cs: Add some more stubs here.
+
+ * StringFormat.cs: Add some more code here.
+
+2003-10-23 Miguel de Icaza <miguel@ximian.com>
+
+ * Image.cs: Kill the InternalImageInfo, everything is now done in
+ terms of Image and BitmapData.
+
+ * Rectangle.cs: Make this one also sequential, change from using
+ Point + Size to use x, y, width, height; So we can use GdiPlus.
+
+ * gdipFunctions.cs (GdipBitmapLockBits): Remove the ref from the
+ BitmapData class argument, and instead use the [In,Out]
+ attributes, which will do struct marshalling on the fields. Now
+ we can use C#'s BitmapData directly to talk to Gdiplus.
+
+ * gdipStructs.cs: Every internal structure that has to talk to
+ Gdi+ is properly prefixed, to minimize the confussion.
+
+ * Bitmap.cs Bitmap (int width, int height, PixelFormat format):
+ Compute the stride here where we have the BPP information,
+ allocate a buffer of the proper size, and pass this to
+ GdipCreateBitmapFromScan0
+
+ * Image.cs: Implement Dispose pattern.
+
+2003-10-14 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Graphics.cs
+ * gdipFunctioncs.cs
+ * gdipStructs.cs DrawString function added
+
+2003-10-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * gdipEnums.cs
+ * gdipFunctions.cs
+ * gdipStructs.cs added
+
+
+2003-10-12 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Bitmap.cs
+ * Brush.cs
+ * Font.cs
+ * FontFamily.cs
+ * Graphics.cs
+ * Image.cs
+ * Pen.cs
+ * SolidBrush.cs
+ implementation changed to gdi+
+
+2003-09-08 Duncan Mak <duncan@ximian.com>
+
+ * Factories.cs (DefaultImplementationNamespace): Change it from
+ "XrImpl" to "Cairo".
+
+2003-08-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Color.cs: fixed FromArgb to handle alpha value correctly. Closes
+ bug #47727.
+
+2003-08-08 Duncan Mak <duncan@ximian.com>
+
+ * Graphics.cs (DrawBezier): Fixed.
+
+2003-08-03 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Graphics.cs delegate Dispose to implementation
+
+2003-08-01 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * FontConverter.cs: stub it out so that system.web compiles.
+
+2003-07-30 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Image.cs InternalImageInfo class improved
+
+2003-07-23 Miguel de Icaza <miguel@ximian.com>
+
+ * Factories.cs: If the AppDomain key `Mono.Running.Windows.Forms'
+ is set, default to Win32Impl
+
+2003-07-22 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Image.cs implementation added
+
+2003-07-21 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Icon.cs: Stubed out (fix for System.Drawing.Design)
+
+2003-07-17 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * StringFormat.cs: Changes to become CLS-compliant
+
+2003-07-14 Miguel de Icaza <miguel@ximian.com>
+
+ * Factories.cs: Remove debugging message.
+
+2003-07-01 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Color.cs code generation program modified
+
+2003-06-29 Alexandre Pigolkine
+ * Graphics.cs image drawing
+
+2003-06-28 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Color.cs
+ * SystemColors.cs
+ supply KnowColor enum value to save Enum.Parse at runtime
+
+2003-06-26 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Graphics.cs coordinate transformations
+ * Image.cs small fix
+
+2003-06-22 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Factories.cs
+ * FontFamily.cs more implementation
+
+2003-06-20 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Font.cs
+ * FontFamily.cs more implementation
+
+2003-06-18 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Graphics.cs few more calls to implementation
+
+2003-06-15 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Bitmap.cs BITMAP declaration removed
+ * Graphics.cs few more calls to implementation
+ * Image.cs InternalImageInfo structure, image read/write functions
+
+
+2003-05-26 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Factories.cs analyse environment variable and machine.config to select implementation
+ * Image.cs PixelFormat property added
+
+2003-04-30 Nick Drochak <ndrochak@gol.com>
+
+ * Factories.cs: Change weird characters that broke build on windows.
+
+2003-04-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ColorConverter.cs:
+ (ConvertFrom): return a system or named color if there's one that fits
+ teh values parsed with Color.FromArgb.
+
+2003-04-26 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Bitmap.cs
+ * Brush.cs
+ * Font.cs
+ * Graphics.cs
+ * Image.cs
+ * Pen.cs
+ * SolidBrush.cs
+ * SystemBrushes.cs
+ * Factories.cs
+ delegate function calls to implementation
+
+2003-04-26 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Bitmap.cs
+ * ChangeLog
+ * Image.cs
+ * SystemBrushes.cs switch to Linux style line terminators
+
+2003-03-29 Alan Tam <Tam@SiuLung.com>
+ * ToolboxBitmapAttribute
+ stubbed more constructors and fixed base class
+
+2003-03-01 Alexandre Pigolkine <pigolkine@gmx.de>
+ * SystemBrushes.cs
+ added stubs to compile SWF
+
+
+2003-02-21 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Font.cs
+ * Graphics.cs
+ * Image.cs
+ * SystemBrushes.cs
+ small changes to be able to run SWF apps
+
+2003-02-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Graphics.cs: stubbed out all the methods.
+
+2003-02-08 Piers Haken <piersh@friskit.com>
+
+ * fixed case of pens.cs and font.cs
+
+2003-02-07 Alexandre Pigolkine <pigolkine@gmx.de>
+ * Font.cs Added
+ * Graphics.cs
+ * StringFormat.cs
+ * SystemBrushes.cs
+ stubs added
+
+2002-11-21 Dennis Hayes (dennish@raytek.com)
+ * checkin for Matt Stump (mstump@swfo.arizona.edu)
+ * Pens.cs
+ * Added file
+
+2002-10-19 Rachel Hestilow <hestilow@ximian.com>
+
+ * ColorTranslator.cs (FromHtml): Implement.
+
+2002-10-14 Dennis Hayes (dennish@raytek.com)
+ * Region.cs
+ * changed using namespace from Drawing2d to Drawing2D
+
+ 2002-9-15 Asier Llano <asierllano@infonegocio.com>
+
+ * Fixes the enum values in the following enums
+ * ContentAlignment.cs:
+ * FontStyle.cs:
+ * GraphicsUnit.cs:
+ * KnownColor.cs:
+ * RotateFlipType.cs:
+ * StringAligment.cs:
+ * StringDigitSubstitute.cs:
+ * StringFormatFlags.cs:
+ * StringTrimming.cs:
+ * StringUnit.cs:
+ * SolidBrush.cs: Easy implementation
+ * Brushes.cs: Implementation based on SolidBrush and Color class.
+ * Brush.cs: Fixes based on the status web).
+ * CharacterRange.cs: Implemented the missing Lenth property.
+
+2002-9-14 Dennis Hayes (dennish@raytek.com)
+
+ * sample.cs
+ * removed personal template that should not have been checked in
+
+2002-09-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ColorConverter.cs: readded MonoTODOs and implemented a couple of
+ methods.
+
+2002-9-14 DennisHayes <dennish@raytek.com>
+
+ * FontConverter.cs
+ * FontFamily.cs
+ * Icon.cs
+ * IconConverter.cs
+ * ImageAnimator.cs
+ * ImageConverter.cs
+ * ImageFormatConverter.cs
+ * PointConverter.cs
+ * RectangleConverter.cs
+ * Sample.cs
+ * SizeConverter.cs
+ * SolidBrush.cs
+ * StringFormat.cs
+ * SystemBrushes.cs
+ * SystemIcons.cs
+ * SystemPens.cs
+ * TextureBrush.cs
+ * ToolboxBitmapAttribute.cs
+ * Added null classes for most/all classes, Many stubs, and some implmentation
+
+2002-9-2 DennisHayes <dennish@raytek.com>
+
+ * Bitmap.cs
+ * Color.cs
+ * ColorConverter.cs
+ * Image.cs
+ * Pen.cs
+ * Added stubs, implmentation
+
+2002-9-2 DennisHayes <dennish@raytek.com>
+
+ * Brushes.cs : stubbed, added colors. Not sure how to implement,
+ but this should at least save someone some typing.
+ * CharacterRange.cs :Implmented
+ * Region.cs : stub needed for system.windows.forms
+
+2002-07-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ColorTranslator.cs: use Color.Name.
+
+2002-07-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Color.cs: implemented SystemColors and NamedColors properties that
+ are used by ColorConverter, removed public constructor, use
+ SystemColors, and misc. fixes to make it behave as MS (ToString,
+ parsing names, FromKnownColor,...).
+
+ * ColorConverter.cs: use NamedColors and SystemColors from Color when
+ trying to get the color from its name.
+
+ * SystemColors.cs: new file.
+
+2002-07-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Color.cs: changed static properties to use FromArgbNamed. Also
+ modified the program included in comments that get the values for
+ static properties.
+
+ (FromArgbNamed): build named colors.
+ (FromKnownColor): fixed.
+ (FromName): use a hash to look up colors by name.
+ (FillColorNames): create the hash of colors.
+ (Equals): compare values and name.
+ (ToString): improved.
+
+ * ColorTranslator.cs: implemented ToHtml.
+
+2002-06-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Color.cs: added TypeConverter attribute.
+
+ * ColorConverter.cs: added constructor.
+
+2002-06-15 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ColorConverter.cs: implemented minimal set of features needed by xsp.
+
+2002-05-03 Mike Kestner <mkestner@speakeasy.net>
+
+ * Bitmap.cs : using System.IO
+ * ColorTranslator.cs : Stubbed off build breakers.
+ * Image.cs : Stub off IDisposable and ICloneable.
+
+2002-04-27 Christian Meyer <Christian.Meyer@cs.tum.edu>
+
+ * Bitmap.cs: Ximian is the new copyright holder now.
+ * Image.cs: ditto
+
+2002-04-05 Christian Meyer <Christian.Meyer@cs.tum.edu>
+
+ * Uppercased several files.
+
+2002-04-05 Christian Meyer <Christian.Meyer@cs.tum.edu>
+
+ * color.cs: Fixed a typo in GetSaturation ().
+
+2002-02-26 Christian Meyer <Christian.Meyer@cs.tum.edu>
+
+ * Bitmap.cs: Added method headers.
+
+2002-02-25 Christian Meyer <Christian.Meyer@cs.tum.edu>
+
+ * Bitmap.cs: Added, no implementation's done, yet.
+
+2001-12-15 Mike Kestner <mkestner@speakeasy.net>
+
+ * Rectangle.cs : Add a doc comment.
+ * RectangleF.cs : New struct implementation.
+
+2001-12-15 Mike Kestner <mkestner@speakeasy.net>
+
+ * Rectangle.cs : New struct implementation.
+
+2001-08-17 Mike Kestner <mkestner@speakeasy.net>
+
+ * PointF.cs, Size.cs, SizeF.cs : New struct implementations.
+
+2001-08-16 Mike Kestner <mkestner@speakeasy.net>
+
+ * Point.cs : New. Implementation of System.Drawing.Point struct.
+
diff --git a/mcs/class/System.Drawing/System.Drawing/CharacterRange.cs b/mcs/class/System.Drawing/System.Drawing/CharacterRange.cs
new file mode 100644
index 00000000000..58b6447a56b
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/CharacterRange.cs
@@ -0,0 +1,91 @@
+//
+// System.Windows.Drawing.CharacterRange.cs
+//
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+//
+// Copyright (C) 2002 Ximian, Inc http://www.ximian.com
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing
+{
+ public struct CharacterRange
+ {
+ private int first;
+ private int length;
+
+ public CharacterRange (int first, int length)
+ {
+ this.first = first;
+ this.length = length;
+ }
+
+ public int First {
+ get {
+ return first;
+ }
+ set {
+ first = value;
+ }
+ }
+
+ public int Length {
+ get {
+ return length;
+ }
+ set {
+ length = value;
+ }
+ }
+#if NET_2_0
+ public override bool Equals (Object o)
+ {
+ if (o is CharacterRange) {
+ if ( ((CharacterRange)o).First == first && ((CharacterRange)o).Length == length)
+ return true;
+ }
+
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return (first * length);
+ }
+
+ public static bool operator == (CharacterRange cr1, CharacterRange cr2)
+ {
+ return cr1.Equals (cr2);
+ }
+
+ public static bool operator != (CharacterRange cr1, CharacterRange cr2)
+ {
+ return !cr1.Equals (cr2);
+ }
+#endif
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Color.cs b/mcs/class/System.Drawing/System.Drawing/Color.cs
new file mode 100644
index 00000000000..ca3feb254ef
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Color.cs
@@ -0,0 +1,1577 @@
+//
+// System.Drawing.Color.cs
+//
+// Authors:
+// Dennis Hayes (dennish@raytek.com)
+// Ben Houston (ben@exocortex.org)
+// Gonzalo Paniagua (gonzalo@ximian.com)
+// Juraj Skripsky (juraj@hotfeet.ch)
+//
+// (C) 2002 Dennis Hayes
+// (c) 2002 Ximian, Inc. (http://www.ximiam.com)
+// (C) 2005 HotFeet GmbH (http://www.hotfeet.ch)
+//
+// TODO: Are the static/non static functions declared correctly
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+using System.Reflection;
+
+namespace System.Drawing
+{
+ [TypeConverter(typeof(ColorConverter))]
+ [ComVisible (true)]
+#if !TARGET_JVM
+ [Editor ("System.Drawing.Design.ColorEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+#endif
+ [Serializable]
+ public struct Color
+ {
+ private static Hashtable namedColors;
+ private static Hashtable systemColors;
+ static Color [] knownColors;
+
+ // Private transparancy (A) and R,G,B fields.
+ private byte a;
+ private byte r;
+ private byte g;
+ private byte b;
+ private static string creatingColorNames = "creatingColorNames";
+
+ // The specs also indicate that all three of these propities are true
+ // if created with FromKnownColor or FromNamedColor, false otherwise (FromARGB).
+ // Per Microsoft and ECMA specs these varibles are set by which constructor is used, not by their values.
+ [Flags]
+ enum ColorType {
+ Empty=0,
+ ARGB=1,
+ Known=2,
+ Named=4,
+ System=8
+ }
+ private ColorType colorType;
+ private KnownColor knownColor;
+
+ private string myname;
+
+#if TARGET_JVM
+ internal java.awt.Color NativeObject {
+ get {
+ return new java.awt.Color (R, G, B, A);
+ }
+ }
+#endif
+
+ public string Name {
+ get{
+ if (myname == null || myname == String.Empty)
+ return String.Format ("{0:x}", ToArgb ());
+ return myname;
+ }
+ }
+
+ public bool IsKnownColor {
+ get{
+ return (colorType & ColorType.Known) != 0;
+ }
+ }
+
+ public bool IsSystemColor {
+ get{
+ return (colorType & ColorType.System) != 0;
+ }
+ }
+
+ public bool IsNamedColor {
+ get{
+ return (colorType & (ColorType.Known|ColorType.Named)) != 0;
+ }
+ }
+
+
+ public static Color FromArgb (int red, int green, int blue)
+ {
+ return FromArgb (255, red, green, blue);
+ }
+
+ public static Color FromArgb (int alpha, int red, int green, int blue)
+ {
+ CheckARGBValues (alpha, red, green, blue);
+ Color color = new Color ();
+ color.colorType = ColorType.ARGB;
+ color.a = (byte) alpha;
+ color.r = (byte) red;
+ color.g = (byte) green;
+ color.b = (byte) blue;
+ color.myname = String.Empty;
+ return color;
+ }
+
+ private static Color FromArgbNamed (int alpha, int red, int green, int blue, string name, KnownColor knownColor)
+ {
+ Color color = FromArgb (alpha, red, green, blue);
+ color.colorType = ColorType.Known|ColorType.Named;
+ //color.issystemcolor = false; //???
+ color.myname = name;
+ // FIXME: here happens SEGFAULT.
+ //color.knownColor = (KnownColor) Enum.Parse (typeof (KnownColor), name, false);
+ color.knownColor = knownColor;
+ return color;
+ }
+
+ internal static Color FromArgbSystem (int alpha, int red, int green, int blue, string name, KnownColor knownColor)
+ {
+ Color color = FromArgbNamed (alpha, red, green, blue, name, knownColor);
+ color.colorType |= ColorType.System;
+ return color;
+ }
+
+ public int ToArgb()
+ {
+ return a << 24 | r << 16 | g << 8 | b;
+ }
+
+ public static Color FromArgb (int alpha, Color baseColor)
+ {
+ return FromArgb (alpha, baseColor.r, baseColor.g, baseColor.b);
+ }
+
+ public static Color FromArgb (int argb)
+ {
+ return FromArgb ((argb >> 24) & 0x0FF, (argb >> 16) & 0x0FF, (argb >> 8) & 0x0FF, argb & 0x0FF);
+ }
+
+ public static Color FromKnownColor (KnownColor c)
+ {
+ if (knownColors == null)
+ FillColorNames ();
+
+#if NET_2_0
+ if (c < KnownColor.ActiveBorder || c > KnownColor.MenuHighlight) {
+#else
+ if (c < KnownColor.ActiveBorder || c > KnownColor.YellowGreen) {
+#endif
+ // This is what it returns!
+ Color d = FromArgb (0, 0, 0, 0);
+ d.myname = c.ToString ();
+ d.colorType |= ColorType.Named;
+ d.knownColor = c;
+ return d;
+ }
+
+ return knownColors [(int) c];
+ }
+
+ private static Hashtable GetColorHashtableFromType (Type type)
+ {
+ Hashtable colorHash = new Hashtable (CaseInsensitiveHashCodeProvider.Default,
+ CaseInsensitiveComparer.Default);
+
+ PropertyInfo [] props = type.GetProperties ();
+ foreach (PropertyInfo prop in props){
+ if (prop.PropertyType != typeof (Color))
+ continue;
+
+ MethodInfo getget = prop.GetGetMethod ();
+ if (getget == null || getget.IsStatic == false)
+ continue;
+
+ object o = prop.GetValue (null, null);
+ colorHash.Add (prop.Name, o);
+
+ Color c = (Color) o;
+ knownColors [(int) c.knownColor] = c;
+ }
+ return colorHash;
+ }
+
+ private static void FillColorNames ()
+ {
+ if (systemColors != null)
+ return;
+
+ lock (creatingColorNames) {
+ if (systemColors != null)
+ return;
+
+#if NET_2_0
+ knownColors = new Color [(int)KnownColor.MenuHighlight + 1];
+#else
+ knownColors = new Color [(int)KnownColor.YellowGreen + 1];
+#endif
+ Hashtable colorHash = GetColorHashtableFromType (typeof (Color));
+ namedColors = colorHash;
+
+ colorHash = GetColorHashtableFromType (typeof (SystemColors));
+ systemColors = colorHash;
+ }
+ }
+
+ internal static void UpdateKnownColor (int alpha, int red, int green, int blue, string name, KnownColor known_color) {
+ FillColorNames ();
+ knownColors[(int)known_color] = Color.FromArgbSystem(alpha, red, green, blue, name, known_color);
+ }
+
+ public static Color FromName (string colorName)
+ {
+ object c = NamedColors [colorName];
+ if (c == null) {
+ c = SystemColors [colorName];
+ if (c == null) {
+ // This is what it returns!
+ Color d = FromArgb (0, 0, 0, 0);
+ d.myname = colorName;
+ d.colorType |= ColorType.Named;
+ c = d;
+ }
+ }
+
+ return (Color) c;
+ }
+
+ internal static Hashtable NamedColors
+ {
+ get {
+ FillColorNames ();
+ return namedColors;
+ }
+ }
+
+ internal static Hashtable SystemColors
+ {
+ get {
+ FillColorNames ();
+ return systemColors;
+ }
+ }
+
+ // -----------------------
+ // Public Shared Members
+ // -----------------------
+
+ /// <summary>
+ /// Empty Shared Field
+ /// </summary>
+ ///
+ /// <remarks>
+ /// An uninitialized Color Structure
+ /// </remarks>
+
+ public static readonly Color Empty;
+
+ /// <summary>
+ /// Equality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two Color objects. The return value is
+ /// based on the equivalence of the A,R,G,B properties
+ /// of the two Colors.
+ /// </remarks>
+
+ public static bool operator == (Color colorA, Color colorB)
+ {
+ if (colorA.a != colorB.a)
+ return false;
+ if (colorA.r != colorB.r)
+ return false;
+ if (colorA.g != colorB.g)
+ return false;
+ if (colorA.b != colorB.b)
+ return false;
+ if (colorA.IsNamedColor != colorB.IsNamedColor)
+ return false;
+ if (colorA.IsSystemColor != colorB.IsSystemColor)
+ return false;
+ if (colorA.Name != colorB.Name)
+ return false;
+ if (colorA.IsEmpty != colorB.IsEmpty)
+ return false;
+ return true;
+ }
+
+ /// <summary>
+ /// Inequality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two Color objects. The return value is
+ /// based on the equivalence of the A,R,G,B properties
+ /// of the two colors.
+ /// </remarks>
+
+ public static bool operator != (Color colorA, Color colorB)
+ {
+ return ! (colorA == colorB);
+ }
+
+ public float GetBrightness ()
+ {
+ byte minval = Math.Min (r, Math.Min (g, b));
+ byte maxval = Math.Max (r, Math.Max (g, b));
+
+ return (float)(maxval + minval) / 510;
+ }
+
+ public float GetSaturation ()
+ {
+ byte minval = Math.Min (r, Math.Min (g, b));
+ byte maxval = Math.Max (r, Math.Max (g, b));
+
+ if (maxval == minval)
+ return 0.0f;
+
+ int sum = maxval + minval;
+ if (sum > 255)
+ sum = 510 - sum;
+
+ return (float)(maxval - minval) / sum;
+ }
+
+ public float GetHue ()
+ {
+ byte minval = Math.Min (r, Math.Min (g, b));
+ byte maxval = Math.Max (r, Math.Max (g, b));
+
+ if (maxval == minval)
+ return 0.0f;
+
+ float diff = (float)(maxval - minval);
+ float rnorm = (maxval - r) / diff;
+ float gnorm = (maxval - g) / diff;
+ float bnorm = (maxval - b) / diff;
+
+ float hue = 0.0f;
+ if (r == maxval)
+ hue = 60.0f * (6.0f + bnorm - gnorm);
+ if (g == maxval)
+ hue = 60.0f * (2.0f + rnorm - bnorm);
+ if (b == maxval)
+ hue = 60.0f * (4.0f + gnorm - rnorm);
+ if (hue > 360.0f)
+ hue = hue - 360.0f;
+
+ return hue;
+ }
+
+ // -----------------------
+ // Public Instance Members
+ // -----------------------
+
+ /// <summary>
+ /// ToKnownColor method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Returns the KnownColor enum value for this color, 0 if is not known.
+ /// </remarks>
+ public KnownColor ToKnownColor ()
+ {
+ return knownColor;
+ }
+
+ /// <summary>
+ /// IsEmpty Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Indicates transparent black. R,G,B = 0; A=0?
+ /// </remarks>
+
+ public bool IsEmpty
+ {
+ get {
+ return colorType == ColorType.Empty;
+ }
+ }
+
+ /// <summary>
+ /// A Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The transparancy of the Color.
+ /// </remarks>
+
+ public byte A
+ {
+ get {
+ return a;
+ }
+ }
+
+ /// <summary>
+ /// R Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The red value of the Color.
+ /// </remarks>
+
+ public byte R
+ {
+ get {
+ return r;
+ }
+ }
+
+ /// <summary>
+ /// G Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The green value of the Color.
+ /// </remarks>
+
+ public byte G
+ {
+ get {
+ return g;
+ }
+ }
+
+ /// <summary>
+ /// B Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The blue value of the Color.
+ /// </remarks>
+
+ public byte B
+ {
+ get {
+ return b;
+ }
+ }
+
+ /// <summary>
+ /// Equals Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks equivalence of this Color and another object.
+ /// </remarks>
+
+ public override bool Equals (object o)
+ {
+ if (! (o is Color))
+ return false;
+ Color c = (Color) o;
+ return this == c;
+ }
+
+ /// <summary>
+ /// Reference Equals Method
+ /// Is commented out because this is handled by the base class.
+ /// TODO: Is it correct to let the base class handel reference equals
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks equivalence of this Color and another object.
+ /// </remarks>
+ //public bool ReferenceEquals (object o)
+ //{
+ // if (!(o is Color))return false;
+ // return (this == (Color) o);
+ //}
+
+
+
+ /// <summary>
+ /// GetHashCode Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Calculates a hashing value.
+ /// </remarks>
+
+ public override int GetHashCode ()
+ {
+ return ToArgb().GetHashCode () ^ Name.GetHashCode ();
+ }
+
+ /// <summary>
+ /// ToString Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Formats the Color as a string in ARGB notation.
+ /// </remarks>
+
+ public override string ToString ()
+ {
+ if (IsEmpty)
+ return "Color [Empty]";
+
+ if (myname != "")
+ return "Color [" + myname + "]";
+
+ return String.Format ("Color [A={0}, R={1}, G={2}, B={3}]", a, r, g, b);
+ }
+
+ private static void CheckRGBValues (int red,int green,int blue)
+ {
+ if( (red > 255) || (red < 0))
+ throw CreateColorArgumentException(red, "red");
+ if( (green > 255) || (green < 0))
+ throw CreateColorArgumentException (green, "green");
+ if( (blue > 255) || (blue < 0))
+ throw CreateColorArgumentException (blue, "blue");
+ }
+
+ private static ArgumentException CreateColorArgumentException (int value, string color)
+ {
+ return new ArgumentException (string.Format ("'{0}' is not a valid"
+ + " value for '{1}'. '{1}' should be greater or equal to 0 and"
+ + " less than or equal to 255.", value, color));
+ }
+
+ private static void CheckARGBValues (int alpha,int red,int green,int blue)
+ {
+ if( (alpha > 255) || (alpha < 0))
+ throw CreateColorArgumentException (alpha, "alpha");
+ CheckRGBValues(red,green,blue);
+ }
+
+ //Documentation, do not remove!
+ //This is the program that was used to generate the C# source code below.
+ //using System;
+ //using System.Diagnostics;
+ //using System.Drawing;
+ //using System.Reflection;
+ //public class m {
+ //static void Main(string[] args)
+ //{
+ // Type cType = typeof (Color);
+ // PropertyInfo [] properties = cType.GetProperties ();
+ // foreach (PropertyInfo property in properties) {
+ // MethodInfo method = property.GetGetMethod();
+ // if (method != null && method.IsStatic && method.ReturnType == cType) {
+ // Color c = (Color) method.Invoke( null, new object[0] );
+ // Console.WriteLine("static public Color " + property.Name);
+ // Console.WriteLine("{\t\n\tget {");
+ // Console.WriteLine("\t\treturn Color.FromArgbNamed ({0}, {1}, {2}, {3}, \"{4}\", KnownColor.{4});",
+ // c.A, c.R, c.G, c.B, property.Name);
+ // Console.WriteLine("\t}");
+ // Console.WriteLine("}\n");
+ // }
+ // }
+ //}
+ //}
+
+ static public Color Transparent
+ {
+ get {
+ return Color.FromArgbNamed (0, 255, 255, 255, "Transparent", KnownColor.Transparent);
+ }
+ }
+
+ static public Color AliceBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 240, 248, 255, "AliceBlue", KnownColor.AliceBlue);
+ }
+ }
+
+ static public Color AntiqueWhite
+ {
+ get {
+ return Color.FromArgbNamed (255, 250, 235, 215, "AntiqueWhite", KnownColor.AntiqueWhite);
+ }
+ }
+
+ static public Color Aqua
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 255, 255, "Aqua", KnownColor.Aqua);
+ }
+ }
+
+ static public Color Aquamarine
+ {
+ get {
+ return Color.FromArgbNamed (255, 127, 255, 212, "Aquamarine", KnownColor.Aquamarine);
+ }
+ }
+
+ static public Color Azure
+ {
+ get {
+ return Color.FromArgbNamed (255, 240, 255, 255, "Azure", KnownColor.Azure);
+ }
+ }
+
+ static public Color Beige
+ {
+ get {
+ return Color.FromArgbNamed (255, 245, 245, 220, "Beige", KnownColor.Beige);
+ }
+ }
+
+ static public Color Bisque
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 228, 196, "Bisque", KnownColor.Bisque);
+ }
+ }
+
+ static public Color Black
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 0, 0, "Black", KnownColor.Black);
+ }
+ }
+
+ static public Color BlanchedAlmond
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 235, 205, "BlanchedAlmond", KnownColor.BlanchedAlmond);
+ }
+ }
+
+ static public Color Blue
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 0, 255, "Blue", KnownColor.Blue);
+ }
+ }
+
+ static public Color BlueViolet
+ {
+ get {
+ return Color.FromArgbNamed (255, 138, 43, 226, "BlueViolet", KnownColor.BlueViolet);
+ }
+ }
+
+ static public Color Brown
+ {
+ get {
+ return Color.FromArgbNamed (255, 165, 42, 42, "Brown", KnownColor.Brown);
+ }
+ }
+
+ static public Color BurlyWood
+ {
+ get {
+ return Color.FromArgbNamed (255, 222, 184, 135, "BurlyWood", KnownColor.BurlyWood);
+ }
+ }
+
+ static public Color CadetBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 95, 158, 160, "CadetBlue", KnownColor.CadetBlue);
+ }
+ }
+
+ static public Color Chartreuse
+ {
+ get {
+ return Color.FromArgbNamed (255, 127, 255, 0, "Chartreuse", KnownColor.Chartreuse);
+ }
+ }
+
+ static public Color Chocolate
+ {
+ get {
+ return Color.FromArgbNamed (255, 210, 105, 30, "Chocolate", KnownColor.Chocolate);
+ }
+ }
+
+ static public Color Coral
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 127, 80, "Coral", KnownColor.Coral);
+ }
+ }
+
+ static public Color CornflowerBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 100, 149, 237, "CornflowerBlue", KnownColor.CornflowerBlue);
+ }
+ }
+
+ static public Color Cornsilk
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 248, 220, "Cornsilk", KnownColor.Cornsilk);
+ }
+ }
+
+ static public Color Crimson
+ {
+ get {
+ return Color.FromArgbNamed (255, 220, 20, 60, "Crimson", KnownColor.Crimson);
+ }
+ }
+
+ static public Color Cyan
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 255, 255, "Cyan", KnownColor.Cyan);
+ }
+ }
+
+ static public Color DarkBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 0, 139, "DarkBlue", KnownColor.DarkBlue);
+ }
+ }
+
+ static public Color DarkCyan
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 139, 139, "DarkCyan", KnownColor.DarkCyan);
+ }
+ }
+
+ static public Color DarkGoldenrod
+ {
+ get {
+ return Color.FromArgbNamed (255, 184, 134, 11, "DarkGoldenrod", KnownColor.DarkGoldenrod);
+ }
+ }
+
+ static public Color DarkGray
+ {
+ get {
+ return Color.FromArgbNamed (255, 169, 169, 169, "DarkGray", KnownColor.DarkGray);
+ }
+ }
+
+ static public Color DarkGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 100, 0, "DarkGreen", KnownColor.DarkGreen);
+ }
+ }
+
+ static public Color DarkKhaki
+ {
+ get {
+ return Color.FromArgbNamed (255, 189, 183, 107, "DarkKhaki", KnownColor.DarkKhaki);
+ }
+ }
+
+ static public Color DarkMagenta
+ {
+ get {
+ return Color.FromArgbNamed (255, 139, 0, 139, "DarkMagenta", KnownColor.DarkMagenta);
+ }
+ }
+
+ static public Color DarkOliveGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 85, 107, 47, "DarkOliveGreen", KnownColor.DarkOliveGreen);
+ }
+ }
+
+ static public Color DarkOrange
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 140, 0, "DarkOrange", KnownColor.DarkOrange);
+ }
+ }
+
+ static public Color DarkOrchid
+ {
+ get {
+ return Color.FromArgbNamed (255, 153, 50, 204, "DarkOrchid", KnownColor.DarkOrchid);
+ }
+ }
+
+ static public Color DarkRed
+ {
+ get {
+ return Color.FromArgbNamed (255, 139, 0, 0, "DarkRed", KnownColor.DarkRed);
+ }
+ }
+
+ static public Color DarkSalmon
+ {
+ get {
+ return Color.FromArgbNamed (255, 233, 150, 122, "DarkSalmon", KnownColor.DarkSalmon);
+ }
+ }
+
+ static public Color DarkSeaGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 143, 188, 139, "DarkSeaGreen", KnownColor.DarkSeaGreen);
+ }
+ }
+
+ static public Color DarkSlateBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 72, 61, 139, "DarkSlateBlue", KnownColor.DarkSlateBlue);
+ }
+ }
+
+ static public Color DarkSlateGray
+ {
+ get {
+ return Color.FromArgbNamed (255, 47, 79, 79, "DarkSlateGray", KnownColor.DarkSlateGray);
+ }
+ }
+
+ static public Color DarkTurquoise
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 206, 209, "DarkTurquoise", KnownColor.DarkTurquoise);
+ }
+ }
+
+ static public Color DarkViolet
+ {
+ get {
+ return Color.FromArgbNamed (255, 148, 0, 211, "DarkViolet", KnownColor.DarkViolet);
+ }
+ }
+
+ static public Color DeepPink
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 20, 147, "DeepPink", KnownColor.DeepPink);
+ }
+ }
+
+ static public Color DeepSkyBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 191, 255, "DeepSkyBlue", KnownColor.DeepSkyBlue);
+ }
+ }
+
+ static public Color DimGray
+ {
+ get {
+ return Color.FromArgbNamed (255, 105, 105, 105, "DimGray", KnownColor.DimGray);
+ }
+ }
+
+ static public Color DodgerBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 30, 144, 255, "DodgerBlue", KnownColor.DodgerBlue);
+ }
+ }
+
+ static public Color Firebrick
+ {
+ get {
+ return Color.FromArgbNamed (255, 178, 34, 34, "Firebrick", KnownColor.Firebrick);
+ }
+ }
+
+ static public Color FloralWhite
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 250, 240, "FloralWhite", KnownColor.FloralWhite);
+ }
+ }
+
+ static public Color ForestGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 34, 139, 34, "ForestGreen", KnownColor.ForestGreen);
+ }
+ }
+
+ static public Color Fuchsia
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 0, 255, "Fuchsia", KnownColor.Fuchsia);
+ }
+ }
+
+ static public Color Gainsboro
+ {
+ get {
+ return Color.FromArgbNamed (255, 220, 220, 220, "Gainsboro", KnownColor.Gainsboro);
+ }
+ }
+
+ static public Color GhostWhite
+ {
+ get {
+ return Color.FromArgbNamed (255, 248, 248, 255, "GhostWhite", KnownColor.GhostWhite);
+ }
+ }
+
+ static public Color Gold
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 215, 0, "Gold", KnownColor.Gold);
+ }
+ }
+
+ static public Color Goldenrod
+ {
+ get {
+ return Color.FromArgbNamed (255, 218, 165, 32, "Goldenrod", KnownColor.Goldenrod);
+ }
+ }
+
+ static public Color Gray
+ {
+ get {
+ return Color.FromArgbNamed (255, 128, 128, 128, "Gray", KnownColor.Gray);
+ }
+ }
+
+ static public Color Green
+ {
+ get {
+ // LAMESPEC: MS uses A=255, R=0, G=128, B=0 for Green Color,
+ // which is seems to be wrong. G must be 255.
+ return Color.FromArgbNamed (255, 0, 128, 0, "Green", KnownColor.Green);
+ }
+ }
+
+ static public Color GreenYellow
+ {
+ get {
+ return Color.FromArgbNamed (255, 173, 255, 47, "GreenYellow", KnownColor.GreenYellow);
+ }
+ }
+
+ static public Color Honeydew
+ {
+ get {
+ return Color.FromArgbNamed (255, 240, 255, 240, "Honeydew", KnownColor.Honeydew);
+ }
+ }
+
+ static public Color HotPink
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 105, 180, "HotPink", KnownColor.HotPink);
+ }
+ }
+
+ static public Color IndianRed
+ {
+ get {
+ return Color.FromArgbNamed (255, 205, 92, 92, "IndianRed", KnownColor.IndianRed);
+ }
+ }
+
+ static public Color Indigo
+ {
+ get {
+ return Color.FromArgbNamed (255, 75, 0, 130, "Indigo", KnownColor.Indigo);
+ }
+ }
+
+ static public Color Ivory
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 255, 240, "Ivory", KnownColor.Ivory);
+ }
+ }
+
+ static public Color Khaki
+ {
+ get {
+ return Color.FromArgbNamed (255, 240, 230, 140, "Khaki", KnownColor.Khaki);
+ }
+ }
+
+ static public Color Lavender
+ {
+ get {
+ return Color.FromArgbNamed (255, 230, 230, 250, "Lavender", KnownColor.Lavender);
+ }
+ }
+
+ static public Color LavenderBlush
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 240, 245, "LavenderBlush", KnownColor.LavenderBlush);
+ }
+ }
+
+ static public Color LawnGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 124, 252, 0, "LawnGreen", KnownColor.LawnGreen);
+ }
+ }
+
+ static public Color LemonChiffon
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 250, 205, "LemonChiffon", KnownColor.LemonChiffon);
+ }
+ }
+
+ static public Color LightBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 173, 216, 230, "LightBlue", KnownColor.LightBlue);
+ }
+ }
+
+ static public Color LightCoral
+ {
+ get {
+ return Color.FromArgbNamed (255, 240, 128, 128, "LightCoral", KnownColor.LightCoral);
+ }
+ }
+
+ static public Color LightCyan
+ {
+ get {
+ return Color.FromArgbNamed (255, 224, 255, 255, "LightCyan", KnownColor.LightCyan);
+ }
+ }
+
+ static public Color LightGoldenrodYellow
+ {
+ get {
+ return Color.FromArgbNamed (255, 250, 250, 210, "LightGoldenrodYellow", KnownColor.LightGoldenrodYellow);
+ }
+ }
+
+ static public Color LightGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 144, 238, 144, "LightGreen", KnownColor.LightGreen);
+ }
+ }
+
+ static public Color LightGray
+ {
+ get {
+ return Color.FromArgbNamed (255, 211, 211, 211, "LightGray", KnownColor.LightGray);
+ }
+ }
+
+ static public Color LightPink
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 182, 193, "LightPink", KnownColor.LightPink);
+ }
+ }
+
+ static public Color LightSalmon
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 160, 122, "LightSalmon", KnownColor.LightSalmon);
+ }
+ }
+
+ static public Color LightSeaGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 32, 178, 170, "LightSeaGreen", KnownColor.LightSeaGreen);
+ }
+ }
+
+ static public Color LightSkyBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 135, 206, 250, "LightSkyBlue", KnownColor.LightSkyBlue);
+ }
+ }
+
+ static public Color LightSlateGray
+ {
+ get {
+ return Color.FromArgbNamed (255, 119, 136, 153, "LightSlateGray", KnownColor.LightSlateGray);
+ }
+ }
+
+ static public Color LightSteelBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 176, 196, 222, "LightSteelBlue", KnownColor.LightSteelBlue);
+ }
+ }
+
+ static public Color LightYellow
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 255, 224, "LightYellow", KnownColor.LightYellow);
+ }
+ }
+
+ static public Color Lime
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 255, 0, "Lime", KnownColor.Lime);
+ }
+ }
+
+ static public Color LimeGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 50, 205, 50, "LimeGreen", KnownColor.LimeGreen);
+ }
+ }
+
+ static public Color Linen
+ {
+ get {
+ return Color.FromArgbNamed (255, 250, 240, 230, "Linen", KnownColor.Linen);
+ }
+ }
+
+ static public Color Magenta
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 0, 255, "Magenta", KnownColor.Magenta);
+ }
+ }
+
+ static public Color Maroon
+ {
+ get {
+ return Color.FromArgbNamed (255, 128, 0, 0, "Maroon", KnownColor.Maroon);
+ }
+ }
+
+ static public Color MediumAquamarine
+ {
+ get {
+ return Color.FromArgbNamed (255, 102, 205, 170, "MediumAquamarine", KnownColor.MediumAquamarine);
+ }
+ }
+
+ static public Color MediumBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 0, 205, "MediumBlue", KnownColor.MediumBlue);
+ }
+ }
+
+ static public Color MediumOrchid
+ {
+ get {
+ return Color.FromArgbNamed (255, 186, 85, 211, "MediumOrchid", KnownColor.MediumOrchid);
+ }
+ }
+
+ static public Color MediumPurple
+ {
+ get {
+ return Color.FromArgbNamed (255, 147, 112, 219, "MediumPurple", KnownColor.MediumPurple);
+ }
+ }
+
+ static public Color MediumSeaGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 60, 179, 113, "MediumSeaGreen", KnownColor.MediumSeaGreen);
+ }
+ }
+
+ static public Color MediumSlateBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 123, 104, 238, "MediumSlateBlue", KnownColor.MediumSlateBlue);
+ }
+ }
+
+ static public Color MediumSpringGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 250, 154, "MediumSpringGreen", KnownColor.MediumSpringGreen);
+ }
+ }
+
+ static public Color MediumTurquoise
+ {
+ get {
+ return Color.FromArgbNamed (255, 72, 209, 204, "MediumTurquoise", KnownColor.MediumTurquoise);
+ }
+ }
+
+ static public Color MediumVioletRed
+ {
+ get {
+ return Color.FromArgbNamed (255, 199, 21, 133, "MediumVioletRed", KnownColor.MediumVioletRed);
+ }
+ }
+
+ static public Color MidnightBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 25, 25, 112, "MidnightBlue", KnownColor.MidnightBlue);
+ }
+ }
+
+ static public Color MintCream
+ {
+ get {
+ return Color.FromArgbNamed (255, 245, 255, 250, "MintCream", KnownColor.MintCream);
+ }
+ }
+
+ static public Color MistyRose
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 228, 225, "MistyRose", KnownColor.MistyRose);
+ }
+ }
+
+ static public Color Moccasin
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 228, 181, "Moccasin", KnownColor.Moccasin);
+ }
+ }
+
+ static public Color NavajoWhite
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 222, 173, "NavajoWhite", KnownColor.NavajoWhite);
+ }
+ }
+
+ static public Color Navy
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 0, 128, "Navy", KnownColor.Navy);
+ }
+ }
+
+ static public Color OldLace
+ {
+ get {
+ return Color.FromArgbNamed (255, 253, 245, 230, "OldLace", KnownColor.OldLace);
+ }
+ }
+
+ static public Color Olive
+ {
+ get {
+ return Color.FromArgbNamed (255, 128, 128, 0, "Olive", KnownColor.Olive);
+ }
+ }
+
+ static public Color OliveDrab
+ {
+ get {
+ return Color.FromArgbNamed (255, 107, 142, 35, "OliveDrab", KnownColor.OliveDrab);
+ }
+ }
+
+ static public Color Orange
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 165, 0, "Orange", KnownColor.Orange);
+ }
+ }
+
+ static public Color OrangeRed
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 69, 0, "OrangeRed", KnownColor.OrangeRed);
+ }
+ }
+
+ static public Color Orchid
+ {
+ get {
+ return Color.FromArgbNamed (255, 218, 112, 214, "Orchid", KnownColor.Orchid);
+ }
+ }
+
+ static public Color PaleGoldenrod
+ {
+ get {
+ return Color.FromArgbNamed (255, 238, 232, 170, "PaleGoldenrod", KnownColor.PaleGoldenrod);
+ }
+ }
+
+ static public Color PaleGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 152, 251, 152, "PaleGreen", KnownColor.PaleGreen);
+ }
+ }
+
+ static public Color PaleTurquoise
+ {
+ get {
+ return Color.FromArgbNamed (255, 175, 238, 238, "PaleTurquoise", KnownColor.PaleTurquoise);
+ }
+ }
+
+ static public Color PaleVioletRed
+ {
+ get {
+ return Color.FromArgbNamed (255, 219, 112, 147, "PaleVioletRed", KnownColor.PaleVioletRed);
+ }
+ }
+
+ static public Color PapayaWhip
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 239, 213, "PapayaWhip", KnownColor.PapayaWhip);
+ }
+ }
+
+ static public Color PeachPuff
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 218, 185, "PeachPuff", KnownColor.PeachPuff);
+ }
+ }
+
+ static public Color Peru
+ {
+ get {
+ return Color.FromArgbNamed (255, 205, 133, 63, "Peru", KnownColor.Peru);
+ }
+ }
+
+ static public Color Pink
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 192, 203, "Pink", KnownColor.Pink);
+ }
+ }
+
+ static public Color Plum
+ {
+ get {
+ return Color.FromArgbNamed (255, 221, 160, 221, "Plum", KnownColor.Plum);
+ }
+ }
+
+ static public Color PowderBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 176, 224, 230, "PowderBlue", KnownColor.PowderBlue);
+ }
+ }
+
+ static public Color Purple
+ {
+ get {
+ return Color.FromArgbNamed (255, 128, 0, 128, "Purple", KnownColor.Purple);
+ }
+ }
+
+ static public Color Red
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 0, 0, "Red", KnownColor.Red);
+ }
+ }
+
+ static public Color RosyBrown
+ {
+ get {
+ return Color.FromArgbNamed (255, 188, 143, 143, "RosyBrown", KnownColor.RosyBrown);
+ }
+ }
+
+ static public Color RoyalBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 65, 105, 225, "RoyalBlue", KnownColor.RoyalBlue);
+ }
+ }
+
+ static public Color SaddleBrown
+ {
+ get {
+ return Color.FromArgbNamed (255, 139, 69, 19, "SaddleBrown", KnownColor.SaddleBrown);
+ }
+ }
+
+ static public Color Salmon
+ {
+ get {
+ return Color.FromArgbNamed (255, 250, 128, 114, "Salmon", KnownColor.Salmon);
+ }
+ }
+
+ static public Color SandyBrown
+ {
+ get {
+ return Color.FromArgbNamed (255, 244, 164, 96, "SandyBrown", KnownColor.SandyBrown);
+ }
+ }
+
+ static public Color SeaGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 46, 139, 87, "SeaGreen", KnownColor.SeaGreen);
+ }
+ }
+
+ static public Color SeaShell
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 245, 238, "SeaShell", KnownColor.SeaShell);
+ }
+ }
+
+ static public Color Sienna
+ {
+ get {
+ return Color.FromArgbNamed (255, 160, 82, 45, "Sienna", KnownColor.Sienna);
+ }
+ }
+
+ static public Color Silver
+ {
+ get {
+ return Color.FromArgbNamed (255, 192, 192, 192, "Silver", KnownColor.Silver);
+ }
+ }
+
+ static public Color SkyBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 135, 206, 235, "SkyBlue", KnownColor.SkyBlue);
+ }
+ }
+
+ static public Color SlateBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 106, 90, 205, "SlateBlue", KnownColor.SlateBlue);
+ }
+ }
+
+ static public Color SlateGray
+ {
+ get {
+ return Color.FromArgbNamed (255, 112, 128, 144, "SlateGray", KnownColor.SlateGray);
+ }
+ }
+
+ static public Color Snow
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 250, 250, "Snow", KnownColor.Snow);
+ }
+ }
+
+ static public Color SpringGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 255, 127, "SpringGreen", KnownColor.SpringGreen);
+ }
+ }
+
+ static public Color SteelBlue
+ {
+ get {
+ return Color.FromArgbNamed (255, 70, 130, 180, "SteelBlue", KnownColor.SteelBlue);
+ }
+ }
+
+ static public Color Tan
+ {
+ get {
+ return Color.FromArgbNamed (255, 210, 180, 140, "Tan", KnownColor.Tan);
+ }
+ }
+
+ static public Color Teal
+ {
+ get {
+ return Color.FromArgbNamed (255, 0, 128, 128, "Teal", KnownColor.Teal);
+ }
+ }
+
+ static public Color Thistle
+ {
+ get {
+ return Color.FromArgbNamed (255, 216, 191, 216, "Thistle", KnownColor.Thistle);
+ }
+ }
+
+ static public Color Tomato
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 99, 71, "Tomato", KnownColor.Tomato);
+ }
+ }
+
+ static public Color Turquoise
+ {
+ get {
+ return Color.FromArgbNamed (255, 64, 224, 208, "Turquoise", KnownColor.Turquoise);
+ }
+ }
+
+ static public Color Violet
+ {
+ get {
+ return Color.FromArgbNamed (255, 238, 130, 238, "Violet", KnownColor.Violet);
+ }
+ }
+
+ static public Color Wheat
+ {
+ get {
+ return Color.FromArgbNamed (255, 245, 222, 179, "Wheat", KnownColor.Wheat);
+ }
+ }
+
+ static public Color White
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 255, 255, "White", KnownColor.White);
+ }
+ }
+
+ static public Color WhiteSmoke
+ {
+ get {
+ return Color.FromArgbNamed (255, 245, 245, 245, "WhiteSmoke", KnownColor.WhiteSmoke);
+ }
+ }
+
+ static public Color Yellow
+ {
+ get {
+ return Color.FromArgbNamed (255, 255, 255, 0, "Yellow", KnownColor.Yellow);
+ }
+ }
+
+ static public Color YellowGreen
+ {
+ get {
+ return Color.FromArgbNamed (255, 154, 205, 50, "YellowGreen", KnownColor.YellowGreen);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/ColorConverter.cs b/mcs/class/System.Drawing/System.Drawing/ColorConverter.cs
new file mode 100644
index 00000000000..5216c5dcb79
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ColorConverter.cs
@@ -0,0 +1,245 @@
+//
+// System.Drawing.ColorConverter
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.Text;
+using System.ComponentModel.Design.Serialization;
+using System.Reflection;
+
+namespace System.Drawing
+{
+ public class ColorConverter : TypeConverter
+ {
+ static StandardValuesCollection cached;
+ static object creatingCached = new object ();
+
+ public ColorConverter () { }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof (string))
+ return true;
+
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
+ {
+ if (destinationType == typeof (InstanceDescriptor))
+ return true;
+
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value)
+ {
+ string s = value as string;
+ if (s == null)
+ return base.ConvertFrom (context, culture, value);
+
+ s = s.Trim ();
+
+ if (s.Length == 0) {
+ return Color.Empty;
+ }
+
+ object named = Color.NamedColors [s];
+ if (named != null)
+ return (Color) named;
+
+ named = Color.SystemColors [s];
+ if (named != null)
+ return (Color) named;
+
+ String numSeparator = culture.TextInfo.ListSeparator;
+
+ Int32Converter converter = new Int32Converter ();
+
+ object result = null;
+
+ if (s.IndexOf (numSeparator) == -1) {
+ if ((s.Length == 8 && (s.StartsWith ("0x") || s.StartsWith ("0X")))
+ || (s.Length == 7 && s.StartsWith ("#"))) {
+ result = Color.FromArgb (-16777216 | (int) converter.
+ ConvertFromString (context, culture, s));
+ }
+ else if ((s.Length == 5 && (s.StartsWith ("0x") || s.StartsWith ("0X")))
+ || (s.Length == 4 && s.StartsWith ("#"))) {
+ int i = (int) converter.ConvertFromString (context, culture, s);
+ i = ((i & 0xf00) << 12) | ((i & 0xf00) << 8) |
+ ((i & 0xf0) << 8) | ((i & 0xf0) << 4) |
+ ((i & 0xf) << 4) | (i & 0xf);
+ result = Color.FromArgb ( -16777216 | i );
+ }
+ }
+
+ if (result == null) {
+ String [] components = s.Split (numSeparator.ToCharArray ());
+
+ // MS seems to convert the indivual component to int before
+ // checking the number of components
+ int[] numComponents = new int[components.Length];
+ for (int i = 0; i < numComponents.Length; i++) {
+ numComponents[i] = (int) converter.ConvertFrom (context,
+ culture, components[i]);
+ }
+
+ switch (components.Length) {
+ case 1:
+ result = Color.FromArgb (numComponents[0]);
+ break;
+ case 3:
+ result = Color.FromArgb (numComponents[0], numComponents[1],
+ numComponents[2]);
+ break;
+ case 4:
+ result = Color.FromArgb (numComponents[0], numComponents[1],
+ numComponents[2], numComponents[3]);
+ break;
+ default:
+ throw new ArgumentException (s + " is not a valid color value.");
+ }
+ }
+
+ if (result != null) {
+ Color resultColor = (Color) result;
+
+ // Look for a named or system color with those values
+ foreach (Color c in Color.NamedColors.Values) {
+ if (c == resultColor)
+ return c;
+ }
+
+ foreach (Color c in Color.SystemColors.Values) {
+ if (c == resultColor)
+ return c;
+ }
+ }
+
+ return result;
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value,
+ Type destinationType)
+ {
+ if ((destinationType == typeof (string)) && (value is Color)) {
+ Color color = (Color) value;
+
+ if (color == Color.Empty) {
+ return string.Empty;
+ }
+
+ if (color.IsKnownColor) {
+ return color.Name;
+ }
+
+ if (color.IsNamedColor)
+ return color.Name;
+
+ String numSeparator = culture.TextInfo.ListSeparator;
+
+ StringBuilder sb = new StringBuilder ();
+ if (color.A != 255) {
+ sb.Append (color.A);
+ sb.Append (numSeparator);
+ sb.Append (" ");
+ }
+ sb.Append (color.R);
+ sb.Append (numSeparator);
+ sb.Append (" ");
+
+ sb.Append (color.G);
+ sb.Append (numSeparator);
+ sb.Append (" ");
+
+ sb.Append (color.B);
+ return sb.ToString ();
+ }
+
+ if (destinationType == typeof (InstanceDescriptor) && value is Color) {
+ Color c = (Color)value;
+ if (c.IsKnownColor){
+ return new InstanceDescriptor (typeof (SystemColors).GetProperty (c.Name), null);
+ } else {
+ MethodInfo met = typeof(Color).GetMethod ("FromArgb", new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) } );
+ return new InstanceDescriptor (met, new object[] {c.A, c.R, c.G, c.B });
+ }
+ }
+
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
+ {
+ if (cached != null)
+ return cached;
+
+ lock (creatingCached)
+ {
+ if (cached != null)
+ return cached;
+
+ ICollection named = (ICollection) Color.NamedColors.Values;
+ ICollection system = (ICollection) Color.SystemColors.Values;
+ Array colors = Array.CreateInstance (typeof (Color), named.Count + system.Count);
+ named.CopyTo (colors, 0);
+ system.CopyTo (colors, named.Count);
+ Array.Sort (colors, 0, colors.Length, new CompareColors ());
+ cached = new StandardValuesCollection (colors);
+ }
+
+ return cached;
+ }
+
+ public override bool GetStandardValuesSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ class CompareColors : IComparer
+ {
+ public int Compare (object x, object y)
+ {
+ return String.Compare (((Color) x).Name, ((Color) y).Name);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs b/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs
new file mode 100644
index 00000000000..181d1a8d0ef
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ColorTranslator.cs
@@ -0,0 +1,200 @@
+//
+// System.Drawing.ColorTranslator.cs
+//
+// Copyright (C) 2001 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+// Authors:
+// Dennis Hayes (dennish@raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ public sealed class ColorTranslator
+ {
+ private ColorTranslator () { }
+
+ public static Color FromHtml (string HtmlFromColor)
+ {
+ switch (HtmlFromColor.ToLower()) {
+ case "buttonface":
+ return SystemColors.Control;
+ case "captiontext":
+ return SystemColors.ActiveCaptionText;
+ case "threeddarkshadow":
+ return SystemColors.ControlDarkDark;
+ case "background":
+ return SystemColors.Desktop;
+ case "buttontext":
+ return SystemColors.ControlText;
+ case "infobackground":
+ return SystemColors.Info;
+ }
+ TypeConverter converter = TypeDescriptor.GetConverter (typeof (Color));
+ return (Color) converter.ConvertFromString (HtmlFromColor);
+ }
+
+ public static Color FromOle (int OleFromColor)
+ {
+ // OleColor format is BGR
+ int R = OleFromColor & 0xFF;
+ int G = (OleFromColor >> 8) & 0xFF;
+ int B = (OleFromColor >> 16) & 0xFF;
+
+ Color retcolor = Color.FromArgb (255, R, G, B);
+ foreach (Color c in Color.NamedColors.Values) {
+ if (c == retcolor)
+ return c;
+ }
+
+ foreach (Color c in Color.SystemColors.Values) {
+ if (c == retcolor)
+ return c;
+ }
+
+ return retcolor;
+ }
+
+ public static Color FromWin32 (int Win32FromColor)
+ {
+ // Win32Color format is BGR
+ int R = Win32FromColor & 0xFF;
+ int G = (Win32FromColor >> 8) & 0xFF;
+ int B = (Win32FromColor >> 16) & 0xFF;
+
+ Color retcolor = Color.FromArgb (255, R, G, B);
+ foreach (Color c in Color.NamedColors.Values) {
+ if (c == retcolor)
+ return c;
+ }
+
+ foreach (Color c in Color.SystemColors.Values) {
+ if (c == retcolor)
+ return c;
+ }
+
+ return retcolor;
+ }
+
+ public static string ToHtml (Color c)
+ {
+ KnownColor kc;
+ if (c.IsEmpty)
+ return "";
+
+ string result;
+ if(c.IsSystemColor) {
+ kc = c.ToKnownColor();
+ switch (kc) {
+ case KnownColor.ActiveBorder:
+ return "activeborder";
+ case KnownColor.ActiveCaption:
+ return "activecaption";
+ case KnownColor.ActiveCaptionText:
+ return "captiontext";
+ case KnownColor.AppWorkspace:
+ return "appworkspace";
+ case KnownColor.Control:
+ return "buttonface";
+ case KnownColor.ControlDark:
+ return "buttonshadow";
+ case KnownColor.ControlDarkDark:
+ return "threeddarkshadow";
+ case KnownColor.ControlLight:
+ return "buttonface";
+ case KnownColor.ControlLightLight:
+ return "buttonhighlight";
+ case KnownColor.ControlText:
+ return "buttontext";
+ case KnownColor.Desktop:
+ return "background";
+ case KnownColor.GrayText:
+ return "graytext";
+ case KnownColor.Highlight:
+ case KnownColor.HotTrack:
+ return "highlight";
+ case KnownColor.HighlightText:
+ return "highlighttext";
+ case KnownColor.InactiveBorder:
+ return "inactiveborder";
+ case KnownColor.InactiveCaption:
+ return "inactivecaption";
+ case KnownColor.InactiveCaptionText:
+ return "inactivecaptiontext";
+ case KnownColor.Info:
+ return "infobackground";
+ case KnownColor.InfoText:
+ return "infotext";
+ case KnownColor.Menu:
+ return "menu";
+ case KnownColor.MenuText:
+ return "menutext";
+ case KnownColor.ScrollBar:
+ return "scrollbar";
+ case KnownColor.Window:
+ return "window";
+ case KnownColor.WindowFrame:
+ return "windowframe";
+ case KnownColor.WindowText:
+ return "windowtext";
+ default:
+ return String.Empty;
+ }
+ }
+
+ if (c.IsNamedColor) {
+ if (c == Color.LightGray) {
+ result = "LightGrey";
+ }
+ else
+ result = c.Name;
+ }
+ else
+ result = String.Format ("#{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B);
+
+ return result;
+ }
+
+ public static int ToOle (Color color)
+ {
+ // OleColor format is BGR, same as Win32
+
+ return ((color.B << 16) | (color.G << 8) | color.R);
+ }
+
+ public static int ToWin32 (Color color)
+ {
+ // Win32Color format is BGR, Same as OleColor
+
+ return ((color.B << 16) | (color.G << 8) | color.R);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/ComIStreamMarshaler.cs b/mcs/class/System.Drawing/System.Drawing/ComIStreamMarshaler.cs
new file mode 100644
index 00000000000..efcd589e760
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ComIStreamMarshaler.cs
@@ -0,0 +1,681 @@
+//
+// System.Drawing.ComIStreamMarshaler.cs
+//
+// Author:
+// Kornél Pál <http://www.kornelpal.hu/>
+//
+// Copyright (C) 2005 Kornél Pál
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+// Undefine to debug the protected blocks
+#define MAP_EX_TO_HR
+
+// Define to debug wrappers recursively
+// #define RECURSIVE_WRAPPING
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+#if NET_2_0
+using System.Runtime.InteropServices.ComTypes;
+using STATSTG = System.Runtime.InteropServices.ComTypes.STATSTG;
+#else
+using IStream = System.Runtime.InteropServices.UCOMIStream;
+#endif
+
+namespace System.Drawing
+{
+ // Mono does not implement COM interface marshaling
+ // This custom marshaler should be replaced with UnmanagedType.Interface
+ // Provides identical behaviour under Mono and .NET Framework
+ internal sealed class ComIStreamMarshaler : ICustomMarshaler
+ {
+ private const int S_OK = 0x00000000;
+ private const int E_NOINTERFACE = unchecked((int)0x80004002);
+
+ private delegate int QueryInterfaceDelegate(IntPtr @this, [In()] ref Guid riid, IntPtr ppvObject);
+ private delegate int AddRefDelegate(IntPtr @this);
+ private delegate int ReleaseDelegate(IntPtr @this);
+ private delegate int ReadDelegate(IntPtr @this, [Out(), MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] pv, int cb, IntPtr pcbRead);
+ private delegate int WriteDelegate(IntPtr @this, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] pv, int cb, IntPtr pcbWritten);
+ private delegate int SeekDelegate(IntPtr @this, long dlibMove, int dwOrigin, IntPtr plibNewPosition);
+ private delegate int SetSizeDelegate(IntPtr @this, long libNewSize);
+ private delegate int CopyToDelegate(IntPtr @this, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten);
+ private delegate int CommitDelegate(IntPtr @this, int grfCommitFlags);
+ private delegate int RevertDelegate(IntPtr @this);
+ private delegate int LockRegionDelegate(IntPtr @this, long libOffset, long cb, int dwLockType);
+ private delegate int UnlockRegionDelegate(IntPtr @this, long libOffset, long cb, int dwLockType);
+ private delegate int StatDelegate(IntPtr @this, out STATSTG pstatstg, int grfStatFlag);
+ private delegate int CloneDelegate(IntPtr @this, out IntPtr ppstm);
+
+ [StructLayout(LayoutKind.Sequential)]
+ private sealed class IStreamInterface
+ {
+ internal IntPtr lpVtbl;
+ internal IntPtr gcHandle;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private sealed class IStreamVtbl
+ {
+ internal QueryInterfaceDelegate QueryInterface;
+ internal AddRefDelegate AddRef;
+ internal ReleaseDelegate Release;
+ internal ReadDelegate Read;
+ internal WriteDelegate Write;
+ internal SeekDelegate Seek;
+ internal SetSizeDelegate SetSize;
+ internal CopyToDelegate CopyTo;
+ internal CommitDelegate Commit;
+ internal RevertDelegate Revert;
+ internal LockRegionDelegate LockRegion;
+ internal UnlockRegionDelegate UnlockRegion;
+ internal StatDelegate Stat;
+ internal CloneDelegate Clone;
+ }
+
+ // Managed COM Callable Wrapper implementation
+ // Reference counting is thread safe
+ private sealed class ManagedToNativeWrapper
+ {
+ // Mono does not implement Marshal.Release
+ [StructLayout(LayoutKind.Sequential)]
+ private sealed class ReleaseSlot
+ {
+ internal ReleaseDelegate Release;
+ }
+
+ private sealed class VtableDestructor
+ {
+ ~VtableDestructor()
+ {
+ Marshal.DestroyStructure(comVtable, typeof(IStreamVtbl));
+ Marshal.FreeHGlobal(comVtable);
+ }
+ }
+
+ private static readonly Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
+ private static readonly Guid IID_IStream = new Guid("0000000C-0000-0000-C000-000000000046");
+ private static readonly MethodInfo exceptionGetHResult = typeof(Exception).GetProperty("HResult", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.ExactBinding, null, typeof(int), new Type[] {}, null).GetGetMethod(true);
+ // Keeps delegates alive while they are marshaled
+ private static readonly IStreamVtbl managedVtable;
+ private static readonly IntPtr comVtable;
+ private static readonly VtableDestructor vtableDestructor;
+
+ private IStream managedInterface;
+ private IntPtr comInterface;
+ // Keeps the object alive when it has no managed references
+ private GCHandle gcHandle;
+ private int refCount = 1;
+
+ static ManagedToNativeWrapper()
+ {
+ IStreamVtbl newVtable;
+
+ newVtable = new IStreamVtbl();
+ newVtable.QueryInterface = new QueryInterfaceDelegate(QueryInterface);
+ newVtable.AddRef = new AddRefDelegate(AddRef);
+ newVtable.Release = new ReleaseDelegate(Release);
+ newVtable.Read = new ReadDelegate(Read);
+ newVtable.Write = new WriteDelegate(Write);
+ newVtable.Seek = new SeekDelegate(Seek);
+ newVtable.SetSize = new SetSizeDelegate(SetSize);
+ newVtable.CopyTo = new CopyToDelegate(CopyTo);
+ newVtable.Commit = new CommitDelegate(Commit);
+ newVtable.Revert = new RevertDelegate(Revert);
+ newVtable.LockRegion = new LockRegionDelegate(LockRegion);
+ newVtable.UnlockRegion = new UnlockRegionDelegate(UnlockRegion);
+ newVtable.Stat = new StatDelegate(Stat);
+ newVtable.Clone = new CloneDelegate(Clone);
+ comVtable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IStreamVtbl)));
+ Marshal.StructureToPtr(newVtable, comVtable, false);
+ managedVtable = newVtable;
+
+ vtableDestructor = new VtableDestructor();
+ }
+
+ private ManagedToNativeWrapper(IStream managedInterface)
+ {
+ IStreamInterface newInterface;
+
+ this.managedInterface = managedInterface;
+ gcHandle = GCHandle.Alloc(this);
+
+ newInterface = new IStreamInterface();
+ newInterface.lpVtbl = comVtable;
+ newInterface.gcHandle = (IntPtr)gcHandle;
+ comInterface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IStreamInterface)));
+ Marshal.StructureToPtr(newInterface, comInterface, false);
+ }
+
+ ~ManagedToNativeWrapper()
+ {
+ Dispose(false);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ Marshal.FreeHGlobal(comInterface);
+ gcHandle.Free();
+ if (disposing)
+ {
+ comInterface = IntPtr.Zero;
+ managedInterface = null;
+ GC.SuppressFinalize(this);
+ }
+ }
+
+ internal static IStream GetUnderlyingInterface(IntPtr comInterface, bool outParam)
+ {
+ if (Marshal.ReadIntPtr(comInterface) == comVtable)
+ {
+ IStream managedInterface = GetObject(comInterface).managedInterface;
+
+ if (outParam)
+ Release(comInterface);
+
+ return managedInterface;
+ }
+ else
+ return null;
+ }
+
+ internal static IntPtr GetInterface(IStream managedInterface)
+ {
+ IntPtr comInterface;
+
+ if (managedInterface == null)
+ return IntPtr.Zero;
+#if !RECURSIVE_WRAPPING
+ else if ((comInterface = NativeToManagedWrapper.GetUnderlyingInterface(managedInterface)) == IntPtr.Zero)
+#endif
+ comInterface = new ManagedToNativeWrapper(managedInterface).comInterface;
+
+ return comInterface;
+ }
+
+ internal static void ReleaseInterface(IntPtr comInterface)
+ {
+ if (comInterface != IntPtr.Zero)
+ {
+ IntPtr vtable = Marshal.ReadIntPtr(comInterface);
+
+ if (vtable == comVtable)
+ Release(comInterface);
+ else
+ {
+ ReleaseSlot releaseSlot = (ReleaseSlot)Marshal.PtrToStructure((IntPtr)((long)vtable + (long)(IntPtr.Size * 2)), typeof(ReleaseSlot));
+ releaseSlot.Release(comInterface);
+ }
+ }
+ }
+
+ // Mono does not implement Marshal.GetHRForException
+ private static int GetHRForException(Exception e)
+ {
+ return (int)exceptionGetHResult.Invoke(e, null);
+ }
+
+ private static ManagedToNativeWrapper GetObject(IntPtr @this)
+ {
+ return (ManagedToNativeWrapper)((GCHandle)Marshal.ReadIntPtr(@this, IntPtr.Size)).Target;
+ }
+
+ private static int QueryInterface(IntPtr @this, ref Guid riid, IntPtr ppvObject)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ if (IID_IUnknown.Equals(riid) || IID_IStream.Equals(riid))
+ {
+ Marshal.WriteIntPtr(ppvObject, @this);
+ AddRef(@this);
+ return S_OK;
+ }
+ else
+ {
+ Marshal.WriteIntPtr(ppvObject, IntPtr.Zero);
+ return E_NOINTERFACE;
+ }
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int AddRef(IntPtr @this)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ ManagedToNativeWrapper thisObject = GetObject(@this);
+
+ lock (thisObject)
+ {
+ return ++thisObject.refCount;
+ }
+#if MAP_EX_TO_HR
+ }
+ catch
+ {
+ return 0;
+ }
+#endif
+ }
+
+ private static int Release(IntPtr @this)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ ManagedToNativeWrapper thisObject = GetObject(@this);
+
+ lock (thisObject)
+ {
+ if ((thisObject.refCount != 0) && (--thisObject.refCount == 0))
+ thisObject.Dispose(true);
+
+ return thisObject.refCount;
+ }
+#if MAP_EX_TO_HR
+ }
+ catch
+ {
+ return 0;
+ }
+#endif
+ }
+
+ private static int Read(IntPtr @this, byte[] pv, int cb, IntPtr pcbRead)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ GetObject(@this).managedInterface.Read(pv, cb, pcbRead);
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int Write(IntPtr @this, byte[] pv, int cb, IntPtr pcbWritten)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ GetObject(@this).managedInterface.Write(pv, cb, pcbWritten);
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int Seek(IntPtr @this, long dlibMove, int dwOrigin, IntPtr plibNewPosition)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ GetObject(@this).managedInterface.Seek(dlibMove, dwOrigin, plibNewPosition);
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int SetSize(IntPtr @this, long libNewSize)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ GetObject(@this).managedInterface.SetSize(libNewSize);
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int CopyTo(IntPtr @this, IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ GetObject(@this).managedInterface.CopyTo(pstm, cb, pcbRead, pcbWritten);
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int Commit(IntPtr @this, int grfCommitFlags)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ GetObject(@this).managedInterface.Commit(grfCommitFlags);
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int Revert(IntPtr @this)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ GetObject(@this).managedInterface.Revert();
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int LockRegion(IntPtr @this, long libOffset, long cb, int dwLockType)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ GetObject(@this).managedInterface.LockRegion(libOffset, cb, dwLockType);
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int UnlockRegion(IntPtr @this, long libOffset, long cb, int dwLockType)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ GetObject(@this).managedInterface.UnlockRegion(libOffset, cb, dwLockType);
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int Stat(IntPtr @this, out STATSTG pstatstg, int grfStatFlag)
+ {
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ GetObject(@this).managedInterface.Stat(out pstatstg, grfStatFlag);
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ pstatstg = new STATSTG();
+ return GetHRForException(e);
+ }
+#endif
+ }
+
+ private static int Clone(IntPtr @this, out IntPtr ppstm)
+ {
+ ppstm = IntPtr.Zero;
+#if MAP_EX_TO_HR
+ try
+ {
+#endif
+ IStream newInterface;
+
+ GetObject(@this).managedInterface.Clone(out newInterface);
+ ppstm = ManagedToNativeWrapper.GetInterface(newInterface);
+ return S_OK;
+#if MAP_EX_TO_HR
+ }
+ catch (Exception e)
+ {
+ return GetHRForException(e);
+ }
+#endif
+ }
+ }
+
+ // Managed Runtime Callable Wrapper implementation
+ private sealed class NativeToManagedWrapper : IStream
+ {
+ private IntPtr comInterface;
+ private IStreamVtbl managedVtable;
+
+ private NativeToManagedWrapper(IntPtr comInterface, bool outParam)
+ {
+ this.comInterface = comInterface;
+ managedVtable = (IStreamVtbl)Marshal.PtrToStructure(Marshal.ReadIntPtr(comInterface), typeof(IStreamVtbl));
+ if (!outParam)
+ managedVtable.AddRef(comInterface);
+ }
+
+ ~NativeToManagedWrapper()
+ {
+ Dispose(false);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ managedVtable.Release(comInterface);
+ if (disposing)
+ {
+ comInterface = IntPtr.Zero;
+ managedVtable = null;
+ GC.SuppressFinalize(this);
+ }
+ }
+
+ internal static IntPtr GetUnderlyingInterface(IStream managedInterface)
+ {
+ if (managedInterface is NativeToManagedWrapper)
+ {
+ NativeToManagedWrapper wrapper = (NativeToManagedWrapper)managedInterface;
+
+ wrapper.managedVtable.AddRef(wrapper.comInterface);
+ return wrapper.comInterface;
+ }
+ else
+ return IntPtr.Zero;
+ }
+
+ internal static IStream GetInterface(IntPtr comInterface, bool outParam)
+ {
+ IStream managedInterface;
+
+ if (comInterface == IntPtr.Zero)
+ return null;
+#if !RECURSIVE_WRAPPING
+ else if ((managedInterface = ManagedToNativeWrapper.GetUnderlyingInterface(comInterface, outParam)) == null)
+#endif
+ managedInterface = (IStream)new NativeToManagedWrapper(comInterface, outParam);
+
+ return managedInterface;
+ }
+
+ internal static void ReleaseInterface(IStream managedInterface)
+ {
+ if (managedInterface is NativeToManagedWrapper)
+ ((NativeToManagedWrapper)managedInterface).Dispose(true);
+ }
+
+ // Mono does not implement Marshal.ThrowExceptionForHR
+ private static void ThrowExceptionForHR(int result)
+ {
+ if (result < 0)
+ throw new COMException(null, result);
+ }
+
+ public void Read(byte[] pv, int cb, IntPtr pcbRead)
+ {
+ ThrowExceptionForHR(managedVtable.Read(comInterface, pv, cb, pcbRead));
+ }
+
+ public void Write(byte[] pv, int cb, IntPtr pcbWritten)
+ {
+ ThrowExceptionForHR(managedVtable.Write(comInterface, pv, cb, pcbWritten));
+ }
+
+ public void Seek(long dlibMove, int dwOrigin, IntPtr plibNewPosition)
+ {
+ ThrowExceptionForHR(managedVtable.Seek(comInterface, dlibMove, dwOrigin, plibNewPosition));
+ }
+
+ public void SetSize(long libNewSize)
+ {
+ ThrowExceptionForHR(managedVtable.SetSize(comInterface, libNewSize));
+ }
+
+ public void CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
+ {
+ ThrowExceptionForHR(managedVtable.CopyTo(comInterface, pstm, cb, pcbRead, pcbWritten));
+ }
+
+ public void Commit(int grfCommitFlags)
+ {
+ ThrowExceptionForHR(managedVtable.Commit(comInterface, grfCommitFlags));
+ }
+
+ public void Revert()
+ {
+ ThrowExceptionForHR(managedVtable.Revert(comInterface));
+ }
+
+ public void LockRegion(long libOffset, long cb, int dwLockType)
+ {
+ ThrowExceptionForHR(managedVtable.LockRegion(comInterface, libOffset, cb, dwLockType));
+ }
+
+ public void UnlockRegion(long libOffset, long cb, int dwLockType)
+ {
+ ThrowExceptionForHR(managedVtable.UnlockRegion(comInterface, libOffset, cb, dwLockType));
+ }
+
+ public void Stat(out STATSTG pstatstg, int grfStatFlag)
+ {
+ ThrowExceptionForHR(managedVtable.Stat(comInterface, out pstatstg, grfStatFlag));
+ }
+
+ public void Clone(out IStream ppstm)
+ {
+ IntPtr newInterface;
+
+ ThrowExceptionForHR(managedVtable.Clone(comInterface, out newInterface));
+ ppstm = NativeToManagedWrapper.GetInterface(newInterface, true);
+ }
+ }
+
+ private static readonly ComIStreamMarshaler defaultInstance = new ComIStreamMarshaler();
+
+ private ComIStreamMarshaler()
+ {
+ }
+
+ private static ICustomMarshaler GetInstance(string cookie)
+ {
+ return defaultInstance;
+ }
+
+ public IntPtr MarshalManagedToNative(object managedObj)
+ {
+#if RECURSIVE_WRAPPING
+ managedObj = NativeToManagedWrapper.GetInterface(ManagedToNativeWrapper.GetInterface((IStream)managedObj), true);
+#endif
+ return ManagedToNativeWrapper.GetInterface((IStream)managedObj);
+ }
+
+ public void CleanUpNativeData(IntPtr pNativeData)
+ {
+ ManagedToNativeWrapper.ReleaseInterface(pNativeData);
+ }
+
+ public object MarshalNativeToManaged(IntPtr pNativeData)
+ {
+#if RECURSIVE_WRAPPING
+ pNativeData = ManagedToNativeWrapper.GetInterface(NativeToManagedWrapper.GetInterface(pNativeData, true));
+#endif
+ return NativeToManagedWrapper.GetInterface(pNativeData, false);
+ }
+
+ public void CleanUpManagedData(object managedObj)
+ {
+ NativeToManagedWrapper.ReleaseInterface((IStream)managedObj);
+ }
+
+ public int GetNativeDataSize()
+ {
+ return -1;
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Drawing/System.Drawing/ComIStreamWrapper.cs b/mcs/class/System.Drawing/System.Drawing/ComIStreamWrapper.cs
new file mode 100644
index 00000000000..74a16c1be1c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ComIStreamWrapper.cs
@@ -0,0 +1,210 @@
+//
+// System.Drawing.ComIStreamWrapper.cs
+//
+// Author:
+// Kornél Pál <http://www.kornelpal.hu/>
+//
+// Copyright (C) 2005 Kornél Pál
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+#if NET_2_0
+using System.Runtime.InteropServices.ComTypes;
+using STATSTG = System.Runtime.InteropServices.ComTypes.STATSTG;
+#else
+using IStream = System.Runtime.InteropServices.UCOMIStream;
+#endif
+
+namespace System.Drawing
+{
+ // Stream to IStream wrapper for COM interop
+ internal sealed class ComIStreamWrapper : IStream
+ {
+ private const int STG_E_INVALIDFUNCTION = unchecked((int)0x80030001);
+
+ private readonly Stream baseStream;
+ private long position = -1;
+
+ internal ComIStreamWrapper(Stream stream)
+ {
+ baseStream = stream;
+ }
+
+ private void SetSizeToPosition()
+ {
+ if (position != -1)
+ {
+ if (position > baseStream.Length)
+ baseStream.SetLength(position);
+ baseStream.Position = position;
+ position = -1;
+ }
+ }
+
+ public void Read(byte[] pv, int cb, IntPtr pcbRead)
+ {
+ int read = 0;
+
+ if (cb != 0)
+ {
+ SetSizeToPosition();
+
+ read = baseStream.Read(pv, 0, cb);
+ }
+
+ if (pcbRead != IntPtr.Zero)
+ Marshal.WriteInt32(pcbRead, read);
+ }
+
+ public void Write(byte[] pv, int cb, IntPtr pcbWritten)
+ {
+ if (cb != 0)
+ {
+ SetSizeToPosition();
+
+ baseStream.Write(pv, 0, cb);
+ }
+
+ if (pcbWritten != IntPtr.Zero)
+ Marshal.WriteInt32(pcbWritten, cb);
+ }
+
+ public void Seek(long dlibMove, int dwOrigin, IntPtr plibNewPosition)
+ {
+ long newPosition;
+
+ if (baseStream.CanWrite)
+ {
+ switch ((SeekOrigin)dwOrigin)
+ {
+ case SeekOrigin.Begin:
+ newPosition = dlibMove;
+ break;
+ case SeekOrigin.Current:
+ if ((newPosition = position) == -1)
+ newPosition = baseStream.Position;
+ newPosition += dlibMove;
+ break;
+ case SeekOrigin.End:
+ newPosition = baseStream.Length + dlibMove;
+ break;
+ default:
+ throw new ExternalException(null, STG_E_INVALIDFUNCTION);
+ }
+
+ if (newPosition > baseStream.Length)
+ position = newPosition;
+ else
+ {
+ baseStream.Position = newPosition;
+ position = -1;
+ }
+ }
+ else
+ {
+ try
+ {
+ newPosition = baseStream.Seek(dlibMove, (SeekOrigin)dwOrigin);
+ }
+ catch (ArgumentException)
+ {
+ throw new ExternalException(null, STG_E_INVALIDFUNCTION);
+ }
+ position = -1;
+ }
+
+ if (plibNewPosition != IntPtr.Zero)
+ Marshal.WriteInt64(plibNewPosition, newPosition);
+ }
+
+ public void SetSize(long libNewSize)
+ {
+ baseStream.SetLength(libNewSize);
+ }
+
+ public void CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
+ {
+ byte[] buffer = new byte[4096];
+ long written = 0;
+ int read;
+
+ if (cb != 0)
+ {
+ SetSizeToPosition();
+ do
+ {
+ int count = 4096;
+
+ if (written + 4096 > cb)
+ count = (int)(cb - written);
+
+ if ((read = baseStream.Read(buffer, 0, count)) == 0)
+ break;
+ pstm.Write(buffer, read, IntPtr.Zero);
+ written += read;
+ } while (written < cb);
+ }
+
+ if (pcbRead != IntPtr.Zero)
+ Marshal.WriteInt64(pcbRead, written);
+ if (pcbWritten != IntPtr.Zero)
+ Marshal.WriteInt64(pcbWritten, written);
+ }
+
+ public void Commit(int grfCommitFlags)
+ {
+ baseStream.Flush();
+ }
+
+ public void Revert()
+ {
+ throw new ExternalException(null, STG_E_INVALIDFUNCTION);
+ }
+
+ public void LockRegion(long libOffset, long cb, int dwLockType)
+ {
+ throw new ExternalException(null, STG_E_INVALIDFUNCTION);
+ }
+
+ public void UnlockRegion(long libOffset, long cb, int dwLockType)
+ {
+ throw new ExternalException(null, STG_E_INVALIDFUNCTION);
+ }
+
+ public void Stat(out STATSTG pstatstg, int grfStatFlag)
+ {
+ pstatstg = new STATSTG();
+ pstatstg.cbSize = baseStream.Length;
+ }
+
+ public void Clone(out IStream ppstm)
+ {
+ ppstm = null;
+ throw new ExternalException(null, STG_E_INVALIDFUNCTION);
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Drawing/System.Drawing/ContentAlignment.cs b/mcs/class/System.Drawing/System.Drawing/ContentAlignment.cs
new file mode 100644
index 00000000000..cc7f4d8f181
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ContentAlignment.cs
@@ -0,0 +1,49 @@
+//
+// System.Drawing.ContentAlignment.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ [Serializable]
+ [Editor ("System.Drawing.Design.ContentAlignmentEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ public enum ContentAlignment {
+ TopLeft = 0x001,
+ TopCenter = 0x002,
+ TopRight = 0x004,
+ MiddleLeft = 0x010,
+ MiddleCenter = 0x020,
+ MiddleRight = 0x040,
+ BottomLeft = 0x100,
+ BottomCenter = 0x200,
+ BottomRight = 0x400
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/CopyPixelOperation.cs b/mcs/class/System.Drawing/System.Drawing/CopyPixelOperation.cs
new file mode 100644
index 00000000000..3f49bc877b0
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/CopyPixelOperation.cs
@@ -0,0 +1,59 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+//
+// Jordi Mas i Hernandez <jordimash@gmail.com>
+//
+//
+
+#if NET_2_0
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing
+{
+ [ComVisibleAttribute(true)]
+ public enum CopyPixelOperation {
+ Blackness = 0x00000042,
+ CaptureBlt = 0x40000000,
+ DestinationInvert = 0x00550009,
+ MergeCopy = 0x00C000CA,
+ MergePaint = 0x00BB0226,
+ NoMirrorBitmap = -2147483648,
+ NotSourceCopy = 0x00330008,
+ NotSourceErase = 0x001100A6,
+ PatCopy = 0x00F00021,
+ PatInvert = 0x005A0049,
+ PatPaint = 0x00FB0A09,
+ SourceAnd = 0x008800C6,
+ SourceCopy = 0x00CC0020,
+ SourceErase = 0x00440328,
+ SourceInvert = 0x00660046,
+ SourcePaint = 0x00EE0086,
+ Whiteness = 0x00FF0062,
+ }
+}
+
+#endif
+
diff --git a/mcs/class/System.Drawing/System.Drawing/Font.cs b/mcs/class/System.Drawing/System.Drawing/Font.cs
new file mode 100644
index 00000000000..2824278887c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Font.cs
@@ -0,0 +1,717 @@
+//
+// System.Drawing.Fonts.cs
+//
+// Authors:
+// Alexandre Pigolkine (pigolkine@gmx.de)
+// Miguel de Icaza (miguel@ximian.com)
+// Todd Berman (tberman@sevenl.com)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2004 Ximian, Inc. (http://www.ximian.com)
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ [Serializable]
+ [ComVisible (true)]
+ [Editor ("System.Drawing.Design.FontEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ [TypeConverter (typeof (FontConverter))]
+ public sealed class Font : MarshalByRefObject, ISerializable, ICloneable, IDisposable
+ {
+ private IntPtr fontObject = IntPtr.Zero;
+ private string systemFontName;
+
+ private void CreateFont(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical) {
+ Status status;
+ FontFamily family;
+
+ // NOTE: If family name is null, empty or invalid,
+ // MS creates Microsoft Sans Serif font.
+ try {
+ family = new FontFamily (familyName);
+ }
+ catch (Exception){
+ family = FontFamily.GenericSansSerif;
+ }
+
+ setProperties (family, emSize, style, unit, charSet, isVertical);
+ status = GDIPlus.GdipCreateFont (family.NativeObject, emSize, style, unit, out fontObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ private Font (SerializationInfo info, StreamingContext context)
+ {
+ string name;
+ float size;
+ FontStyle style;
+ GraphicsUnit unit;
+
+ name = (string)info.GetValue("Name", typeof(string));
+ size = (float)info.GetValue("Size", typeof(float));
+ style = (FontStyle)info.GetValue("Style", typeof(FontStyle));
+ unit = (GraphicsUnit)info.GetValue("Unit", typeof(GraphicsUnit));
+
+ CreateFont(name, size, style, unit, (byte)0, false);
+ }
+
+ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue("Name", Name);
+ info.AddValue("Size", Size);
+ info.AddValue("Style", Style);
+ info.AddValue("Unit", Unit);
+ }
+
+ ~Font()
+ {
+ Dispose ();
+ }
+
+ public void Dispose ()
+ {
+ if (fontObject != IntPtr.Zero) {
+ GDIPlus.CheckStatus (GDIPlus.GdipDeleteFont (fontObject));
+ fontObject = IntPtr.Zero;
+ GC.SuppressFinalize (this);
+ }
+ }
+
+ internal void unitConversion (GraphicsUnit fromUnit, GraphicsUnit toUnit, float nSrc, out float nTrg)
+ {
+ float inchs = 0;
+ nTrg = 0;
+
+ switch (fromUnit) {
+ case GraphicsUnit.Display:
+ inchs = nSrc / 75f;
+ break;
+ case GraphicsUnit.Document:
+ inchs = nSrc / 300f;
+ break;
+ case GraphicsUnit.Inch:
+ inchs = nSrc;
+ break;
+ case GraphicsUnit.Millimeter:
+ inchs = nSrc / 25.4f;
+ break;
+ case GraphicsUnit.Pixel:
+ case GraphicsUnit.World:
+ inchs = nSrc / Graphics.systemDpiX;
+ break;
+ case GraphicsUnit.Point:
+ inchs = nSrc / 72f;
+ break;
+ default:
+ throw new ArgumentException("Invalid GraphicsUnit");
+ }
+
+ switch (toUnit) {
+ case GraphicsUnit.Display:
+ nTrg = inchs * 75;
+ break;
+ case GraphicsUnit.Document:
+ nTrg = inchs * 300;
+ break;
+ case GraphicsUnit.Inch:
+ nTrg = inchs;
+ break;
+ case GraphicsUnit.Millimeter:
+ nTrg = inchs * 25.4f;
+ break;
+ case GraphicsUnit.Pixel:
+ case GraphicsUnit.World:
+ nTrg = inchs * Graphics.systemDpiX;
+ break;
+ case GraphicsUnit.Point:
+ nTrg = inchs * 72;
+ break;
+ default:
+ throw new ArgumentException("Invalid GraphicsUnit");
+ }
+ }
+
+ internal void setProperties (FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical)
+ {
+ _name = family.Name;
+ _fontFamily = family;
+ _size = emSize;
+
+ // MS throws ArgumentException, if unit is set to GraphicsUnit.Display
+ _unit = unit;
+ _style = style;
+ _gdiCharSet = charSet;
+ _gdiVerticalFont = isVertical;
+
+ unitConversion (unit, GraphicsUnit.Point, emSize, out _sizeInPoints);
+
+ _bold = _italic = _strikeout = _underline = false;
+
+ if ((style & FontStyle.Bold) == FontStyle.Bold)
+ _bold = true;
+
+ if ((style & FontStyle.Italic) == FontStyle.Italic)
+ _italic = true;
+
+ if ((style & FontStyle.Strikeout) == FontStyle.Strikeout)
+ _strikeout = true;
+
+ if ((style & FontStyle.Underline) == FontStyle.Underline)
+ _underline = true;
+ }
+
+ public static Font FromHfont (IntPtr Hfont)
+ {
+ OperatingSystem osInfo = Environment.OSVersion;
+ IntPtr newObject;
+ IntPtr hdc;
+ FontStyle newStyle = FontStyle.Regular;
+ float newSize;
+ LOGFONTA lf = new LOGFONTA ();
+
+ // Sanity. Should we throw an exception?
+ if (Hfont == IntPtr.Zero) {
+ Font result = new Font ("Arial", (float)10.0, FontStyle.Regular);
+ return(result);
+ }
+
+ if ((int) osInfo.Platform == 128 || (int) osInfo.Platform == 4) {
+ // 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);
+ Font f = FromLogFont (lf, hdc);
+ GDIPlus.ReleaseDC (hdc);
+ return f;
+ }
+
+ 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;
+ }
+
+ return (new Font (newObject, lf.lfFaceName, newStyle, newSize));
+ }
+
+ public IntPtr ToHfont ()
+ {
+ IntPtr Hfont;
+ OperatingSystem osInfo = Environment.OSVersion;
+
+ // Sanity. Should we throw an exception?
+ if (fontObject == IntPtr.Zero) {
+ return IntPtr.Zero;
+ }
+
+ if ((int) osInfo.Platform == 128 || (int) osInfo.Platform == 4) {
+ return fontObject;
+ } else {
+ LOGFONTA lf = new LOGFONTA ();
+ ToLogFont(lf);
+ Hfont = GDIPlus.CreateFontIndirectA (ref lf);
+ }
+ return Hfont;
+ }
+
+ internal Font (IntPtr newFontObject, string familyName, FontStyle style, float size)
+ {
+ FontFamily fontFamily;
+
+ try {
+ fontFamily = new FontFamily (familyName);
+ }
+ catch (Exception){
+ fontFamily = FontFamily.GenericSansSerif;
+ }
+
+ setProperties (fontFamily, size, style, GraphicsUnit.Pixel, 0, false);
+ fontObject = newFontObject;
+ }
+
+ public Font (Font original, FontStyle style)
+ {
+ Status status;
+ setProperties (original.FontFamily, original.Size, style, original.Unit, original.GdiCharSet, original.GdiVerticalFont);
+
+ status = GDIPlus.GdipCreateFont (_fontFamily.NativeObject, Size, Style, Unit, out fontObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Font (FontFamily family, float emSize, GraphicsUnit unit)
+ : this (family, emSize, FontStyle.Regular, unit, (byte)0, false)
+ {
+ }
+
+ public Font (string familyName, float emSize, GraphicsUnit unit)
+ : this (new FontFamily (familyName), emSize, FontStyle.Regular, unit, (byte)0, false)
+ {
+ }
+
+ public Font (FontFamily family, float emSize)
+ : this (family, emSize, FontStyle.Regular, GraphicsUnit.Point, (byte)0, false)
+ {
+ }
+
+ public Font (FontFamily family, float emSize, FontStyle style)
+ : this (family, emSize, style, GraphicsUnit.Point, (byte)0, false)
+ {
+ }
+
+ public Font (FontFamily family, float emSize, FontStyle style, GraphicsUnit unit)
+ : this (family, emSize, style, unit, (byte)0, false)
+ {
+ }
+
+ public Font (FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte charSet)
+ : this (family, emSize, style, unit, charSet, false)
+ {
+ }
+
+ public Font (FontFamily family, float emSize, FontStyle style,
+ GraphicsUnit unit, byte charSet, bool isVertical)
+ {
+ // MS does not accept null family
+ Status status;
+ setProperties (family, emSize, style, unit, charSet, isVertical);
+ status = GDIPlus.GdipCreateFont (family.NativeObject, emSize, style, unit, out fontObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Font (string familyName, float emSize)
+ : this (familyName, emSize, FontStyle.Regular, GraphicsUnit.Point, (byte)0, false)
+ {
+ }
+
+ public Font (string familyName, float emSize, FontStyle style)
+ : this (familyName, emSize, style, GraphicsUnit.Point, (byte)0, false)
+ {
+ }
+
+ public Font (string familyName, float emSize, FontStyle style, GraphicsUnit unit)
+ : this (familyName, emSize, style, unit, (byte)0, false)
+ {
+ }
+
+ public Font (string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet)
+ : this (familyName, emSize, style, unit, charSet, false)
+ {
+ }
+
+ public Font (string familyName, float emSize, FontStyle style,
+ GraphicsUnit unit, byte charSet, bool isVertical)
+ {
+ CreateFont(familyName, emSize, style, unit, charSet, isVertical);
+ }
+
+ public object Clone ()
+ {
+ return new Font (this, Style);
+ }
+
+ internal IntPtr NativeObject {
+ get {
+ return fontObject;
+ }
+ set {
+ fontObject = value;
+ }
+ }
+
+#if NET_2_0
+ internal string SysFontName {
+ set {
+ systemFontName = value;
+ }
+ }
+#endif
+
+ private bool _bold;
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public bool Bold {
+ get {
+ return _bold;
+ }
+ }
+
+ private FontFamily _fontFamily;
+
+ [Browsable (false)]
+ public FontFamily FontFamily {
+ get {
+ return _fontFamily;
+ }
+ }
+
+ private byte _gdiCharSet;
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public byte GdiCharSet {
+ get {
+ return _gdiCharSet;
+ }
+ }
+
+ private bool _gdiVerticalFont;
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public bool GdiVerticalFont {
+ get {
+ return _gdiVerticalFont;
+ }
+ }
+
+ [Browsable (false)]
+ public int Height {
+ get {
+ return (int) Math.Ceiling (GetHeight ());
+ }
+ }
+
+#if NET_2_0
+ [Browsable(false)]
+ public bool IsSystemFont {
+ get {
+ if (systemFontName == null)
+ return false;
+
+ return StringComparer.InvariantCulture.Compare (systemFontName, string.Empty) != 0;
+ }
+ }
+#endif
+
+ private bool _italic;
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public bool Italic {
+ get {
+ return _italic;
+ }
+ }
+
+ private string _name;
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [Editor ("System.Drawing.Design.FontNameEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ [TypeConverter (typeof (FontConverter.FontNameConverter))]
+ public string Name {
+ get {
+ return _name;
+ }
+ }
+
+ private float _size;
+ public float Size {
+ get {
+ return _size;
+ }
+ }
+
+ private float _sizeInPoints;
+
+ [Browsable (false)]
+ public float SizeInPoints {
+ get {
+ return _sizeInPoints;
+ }
+ }
+
+ private bool _strikeout;
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public bool Strikeout {
+ get {
+ return _strikeout;
+ }
+ }
+
+ private FontStyle _style;
+
+ [Browsable (false)]
+ public FontStyle Style {
+ get {
+ return _style;
+ }
+ }
+
+#if NET_2_0
+ [Browsable(false)]
+ public string SystemFontName {
+ get {
+ return systemFontName;
+ }
+ }
+#endif
+ private bool _underline;
+
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public bool Underline {
+ get {
+ return _underline;
+ }
+ }
+
+ private GraphicsUnit _unit;
+
+ [TypeConverter (typeof (FontConverter.FontUnitConverter))]
+ public GraphicsUnit Unit {
+ get {
+ return _unit;
+ }
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (! (obj is Font))
+ return false;
+
+ Font fnt = (Font) obj;
+
+ if (fnt.FontFamily.Equals (FontFamily) && fnt.Size == Size &&
+ fnt.Style == Style && fnt.Unit == Unit &&
+ fnt.GdiCharSet == GdiCharSet &&
+ fnt.GdiVerticalFont == GdiVerticalFont)
+ return true;
+ else
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return _name.GetHashCode ();
+ }
+
+ [MonoTODO]
+ public static Font FromHdc (IntPtr hdc)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO("This is temporary implementation")]
+ public static Font FromLogFont (object lf, IntPtr hdc)
+ {
+ IntPtr newObject;
+ LOGFONTA o = (LOGFONTA)lf;
+ GDIPlus.GdipCreateFontFromLogfontA (hdc, ref o, out newObject);
+ return new Font (newObject, "Microsoft Sans Serif", FontStyle.Regular, 10);
+ }
+
+ public float GetHeight ()
+ {
+ return GetHeight (Graphics.systemDpiY);
+ }
+
+ public static Font FromLogFont (object lf)
+ {
+ if ((int) Environment.OSVersion.Platform == 128 || (int) Environment.OSVersion.Platform == 4) {
+ return FromLogFont(lf, IntPtr.Zero);
+ } else {
+ IntPtr hDC;
+
+ hDC = IntPtr.Zero;
+
+ try {
+ hDC = GDIPlus.GetDC(IntPtr.Zero);
+ return FromLogFont (lf, hDC);
+ }
+
+ finally {
+ GDIPlus.ReleaseDC(hDC);
+ }
+ }
+
+ }
+
+ public void ToLogFont (object logFont)
+ {
+ Graphics g;
+
+ g = null;
+
+ if ((int) Environment.OSVersion.Platform == 128 || (int) Environment.OSVersion.Platform == 4) {
+ // Unix
+ Bitmap img;
+
+ img = null;
+
+ try {
+ // We don't have a window we could associate the DC with
+ // so we use an image instead
+ img = new Bitmap(1, 1, Imaging.PixelFormat.Format32bppArgb);
+ g = Graphics.FromImage(img);
+ ToLogFont(logFont, g);
+ }
+
+ finally {
+ if (g != null) {
+ g.Dispose();
+ }
+
+ if (img != null) {
+ img.Dispose();
+ }
+ }
+ } else {
+ // Windows
+ IntPtr hDC;
+
+ hDC = IntPtr.Zero;
+
+ try {
+
+ hDC = GDIPlus.GetDC(IntPtr.Zero);
+ g = Graphics.FromHdc(hDC);
+
+ ToLogFont (logFont, g);
+ }
+
+ finally {
+ if (g != null) {
+ g.Dispose();
+ }
+
+ GDIPlus.ReleaseDC(hDC);
+ }
+ }
+ }
+
+ public void ToLogFont (object logFont, Graphics graphics)
+ {
+ IntPtr lf;
+
+ if (graphics == null) {
+ throw new ArgumentNullException ("graphics");
+ }
+
+ lf = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LOGFONTW)));
+ if (lf == IntPtr.Zero) {
+ throw new OutOfMemoryException("Could not allocate logfont structure memory");
+ }
+ GDIPlus.CheckStatus (GDIPlus.GdipGetLogFontW(NativeObject, graphics.NativeObject, lf));
+
+ Marshal.PtrToStructure(lf, logFont);
+ Marshal.FreeHGlobal(lf);
+ }
+
+ public float GetHeight (Graphics graphics)
+ {
+ float height = GetHeight (graphics.DpiY);
+
+ switch (graphics.PageUnit) {
+ case GraphicsUnit.Document:
+ height *= (300f / graphics.DpiY);
+ break;
+ case GraphicsUnit.Display:
+ height *= (75f / graphics.DpiY);
+ break;
+ case GraphicsUnit.Inch:
+ height /= graphics.DpiY;
+ break;
+ case GraphicsUnit.Millimeter:
+ height *= (25.4f / graphics.DpiY);
+ break;
+ case GraphicsUnit.Point:
+ height *= (72f / graphics.DpiY);
+ break;
+
+ case GraphicsUnit.Pixel:
+ case GraphicsUnit.World:
+ default:
+ break;
+ }
+
+ return height;
+ }
+
+ public float GetHeight (float dpi)
+ {
+ float height;
+ int emHeight = _fontFamily.GetEmHeight (_style);
+ int lineSpacing = _fontFamily.GetLineSpacing (_style);
+
+ height = lineSpacing * (_size / emHeight);
+
+ switch (_unit) {
+ case GraphicsUnit.Document:
+ height *= (dpi / 300f);
+ break;
+ case GraphicsUnit.Display:
+ height *= (dpi / 75f);
+ break;
+ case GraphicsUnit.Inch:
+ height *= dpi;
+ break;
+ case GraphicsUnit.Millimeter:
+ height *= (dpi / 25.4f);
+ break;
+ case GraphicsUnit.Point:
+ height *= (dpi / 72f);
+ break;
+
+ case GraphicsUnit.Pixel:
+ case GraphicsUnit.World:
+ default:
+ break;
+ }
+
+ return height;
+ }
+
+ public override String ToString ()
+ {
+ return String.Format ("[Font: Name={0}, Size={1}, Units={2}, GdiCharSet={3}, GdiVerticalFont={4}]", _name, _size, (int)_unit, _gdiCharSet, _gdiVerticalFont);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Font.jvm.cs b/mcs/class/System.Drawing/System.Drawing/Font.jvm.cs
new file mode 100644
index 00000000000..6f196d93a26
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Font.jvm.cs
@@ -0,0 +1,295 @@
+
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+using awt = java.awt;
+using TextAttribute = java.awt.font.TextAttribute;
+
+namespace System.Drawing {
+ [Serializable]
+ public sealed class Font: MarshalByRefObject, ISerializable, ICloneable, IDisposable {
+
+ #region variables
+
+ const byte DEFAULT_CHARSET = 1;
+
+ private readonly GraphicsUnit _gUnit = GraphicsUnit.Point;
+ private readonly FontFamily _fontFamily;
+ private readonly awt.Font _jFont;
+ private readonly byte _charset;
+
+ #endregion
+
+ internal awt.Font NativeObject {
+ get {
+ return _jFont;
+ }
+ }
+
+ #region ISerializable
+
+ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) {
+ info.AddValue("Name", Name);
+ info.AddValue("Size", Size);
+ info.AddValue("Style", Style, typeof(FontStyle));
+ info.AddValue("Unit", Unit, typeof(GraphicsUnit));
+ }
+
+ #endregion
+
+ #region ctors
+
+ private Font (SerializationInfo info, StreamingContext context)
+ : this(
+ info.GetString("Name"),
+ info.GetSingle("Size"),
+ (FontStyle)info.GetValue("Style", typeof(FontStyle)),
+ (GraphicsUnit)info.GetValue("Unit", typeof(GraphicsUnit)) ) {
+ }
+
+ public Font(Font original, FontStyle style) {
+ _jFont = original.NativeObject.deriveFont( DeriveStyle(original.NativeObject.getAttributes(), style, true) );
+ _gUnit = original._gUnit;
+ _fontFamily = original._fontFamily;
+ }
+
+ public Font(FontFamily family, float emSize)
+ : this(family, emSize, FontStyle.Regular, GraphicsUnit.Point, DEFAULT_CHARSET, false) {
+ }
+
+ public Font(FontFamily family, float emSize, FontStyle style)
+ : this(family, emSize, style, GraphicsUnit.Point, DEFAULT_CHARSET, false) {
+ }
+ public Font(FontFamily family, float emSize, GraphicsUnit unit)
+ : this(family, emSize, FontStyle.Regular, unit, DEFAULT_CHARSET, false) {
+ }
+
+ public Font(FontFamily family, float emSize, FontStyle style, GraphicsUnit unit)
+ : this(family, emSize, style, unit, DEFAULT_CHARSET, false) {
+ }
+
+ public Font(FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte charSet)
+ : this(family, emSize, style, unit, charSet, false) {
+ }
+
+ public Font(FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical) {
+ if (family == null)
+ throw new ArgumentNullException("family");
+
+ _gUnit = unit;
+ _fontFamily = family;
+ _charset = charSet;
+
+ java.util.Hashtable attribs = new java.util.Hashtable();
+ attribs.put(TextAttribute.FAMILY, family.Name/*TODO: family doungrade possibility*/);
+ //init defaults
+ attribs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);
+
+ float newSize = emSize * Graphics.UnitConversion[ (int)_gUnit ];
+ attribs.put(TextAttribute.SIZE, new java.lang.Float(newSize));
+
+ DeriveStyle(attribs, style, false);
+
+ _jFont = family.FamilyFont.deriveFont(attribs);
+ }
+
+ public Font(string familyName, float emSize)
+ : this(familyName, emSize, FontStyle.Regular, GraphicsUnit.Point, (byte)0, false) {
+ }
+
+ public Font(string familyName, float emSize, FontStyle style)
+ : this(familyName, emSize, style, GraphicsUnit.Point, (byte)0, false) {
+ }
+
+ public Font(string familyName, float emSize, GraphicsUnit unit)
+ : this(familyName, emSize, FontStyle.Regular, unit, (byte)0, false) {
+ }
+
+ public Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit)
+ : this(familyName, emSize, style, unit, (byte)0, false) {
+ }
+
+ public Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet)
+ : this(familyName, emSize, style, unit, charSet, false) {
+ }
+
+ public Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical)
+ :this(new FontFamily(familyName), emSize, style, unit, charSet, isVertical) {
+ }
+
+ #endregion
+
+ #region IDisposable members
+
+ public void Dispose() {
+ }
+
+ #endregion
+
+ #region ICloneable
+
+ public object Clone() {
+ return (Font)MemberwiseClone();
+ }
+
+ #endregion
+
+#if INTPTR_SUPPORT
+ [MonoTODO]
+ public IntPtr ToHfont ()
+ {
+ throw new NotImplementedException();
+ }
+#endif
+
+ #region public properties
+
+ public bool Bold {
+ get {
+ return _jFont.isBold();
+ }
+ }
+
+ public FontFamily FontFamily {
+ get {
+ return _fontFamily;
+ }
+ }
+
+ public byte GdiCharSet {
+ get {
+ return _charset;
+ }
+ }
+
+ public bool GdiVerticalFont {
+ get {
+ return Name.StartsWith("@");
+ }
+ }
+
+ public int Height {
+ get {
+ awt.Container c = new awt.Container();
+ return c.getFontMetrics(NativeObject).getHeight();
+ }
+ }
+
+ public bool Italic {
+ get {
+ return _jFont.isItalic();
+ }
+ }
+
+ public string Name {
+ get {
+ return _jFont.getName();
+ }
+ }
+
+ public float Size {
+ get {
+ return SizeInPoints / Graphics.UnitConversion[ (int)_gUnit ];
+ }
+ }
+
+ public float SizeInPoints {
+ get {
+ return _jFont.getSize2D();
+ }
+ }
+
+ public bool Strikeout {
+ get {
+ try {
+ if((java.lang.Boolean)_jFont.getAttributes().get(TextAttribute.STRIKETHROUGH)
+ == TextAttribute.STRIKETHROUGH_ON )
+ return true;
+ }
+ catch {
+ }
+ return false;
+ }
+ }
+
+ public FontStyle Style {
+ get {
+ FontStyle style = FontStyle.Regular;
+ if (Bold)
+ style |= FontStyle.Bold;
+ if (Italic)
+ style |= FontStyle.Italic;
+ if (Underline)
+ style |= FontStyle.Underline;
+ if (Strikeout)
+ style |= FontStyle.Strikeout;
+
+ return style;
+ }
+ }
+
+ public bool Underline {
+ get {
+ try {
+ if((java.lang.Integer)_jFont.getAttributes().get(TextAttribute.UNDERLINE)
+ == TextAttribute.UNDERLINE_ON )
+ return true;
+ }
+ catch {
+ }
+ return false;
+ }
+ }
+
+ [TypeConverter(typeof(FontConverter.FontUnitConverter))]
+ public GraphicsUnit Unit {
+ get {
+ return _gUnit;
+ }
+ }
+
+ #endregion
+
+ public override System.String ToString() {
+ return ("[Font: Name="+ Name +", Size="+ Size +", Style="+ Style +", Units="+ Unit +"]");
+ }
+
+ static internal java.util.Map DeriveStyle(java.util.Map attribs, FontStyle style, bool createNew) {
+ java.util.Map newAttribs;
+ if (createNew) {
+ newAttribs = new java.util.Hashtable( attribs.size() );
+ object [] keys = attribs.keySet().toArray();
+ for (int i=0; i < keys.Length; i++)
+ newAttribs.put( keys[i], attribs.get( keys[i] ) );
+ }
+ else
+ newAttribs = attribs;
+
+ //Bold
+ if((style & FontStyle.Bold) == FontStyle.Bold)
+ newAttribs.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
+ else
+ newAttribs.remove(TextAttribute.WEIGHT);
+
+ //Italic
+ if((style & FontStyle.Italic) == FontStyle.Italic)
+ newAttribs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
+ else
+ newAttribs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);
+
+ //Underline
+ if((style & FontStyle.Underline) == FontStyle.Underline)
+ newAttribs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
+ else
+ newAttribs.remove(TextAttribute.UNDERLINE);
+
+ //Strikeout
+ if((style & FontStyle.Strikeout) == FontStyle.Strikeout)
+ newAttribs.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
+ else
+ newAttribs.remove(TextAttribute.STRIKETHROUGH);
+
+ return newAttribs;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/FontConverter.cs b/mcs/class/System.Drawing/System.Drawing/FontConverter.cs
new file mode 100644
index 00000000000..296ebabbb87
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/FontConverter.cs
@@ -0,0 +1,310 @@
+//
+// System.Drawing.FontConverter.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002,2003 Ximian, Inc. http://www.ximian.com
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.Drawing.Text;
+using System.ComponentModel.Design.Serialization;
+using System.Reflection;
+
+namespace System.Drawing
+{
+ public class FontConverter : TypeConverter
+ {
+ public FontConverter ()
+ {
+ }
+
+ ~FontConverter ()
+ {
+
+ }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof (string))
+ return true;
+
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
+ {
+ if (destinationType == typeof (String))
+ return true;
+
+ if (destinationType == typeof (InstanceDescriptor))
+ return true;
+
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value,
+ Type destinationType)
+ {
+ if ((destinationType == typeof (string)) && (value is Font)) {
+ Font font = (Font) value;
+ StringBuilder sb = new StringBuilder ();
+ sb.Append (font.Name).Append (", ");
+ sb.Append (font.Size);
+
+ switch (font.Unit) {
+ // MS throws ArgumentException, if unit is set
+ // to GraphicsUnit.Display
+ // Don't know what to append for GraphicsUnit.Display
+ case GraphicsUnit.Display:
+ sb.Append ("display"); break;
+
+ case GraphicsUnit.Document:
+ sb.Append ("doc"); break;
+
+ case GraphicsUnit.Point:
+ sb.Append ("pt"); break;
+
+ case GraphicsUnit.Inch:
+ sb.Append ("in"); break;
+
+ case GraphicsUnit.Millimeter:
+ sb.Append ("mm"); break;
+
+ case GraphicsUnit.Pixel:
+ sb.Append ("px"); break;
+
+ case GraphicsUnit.World:
+ sb.Append ("world"); break;
+ }
+
+ if (font.Style != FontStyle.Regular)
+ sb.Append (", style=").Append (font.Style);
+
+ return sb.ToString ();
+ }
+
+ if ((destinationType == typeof (InstanceDescriptor)) && (value is Font)) {
+ Font font = (Font) value;
+ ConstructorInfo met = typeof(Font).GetConstructor (new Type[] {typeof(string), typeof(float), typeof(FontStyle), typeof(GraphicsUnit)});
+ object[] args = new object[4];
+ args [0] = font.Name;
+ args [1] = font.Size;
+ args [2] = font.Style;
+ args [3] = font.Unit;
+ return new InstanceDescriptor (met, args);
+ }
+
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value)
+ {
+ string fontFamily = value as string;
+ if (fontFamily == null)
+ return base.ConvertFrom (context, culture, value);
+
+ // MS creates a font from the given family with
+ // emSize = 8.
+ return new Font (fontFamily, 8);
+ }
+
+ public override object CreateInstance (ITypeDescriptorContext context,
+ IDictionary propertyValues)
+ {
+ Object value;
+ byte charSet = 1;
+ float size = 8;
+ String name = null;
+ bool vertical = false;
+ FontStyle style = FontStyle.Regular;
+ FontFamily fontFamily = null;
+ GraphicsUnit unit = GraphicsUnit.Point;
+
+ if ((value = propertyValues ["GdiCharSet"]) != null)
+ charSet = (byte) value;
+
+ if ((value = propertyValues ["Size"]) != null)
+ size = (float) value;
+
+ if ((value = propertyValues ["Unit"]) != null)
+ unit = (GraphicsUnit) value;
+
+ if ((value = propertyValues ["Name"]) != null)
+ name = (String) value;
+
+ if ((value = propertyValues ["GdiVerticalFont"]) != null)
+ vertical = (bool) value;
+
+ if ((value = propertyValues ["Bold"]) != null) {
+ bool bold = (bool) value;
+ if (bold == true)
+ style |= FontStyle.Bold;
+ }
+
+ if ((value = propertyValues ["Italic"]) != null) {
+ bool italic = (bool) value;
+ if (italic == true)
+ style |= FontStyle.Italic;
+ }
+
+ if ((value = propertyValues ["Strikeout"]) != null) {
+ bool strike = (bool) value;
+ if (strike == true)
+ style |= FontStyle.Strikeout;
+ }
+
+ if ((value = propertyValues ["Underline"]) != null) {
+ bool underline = (bool) value;
+ if (underline == true)
+ style |= FontStyle.Underline;
+ }
+
+ /* ?? Should default font be culture dependent ?? */
+ if (name == null)
+ fontFamily = new FontFamily ("Tahoma");
+ else {
+ name = name.ToLower ();
+ FontCollection collection = new InstalledFontCollection ();
+ FontFamily [] installedFontList = collection.Families;
+ foreach (FontFamily font in installedFontList) {
+ if (name == font.Name.ToLower ()) {
+ fontFamily = font;
+ break;
+ }
+ }
+
+ // font family not found in installed fonts
+ if (fontFamily == null) {
+ collection = new PrivateFontCollection ();
+ FontFamily [] privateFontList = collection.Families;
+ foreach (FontFamily font in privateFontList) {
+ if (name == font.Name.ToLower ()) {
+ fontFamily = font;
+ break;
+ }
+ }
+ }
+
+ // font family not found in private fonts also
+ if (fontFamily == null)
+ fontFamily = FontFamily.GenericSansSerif;
+ }
+
+ return new Font (fontFamily, size, style, unit, charSet, vertical);
+ }
+
+ public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ public override PropertyDescriptorCollection GetProperties
+ (ITypeDescriptorContext context,
+ object value, Attribute [] attributes)
+ {
+ if (value is Font)
+ return TypeDescriptor.GetProperties (value, attributes);
+
+ return base.GetProperties (context, value, attributes);
+ }
+
+ public override bool GetPropertiesSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ public sealed class FontNameConverter : TypeConverter
+#if NET_2_0
+ , IDisposable
+#endif
+ {
+ public FontNameConverter ()
+ {
+ }
+#if NET_2_0
+ void IDisposable.Dispose ()
+ {
+
+ }
+#endif
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof (string))
+ return true;
+
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ [MonoTODO]
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool GetStandardValuesExclusive (ITypeDescriptorContext context)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool GetStandardValuesSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+ }
+
+ public class FontUnitConverter : EnumConverter
+ {
+ public FontUnitConverter () : base (typeof (GraphicsUnit))
+ {
+ }
+
+ [MonoTODO]
+ public override TypeConverter.StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/FontFamily.cs b/mcs/class/System.Drawing/System.Drawing/FontFamily.cs
new file mode 100644
index 00000000000..353e5d67ae5
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/FontFamily.cs
@@ -0,0 +1,313 @@
+//
+// System.Drawing.FontFamily.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Alexandre Pigolkine (pigolkine@gmx.de)
+//
+// Copyright (C) 2002/2004 Ximian, Inc http://www.ximian.com
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing.Text;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing {
+
+ public sealed class FontFamily : MarshalByRefObject, IDisposable
+ {
+
+ static private FontFamily genericMonospace = null;
+ static private FontFamily genericSansSerif = null;
+ static private FontFamily genericSerif = null;
+ private string name;
+ internal IntPtr nativeFontFamily = IntPtr.Zero;
+
+ internal FontFamily(IntPtr fntfamily)
+ {
+ nativeFontFamily = fntfamily;
+ refreshName();
+ }
+
+ internal void refreshName()
+ {
+ if (nativeFontFamily != IntPtr.Zero) {
+ int language = 0;
+ IntPtr buffer;
+
+ buffer = Marshal.AllocHGlobal(GDIPlus.FACESIZE * UnicodeEncoding.CharSize);
+ Status status = GDIPlus.GdipGetFamilyName (nativeFontFamily, buffer, language);
+ GDIPlus.CheckStatus (status);
+ name = Marshal.PtrToStringUni(buffer);
+ }
+ }
+
+ //Need to come back here, is Arial the right thing to do
+ internal FontFamily() : this ("Arial", null)
+ {
+
+ }
+
+
+ ~FontFamily()
+ {
+ Dispose ();
+ }
+
+ internal IntPtr NativeObject
+ {
+ get
+ {
+ return nativeFontFamily;
+ }
+ set
+ {
+ nativeFontFamily = value;
+ }
+ }
+
+ public FontFamily(GenericFontFamilies genericFamily)
+ {
+ Status status;
+ switch (genericFamily)
+ {
+ case GenericFontFamilies.Monospace:
+ status = GDIPlus.GdipGetGenericFontFamilyMonospace (out nativeFontFamily);
+ GDIPlus.CheckStatus (status);
+ refreshName ();
+ break;
+ case GenericFontFamilies.SansSerif:
+ status = GDIPlus.GdipGetGenericFontFamilySansSerif (out nativeFontFamily);
+ GDIPlus.CheckStatus (status);
+ refreshName ();
+ break;
+ case GenericFontFamilies.Serif:
+ status = GDIPlus.GdipGetGenericFontFamilySerif (out nativeFontFamily);
+ GDIPlus.CheckStatus (status);
+ refreshName ();
+ break;
+ default: // Undocumented default
+ status = GDIPlus.GdipGetGenericFontFamilyMonospace (out nativeFontFamily);
+ GDIPlus.CheckStatus (status);
+ refreshName ();
+ break;
+ }
+ }
+
+ public FontFamily(string familyName) : this (familyName, null)
+ {
+ }
+
+ public FontFamily (string familyName, FontCollection collection)
+ {
+ Status status;
+ if ( collection != null )
+ status = GDIPlus.GdipCreateFontFamilyFromName (familyName, collection.nativeFontCollection, out nativeFontFamily);
+ else
+ status = GDIPlus.GdipCreateFontFamilyFromName (familyName, IntPtr.Zero, out nativeFontFamily);
+ GDIPlus.CheckStatus (status);
+
+ refreshName ();
+ }
+
+ public string Name
+ {
+ get
+ {
+ return name;
+ }
+ }
+
+ public static FontFamily GenericMonospace
+ {
+ get
+ {
+
+ IntPtr generic = IntPtr.Zero;
+ Status status = GDIPlus.GdipGetGenericFontFamilyMonospace (out generic);
+ GDIPlus.CheckStatus (status);
+ FontFamily genericMonospace = new FontFamily (generic);
+ genericMonospace.refreshName ();
+ return genericMonospace;
+ }
+ }
+
+ public static FontFamily GenericSansSerif
+ {
+ get
+ {
+ IntPtr generic = IntPtr.Zero;
+ Status status = GDIPlus.GdipGetGenericFontFamilySansSerif (out generic);
+ GDIPlus.CheckStatus (status);
+ FontFamily genericSansSerif = new FontFamily (generic);
+ genericSansSerif.refreshName ();
+ return genericSansSerif;
+ }
+ }
+
+ public static FontFamily GenericSerif
+ {
+ get
+ {
+ IntPtr generic = IntPtr.Zero;
+ Status status = GDIPlus.GdipGetGenericFontFamilySerif (out generic);
+ GDIPlus.CheckStatus (status);
+ FontFamily genericSerif = new FontFamily (generic);
+ genericSerif.refreshName ();
+ return genericSerif;
+ }
+ }
+
+ //[MONO TODO]
+ //Need to check how to get the Flags attribute to read
+ //bitwise value of the enumeration
+ internal int GetStyleCheck(FontStyle style)
+ {
+ int styleCheck = 0 ;
+ switch ( style) {
+ case FontStyle.Bold:
+ styleCheck = 1;
+ break;
+ case FontStyle.Italic:
+ styleCheck = 2;
+ break;
+ case FontStyle.Regular:
+ styleCheck = 0;
+ break;
+ case FontStyle.Strikeout:
+ styleCheck = 8;
+ break;
+ case FontStyle.Underline:
+ styleCheck = 4;
+ break;
+ }
+ return styleCheck;
+ }
+
+ public int GetCellAscent (FontStyle style)
+ {
+ Status status;
+ short outProperty;
+ int styleCheck = GetStyleCheck (style);
+ status = GDIPlus.GdipGetCellAscent (nativeFontFamily, styleCheck, out outProperty);
+ GDIPlus.CheckStatus (status);
+
+ return (int) outProperty;
+ }
+
+ public int GetCellDescent (FontStyle style)
+ {
+ Status status;
+ short outProperty;
+ int styleCheck = GetStyleCheck (style);
+ status = GDIPlus.GdipGetCellDescent (nativeFontFamily, styleCheck, out outProperty);
+ GDIPlus.CheckStatus (status);
+
+ return (int) outProperty;
+ }
+
+ public int GetEmHeight (FontStyle style)
+ {
+ Status status;
+ short outProperty;
+ int styleCheck = GetStyleCheck (style);
+ status = GDIPlus.GdipGetEmHeight (nativeFontFamily, styleCheck, out outProperty);
+ GDIPlus.CheckStatus (status);
+
+ return (int) outProperty;
+ }
+
+ public int GetLineSpacing (FontStyle style)
+ {
+ Status status;
+ short outProperty;
+ int styleCheck = GetStyleCheck (style);
+ status = GDIPlus.GdipGetLineSpacing (nativeFontFamily, styleCheck, out outProperty);
+ GDIPlus.CheckStatus (status);
+
+ return (int) outProperty;
+ }
+
+ public bool IsStyleAvailable (FontStyle style)
+ {
+ Status status;
+ bool outProperty;
+ int styleCheck = GetStyleCheck (style);
+ status = GDIPlus.GdipIsStyleAvailable (nativeFontFamily, styleCheck, out outProperty);
+ GDIPlus.CheckStatus (status);
+
+ return outProperty;
+ }
+
+ public void Dispose ()
+ {
+ Status status = GDIPlus.GdipDeleteFontFamily (nativeFontFamily);
+ if ( status == Status.Ok )
+ nativeFontFamily = IntPtr.Zero;
+ GC.SuppressFinalize(this);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (!(obj is FontFamily))
+ return false;
+
+ FontFamily o = (FontFamily) obj;
+ return (nativeFontFamily == o.nativeFontFamily);
+ }
+
+ public override int GetHashCode ()
+ {
+ return name.GetHashCode ();
+ }
+
+
+ public static FontFamily[] Families
+ {
+ get {
+
+ return GetFamilies (null);
+ }
+ }
+
+ public static FontFamily[] GetFamilies (Graphics graphics)
+ {
+ InstalledFontCollection fntcol = new InstalledFontCollection ();
+ return fntcol.Families;
+ }
+
+ [MonoTODO ("We only support the default system language")]
+ public string GetName (int language)
+ {
+ return name;
+ }
+
+ public override string ToString ()
+ {
+ return "FontFamily :" + name;
+ }
+
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing/FontFamily.jvm.cs b/mcs/class/System.Drawing/System.Drawing/FontFamily.jvm.cs
new file mode 100644
index 00000000000..94f322783dd
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/FontFamily.jvm.cs
@@ -0,0 +1,232 @@
+//
+// System.Drawing.FontFamily.cs
+//
+// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+// Author: Konstantin Triger (kostat@mainsoft.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Text;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.Globalization;
+using awt = java.awt;
+using geom = java.awt.geom;
+using font = java.awt.font;
+using TextAttribute = java.awt.font.TextAttribute;
+
+namespace System.Drawing {
+
+ public sealed class FontFamily : MarshalByRefObject, IDisposable {
+
+ static readonly FontFamily _genericMonospace;
+ static readonly FontFamily _genericSansSerif;
+ static readonly FontFamily _genericSerif;
+ static readonly FontCollection _installedFonts;
+ static readonly awt.Container _container = new awt.Container();
+
+ static FontFamily() {
+ _installedFonts = new InstalledFontCollection();
+ _genericMonospace = new FontFamily(GenericFontFamilies.Monospace);
+ _genericSansSerif = new FontFamily(GenericFontFamilies.SansSerif);
+ _genericSerif = new FontFamily(GenericFontFamilies.Serif);
+ }
+
+ private readonly string _name;
+
+ private awt.FontMetrics _fontMetrics = null;
+ private FontStyle _lastStyle = FontStyle.Regular;
+ private readonly awt.Font _font;
+
+ // this is unavailable through Java API, usually 2048 for TT fonts
+ const int UnitsPerEm = 2048;
+ // the margin for text drawing
+ const int DrawMargin = 571;
+
+ #region ctors
+
+ // dummy ctors to work around convertor problems
+ internal FontFamily() {}
+ internal FontFamily(IntPtr family) {}
+
+ static string ToGenericFontName(GenericFontFamilies genericFamily) {
+ switch(genericFamily) {
+ case GenericFontFamilies.SansSerif:
+ return "SansSerif";
+ case GenericFontFamilies.Serif:
+ return "Serif";
+ default:
+ return "Monospaced";
+ }
+ }
+
+ public FontFamily(string familyName) : this(familyName, null) {
+ }
+
+ public FontFamily(string name, FontCollection fontCollection) {
+ if (name == null)
+ throw new ArgumentNullException("name");
+
+ if (fontCollection == null)
+ fontCollection = _installedFonts;
+
+ if (fontCollection.Contains(name))
+ _name = name;
+ else {
+ _name = ToGenericFontName(GenericFontFamilies.SansSerif);
+ fontCollection = _installedFonts;
+ }
+
+ _font = fontCollection.GetInitialFont( _name );
+ }
+
+ public FontFamily(GenericFontFamilies genericFamily) : this(ToGenericFontName(genericFamily)) {
+ }
+
+ #endregion
+
+ public string Name {
+ get {
+ return _name;
+ }
+ }
+
+ internal int GetDrawMargin(FontStyle style) {
+ return DrawMargin;
+ }
+
+ awt.FontMetrics GetMetrics(FontStyle style) {
+ if ((_lastStyle != style) || (_fontMetrics == null)) {
+ java.util.Map attrib = Font.DeriveStyle( FamilyFont.getAttributes(), style, true);
+ attrib.put(TextAttribute.SIZE, new java.lang.Float((float)(UnitsPerEm<<1)));
+ _fontMetrics = _container.getFontMetrics( FamilyFont.deriveFont( attrib ) );
+ }
+ return _fontMetrics;
+ }
+
+ public int GetCellAscent(FontStyle style) {
+ return GetMetrics(style).getMaxAscent()>>1;
+ }
+
+ public int GetCellDescent(FontStyle style) {
+ return GetMetrics(style).getMaxDecent()>>1;
+ }
+
+ public int GetEmHeight(FontStyle style) {
+ return UnitsPerEm;
+ }
+
+ public int GetLineSpacing(FontStyle style) {
+ return GetMetrics(style).getHeight()>>1;
+ }
+
+ public string GetName(int language) {
+ try {
+ CultureInfo culture = new CultureInfo(language, false);
+ java.util.Locale locale = vmw.@internal.EnvironmentUtils.getLocaleFromCultureInfo( culture );
+
+ return FamilyFont.getFamily( locale );
+ }
+ catch {
+ return Name;
+ }
+ }
+
+ public bool IsStyleAvailable(FontStyle style) {
+ //unable to get this infromation from java
+ return true;
+ }
+
+ #region static members
+
+ public static FontFamily[] Families {
+ get {
+ return _installedFonts.Families;
+ }
+ }
+
+ public static FontFamily GenericMonospace {
+ get {
+ return (FontFamily)_genericMonospace.MemberwiseClone();
+ }
+ }
+
+ public static FontFamily GenericSansSerif {
+ get {
+ return (FontFamily)_genericSansSerif.MemberwiseClone();
+ }
+ }
+
+ public static FontFamily GenericSerif {
+ get {
+ return (FontFamily)_genericSerif.MemberwiseClone();
+ }
+ }
+
+ public static FontFamily[] GetFamilies(Graphics graphics) {
+ if (graphics == null) {
+ throw new ArgumentNullException("graphics");
+ }
+ return _installedFonts.Families;
+ }
+
+ #endregion
+
+ #region Object members
+
+ public override bool Equals(object obj) {
+ if (this == obj)
+ return true;
+
+ if (!(obj is FontFamily))
+ return false;
+
+ return string.Compare(Name, ((FontFamily)obj).Name, true) == 0;
+ }
+
+ public override int GetHashCode() {
+ return Name.ToLower().GetHashCode();
+ }
+
+ public override string ToString() {
+ return string.Format("[{0}: Name={1}]", GetType().Name, Name);
+ }
+
+ #endregion
+
+ #region IDisposable Members
+
+ public void Dispose() {
+ }
+
+ #endregion
+
+ internal awt.Font FamilyFont {
+ get {
+ return _font;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing/FontStyle.cs b/mcs/class/System.Drawing/System.Drawing/FontStyle.cs
new file mode 100644
index 00000000000..60bb82f9a62
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/FontStyle.cs
@@ -0,0 +1,44 @@
+//
+// System.Drawing.FontStyle.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+namespace System.Drawing
+{
+ [Flags]
+ [Serializable]
+ public enum FontStyle {
+ Regular = 0,
+ Bold = 1,
+ Italic = 2,
+ Underline = 4,
+ Strikeout = 8
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Graphics.cs b/mcs/class/System.Drawing/System.Drawing/Graphics.cs
new file mode 100644
index 00000000000..bde98b2eba2
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Graphics.cs
@@ -0,0 +1,2448 @@
+//
+// System.Drawing.Graphics.cs
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com) (stubbed out)
+// Alexandre Pigolkine(pigolkine@gmx.de)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+// Copyright (C) 2003 Ximian, Inc. (http://www.ximian.com)
+//
+// Copyright (C) 2004-2005 Novell, Inc. (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Drawing.Text;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using System.Security.Permissions;
+using System.Text;
+
+namespace System.Drawing
+{
+#if !NET_2_0
+ [ComVisible(false)]
+#endif
+ public sealed class Graphics : MarshalByRefObject, IDisposable
+#if NET_2_0
+ , IDeviceContext
+#endif
+ {
+ internal IntPtr nativeObject = IntPtr.Zero;
+ private bool disposed = false;
+ private static float defDpiX = 0;
+ private static float defDpiY = 0;
+
+ [ComVisible(false)]
+ public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
+ int flags,
+ int dataSize,
+ IntPtr data,
+ PlayRecordCallback callbackData);
+
+ [ComVisible (false)]
+ public delegate bool DrawImageAbort (IntPtr callbackData);
+
+ internal Graphics (IntPtr nativeGraphics)
+ {
+ nativeObject = nativeGraphics;
+ }
+
+ ~Graphics ()
+ {
+ Dispose ();
+ }
+
+ static internal float systemDpiX {
+ get {
+ if (defDpiX == 0) {
+ Bitmap bmp = new Bitmap (1, 1);
+ Graphics g = Graphics.FromImage (bmp);
+ defDpiX = g.DpiX;
+ defDpiY = g.DpiY;
+ }
+ return defDpiX;
+ }
+ }
+
+ static internal float systemDpiY {
+ get {
+ if (defDpiY == 0) {
+ Bitmap bmp = new Bitmap (1, 1);
+ Graphics g = Graphics.FromImage (bmp);
+ defDpiX = g.DpiX;
+ defDpiY = g.DpiY;
+ }
+ return defDpiY;
+ }
+ }
+
+ internal IntPtr NativeObject {
+ get {
+ return nativeObject;
+ }
+
+ set {
+ nativeObject = value;
+ }
+ }
+
+ [MonoTODO]
+ public void AddMetafileComment (byte [] data)
+ {
+ throw new NotImplementedException ();
+ }
+
+
+ public GraphicsContainer BeginContainer ()
+ {
+ int state;
+ Status status;
+ status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
+ GDIPlus.CheckStatus (status);
+
+ return new GraphicsContainer(state);
+ }
+
+ public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
+ {
+ int state;
+ Status status;
+ status = GDIPlus.GdipBeginContainerI (nativeObject, dstrect, srcrect, unit, out state);
+ GDIPlus.CheckStatus (status);
+
+ return new GraphicsContainer (state);
+ }
+
+
+ public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
+ {
+ int state;
+ Status status;
+ status = GDIPlus.GdipBeginContainer (nativeObject, dstrect, srcrect, unit, out state);
+ GDIPlus.CheckStatus (status);
+
+ return new GraphicsContainer (state);
+ }
+
+
+ public void Clear (Color color)
+ {
+ Status status;
+ status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ());
+ GDIPlus.CheckStatus (status);
+ }
+#if NET_2_0
+ public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
+ {
+ CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
+ blockRegionSize, CopyPixelOperation.SourceCopy);
+ }
+
+ public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
+ {
+ CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
+ blockRegionSize, copyPixelOperation);
+ }
+
+ public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize)
+ {
+ CopyFromScreen (sourceX, sourceY, destinationX, destinationY, blockRegionSize,
+ CopyPixelOperation.SourceCopy);
+ }
+
+ public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
+ {
+ IntPtr window;
+
+ if (!Enum.IsDefined (typeof (CopyPixelOperation), copyPixelOperation))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for CopyPixelOperation", copyPixelOperation));
+
+ if (GDIPlus.UseCocoaDrawable || GDIPlus.UseQuartzDrawable) {
+ throw new NotImplementedException ();
+ }
+
+ if (GDIPlus.UseX11Drawable) { // X11 implementation
+ IntPtr image, defvisual, vPtr;
+ int AllPlanes = ~0, nitems = 0, pixel;
+
+ if (copyPixelOperation != CopyPixelOperation.SourceCopy)
+ throw new NotImplementedException ("Operation not implemented under X11");
+
+ if (GDIPlus.Display == IntPtr.Zero) {
+ GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
+ }
+
+ window = GDIPlus.XRootWindow (GDIPlus.Display, 0);
+ defvisual = GDIPlus.XDefaultVisual (GDIPlus.Display, 0);
+ XVisualInfo visual = new XVisualInfo ();
+
+ /* Get XVisualInfo for this visual */
+ visual.visualid = GDIPlus.XVisualIDFromVisual(defvisual);
+ vPtr = GDIPlus.XGetVisualInfo (GDIPlus.Display, 0x1 /* VisualIDMask */, ref visual, ref nitems);
+ visual = (XVisualInfo) Marshal.PtrToStructure(vPtr, typeof (XVisualInfo));
+
+ /* Sorry I do not have access to a computer with > deepth. Fell free to add more pixel formats */
+ image = GDIPlus.XGetImage (GDIPlus.Display, window, sourceX, sourceY, blockRegionSize.Width,
+ blockRegionSize.Height, AllPlanes, 2 /* ZPixmap*/);
+
+ Bitmap bmp = new Bitmap (blockRegionSize.Width, blockRegionSize.Height);
+ int red, blue, green;
+ for (int y = sourceY; y < sourceY + blockRegionSize.Height; y++) {
+ for (int x = sourceX; x < sourceX + blockRegionSize.Width; x++) {
+ pixel = GDIPlus.XGetPixel (image, x, y);
+
+ switch (visual.depth) {
+ case 16: /* 16bbp pixel transformation */
+ red = (int) ((pixel & visual.red_mask ) >> 8) & 0xff;
+ green = (int) (((pixel & visual.green_mask ) >> 3 )) & 0xff;
+ blue = (int) ((pixel & visual.blue_mask ) << 3 ) & 0xff;
+ break;
+ case 24:
+ case 32:
+ red = (int) ((pixel & visual.red_mask ) >> 16) & 0xff;
+ green = (int) (((pixel & visual.green_mask ) >> 8 )) & 0xff;
+ blue = (int) ((pixel & visual.blue_mask )) & 0xff;
+ break;
+ default:
+ throw new NotImplementedException ("Deepth not supported right now");
+ }
+
+ bmp.SetPixel (x, y, Color.FromArgb (255, red, green, blue));
+ }
+ }
+
+ DrawImage (bmp, 0, 0);
+ bmp.Dispose ();
+ GDIPlus.XDestroyImage (image);
+ return;
+ }
+
+ // Win32 implementation
+ window = GDIPlus.GetDesktopWindow ();
+ IntPtr srcDC = GDIPlus.GetDC (window);
+ IntPtr dstDC = GetHdc ();
+ GDIPlus.BitBlt (dstDC, destinationX, destinationY, blockRegionSize.Width,
+ blockRegionSize.Height, srcDC, sourceX, sourceY, (int) copyPixelOperation);
+
+ GDIPlus.ReleaseDC (srcDC);
+ ReleaseHdc (dstDC);
+ }
+#endif
+
+ public void Dispose ()
+ {
+ Status status;
+ if (! disposed) {
+ status = GDIPlus.GdipDeleteGraphics (nativeObject);
+ nativeObject = IntPtr.Zero;
+ GDIPlus.CheckStatus (status);
+ disposed = true;
+ }
+ GC.SuppressFinalize(this);
+ }
+
+
+ public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
+ {
+ DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+ }
+
+
+ public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
+ {
+ DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+ }
+
+
+ public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
+ {
+ Status status;
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+
+ status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
+ x, y, width, height, startAngle, sweepAngle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ // Microsoft documentation states that the signature for this member should be
+ // public void DrawArc( Pen pen, int x, int y, int width, int height, int startAngle,
+ // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
+ public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
+ {
+ Status status;
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
+ x, y, width, height, startAngle, sweepAngle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
+ {
+ Status status;
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
+ pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
+ pt3.Y, pt4.X, pt4.Y);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
+ {
+ Status status;
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
+ pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
+ pt3.Y, pt4.X, pt4.Y);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
+ {
+ Status status;
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
+ y1, x2, y2, x3, y3, x4, y4);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawBeziers (Pen pen, Point [] points)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ int length = points.Length;
+ Status status;
+
+ if (length < 3)
+ return;
+
+ for (int i = 0; i < length; i += 3) {
+ Point p1 = points [i];
+ Point p2 = points [i + 1];
+ Point p3 = points [i + 2];
+ Point p4 = points [i + 3];
+
+ status = GDIPlus.GdipDrawBezier (nativeObject,
+ pen.nativeObject,
+ p1.X, p1.Y, p2.X, p2.Y,
+ p3.X, p3.Y, p4.X, p4.Y);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public void DrawBeziers (Pen pen, PointF [] points)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ int length = points.Length;
+ Status status;
+
+ if (length < 3)
+ return;
+
+ for (int i = 0; i < length; i += 3) {
+ PointF p1 = points [i];
+ PointF p2 = points [i + 1];
+ PointF p3 = points [i + 2];
+ PointF p4 = points [i + 3];
+
+ status = GDIPlus.GdipDrawBezier (nativeObject,
+ pen.nativeObject,
+ p1.X, p1.Y, p2.X, p2.Y,
+ p3.X, p3.Y, p4.X, p4.Y);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+
+ public void DrawClosedCurve (Pen pen, PointF [] points)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawClosedCurve (Pen pen, Point [] points)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawCurve (Pen pen, Point [] points)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawCurve (Pen pen, PointF [] points)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawCurve (Pen pen, PointF [] points, float tension)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawCurve (Pen pen, Point [] points, float tension)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
+ points, points.Length, offset,
+ numberOfSegments, 0.5f);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
+ points, points.Length, offset,
+ numberOfSegments, tension);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+
+ Status status;
+ status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
+ points, points.Length, offset,
+ numberOfSegments, tension);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawEllipse (Pen pen, Rectangle rect)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+
+ DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void DrawEllipse (Pen pen, RectangleF rect)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void DrawEllipse (Pen pen, int x, int y, int width, int height)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ Status status;
+ status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawEllipse (Pen pen, float x, float y, float width, float height)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawIcon (Icon icon, Rectangle targetRect)
+ {
+ Image img = icon.ToBitmap ();
+ DrawImage (img, targetRect);
+ }
+
+ public void DrawIcon (Icon icon, int x, int y)
+ {
+ Image img = icon.ToBitmap ();
+ DrawImage (img, x, y);
+ }
+
+ public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
+ {
+ Image img = icon.ToBitmap ();
+ DrawImageUnscaled (img, targetRect);
+ }
+
+ public void DrawImage (Image image, RectangleF rect)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+
+ Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, PointF point)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+
+ Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Point [] destPoints)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ if (destPoints == null)
+ throw new ArgumentNullException ("destPoints");
+
+ Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Point point)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ DrawImage (image, point.X, point.Y);
+ }
+
+
+ public void DrawImage (Image image, Rectangle rect)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ DrawImage (image, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+
+ public void DrawImage (Image image, PointF [] destPoints)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ if (destPoints == null)
+ throw new ArgumentNullException ("destPoints");
+ Status status = GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, int x, int y)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, float x, float y)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
+ destRect.X, destRect.Y, destRect.Width, destRect.Height,
+ srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
+ srcUnit, IntPtr.Zero, null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
+ destRect.X, destRect.Y, destRect.Width, destRect.Height,
+ srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
+ srcUnit, IntPtr.Zero, null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ if (destPoints == null)
+ throw new ArgumentNullException ("destPoints");
+
+ Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
+ destPoints, destPoints.Length , srcRect.X, srcRect.Y,
+ srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
+ null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ if (destPoints == null)
+ throw new ArgumentNullException ("destPoints");
+
+ Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
+ destPoints, destPoints.Length , srcRect.X, srcRect.Y,
+ srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
+ null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
+ ImageAttributes imageAttr)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ if (destPoints == null)
+ throw new ArgumentNullException ("destPoints");
+ Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
+ destPoints, destPoints.Length , srcRect.X, srcRect.Y,
+ srcRect.Width, srcRect.Height, srcUnit,
+ imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawImage (Image image, float x, float y, float width, float height)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
+ width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
+ ImageAttributes imageAttr)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ if (destPoints == null)
+ throw new ArgumentNullException ("destPoints");
+ Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
+ destPoints, destPoints.Length , srcRect.X, srcRect.Y,
+ srcRect.Width, srcRect.Height, srcUnit,
+ imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawImage (Image image, int x, int y, int width, int height)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ if (destPoints == null)
+ throw new ArgumentNullException ("destPoints");
+ Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
+ destPoints, destPoints.Length , srcRect.X, srcRect.Y,
+ srcRect.Width, srcRect.Height, srcUnit,
+ imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ if (destPoints == null)
+ throw new ArgumentNullException ("destPoints");
+
+ Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
+ destPoints, destPoints.Length , srcRect.X, srcRect.Y,
+ srcRect.Width, srcRect.Height, srcUnit,
+ imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ if (destPoints == null)
+ throw new ArgumentNullException ("destPoints");
+
+ Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
+ destPoints, destPoints.Length , srcRect.X, srcRect.Y,
+ srcRect.Width, srcRect.Height, srcUnit,
+ imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
+ destRect.X, destRect.Y, destRect.Width, destRect.Height,
+ srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
+ null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
+ {
+ Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
+ destPoints, destPoints.Length , srcRect.X, srcRect.Y,
+ srcRect.Width, srcRect.Height, srcUnit,
+ imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
+ destRect.X, destRect.Y, destRect.Width, destRect.Height,
+ srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
+ null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
+ destRect.X, destRect.Y, destRect.Width, destRect.Height,
+ srcX, srcY, srcWidth, srcHeight, srcUnit,
+ imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
+ destRect.X, destRect.Y, destRect.Width,
+ destRect.Height, srcX, srcY, srcWidth, srcHeight,
+ srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
+ destRect.X, destRect.Y, destRect.Width,
+ destRect.Height, srcX, srcY, srcWidth, srcHeight,
+ srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback,
+ IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
+ destRect.X, destRect.Y, destRect.Width,
+ destRect.Height, srcX, srcY, srcWidth, srcHeight,
+ srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero,
+ callback, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
+ destRect.X, destRect.Y, destRect.Width, destRect.Height,
+ srcX, srcY, srcWidth, srcHeight, srcUnit,
+ imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
+ destRect.X, destRect.Y, destRect.Width, destRect.Height,
+ srcX, srcY, srcWidth, srcHeight, srcUnit,
+ imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawImageUnscaled (Image image, Point point)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ DrawImageUnscaled (image, point.X, point.Y);
+ }
+
+ public void DrawImageUnscaled (Image image, Rectangle rect)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void DrawImageUnscaled (Image image, int x, int y)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ DrawImage (image, x, y, image.Width, image.Height);
+ }
+
+ public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
+ {
+ if (image == null)
+ throw new ArgumentNullException ("image");
+ Image tmpImg = new Bitmap (width, height);
+ Graphics g = FromImage (tmpImg);
+ g.DrawImage (image, 0, 0, image.Width, image.Height);
+ this.DrawImage (tmpImg, x, y, width, height);
+ tmpImg.Dispose ();
+ g.Dispose ();
+ }
+
+#if NET_2_0
+ public void DrawImageUnscaledAndClipped (Image image, Rectangle rect)
+ {
+ int height, width;
+ width = (image.Width > rect.Width) ? rect.Width : image.Width;
+ height = (image.Height > rect.Height) ? rect.Height : image.Height;
+
+ DrawImageUnscaled (image, rect.X, rect.Y, width, height);
+ }
+#endif
+
+ public void DrawLine (Pen pen, PointF pt1, PointF pt2)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
+ pt1.X, pt1.Y, pt2.X, pt2.Y);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawLine (Pen pen, Point pt1, Point pt2)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
+ pt1.X, pt1.Y, pt2.X, pt2.Y);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawLines (Pen pen, PointF [] points)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawLines (Pen pen, Point [] points)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawPath (Pen pen, GraphicsPath path)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (path == null)
+ throw new ArgumentNullException ("path");
+ Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+ }
+
+ public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+ }
+
+ public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ // Microsoft documentation states that the signature for this member should be
+ // public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle
+ // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
+ public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawPolygon (Pen pen, Point [] points)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawPolygon (Pen pen, PointF [] points)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ internal void DrawRectangle (Pen pen, RectangleF rect)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
+ }
+
+ public void DrawRectangle (Pen pen, Rectangle rect)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
+ }
+
+ public void DrawRectangle (Pen pen, float x, float y, float width, float height)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawRectangle (Pen pen, int x, int y, int width, int height)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("pen");
+ Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawRectangles (Pen pen, RectangleF [] rects)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("image");
+ if (rects == null)
+ throw new ArgumentNullException ("rects");
+ Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawRectangles (Pen pen, Rectangle [] rects)
+ {
+ if (pen == null)
+ throw new ArgumentNullException ("image");
+ if (rects == null)
+ throw new ArgumentNullException ("rects");
+ Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
+ {
+ DrawString (s, font, brush, layoutRectangle, null);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, PointF point)
+ {
+ DrawString (s, font, brush, new RectangleF (point.X, point.Y, 0, 0), null);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
+ {
+ DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, float x, float y)
+ {
+ DrawString (s, font, brush, new RectangleF (x, y, 0, 0), null);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
+ {
+ DrawString (s, font, brush, new RectangleF(x, y, 0, 0), format);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
+ {
+ if (font == null)
+ throw new ArgumentNullException ("font");
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (s == null || s.Length == 0)
+ return;
+
+ Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void EndContainer (GraphicsContainer container)
+ {
+ if (container == null)
+ throw new ArgumentNullException ("container");
+ Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void ExcludeClip (Rectangle rect)
+ {
+ Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ExcludeClip (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException ("region");
+ Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void FillClosedCurve (Brush brush, PointF [] points)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void FillClosedCurve (Brush brush, Point [] points)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ FillClosedCurve (brush, points, fillmode, 0.5f);
+ }
+
+ public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ FillClosedCurve (brush, points, fillmode, 0.5f);
+ }
+
+ public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillEllipse (Brush brush, Rectangle rect)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void FillEllipse (Brush brush, RectangleF rect)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void FillEllipse (Brush brush, float x, float y, float width, float height)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillEllipse (Brush brush, int x, int y, int width, int height)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillPath (Brush brush, GraphicsPath path)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (path == null)
+ throw new ArgumentNullException ("path");
+ Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillPolygon (Brush brush, PointF [] points)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillPolygon (Brush brush, Point [] points)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (points == null)
+ throw new ArgumentNullException ("points");
+ Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillRectangle (Brush brush, RectangleF rect)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
+ }
+
+ public void FillRectangle (Brush brush, Rectangle rect)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
+ }
+
+ public void FillRectangle (Brush brush, int x, int y, int width, int height)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+
+ Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillRectangle (Brush brush, float x, float y, float width, float height)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+
+ Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillRectangles (Brush brush, Rectangle [] rects)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+
+ Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void FillRectangles (Brush brush, RectangleF [] rects)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+
+ Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void FillRegion (Brush brush, Region region)
+ {
+ if (brush == null)
+ throw new ArgumentNullException ("brush");
+ if (region == null)
+ throw new ArgumentNullException ("region");
+
+ Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);
+ GDIPlus.CheckStatus(status);
+ }
+
+
+ public void Flush ()
+ {
+ Flush (FlushIntention.Flush);
+ }
+
+
+ public void Flush (FlushIntention intention)
+ {
+ if (nativeObject == IntPtr.Zero) {
+ return;
+ }
+
+ Status status = GDIPlus.GdipFlush (nativeObject, intention);
+ GDIPlus.CheckStatus (status);
+ if (GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable)
+ Carbon.CGContextSynchronize (GDIPlus.Display);
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public static Graphics FromHdc (IntPtr hdc)
+ {
+ IntPtr graphics;
+ Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
+ GDIPlus.CheckStatus (status);
+ return new Graphics (graphics);
+ }
+
+ [MonoTODO]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
+ public static Graphics FromHdcInternal (IntPtr hdc)
+ {
+ GDIPlus.Display = hdc;
+ return null;
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public static Graphics FromHwnd (IntPtr hwnd)
+ {
+ IntPtr graphics;
+
+ if (GDIPlus.UseCocoaDrawable) {
+ CarbonContext cgContext = Carbon.GetCGContextForNSView (hwnd);
+ GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
+
+ GDIPlus.Display = cgContext.ctx;
+ return new Graphics (graphics);
+ }
+ if (GDIPlus.UseQuartzDrawable) {
+ CarbonContext cgContext = Carbon.GetCGContextForView (hwnd);
+ GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
+
+ GDIPlus.Display = cgContext.ctx;
+ return new Graphics (graphics);
+ }
+ if (GDIPlus.UseX11Drawable) {
+ if (GDIPlus.Display == IntPtr.Zero) {
+ GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
+ }
+
+ return FromXDrawable (hwnd, GDIPlus.Display);
+
+ }
+
+ Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
+ GDIPlus.CheckStatus (status);
+
+ return new Graphics (graphics);
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
+ public static Graphics FromHwndInternal (IntPtr hwnd)
+ {
+ return FromHwnd (hwnd);
+ }
+
+ public static Graphics FromImage (Image image)
+ {
+ IntPtr graphics;
+
+ if (image == null)
+ throw new ArgumentNullException ("image");
+
+ Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
+ GDIPlus.CheckStatus (status);
+ Graphics result = new Graphics (graphics);
+
+ // check for Unix platforms - see FAQ for more details
+ // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
+ int platform = (int) Environment.OSVersion.Platform;
+ if ((platform == 4) || (platform == 128)) {
+ Rectangle rect = new Rectangle (0,0, image.Width, image.Height);
+ GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
+ }
+
+ return result;
+ }
+
+ internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
+ {
+ IntPtr graphics;
+
+ Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
+ GDIPlus.CheckStatus (s);
+ return new Graphics (graphics);
+ }
+
+ [MonoTODO]
+ public static IntPtr GetHalftonePalette ()
+ {
+ throw new NotImplementedException ();
+ }
+
+#if !NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
+ public IntPtr GetHdc ()
+ {
+ IntPtr hdc;
+ GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out hdc));
+ return hdc;
+ }
+
+
+ public Color GetNearestColor (Color color)
+ {
+ int argb;
+
+ Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
+ GDIPlus.CheckStatus (status);
+
+ return Color.FromArgb (argb);
+ }
+
+
+ public void IntersectClip (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException ("region");
+ Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void IntersectClip (RectangleF rect)
+ {
+ Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void IntersectClip (Rectangle rect)
+ {
+ Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public bool IsVisible (Point point)
+ {
+ bool isVisible = false;
+
+ Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
+ GDIPlus.CheckStatus (status);
+
+ return isVisible;
+ }
+
+
+ public bool IsVisible (RectangleF rect)
+ {
+ bool isVisible = false;
+
+ Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
+ GDIPlus.CheckStatus (status);
+
+ return isVisible;
+ }
+
+ public bool IsVisible (PointF point)
+ {
+ bool isVisible = false;
+
+ Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
+ GDIPlus.CheckStatus (status);
+
+ return isVisible;
+ }
+
+ public bool IsVisible (Rectangle rect)
+ {
+ bool isVisible = false;
+
+ Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
+ GDIPlus.CheckStatus (status);
+
+ return isVisible;
+ }
+
+ public bool IsVisible (float x, float y)
+ {
+ return IsVisible (new PointF (x, y));
+ }
+
+ public bool IsVisible (int x, int y)
+ {
+ return IsVisible (new Point (x, y));
+ }
+
+ public bool IsVisible (float x, float y, float width, float height)
+ {
+ return IsVisible (new RectangleF (x, y, width, height));
+ }
+
+
+ public bool IsVisible (int x, int y, int width, int height)
+ {
+ return IsVisible (new Rectangle (x, y, width, height));
+ }
+
+
+ public Region [] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
+ {
+ Status status;
+ int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
+ IntPtr[] native_regions = new IntPtr [regcount];
+ Region[] regions = new Region [regcount];
+
+ for (int i = 0; i < regcount; i++) {
+ regions[i] = new Region ();
+ native_regions[i] = regions[i].NativeObject;
+ }
+
+ status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
+ font.NativeObject, ref layoutRect, stringFormat.NativeObject,
+ regcount, out native_regions[0]);
+
+ GDIPlus.CheckStatus (status);
+
+ return regions;
+ }
+
+
+ public SizeF MeasureString (string text, Font font)
+ {
+ return MeasureString (text, font, new Size (0, 0));
+ }
+
+
+ public SizeF MeasureString (string text, Font font, SizeF layoutArea)
+ {
+ int charactersFitted, linesFilled;
+ RectangleF boundingBox = new RectangleF ();
+ RectangleF rect = new RectangleF (0, 0, layoutArea.Width,
+ layoutArea.Height);
+
+ if (text == null || text.Length == 0)
+ return SizeF.Empty;
+
+ if (font == null)
+ throw new ArgumentNullException ("font");
+
+ Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
+ font.NativeObject, ref rect,
+ IntPtr.Zero, out boundingBox,
+ out charactersFitted, out linesFilled);
+ GDIPlus.CheckStatus (status);
+
+ return new SizeF (boundingBox.Width, boundingBox.Height);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, int width)
+ {
+ RectangleF boundingBox = new RectangleF ();
+ RectangleF rect = new RectangleF (0, 0, width, 999999);
+ int charactersFitted, linesFilled;
+
+ if (text == null || text.Length == 0)
+ return SizeF.Empty;
+
+ if (font == null)
+ throw new ArgumentNullException ("font");
+
+ Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
+ font.NativeObject, ref rect,
+ IntPtr.Zero, out boundingBox,
+ out charactersFitted, out linesFilled);
+ GDIPlus.CheckStatus (status);
+
+ return new SizeF (boundingBox.Width, boundingBox.Height);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, SizeF layoutArea,
+ StringFormat stringFormat)
+ {
+ int charactersFitted, linesFilled;
+ return MeasureString (text, font, layoutArea, stringFormat,
+ out charactersFitted, out linesFilled);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, int width, StringFormat format)
+ {
+ int charactersFitted, linesFilled;
+ return MeasureString (text, font, new SizeF (width, 999999),
+ format, out charactersFitted, out linesFilled);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, PointF origin,
+ StringFormat stringFormat)
+ {
+ RectangleF boundingBox = new RectangleF ();
+ RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
+ int charactersFitted, linesFilled;
+
+ if (text == null || text.Length == 0)
+ return SizeF.Empty;
+
+ if (font == null)
+ throw new ArgumentNullException ("font");
+
+ if (stringFormat == null)
+ stringFormat = new StringFormat ();
+
+ Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
+ font.NativeObject, ref rect,
+ stringFormat.NativeObject,
+ out boundingBox,
+ out charactersFitted,
+ out linesFilled);
+ GDIPlus.CheckStatus (status);
+
+ return new SizeF (boundingBox.Width, boundingBox.Height);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, SizeF layoutArea,
+ StringFormat stringFormat, out int charactersFitted,
+ out int linesFilled)
+ {
+ RectangleF boundingBox = new RectangleF ();
+ RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
+ charactersFitted = 0;
+ linesFilled = 0;
+
+ if (text == null || text.Length == 0)
+ return SizeF.Empty;
+
+ if (font == null)
+ throw new ArgumentNullException ("font");
+
+ if (stringFormat == null)
+ stringFormat = new StringFormat ();
+
+ Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
+ font.NativeObject, ref rect,
+ stringFormat.NativeObject,
+ out boundingBox,
+ out charactersFitted,
+ out linesFilled);
+ GDIPlus.CheckStatus (status);
+
+ return new SizeF (boundingBox.Width, boundingBox.Height);
+ }
+
+ public void MultiplyTransform (Matrix matrix)
+ {
+ MultiplyTransform (matrix, MatrixOrder.Prepend);
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject,
+ matrix.nativeMatrix,
+ order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public void ReleaseHdc (IntPtr hdc)
+ {
+ Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
+ GDIPlus.CheckStatus (status);
+ }
+#if NET_2_0
+ public void ReleaseHdc()
+ {
+
+ }
+#endif
+ [MonoTODO]
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Never)]
+#else
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
+ [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
+ public void ReleaseHdcInternal (IntPtr hdc)
+ {
+ throw new NotImplementedException ();
+ }
+
+
+ public void ResetClip ()
+ {
+ Status status = GDIPlus.GdipResetClip (nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ResetTransform ()
+ {
+ Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Restore (GraphicsState gstate)
+ {
+ Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void RotateTransform (float angle)
+ {
+ RotateTransform (angle, MatrixOrder.Prepend);
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order)
+ {
+
+ Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public GraphicsState Save ()
+ {
+ uint saveState;
+ Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
+ GDIPlus.CheckStatus (status);
+
+ GraphicsState state = new GraphicsState ();
+ state.nativeState = saveState;
+ return state;
+ }
+
+ public void ScaleTransform (float sx, float sy)
+ {
+ ScaleTransform (sx, sy, MatrixOrder.Prepend);
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void SetClip (RectangleF rect)
+ {
+ SetClip (rect, CombineMode.Replace);
+ }
+
+
+ public void SetClip (GraphicsPath path)
+ {
+ SetClip (path, CombineMode.Replace);
+ }
+
+
+ public void SetClip (Rectangle rect)
+ {
+ SetClip (rect, CombineMode.Replace);
+ }
+
+
+ public void SetClip (Graphics g)
+ {
+ SetClip (g, CombineMode.Replace);
+ }
+
+
+ public void SetClip (Graphics g, CombineMode combineMode)
+ {
+ if (g == null)
+ throw new ArgumentNullException ("g");
+
+ Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void SetClip (Rectangle rect, CombineMode combineMode)
+ {
+ Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void SetClip (RectangleF rect, CombineMode combineMode)
+ {
+ Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void SetClip (Region region, CombineMode combineMode)
+ {
+ if (region == null)
+ throw new ArgumentNullException ("region");
+ Status status = GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void SetClip (GraphicsPath path, CombineMode combineMode)
+ {
+ if (path == null)
+ throw new ArgumentNullException ("path");
+ Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
+ {
+ if (pts == null)
+ throw new ArgumentNullException ("pts");
+
+ IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
+
+ Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
+ GDIPlus.CheckStatus (status);
+
+ GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
+ }
+
+
+ public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
+ {
+ if (pts == null)
+ throw new ArgumentNullException ("pts");
+ IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
+
+ Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
+ GDIPlus.CheckStatus (status);
+
+ GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
+ }
+
+
+ public void TranslateClip (int dx, int dy)
+ {
+ Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void TranslateClip (float dx, float dy)
+ {
+ Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TranslateTransform (float dx, float dy)
+ {
+ TranslateTransform (dx, dy, MatrixOrder.Prepend);
+ }
+
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Region Clip {
+ get {
+ Region reg = new Region();
+ Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
+ GDIPlus.CheckStatus (status);
+ return reg;
+ }
+ set {
+ SetClip (value, CombineMode.Replace);
+ }
+ }
+
+ public RectangleF ClipBounds {
+ get {
+ RectangleF rect = new RectangleF ();
+ Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
+ GDIPlus.CheckStatus (status);
+ return rect;
+ }
+ }
+
+ public CompositingMode CompositingMode {
+ get {
+ CompositingMode mode;
+ Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
+ GDIPlus.CheckStatus (status);
+
+ return mode;
+ }
+ set {
+ Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+
+ }
+
+ public CompositingQuality CompositingQuality {
+ get {
+ CompositingQuality quality;
+
+ Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
+ GDIPlus.CheckStatus (status);
+ return quality;
+ }
+ set {
+ Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public float DpiX {
+ get {
+ float x;
+
+ Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
+ GDIPlus.CheckStatus (status);
+ return x;
+ }
+ }
+
+ public float DpiY {
+ get {
+ float y;
+
+ Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
+ GDIPlus.CheckStatus (status);
+ return y;
+ }
+ }
+
+ public InterpolationMode InterpolationMode {
+ get {
+ InterpolationMode imode = InterpolationMode.Invalid;
+ Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
+ GDIPlus.CheckStatus (status);
+ return imode;
+ }
+ set {
+ Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public bool IsClipEmpty {
+ get {
+ bool isEmpty = false;
+
+ Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
+ GDIPlus.CheckStatus (status);
+ return isEmpty;
+ }
+ }
+
+ public bool IsVisibleClipEmpty {
+ get {
+ bool isEmpty = false;
+
+ Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
+ GDIPlus.CheckStatus (status);
+ return isEmpty;
+ }
+ }
+
+ public float PageScale {
+ get {
+ float scale;
+
+ Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
+ GDIPlus.CheckStatus (status);
+ return scale;
+ }
+ set {
+ Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public GraphicsUnit PageUnit {
+ get {
+ GraphicsUnit unit;
+
+ Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
+ GDIPlus.CheckStatus (status);
+ return unit;
+ }
+ set {
+ Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public PixelOffsetMode PixelOffsetMode {
+ get {
+ PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
+
+ Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
+ GDIPlus.CheckStatus (status);
+ return pixelOffset;
+ }
+ set {
+ Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public Point RenderingOrigin {
+ get {
+ int x, y;
+ Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
+ GDIPlus.CheckStatus (status);
+ return new Point (x, y);
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public SmoothingMode SmoothingMode {
+ get {
+ SmoothingMode mode = SmoothingMode.Invalid;
+
+ Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
+ GDIPlus.CheckStatus (status);
+ return mode;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public int TextContrast {
+ get {
+ int contrast;
+
+ Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
+ GDIPlus.CheckStatus (status);
+ return contrast;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public TextRenderingHint TextRenderingHint {
+ get {
+ TextRenderingHint hint;
+
+ Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
+ GDIPlus.CheckStatus (status);
+ return hint;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public Matrix Transform {
+ get {
+ Matrix matrix = new Matrix ();
+ Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ return matrix;
+ }
+ set {
+ if (value == null)
+ throw new ArgumentNullException ("value");
+
+ Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public RectangleF VisibleClipBounds {
+ get {
+ RectangleF rect;
+
+ Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
+ GDIPlus.CheckStatus (status);
+ return rect;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing/Graphics.jvm.cs b/mcs/class/System.Drawing/System.Drawing/Graphics.jvm.cs
new file mode 100755
index 00000000000..95974324a17
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Graphics.jvm.cs
@@ -0,0 +1,2564 @@
+using System;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Drawing.Text;
+using System.ComponentModel;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Text;
+using awt = java.awt;
+using geom = java.awt.geom;
+
+namespace System.Drawing {
+ [ComVisible(false)]
+ public sealed class Graphics : MarshalByRefObject, IDisposable {
+ sealed class DummyStroke : awt.Stroke {
+ #region Stroke Members
+
+ awt.Shape awt.Stroke.createStrokedShape(awt.Shape arg_0) {
+ throw new NotImplementedException("DummyStroke");
+ }
+
+ #endregion
+ }
+
+ sealed class NormalizingPathIterator : geom.PathIterator {
+
+ #region fields
+
+ readonly geom.PathIterator _iter;
+
+ const float norm = 0.5f;
+ const float rnd = (1.0f - norm);
+ float ax = 0.0f;
+ float ay = 0.0f;
+
+ #endregion
+
+ #region ctor
+
+ public NormalizingPathIterator(geom.PathIterator iter) {
+ _iter = iter;
+ }
+
+ #endregion
+
+ #region methods
+
+ static int GetIndex(int type) {
+ int index;
+ switch ((GraphicsPath.JPI)type) {
+ case GraphicsPath.JPI.SEG_CUBICTO:
+ index = 4;
+ break;
+ case GraphicsPath.JPI.SEG_QUADTO:
+ index = 2;
+ break;
+ case GraphicsPath.JPI.SEG_MOVETO:
+ case GraphicsPath.JPI.SEG_LINETO:
+ index = 0;
+ break;
+ case GraphicsPath.JPI.SEG_CLOSE:
+ default:
+ index = -1;
+ break;
+ }
+
+ return index;
+ }
+
+ #endregion
+
+ #region PathIterator Members
+
+ void geom.PathIterator.next() {
+ _iter.next();
+ }
+
+ bool geom.PathIterator.isDone() {
+ return _iter.isDone();
+ }
+
+ int geom.PathIterator.currentSegment(float[] point) {
+ int type = _iter.currentSegment(point);
+
+ int index = GetIndex(type);
+
+ if (index >= 0) {
+ float ox = point[index];
+ float oy = point[index+1];
+ float newax = (float) java.lang.Math.floor(ox + rnd) + norm;
+ float neway = (float) java.lang.Math.floor(oy + rnd) + norm;
+ point[index] = newax;
+ point[index+1] = neway;
+ newax -= ox;
+ neway -= oy;
+ switch ((GraphicsPath.JPI)type) {
+ case GraphicsPath.JPI.SEG_CUBICTO:
+ point[0] += ax;
+ point[1] += ay;
+ point[2] += newax;
+ point[3] += neway;
+ break;
+ case GraphicsPath.JPI.SEG_QUADTO:
+ point[0] += (newax + ax) / 2;
+ point[1] += (neway + ay) / 2;
+ break;
+ // case GraphicsPath.JPI.SEG_MOVETO:
+ // case GraphicsPath.JPI.SEG_LINETO:
+ // case GraphicsPath.JPI.SEG_CLOSE:
+ // break;
+ }
+ ax = newax;
+ ay = neway;
+ }
+
+ return type;
+ }
+
+ int geom.PathIterator.currentSegment(double[] point) {
+ int type = _iter.currentSegment(point);
+
+ int index = GetIndex(type);
+
+ if (index >= 0) {
+ float ox = (float)point[index];
+ float oy = (float)point[index+1];
+ float newax = (float)java.lang.Math.floor(ox + rnd) + norm;
+ float neway = (float)java.lang.Math.floor(oy + rnd) + norm;
+ point[index] = newax;
+ point[index+1] = neway;
+ newax -= ox;
+ neway -= oy;
+ switch ((GraphicsPath.JPI)type) {
+ case GraphicsPath.JPI.SEG_CUBICTO:
+ point[0] += ax;
+ point[1] += ay;
+ point[2] += newax;
+ point[3] += neway;
+ break;
+ case GraphicsPath.JPI.SEG_QUADTO:
+ point[0] += (newax + ax) / 2;
+ point[1] += (neway + ay) / 2;
+ break;
+ // case GraphicsPath.JPI.SEG_MOVETO:
+ // case GraphicsPath.JPI.SEG_LINETO:
+ // case GraphicsPath.JPI.SEG_CLOSE:
+ // break;
+ }
+ ax = newax;
+ ay = neway;
+ }
+
+ return type;
+ }
+
+ int geom.PathIterator.getWindingRule() {
+ return _iter.getWindingRule();
+ }
+
+ #endregion
+
+ }
+
+
+ #region Variables
+
+ readonly awt.Graphics2D _nativeObject;
+ PixelOffsetMode _pixelOffsetMode = PixelOffsetMode.Default;
+ int _textContrast = 4;
+ TextRenderingHint _textRenderingHint;
+ readonly Image _image;
+
+ readonly Matrix _transform;
+ GraphicsUnit _pageUnit = GraphicsUnit.Display;
+ float _pageScale = 1.0f;
+
+ readonly Region _clip;
+ readonly awt.Rectangle _windowRect;
+
+ GraphicsState _nextGraphicsState = null;
+
+ static readonly float [] _unitConversion = {
+ 1, // World
+ 1, // Display
+ 1, // Pixel
+ DefaultScreenResolution / 72.0f, // Point
+ DefaultScreenResolution, // Inch
+ DefaultScreenResolution / 300.0f,// Document
+ DefaultScreenResolution / 25.4f // Millimeter
+ };
+
+ static int _isHeadless;
+ static internal bool IsHeadless {
+ get {
+ if (_isHeadless == 0) {
+ bool isHeadless = awt.GraphicsEnvironment.isHeadless();
+ if (!isHeadless) {
+ try {
+ awt.Toolkit.getDefaultToolkit();
+ }
+ catch{
+ isHeadless = true;
+ }
+ }
+
+ _isHeadless = isHeadless ? 2 : 1;
+ }
+
+ return _isHeadless > 1;
+ }
+ }
+
+ #endregion
+
+#if INTPTR_SUPPORT
+ [ComVisible(false)]
+ public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
+ int flags,
+ int dataSize,
+ IntPtr data,
+ PlayRecordCallback callbackData);
+ [ComVisible (false)]
+ public delegate bool DrawImageAbort (IntPtr callbackData);
+#endif
+
+ #region Constr. and Destr.
+ private Graphics (Image image) {
+ _nativeObject = (awt.Graphics2D)image.NativeObject.CurrentImage.NativeImage.getGraphics();
+ _image = image;
+ _transform = new Matrix ();
+
+ NativeObject.setStroke(new DummyStroke());
+ NativeObject.setRenderingHint(awt.RenderingHints.KEY_COLOR_RENDERING, awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+
+ InterpolationMode = InterpolationMode.Bilinear;
+ TextRenderingHint = TextRenderingHint.SystemDefault;
+
+ _windowRect = new awt.Rectangle(_image.Width, _image.Height);
+ _clip = new Region();
+ }
+
+ #endregion
+
+ #region Internal Accessors
+
+ static internal float [] UnitConversion {
+ get {
+ return _unitConversion;
+ }
+ }
+
+ static internal int DefaultScreenResolution {
+ get {
+ return IsHeadless ? 96 :
+ awt.Toolkit.getDefaultToolkit().getScreenResolution();
+ }
+ }
+
+ internal java.awt.Graphics2D NativeObject {
+ get {
+ return _nativeObject;
+ }
+ }
+ #endregion
+
+ #region FromImage (static accessor)
+ public static Graphics FromImage (Image image) {
+ return new Graphics(image);
+ }
+ #endregion
+
+
+ #region Workers [INTERNAL]
+ void DrawShape(Pen pen, awt.Shape shape) {
+ if (pen == null)
+ throw new ArgumentNullException("pen");
+
+ if (StrokeFactory.CanCreateAdvancedStroke &&
+ (!pen.CanCreateBasicStroke || !NeedsNormalization)) {
+ geom.AffineTransform oldT = NativeObject.getTransform();
+ NativeObject.setTransform(Matrix.IdentityTransform.NativeObject);
+
+ try {
+ geom.AffineTransform t = GetFinalTransform();
+ if (!oldT.isIdentity()) {
+ t = (geom.AffineTransform)t.clone();
+ t.preConcatenate(oldT);
+ }
+
+ double widthsquared = pen.GetSquaredTransformedWidth(t);
+
+ bool antiAlias = (SmoothingMode == SmoothingMode.AntiAlias);
+
+ bool thin = (widthsquared <= (antiAlias ?
+ AdvancedStroke.MinPenSizeAASquared :
+ AdvancedStroke.MinPenSizeSquared));
+
+ PenFit penFit = thin ? (antiAlias ? PenFit.ThinAntiAlias : PenFit.Thin) : PenFit.NotThin;
+
+ if (NeedsNormalization) {
+
+ bool normThin =
+ widthsquared <= AdvancedStroke.MinPenSizeSquaredNorm;
+
+ if (normThin) {
+ shape = GetNormalizedShape(shape, t);
+ shape = pen.GetNativeObject(
+ t, null, penFit).createStrokedShape(shape);
+ }
+ else {
+ shape = pen.GetNativeObject(t, penFit).createStrokedShape(shape);
+ shape = GetNormalizedShape(shape, null);
+ }
+ }
+ else {
+ shape = pen.GetNativeObject(t, penFit).createStrokedShape(shape);
+ }
+
+ FillScaledShape(pen.Brush, shape);
+ }
+ finally {
+ NativeObject.setTransform(oldT);
+ }
+ }
+ else {
+ awt.Stroke oldStroke = NativeObject.getStroke();
+ NativeObject.setStroke(pen.GetNativeObject(null, PenFit.NotThin));
+ try {
+
+ NativeObject.setPaint(pen.Brush);
+
+ geom.AffineTransform oldT = NativeObject.getTransform();
+ NativeObject.transform(GetFinalTransform());
+ try {
+ NativeObject.draw(shape);
+ }
+ finally {
+ NativeObject.setTransform(oldT);
+ }
+ }
+ finally {
+ NativeObject.setStroke(oldStroke);
+ }
+ }
+ }
+ void FillShape(Brush paint, awt.Shape shape) {
+ if (paint == null)
+ throw new ArgumentNullException("brush");
+
+ geom.AffineTransform oldT = null;
+ if (NeedsNormalization) {
+ oldT = NativeObject.getTransform();
+ geom.AffineTransform t = GetFinalTransform();
+ if (!oldT.isIdentity()) {
+ t = (geom.AffineTransform)t.clone();
+ t.preConcatenate(oldT);
+ }
+ shape = GetNormalizedShape(shape, t);
+ }
+ else {
+ geom.AffineTransform t = GetFinalTransform();
+ if (!t.isIdentity())
+ shape = t.createTransformedShape(shape);
+ }
+
+ if (oldT != null)
+ NativeObject.setTransform(Matrix.IdentityTransform.NativeObject);
+
+ try {
+ FillScaledShape(paint, shape);
+ }
+ finally {
+ if (oldT != null)
+ NativeObject.setTransform(oldT);
+ }
+ }
+
+ bool NeedsNormalization {
+ get {
+ return PixelOffsetMode != PixelOffsetMode.Half &&
+ PixelOffsetMode != PixelOffsetMode.HighQuality;
+ }
+ }
+
+ static awt.Shape GetNormalizedShape(awt.Shape shape, geom.AffineTransform t) {
+ geom.PathIterator iter = new NormalizingPathIterator(shape.getPathIterator(t));
+
+ geom.GeneralPath path = new geom.GeneralPath(iter.getWindingRule());
+ path.append(iter, false);
+ return path;
+ }
+
+ void FillScaledShape(Brush paint, awt.Shape shape) {
+ Matrix m = null;
+ if (!(paint is SolidBrush || paint is HatchBrush) && !_transform.IsIdentity) {
+ m = paint.BrushTransform;
+ paint.BrushMultiplyTransform( _transform );
+ }
+
+ try {
+ NativeObject.setPaint(paint);
+ NativeObject.fill(shape);
+ }
+ finally {
+ if (m != null)
+ paint.BrushTransform = m;
+ }
+ }
+
+ #endregion
+
+ #region Dispose
+ public void Dispose() {
+ NativeObject.dispose();
+ }
+ #endregion
+
+ #region Clear
+ public void Clear (Color color) {
+ FillScaledShape(new SolidBrush( color ), _clip.NativeObject);
+ }
+ #endregion
+
+ #region DrawArc
+ public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle) {
+ DrawArc (pen,
+ rect.X,
+ rect.Y,
+ rect.Width,
+ rect.Height,
+ startAngle,
+ sweepAngle);
+ }
+
+
+ public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle) {
+ DrawArc (pen,
+ rect.X,
+ rect.Y,
+ rect.Width,
+ rect.Height,
+ startAngle,
+ sweepAngle);
+ }
+
+ public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle) {
+ DrawArc(pen,
+ (float)x,
+ (float)y,
+ (float)width,
+ (float)height,
+ (float)startAngle,
+ (float)sweepAngle);
+ }
+
+ public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddArc(x, y, width, height, startAngle, sweepAngle);
+ DrawPath(pen, path);
+ }
+ #endregion
+
+ #region DrawBezier(s)
+ public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4) {
+ DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
+ }
+
+ public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4) {
+ DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
+ }
+
+ public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
+ geom.GeneralPath path = new geom.GeneralPath();
+ path.moveTo(x1,y1);
+ path.curveTo(x2,y2,x3,y3,x4,y4);
+ DrawShape(pen, path);
+ }
+
+ public void DrawBeziers (Pen pen, Point [] points) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddBeziers(points);
+ DrawPath(pen, path);
+ }
+
+ public void DrawBeziers (Pen pen, PointF [] points) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddBeziers(points);
+ DrawPath(pen, path);
+ }
+ #endregion
+
+ #region DrawClosedCurve
+ public void DrawClosedCurve (Pen pen, PointF [] points) {
+ DrawClosedCurve(pen, points, 0.5f, FillMode.Alternate);
+ }
+
+ public void DrawClosedCurve (Pen pen, Point [] points) {
+ DrawClosedCurve(pen, points, 0.5f, FillMode.Alternate);
+ }
+
+ public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode) {
+ GraphicsPath path = new GraphicsPath(fillmode);
+ path.AddClosedCurve(points, tension);
+ DrawPath(pen, path);
+ }
+
+ public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode) {
+ GraphicsPath path = new GraphicsPath(fillmode);
+ path.AddClosedCurve(points, tension);
+ DrawPath(pen, path);
+ }
+ #endregion
+
+ #region DrawCurve
+ public void DrawCurve (Pen pen, Point [] points) {
+ DrawCurve(pen, points, 0.5f);
+ }
+
+ public void DrawCurve (Pen pen, PointF [] points) {
+ DrawCurve(pen, points, 0.5f);
+ }
+
+ public void DrawCurve (Pen pen, PointF [] points, float tension) {
+ DrawCurve(pen, points, 0, points.Length-1, tension);
+ }
+
+ public void DrawCurve (Pen pen, Point [] points, float tension) {
+ DrawCurve(pen, points, 0, points.Length-1, tension);
+ }
+
+
+ public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments) {
+ DrawCurve(pen, points, offset, numberOfSegments, 0.5f);
+ }
+
+ public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddCurve(points, offset, numberOfSegments, tension);
+ DrawPath(pen, path);
+ }
+
+
+ public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddCurve(points, offset, numberOfSegments, tension);
+ DrawPath(pen, path);
+ }
+ #endregion
+
+ #region DrawEllipse
+ public void DrawEllipse (Pen pen, Rectangle rect) {
+ DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void DrawEllipse (Pen pen, RectangleF rect) {
+ DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void DrawEllipse (Pen pen, int x, int y, int width, int height) {
+ DrawEllipse(pen,(float)x,(float)y,(float)width,(float)height);
+ }
+
+ public void DrawEllipse (Pen pen, float x, float y, float width, float height) {
+ DrawShape(pen, new geom.Ellipse2D.Float(x,y,width,height));
+ }
+ #endregion
+
+ #region DrawIcon
+ public void DrawIcon (Icon icon, Rectangle targetRect) {
+ Bitmap b = icon.ToBitmap ();
+ this.DrawImage (b, targetRect);
+ }
+
+ public void DrawIcon (Icon icon, int x, int y) {
+ Bitmap b = icon.ToBitmap ();
+ this.DrawImage (b, x, y);
+ }
+
+ public void DrawIconUnstretched (Icon icon, Rectangle targetRect) {
+ Bitmap b = icon.ToBitmap ();
+ this.DrawImageUnscaled (b, targetRect);
+ }
+ #endregion
+
+ #region DrawImage
+
+ public void DrawImage (Image image, Point point) {
+ DrawImage(image, point.X, point.Y);
+ }
+
+ public void DrawImage (Image image, PointF point) {
+ DrawImage(image, point.X, point.Y);
+ }
+
+
+ public void DrawImage (Image image, Point [] destPoints) {
+ Matrix m = new Matrix(new Rectangle(0, 0, image.Width, image.Height), destPoints);
+ DrawImage(image, m);
+ }
+
+ public void DrawImage (Image image, PointF [] destPoints) {
+ Matrix m = new Matrix(new RectangleF(0, 0, image.Width, image.Height), destPoints);
+ DrawImage(image, m);
+ }
+
+
+ public void DrawImage (Image image, Rectangle rect) {
+ DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void DrawImage (Image image, RectangleF rect) {
+ DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+
+ public void DrawImage (Image image, int x, int y) {
+ DrawImage(image, (float)x, (float)y);
+ }
+
+ public void DrawImage (Image image, float x, float y) {
+ if ((image.HorizontalResolution != DpiX) || (image.VerticalResolution != DpiY))
+ DrawImage( image, x, y,
+ (float)image.Width * (DpiX / image.HorizontalResolution) / _unitConversion[(int)PageUnit],
+ (float)image.Height * (DpiY / image.VerticalResolution) / _unitConversion[(int)PageUnit]) ;
+ else
+ DrawImage( image, x, y,
+ (float)image.Width / _unitConversion[(int)PageUnit],
+ (float)image.Height / _unitConversion[(int)PageUnit] );
+ }
+
+
+ public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit) {
+ DrawImage(
+ image,
+ new Point [] {
+ new Point( destRect.X, destRect.Y),
+ new Point( destRect.X + destRect.Width, destRect.Y),
+ new Point( destRect.X, destRect.Y + destRect.Height)},
+ srcRect,
+ srcUnit);
+ }
+
+ public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit) {
+ DrawImage(
+ image,
+ new PointF [] {
+ new PointF( destRect.X, destRect.Y),
+ new PointF( destRect.X + destRect.Width, destRect.Y),
+ new PointF( destRect.X, destRect.Y + destRect.Height)},
+ srcRect,
+ srcUnit);
+ }
+
+
+ public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit) {
+ DrawImage(image, destPoints, srcRect, srcUnit, null);
+ }
+
+ public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit) {
+ DrawImage(image, destPoints, srcRect, srcUnit, null);
+ }
+
+ [MonoTODO]
+ public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr) {
+ //TBD: ImageAttributes
+ if (srcUnit != GraphicsUnit.Pixel)
+ throw new NotImplementedException();
+ // Like in .NET http://dotnet247.com/247reference/msgs/45/227979.aspx
+
+ Matrix mx = new Matrix(srcRect, destPoints);
+
+ Region region = new Region(srcRect);
+ DrawImage(image, mx, region);
+ }
+
+ [MonoTODO]
+ public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr) {
+ //TBD: ImageAttributes
+ if (srcUnit != GraphicsUnit.Pixel)
+ throw new NotImplementedException();
+ // Like in .NET http://dotnet247.com/247reference/msgs/45/227979.aspx
+
+ Matrix mx = new Matrix(srcRect, destPoints);
+
+ Region region = new Region(srcRect);
+ DrawImage(image, mx, region);
+ }
+
+
+ public void DrawImage (Image image, int x, int y, int width, int height) {
+ DrawImage(image, (float)x, (float)y, (float)width, (float)height);
+ }
+
+ public void DrawImage (Image image, float x, float y, float width, float height) {
+ Matrix mx = new Matrix();
+ mx.Translate((float)x, (float)y);
+ mx.Scale(width / (float)image.Width, height / (float)image.Height);
+
+ DrawImage( image, mx );
+ }
+
+
+ public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit) {
+ DrawImage(image, new Rectangle(x, y, srcRect.Width, srcRect.Height), srcRect, srcUnit);
+ }
+
+ public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit) {
+ DrawImage(image, new RectangleF(x, y, srcRect.Width, srcRect.Height), srcRect, srcUnit);
+ }
+
+
+ public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit) {
+ DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, null);
+ }
+
+ public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit) {
+ DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, null);
+ }
+
+
+ [MonoTODO]
+ public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr) {
+ //TBD: attributes
+ DrawImage(
+ image,
+ destRect,
+ new Rectangle(srcX, srcY, srcWidth, srcHeight),
+ srcUnit);
+ }
+
+ [MonoTODO]
+ public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs) {
+ //TBD: attributes
+ DrawImage(
+ image,
+ destRect,
+ new RectangleF(srcX, srcY, srcWidth, srcHeight),
+ srcUnit);
+ }
+
+
+ internal void DrawImage (Image image, Matrix m) {
+ DrawImage(image, m, null);
+ }
+
+ internal void DrawImage (Image image, Matrix m, Region clip) {
+ if (clip == null) {
+ clip = new Region( new RectangleF( 0, 0, image.Width, image.Height ) );
+ }
+
+ geom.AffineTransform t = GetFinalTransform(_transform.NativeObject, PageUnit, 1.0f);
+ if (!t.isIdentity())
+ m.NativeObject.preConcatenate(t);
+
+ clip.Transform( m );
+
+ if (NeedsNormalization) {
+ Matrix normMatrix = ComputeClipNormalization(clip.GetBounds(this));
+ clip.Transform(normMatrix);
+ }
+
+ awt.Shape oldClip = NativeObject.getClip();
+ IntersectScaledClipWithBase(clip);
+
+ try {
+ Matrix mm = ComputeImageNormalization(image, m);
+ NativeObject.drawImage(image.NativeObject.CurrentImage.NativeImage, mm.NativeObject, null);
+ }
+ finally {
+ NativeObject.setClip( oldClip );
+ }
+ }
+
+ private static Matrix ComputeImageNormalization(Image img, Matrix m) {
+ if ( m.IsIdentity )
+ return m;
+
+ //m.Translate( -(m.Elements[0] + m.Elements[2]) / 2.0f, -(m.Elements[3] + m.Elements[1]) / 2.0f, MatrixOrder.Append);
+ m.Translate(
+ -(float)(m.NativeObject.getScaleX() + m.NativeObject.getShearX()) / 2.0f,
+ -(float)(m.NativeObject.getScaleY() + m.NativeObject.getShearY()) / 2.0f, MatrixOrder.Append);
+
+ PointF [] p = new PointF[] {
+ new PointF( 0, 0 ),
+ new PointF( img.Width, 0 ),
+ new PointF( 0, img.Height )};
+
+ m.TransformPoints(p);
+ for (int i=0; i < p.Length; i++) {
+ p[i].X = (float)( p[i].X + 0.5f );
+ p[i].Y = (float)( p[i].Y + 0.5f );
+ }
+
+ return new Matrix( new Rectangle(0, 0, img.Width, img.Height), p );
+ }
+ private static Matrix ComputeClipNormalization(RectangleF rect) {
+ PointF [] p = new PointF[] {
+ new PointF( rect.X, rect.Y ),
+ new PointF( rect.X + rect.Width, rect.Y ),
+ new PointF( rect.X, rect.Y + rect.Height )};
+
+ for (int i=0; i < p.Length; i++) {
+ p[i].X = (float)Math.Round( p[i].X + 0.5f ) + 0.5f;
+ p[i].Y = (float)Math.Round( p[i].Y + 0.5f ) + 0.5f;
+ }
+
+ return new Matrix( rect, p );
+ }
+
+
+#if INTPTR_SUPPORT
+ [MonoTODO]
+ public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
+ {
+
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
+ {
+ throw new NotImplementedException();
+ }
+#endif
+
+#if INTPTR_SUPPORT
+ [MonoTODO]
+ public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
+ {
+ throw new NotImplementedException();
+ }
+#endif
+
+#if INTPTR_SUPPORT
+ public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
+ {
+ //TBD:units,attributes, callback
+ java.awt.Graphics2D g = (java.awt.Graphics2D)nativeObject;
+ g.drawImage(image.NativeObject,destRect.X,destRect.Y,destRect.Width,destRect.Height,srcX,srcY,srcWidth,srcHeight,null);
+ }
+
+ public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
+ {
+ //TBD:units,attributes, callback
+ java.awt.Graphics2D g = (java.awt.Graphics2D)nativeObject;
+ g.drawImage(image.NativeObject,
+ (int)destRect.X,
+ (int)destRect.Y,
+ (int)destRect.Width,
+ (int)destRect.Height,
+ (int)srcX,
+ (int)srcY,
+ (int)srcWidth,
+ (int)srcHeight,null);
+ }
+
+ public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
+ {
+ //TBD:units,attributes, callback
+ java.awt.Graphics2D g = (java.awt.Graphics2D)nativeObject;
+ g.drawImage(image.NativeObject,
+ (int)destRect.X,
+ (int)destRect.Y,
+ (int)destRect.Width,
+ (int)destRect.Height,
+ (int)srcX,
+ (int)srcY,
+ (int)srcWidth,
+ (int)srcHeight,null);
+ }
+
+ public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
+ {
+ //TBD:units,attributes, callback
+ java.awt.Graphics2D g = (java.awt.Graphics2D)nativeObject;
+ g.drawImage(image.NativeObject,
+ destRect.X,
+ destRect.Y,
+ destRect.Width,
+ destRect.Height,
+ srcX,
+ srcY,
+ srcWidth,
+ srcHeight,null);
+ }
+#endif
+
+ public void DrawImageUnscaled (Image image, Point point)
+ {
+ DrawImageUnscaled (image, point.X, point.Y);
+ }
+
+ public void DrawImageUnscaled (Image image, Rectangle rect) {
+ DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void DrawImageUnscaled (Image image, int x, int y) {
+ DrawImage (image, x, y, image.Width, image.Height);
+ }
+
+ public void DrawImageUnscaled (Image image, int x, int y, int width, int height) {
+ Image tmpImg = new Bitmap (width, height);
+ Graphics g = FromImage (tmpImg);
+ g.DrawImage (image, 0, 0, image.Width, image.Height);
+ this.DrawImage (tmpImg, x, y, width, height);
+ tmpImg.Dispose ();
+ g.Dispose ();
+ }
+ #endregion
+
+ #region DrawLine
+ public void DrawLine (Pen pen, PointF pt1, PointF pt2) {
+ DrawLine(pen,pt1.X,pt1.Y,pt2.X,pt2.Y);
+ }
+
+ public void DrawLine (Pen pen, Point pt1, Point pt2) {
+ DrawLine(pen,(float)pt1.X,(float)pt1.Y,(float)pt2.X,(float)pt2.Y);
+ }
+
+ public void DrawLine (Pen pen, int x1, int y1, int x2, int y2) {
+ DrawLine(pen,(float)x1,(float)y1,(float)x2,(float)y2);
+ }
+
+ public void DrawLine (Pen pen, float x1, float y1, float x2, float y2) {
+ DrawShape(pen, new geom.Line2D.Float(x1,y1,x2,y2));
+ }
+
+ public void DrawLines (Pen pen, PointF [] points) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddLines(points);
+ DrawShape(pen, path);
+ }
+
+ public void DrawLines (Pen pen, Point [] points) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddLines(points);
+ DrawShape(pen, path);
+ }
+ #endregion
+
+ #region DrawPath
+ public void DrawPath (Pen pen, GraphicsPath path) {
+ DrawShape(pen, path);
+ }
+ #endregion
+
+ #region DrawPie
+ public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle) {
+ DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+ }
+
+ public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle) {
+ DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+ }
+
+ public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddPie(x, y, width, height, startAngle, sweepAngle);
+ DrawPath(pen, path);
+ }
+
+ public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle) {
+ DrawPie(pen,(float)x,(float)y,(float)width,(float)height,(float)startAngle,(float)sweepAngle);
+ }
+ #endregion
+
+ #region DrawPolygon
+ public void DrawPolygon (Pen pen, Point [] points) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddPolygon(points);
+ DrawPath(pen, path);
+ }
+
+ public void DrawPolygon (Pen pen, PointF [] points) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddPolygon(points);
+ DrawPath(pen, path);
+ }
+ #endregion
+
+ #region DrawRectangle(s)
+ internal void DrawRectangle (Pen pen, RectangleF rect) {
+ DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
+ }
+
+ public void DrawRectangle (Pen pen, Rectangle rect) {
+ DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
+ }
+
+ public void DrawRectangle (Pen pen, float x, float y, float width, float height) {
+ DrawShape(pen, new geom.Rectangle2D.Float(x,y,width,height));
+ }
+
+ public void DrawRectangle (Pen pen, int x, int y, int width, int height) {
+ DrawRectangle (pen,(float) x,(float) y,(float) width,(float) height);
+ }
+
+ public void DrawRectangles (Pen pen, RectangleF [] rects) {
+ foreach(RectangleF r in rects)
+ DrawRectangle (pen, r.Left, r.Top, r.Width, r.Height);
+ }
+
+ public void DrawRectangles (Pen pen, Rectangle [] rects) {
+ foreach(Rectangle r in rects)
+ DrawRectangle (pen, r.Left, r.Top, r.Width, r.Height);
+ }
+ #endregion
+
+ #region DrawString
+ public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle) {
+ DrawString(s, font, brush, layoutRectangle.X, layoutRectangle.Y, layoutRectangle.Width, layoutRectangle.Height, null);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, PointF point) {
+ DrawString(s, font, brush, point.X, point.Y, float.PositiveInfinity, float.PositiveInfinity, null);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format) {
+ DrawString(s, font, brush, point.X, point.Y, float.PositiveInfinity, float.PositiveInfinity, format);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format) {
+ DrawString(s, font, brush, layoutRectangle.X, layoutRectangle.Y, layoutRectangle.Width, layoutRectangle.Height, format);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, float x, float y) {
+ DrawString(s, font, brush, x, y, float.PositiveInfinity, float.PositiveInfinity, null);
+ }
+
+ public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format) {
+ DrawString(s, font, brush, x, y, float.PositiveInfinity, float.PositiveInfinity, format);
+ }
+
+ void DrawString (string s, Font font, Brush brush,
+ float x, float y, float width, float height,
+ StringFormat format) {
+ if (brush == null)
+ throw new ArgumentNullException("brush");
+
+ if (font == null)
+ throw new ArgumentNullException("font");
+
+ if (format != null && format.LineAlignment != StringAlignment.Near) {
+
+ SizeF sizeF = MeasureString(s, font, format, width, height, null);
+
+ float lineAWidth = width;
+ float lineAHeight = height;
+
+ if (float.IsPositiveInfinity(width))
+ lineAWidth = lineAHeight = 0;
+
+ float wdelta = format.IsVertical ? lineAWidth - sizeF.Width : lineAHeight - sizeF.Height;
+ float pdelta = format.LineAlignment == StringAlignment.Center ? wdelta/2 : wdelta;
+ if (format.IsVertical) {
+ if (!(format.IsRightToLeft && format.LineAlignment == StringAlignment.Far))
+ x += pdelta;
+ if (!float.IsPositiveInfinity(width))
+ width -= wdelta;
+ }
+ else {
+ y += pdelta;
+ if (!float.IsPositiveInfinity(width))
+ height -= wdelta;
+ }
+ }
+
+ awt.Paint oldP = NativeObject.getPaint();
+ NativeObject.setPaint(brush);
+ try {
+ geom.AffineTransform oldT = NativeObject.getTransform();
+ NativeObject.transform(GetFinalTransform());
+ try {
+
+ bool noclip = float.IsPositiveInfinity(width) || (format != null && format.NoClip);
+
+ awt.Shape oldClip = null;
+ if (!noclip) {
+ oldClip = NativeObject.getClip();
+ NativeObject.clip(new geom.Rectangle2D.Float(x, y, width, height));
+ }
+ try {
+ TextLineIterator iter = new TextLineIterator(s, font, NativeObject.getFontRenderContext(), format, width, height);
+ NativeObject.transform(iter.Transform);
+ for (LineLayout layout = iter.NextLine(); layout != null; layout = iter.NextLine()) {
+ layout.Draw(NativeObject, x, y);
+ }
+ }
+ finally {
+ if (!noclip)
+ NativeObject.setClip(oldClip);
+ }
+ }
+ finally {
+ NativeObject.setTransform(oldT);
+ }
+ }
+ finally {
+ NativeObject.setPaint(oldP);
+ }
+ }
+ #endregion
+
+ #region Container
+
+ void PushGraphicsState(GraphicsState state) {
+ state.Next = _nextGraphicsState;
+ _nextGraphicsState = state;
+ }
+
+ GraphicsState PopGraphicsState() {
+ GraphicsState state = _nextGraphicsState;
+ _nextGraphicsState = _nextGraphicsState.Next;
+ return state;
+ }
+
+ bool ContainsGraphicsState(GraphicsState state) {
+ GraphicsState gs = _nextGraphicsState;
+
+ while(gs != null) {
+ if (gs == state)
+ return true;
+
+ gs = gs.Next;
+ }
+
+ return false;
+ }
+
+ public void EndContainer (GraphicsContainer container) {
+ Restore(container.StateObject);
+ }
+
+ public GraphicsContainer BeginContainer () {
+ return new GraphicsContainer(Save(Matrix.IdentityTransform, true));
+ }
+
+ public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit) {
+ Matrix containerTransfrom =
+ new Matrix( srcrect,
+ new Point [] { new Point (dstrect.X, dstrect.Y),
+ new Point (dstrect.X + dstrect.Width, dstrect.Y),
+ new Point (dstrect.X, dstrect.Y + dstrect.Height) });
+
+ float scale = _unitConversion[ (int)PageUnit ] / _unitConversion[ (int)unit ];
+ containerTransfrom.Scale(scale, scale);
+
+ return new GraphicsContainer(Save(containerTransfrom, true));
+ }
+
+
+ public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit) {
+ Matrix containerTransfrom =
+ new Matrix( srcrect,
+ new PointF [] { new PointF (dstrect.X, dstrect.Y),
+ new PointF (dstrect.X + dstrect.Width, dstrect.Y),
+ new PointF (dstrect.X, dstrect.Y + dstrect.Height) });
+
+ float scale = _unitConversion[ (int)PageUnit ] / _unitConversion[ (int)unit ];
+ containerTransfrom.Scale(scale, scale);
+
+ return new GraphicsContainer(Save(containerTransfrom, true));
+ }
+
+ GraphicsState Save(Matrix matrix, bool resetState) {
+ GraphicsState graphicsState = new GraphicsState(this, matrix, resetState);
+
+ PushGraphicsState( graphicsState );
+ return graphicsState;
+ }
+
+ public GraphicsState Save () {
+ return Save(Matrix.IdentityTransform, false);
+ }
+
+ public void Restore (GraphicsState graphicsState) {
+ if (ContainsGraphicsState(graphicsState)) {
+ GraphicsState gs = PopGraphicsState();
+ while ( gs != graphicsState )
+ gs = PopGraphicsState();
+
+ graphicsState.RestoreState(this);
+ }
+ }
+
+ #endregion
+
+ #region Metafiles Staff
+ [MonoTODO]
+ public void AddMetafileComment (byte [] data) {
+ throw new NotImplementedException ();
+ }
+
+#if INTPTR_SUPPORT
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+ #endregion
+
+ #region ExcludeClip
+ void ExcludeClip(geom.Area area) {
+
+ geom.AffineTransform t = GetFinalTransform();
+ if (!t.isIdentity()) {
+ area = (geom.Area)area.clone();
+ area.transform(t);
+ }
+
+ _clip.NativeObject.subtract(area);
+ RestoreBaseClip();
+ NativeObject.clip(_clip);
+ }
+
+ public void ExcludeClip (Rectangle rect) {
+ ExcludeClip(new geom.Area(rect.NativeObject));
+ }
+
+ public void ExcludeClip (Region region) {
+ if (region == null)
+ throw new ArgumentNullException("region");
+ ExcludeClip(region.NativeObject);
+ }
+ #endregion
+
+ #region FillClosedCurve
+ public void FillClosedCurve (Brush brush, PointF [] points) {
+ FillClosedCurve (brush, points, FillMode.Alternate);
+ }
+
+
+ public void FillClosedCurve (Brush brush, Point [] points) {
+ FillClosedCurve (brush, points, FillMode.Alternate);
+ }
+
+
+ public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode) {
+ FillClosedCurve (brush, points, fillmode, 0.5f);
+ }
+
+ public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode) {
+ FillClosedCurve (brush, points, fillmode, 0.5f);
+ }
+
+ public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension) {
+ GraphicsPath path = new GraphicsPath(fillmode);
+ path.AddClosedCurve(points, tension);
+ FillPath(brush, path);
+ }
+
+ public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension) {
+ GraphicsPath path = new GraphicsPath(fillmode);
+ path.AddClosedCurve(points, tension);
+ FillPath(brush, path);
+ }
+ #endregion
+
+ #region FillEllipse
+ public void FillEllipse (Brush brush, Rectangle rect) {
+ FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void FillEllipse (Brush brush, RectangleF rect) {
+ FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public void FillEllipse (Brush brush, float x, float y, float width, float height) {
+ FillShape(brush,new java.awt.geom.Ellipse2D.Float(x,y,width,height));
+ }
+
+ public void FillEllipse (Brush brush, int x, int y, int width, int height) {
+ FillEllipse (brush,(float)x,(float)y,(float)width,(float)height);
+ }
+ #endregion
+
+ #region FillPath
+ public void FillPath (Brush brush, GraphicsPath path) {
+ if (path == null)
+ throw new ArgumentNullException("path");
+
+ FillShape(brush,path);
+ }
+ #endregion
+
+ #region FillPie
+ public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle) {
+ FillPie(brush,(float)rect.X,(float)rect.Y,(float)rect.Width,(float)rect.Height,(float)startAngle,(float)sweepAngle);
+ }
+
+ public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle) {
+ FillPie(brush,(float)x,(float)y,(float)width,(float)height,(float)startAngle,(float)sweepAngle);
+ }
+
+ public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddPie(x, y, width, height, startAngle, sweepAngle);
+ FillPath(brush, path);
+ }
+ #endregion
+
+ #region FillPolygon
+ public void FillPolygon (Brush brush, PointF [] points) {
+ FillPolygon(brush, points, FillMode.Alternate);
+ }
+
+ public void FillPolygon (Brush brush, Point [] points) {
+ FillPolygon(brush, points, FillMode.Alternate);
+ }
+
+ public void FillPolygon (Brush brush, Point [] points, FillMode fillMode) {
+ GraphicsPath path = new GraphicsPath(fillMode);
+ path.AddPolygon(points);
+ FillPath(brush,path);
+ }
+
+ public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode) {
+ GraphicsPath path = new GraphicsPath(fillMode);
+ path.AddPolygon(points);
+ FillPath(brush,path);
+ }
+ #endregion
+
+ #region FillRectangle
+ public void FillRectangle (Brush brush, RectangleF rect) {
+ FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
+ }
+
+ public void FillRectangle (Brush brush, Rectangle rect) {
+ FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
+ }
+
+ public void FillRectangle (Brush brush, int x, int y, int width, int height) {
+ FillRectangle(brush,(float)x,(float)y,(float)width,(float)height);
+ }
+
+ public void FillRectangle (Brush brush, float x, float y, float width, float height) {
+ FillShape(brush,new java.awt.geom.Rectangle2D.Float(x,y,width,height));
+ }
+
+ public void FillRectangles (Brush brush, Rectangle [] rects) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddRectangles(rects);
+ FillPath(brush,path);
+ }
+
+ public void FillRectangles (Brush brush, RectangleF [] rects) {
+ GraphicsPath path = new GraphicsPath();
+ path.AddRectangles(rects);
+ FillPath(brush,path);
+ }
+ #endregion
+
+ #region FillRegion
+ public void FillRegion (Brush brush, Region region) {
+ FillShape(brush,region);
+ }
+
+ #endregion
+
+ public void Flush () {
+ Flush (FlushIntention.Flush);
+ }
+
+
+ public void Flush (FlushIntention intention) {
+ if (_image != null)
+ _image.NativeObject.CurrentImage.NativeImage.flush();
+ }
+
+#if INTPTR_SUPPORTED
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [MonoTODO]
+ public void ReleaseHdc (IntPtr hdc)
+ {
+ throw new NotImplementedException();
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [MonoTODO]
+ public void ReleaseHdcInternal (IntPtr hdc)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [MonoTODO]
+ public static Graphics FromHdc (IntPtr hdc)
+ {
+ throw new NotImplementedException();
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [MonoTODO]
+ public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [MonoTODO]
+ public static Graphics FromHdcInternal (IntPtr hdc)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [MonoTODO]
+ public static Graphics FromHwnd (IntPtr hwnd)
+ {
+ throw new NotImplementedException();
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [MonoTODO]
+ public static Graphics FromHwndInternal (IntPtr hwnd)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public static IntPtr GetHalftonePalette ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [MonoTODO]
+ public IntPtr GetHdc ()
+ {
+ throw new NotImplementedException();
+ }
+#endif
+
+ #region GetNearestColor
+ [MonoTODO]
+ public Color GetNearestColor (Color color) {
+ throw new NotImplementedException();
+ }
+ #endregion
+
+ #region IntersectClip
+ void IntersectClip (geom.Area area) {
+
+ geom.AffineTransform t = GetFinalTransform();
+ if (!t.isIdentity()) {
+ area = (geom.Area)area.clone();
+ area.transform(t);
+ }
+
+ _clip.NativeObject.intersect(area);
+ RestoreBaseClip();
+ NativeObject.clip(_clip);
+ }
+
+ public void IntersectClip (Region region) {
+ if (region == null)
+ throw new ArgumentNullException("region");
+
+ IntersectClip(region.NativeObject);
+ }
+
+ public void IntersectClip (RectangleF rect) {
+ IntersectClip(new geom.Area(rect.NativeObject));
+ }
+
+ public void IntersectClip (Rectangle rect) {
+ IntersectClip(new geom.Area(rect.NativeObject));
+ }
+ #endregion
+
+ #region IsVisible
+ public bool IsVisible (Point point) {
+ return IsVisible(point.X,point.Y);
+ }
+
+
+ public bool IsVisible (RectangleF rect) {
+ return IsVisible ((float)rect.X,(float)rect.Y,(float)rect.Width,(float)rect.Height);
+ }
+
+ public bool IsVisible (PointF point) {
+ return IsVisible(point.X,point.Y);
+ }
+
+ public bool IsVisible (Rectangle rect) {
+ return IsVisible ((float)rect.X,(float)rect.Y,(float)rect.Width,(float)rect.Height);
+ }
+
+ public bool IsVisible (float x, float y) {
+ double dx = x;
+ double dy = y;
+ geom.AffineTransform t = GetFinalTransform();
+ if (!t.isIdentity()) {
+ double[] p = new double[] {dx, dy};
+ t.transform(p, 0, p, 0, 1);
+
+ dx = p[0];
+ dy = p[1];
+ }
+ if (!_clip.NativeObject.contains(dx, dy))
+ return false;
+
+ awt.Shape clip = NativeObject.getClip();
+ if (clip == null)
+ return true;
+
+ return clip.contains(dx, dy);
+ }
+
+ public bool IsVisible (int x, int y) {
+ return IsVisible ((float)x,(float)y);
+ }
+
+ public bool IsVisible (float x, float y, float width, float height) {
+
+ geom.AffineTransform t = GetFinalTransform();
+ geom.Rectangle2D r = new geom.Rectangle2D.Float(x, y, width, height);
+
+ if (!t.isIdentity())
+ r = t.createTransformedShape(r).getBounds2D();
+
+ return NativeObject.hitClip(
+ (int)(r.getX()+0.5), (int)(r.getY()+0.5),
+ (int)(r.getWidth()+0.5), (int)(r.getHeight()+0.5))
+ && _clip.NativeObject.intersects(r);
+ }
+
+
+ public bool IsVisible (int x, int y, int width, int height) {
+ return IsVisible ((float)x,(float)y,(float)width,(float)height);
+ }
+ #endregion
+
+ #region MeasureCharacterRanges
+ public Region [] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat) {
+ if (stringFormat == null)
+ throw new ArgumentException("stringFormat");
+
+ CharacterRange[] ranges = stringFormat.CharRanges;
+ if (ranges == null || ranges.Length == 0)
+ return new Region[0];
+
+ GraphicsPath[] pathes = new GraphicsPath[ranges.Length];
+ for (int i = 0; i < pathes.Length; i++)
+ pathes[i] = new GraphicsPath();
+
+ TextLineIterator iter = new TextLineIterator(text, font, NativeObject.getFontRenderContext(),
+ stringFormat, layoutRect.Width, layoutRect.Height);
+
+ for (LineLayout layout = iter.NextLine(); layout != null; layout = iter.NextLine()) {
+
+ for (int i = 0; i < ranges.Length; i++) {
+ int start = ranges[i].First;
+ int length = ranges[i].Length;
+ start -= iter.CharsConsumed;
+ int limit = start + length;
+ int layoutStart = iter.CurrentPosition - layout.CharacterCount;
+ if (start < iter.CurrentPosition && limit > layoutStart) {
+
+ float layoutOffset;
+ if (start > layoutStart)
+ layoutOffset = iter.GetAdvanceBetween(layoutStart, start);
+ else {
+ layoutOffset = 0;
+ start = layoutStart;
+ }
+
+ float width = (limit < iter.CurrentPosition) ?
+ iter.GetAdvanceBetween(start, limit) :
+ layout.Width - layoutOffset;
+
+ float height = layout.Ascent + layout.Descent;
+
+ float x = layout.NativeX;
+ float y = layout.NativeY;
+
+ if (stringFormat.IsVertical) {
+ y += layoutOffset;
+ x -= layout.Descent;
+ }
+ else {
+ x += layoutOffset;
+ y -= layout.Ascent;
+ }
+
+ if (layout.AccumulatedHeight + height > iter.WrapHeight) {
+ float diff = iter.WrapHeight - layout.AccumulatedHeight;
+ if (stringFormat.IsVertical && stringFormat.IsRightToLeft) {
+ x += diff;
+ height -= diff;
+ }
+ else
+ height = diff;
+ }
+
+ if (stringFormat.IsVertical)
+ pathes[i].AddRectangle(x + layoutRect.X, y + layoutRect.Y, height, width);
+ else
+ pathes[i].AddRectangle(x + layoutRect.X, y + layoutRect.Y, width, height);
+ }
+ }
+ }
+
+ geom.AffineTransform lineAlignT = iter.CalcLineAlignmentTransform();
+ if (lineAlignT != null) {
+ for (int i = 0; i < pathes.Length; i++)
+ pathes[i].NativeObject.transform(lineAlignT);
+ }
+
+ Region[] regions = new Region[ranges.Length];
+ for (int i = 0; i < regions.Length; i++)
+ regions[i] = new Region(pathes[i]);
+
+ return regions;
+ }
+ #endregion
+
+ #region MeasureString
+ public SizeF MeasureString (string text, Font font) {
+ return MeasureString(text, font, null, float.PositiveInfinity, float.PositiveInfinity, null);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, SizeF layoutArea) {
+ return MeasureString(text, font, layoutArea, null);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, int width) {
+ return MeasureString(text, font, width, null);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat format) {
+ return MeasureString(text, font, format, layoutArea.Width, layoutArea.Height, null);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, int width, StringFormat format) {
+ return MeasureString(text, font, format, width, float.PositiveInfinity, null);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, PointF origin, StringFormat format) {
+ return MeasureString(text, font, format, float.PositiveInfinity, float.PositiveInfinity, null);
+ }
+
+ SizeF MeasureString (string text, Font font, StringFormat format, float width, float height, int[] statistics) {
+
+ if (statistics != null) {
+ statistics[0] = 0;
+ statistics[1] = 0;
+ }
+
+ TextLineIterator iter = new TextLineIterator(text, font, NativeObject.getFontRenderContext(), format, width, height);
+
+ float mwidth = 0;
+ int linesFilled = 0;
+ for (LineLayout layout = iter.NextLine(); layout != null; layout = iter.NextLine()) {
+
+ linesFilled ++;
+ float w = layout.MeasureWidth;
+
+ if (w > mwidth)
+ mwidth = w;
+ }
+
+ if (linesFilled == 0)
+ return SizeF.Empty;
+
+ float mheight = iter.AccumulatedHeight;
+
+ if (format != null) {
+ if (format.IsVertical) {
+ float temp = mheight;
+ mheight = mwidth;
+ mwidth = temp;
+ }
+ }
+
+ if (!(format != null && format.NoClip)) {
+ if (mwidth > width)
+ mwidth = width;
+ if (mheight > height)
+ mheight = height;
+ }
+
+ if (statistics != null) {
+ statistics[0] = linesFilled;
+ statistics[1] = iter.CharsConsumed;
+ }
+
+ return new SizeF(mwidth, mheight);
+ }
+
+
+ public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat, out int charactersFitted, out int linesFilled) {
+ linesFilled = 0;
+ charactersFitted = 0;
+
+ int[] statistics = new int[2];
+ SizeF sz = MeasureString(text, font, stringFormat, layoutArea.Width, layoutArea.Height, statistics);
+ linesFilled = statistics[0];
+ charactersFitted = statistics[1];
+ return sz;
+ }
+ #endregion
+
+ #region MultiplyTransform
+ public void MultiplyTransform (Matrix matrix) {
+ MultiplyTransform (matrix, MatrixOrder.Prepend);
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order) {
+ ConcatenateTransform(matrix.NativeObject, order);
+ }
+ #endregion
+
+ #region Reset (Clip and Transform)
+ public void ResetClip () {
+ _clip.MakeInfinite();
+ RestoreBaseClip();
+ NativeObject.clip(_clip);
+ }
+
+ public void ResetTransform () {
+ _transform.Reset();
+ }
+ #endregion
+
+ #region RotateTransform
+ public void RotateTransform (float angle) {
+ RotateTransform (angle, MatrixOrder.Prepend);
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order) {
+ ConcatenateTransform(
+ geom.AffineTransform.getRotateInstance(java.lang.Math.toRadians(angle)),
+ order);
+ }
+ #endregion
+
+ #region ScaleTransform
+ public void ScaleTransform (float sx, float sy) {
+ ScaleTransform (sx, sy, MatrixOrder.Prepend);
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order) {
+ ConcatenateTransform(
+ geom.AffineTransform.getScaleInstance(sx, sy),
+ order);
+ }
+ #endregion
+
+ #region SetClip [Must be reviewed - more abstraction needed]
+ public void SetClip (RectangleF rect) {
+ SetClip (rect, CombineMode.Replace);
+ }
+
+ public void SetClip (GraphicsPath path) {
+ SetClip (path, CombineMode.Replace);
+ }
+
+ public void SetClip (Rectangle rect) {
+ SetClip (rect, CombineMode.Replace);
+ }
+
+ public void SetClip (Graphics g) {
+ SetClip (g, CombineMode.Replace);
+ }
+
+ public void SetClip (Graphics g, CombineMode combineMode) {
+ if(g == null)
+ throw new NullReferenceException();
+
+ CombineClipArea(g._clip.NativeObject, combineMode);
+ }
+
+ public void SetClip (Rectangle rect, CombineMode combineMode) {
+ SetClip(rect.X,rect.Y,rect.Width,rect.Height,combineMode);
+ }
+ public void SetClip (RectangleF rect, CombineMode combineMode) {
+ SetClip(rect.X,rect.Y,rect.Width,rect.Height,combineMode);
+ }
+
+ public void SetClip (Region region, CombineMode combineMode) {
+ if(region == null)
+ throw new ArgumentNullException("region");
+
+ CombineClipArea((geom.Area)region.NativeObject.clone(),combineMode);
+ }
+
+ public void SetClip (GraphicsPath path, CombineMode combineMode) {
+ if(path == null)
+ throw new ArgumentNullException("path");
+
+ CombineClipArea(new geom.Area(path.NativeObject), combineMode);
+ }
+ #endregion
+
+ #region Clipping Staff [INTERNAL]
+ internal Region ScaledClip {
+ get {
+ return _clip.Clone();
+ }
+ set {
+ _clip.NativeObject.reset();
+ _clip.NativeObject.add(value.NativeObject);
+ }
+ }
+ internal void SetClip(float x,float y,float width,float height,CombineMode combineMode) {
+ CombineClipArea(new geom.Area(
+ new geom.Rectangle2D.Float(x,y,width,height)),combineMode);
+ }
+
+ void CombineClipArea(geom.Area area, CombineMode combineMode) {
+ geom.AffineTransform t = GetFinalTransform();
+ if (!t.isIdentity())
+ area.transform(t);
+ if (combineMode == CombineMode.Replace) {
+ _clip.NativeObject.reset();
+ _clip.NativeObject.add(area);
+ }
+ else {
+ geom.Area curClip = _clip.NativeObject;
+ switch(combineMode) {
+ case CombineMode.Complement:
+ curClip.add(area);
+ break;
+ case CombineMode.Exclude:
+ curClip.subtract(area);
+ break;
+ case CombineMode.Intersect:
+ curClip.intersect(area);
+ break;
+ case CombineMode.Union:
+ curClip.add(area);
+ break;
+ case CombineMode.Xor:
+ curClip.exclusiveOr(area);
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+
+ RestoreBaseClip();
+ NativeObject.clip(_clip);
+ }
+
+ internal void IntersectScaledClipWithBase(awt.Shape clip) {
+ NativeObject.clip(clip);
+ }
+
+ void RestoreBaseClip() {
+ if (_nextGraphicsState == null) {
+ NativeObject.setClip(_windowRect);
+ return;
+ }
+
+ _nextGraphicsState.RestoreBaseClip(this);
+ }
+
+ #endregion
+
+ #region TransformPoints
+ [MonoTODO]
+ public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts) {
+ //TBD:CoordinateSpace
+ java.awt.geom.AffineTransform tr = this.Transform.NativeObject;
+ float[] fpts = new float[2];
+ for(int i = 0; i< pts.Length; i++) {
+ fpts[0] = pts[i].X;
+ fpts[1] = pts[i].Y;
+ tr.transform(fpts, 0, fpts, 0, 1);
+ pts[i].X = fpts[0];
+ pts[i].Y = fpts[1];
+ }
+ }
+
+ [MonoTODO]
+ public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts) {
+ //TBD:CoordinateSpace
+ java.awt.geom.AffineTransform tr = this.Transform.NativeObject;
+ float[] fpts = new float[2];
+ for(int i = 0; i< pts.Length; i++) {
+ fpts[0] = pts[i].X;
+ fpts[1] = pts[i].Y;
+ tr.transform(fpts, 0, fpts, 0, 1);
+ pts[i].X = (int)fpts[0];
+ pts[i].Y = (int)fpts[1];
+ }
+ }
+ #endregion
+
+ #region TranslateClip
+ public void TranslateClip (int dx, int dy) {
+ TranslateClip((float)dx, (float)dy);
+ }
+
+
+ public void TranslateClip (float dx, float dy) {
+ double x = dx;
+ double y = dy;
+ geom.AffineTransform f = GetFinalTransform();
+
+ if (!f.isIdentity()) {
+ double[] p = new double[] {x, y};
+ f.deltaTransform(p, 0, p, 0, 1);
+
+ x = p[0];
+ y = p[1];
+ }
+
+ // It seems .Net does exactly this...
+ x = Math.Floor(x+0.96875);
+ y = Math.Floor(y+0.96875);
+
+ geom.AffineTransform t = geom.AffineTransform.getTranslateInstance(x, y);
+
+ _clip.NativeObject.transform(t);
+ RestoreBaseClip();
+ NativeObject.clip(_clip);
+ }
+ #endregion
+
+ #region TranslateTransform
+ public void TranslateTransform (float dx, float dy) {
+ TranslateTransform (dx, dy, MatrixOrder.Prepend);
+ }
+
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order) {
+ ConcatenateTransform(
+ geom.AffineTransform.getTranslateInstance(dx, dy),
+ order);
+ }
+ #endregion
+
+ #region Properties [Partial TODO]
+ public Region Clip {
+ get {
+ Region r = _clip.Clone();
+ geom.AffineTransform t = GetFinalTransform();
+ if (!t.isIdentity())
+ r.NativeObject.transform(t.createInverse());
+
+ return r;
+ }
+ set {
+ SetClip (value, CombineMode.Replace);
+ }
+ }
+
+ public RectangleF ClipBounds {
+ get {
+ awt.Shape shape = _clip.NativeObject;
+ if (shape == null)
+ shape = Region.InfiniteRegion.NativeObject;
+
+ geom.RectangularShape r = shape.getBounds2D();
+ geom.AffineTransform t = GetFinalTransform();
+ if (!t.isIdentity()) {
+ geom.AffineTransform it = t.createInverse();
+ r = it.createTransformedShape(r).getBounds2D();
+ }
+
+ return new RectangleF (r);
+ }
+ }
+
+ public CompositingMode CompositingMode {
+ //TBD:check this carefully
+ get {
+ return (NativeObject.getComposite() == awt.AlphaComposite.SrcOver) ?
+ CompositingMode.SourceOver : CompositingMode.SourceCopy;
+ }
+ set {
+ NativeObject.setComposite(
+ (value == CompositingMode.SourceOver) ?
+ awt.AlphaComposite.SrcOver : awt.AlphaComposite.Src);
+ }
+
+ }
+
+ public CompositingQuality CompositingQuality {
+ get {
+ awt.RenderingHints hints = NativeObject.getRenderingHints();
+ if(hints.containsKey(awt.RenderingHints.KEY_ALPHA_INTERPOLATION)) {
+ object value_ai = hints.get(awt.RenderingHints.KEY_ALPHA_INTERPOLATION);
+
+ if (value_ai == awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED)
+ return CompositingQuality.HighSpeed;
+ if (value_ai == awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY)
+ return CompositingQuality.HighQuality;
+ if (value_ai == awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT)
+ return CompositingQuality.Default;
+ }
+
+ return CompositingQuality.Default;
+
+ }
+ set {
+ awt.RenderingHints hints = NativeObject.getRenderingHints();
+ switch (value) {
+ case CompositingQuality.AssumeLinear:
+ case CompositingQuality.Default:
+ case CompositingQuality.GammaCorrected:
+ hints.put(awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
+ awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
+ break;
+ case CompositingQuality.HighQuality:
+ hints.put(awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
+ awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ break;
+ case CompositingQuality.HighSpeed:
+ hints.put(awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
+ awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
+ break;
+// case CompositingQuality.Invalid:
+// if(hints.containsKey(awt.RenderingHints.KEY_ALPHA_INTERPOLATION))
+// hints.remove(awt.RenderingHints.KEY_ALPHA_INTERPOLATION);
+ }
+
+ NativeObject.setRenderingHints(hints);
+ }
+ }
+
+ public float DpiX {
+ get {
+ return DefaultScreenResolution;
+ }
+ }
+
+ public float DpiY {
+ get {
+ //TBD: assume 72 (screen) for now
+ return DpiX;
+ }
+ }
+
+ public InterpolationMode InterpolationMode {
+ get {
+ awt.RenderingHints hints = NativeObject.getRenderingHints();
+ if(hints.containsKey(awt.RenderingHints.KEY_INTERPOLATION)) {
+ object value_i = hints.get(awt.RenderingHints.KEY_INTERPOLATION);
+
+ if (value_i == awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR)
+ return InterpolationMode.Bilinear;
+ if (value_i == awt.RenderingHints.VALUE_INTERPOLATION_BICUBIC)
+ return InterpolationMode.Bicubic;
+ if (value_i == awt.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)
+ return InterpolationMode.NearestNeighbor;
+ }
+
+ return InterpolationMode.Default;
+ }
+ set {
+ awt.RenderingHints hints = NativeObject.getRenderingHints();
+
+ switch (value) {
+ case InterpolationMode.Bicubic:
+ case InterpolationMode.HighQualityBicubic:
+ case InterpolationMode.Low:
+ hints.put(awt.RenderingHints.KEY_INTERPOLATION, awt.RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ break;
+ case InterpolationMode.High:
+ case InterpolationMode.Bilinear:
+ case InterpolationMode.HighQualityBilinear:
+ hints.put(awt.RenderingHints.KEY_INTERPOLATION, awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+ break;
+ case InterpolationMode.Default:
+ if (hints.containsKey(awt.RenderingHints.KEY_INTERPOLATION))
+ hints.remove(awt.RenderingHints.KEY_INTERPOLATION);
+ break;
+ case InterpolationMode.NearestNeighbor:
+ hints.put(awt.RenderingHints.KEY_INTERPOLATION, awt.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
+ break;
+ case InterpolationMode.Invalid:
+ throw new ArgumentException();
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+
+ NativeObject.setRenderingHints(hints);
+ }
+ }
+
+ public bool IsClipEmpty {
+ get {
+ return _clip.IsEmpty(this);
+ }
+ }
+
+ public bool IsVisibleClipEmpty {
+ get {
+ if (_clip.IsEmpty(this))
+ return true;
+
+ return VisibleClipBounds.IsEmpty;
+ }
+ }
+
+ public float PageScale {
+ get {
+ return _pageScale;
+ }
+ set {
+ _pageScale = value;
+ }
+ }
+
+ public GraphicsUnit PageUnit {
+ get {
+ return _pageUnit;
+ }
+ set {
+ _pageUnit = value;
+ }
+ }
+
+ static internal geom.AffineTransform GetFinalTransform(
+ geom.AffineTransform transform, GraphicsUnit pageUnit, float pageScale) {
+ geom.AffineTransform t = null;
+ if (pageUnit != GraphicsUnit.Display) {
+ float scale = pageScale * _unitConversion[ (int)pageUnit ];
+ if (Math.Abs(scale-1f) > float.Epsilon)
+ t = geom.AffineTransform.getScaleInstance(scale, scale);
+ }
+
+ if (t != null)
+ t.concatenate(transform);
+ else
+ t = transform;
+
+ return t;
+ }
+
+ geom.AffineTransform GetFinalTransform() {
+ return GetFinalTransform(_transform.NativeObject, PageUnit, PageScale);
+ }
+
+ public PixelOffsetMode PixelOffsetMode {
+ get {
+ return _pixelOffsetMode;
+ }
+ set {
+ _pixelOffsetMode = value;
+ }
+ }
+
+ [MonoTODO]
+ public Point RenderingOrigin {
+ get {
+ throw new NotImplementedException();
+ }
+ set {
+ throw new NotImplementedException();
+ }
+ }
+
+ public SmoothingMode SmoothingMode {
+ get {
+ awt.RenderingHints hints = NativeObject.getRenderingHints();
+ if(hints.containsKey(awt.RenderingHints.KEY_ANTIALIASING)) {
+ object value_aa = hints.get(awt.RenderingHints.KEY_ANTIALIASING);
+ if (value_aa == awt.RenderingHints.VALUE_ANTIALIAS_ON) {
+ if(hints.containsKey(awt.RenderingHints.KEY_RENDERING)) {
+ object value_render = hints.get(awt.RenderingHints.KEY_RENDERING);
+ if (value_render == awt.RenderingHints.VALUE_RENDER_QUALITY)
+ return SmoothingMode.HighQuality;
+ if (value_render == awt.RenderingHints.VALUE_RENDER_SPEED)
+ return SmoothingMode.HighSpeed;
+ }
+
+ return SmoothingMode.AntiAlias;
+ }
+
+ if (value_aa == awt.RenderingHints.VALUE_ANTIALIAS_DEFAULT)
+ return SmoothingMode.Default;
+ }
+ return SmoothingMode.None;
+
+ }
+
+ set {
+ awt.RenderingHints hints = NativeObject.getRenderingHints();
+
+ switch (value) {
+ case SmoothingMode.None:
+ if(hints.containsKey(awt.RenderingHints.KEY_ANTIALIASING))
+ hints.remove(awt.RenderingHints.KEY_ANTIALIASING);
+ if(hints.containsKey(awt.RenderingHints.KEY_RENDERING))
+ hints.remove(awt.RenderingHints.KEY_RENDERING);
+ break;
+ case SmoothingMode.AntiAlias:
+ hints.put(awt.RenderingHints.KEY_ANTIALIASING, awt.RenderingHints.VALUE_ANTIALIAS_ON);
+ break;
+ case SmoothingMode.HighQuality:
+ hints.put(awt.RenderingHints.KEY_RENDERING, awt.RenderingHints.VALUE_RENDER_QUALITY);
+ goto case SmoothingMode.AntiAlias;
+ case SmoothingMode.HighSpeed:
+ hints.put(awt.RenderingHints.KEY_RENDERING, awt.RenderingHints.VALUE_RENDER_SPEED);
+ goto case SmoothingMode.None;
+ case SmoothingMode.Default:
+ hints.put(awt.RenderingHints.KEY_RENDERING, awt.RenderingHints.VALUE_RENDER_DEFAULT);
+ goto case SmoothingMode.AntiAlias;
+ case SmoothingMode.Invalid:
+ throw new ArgumentException("Invalid parameter used.");
+ }
+
+ NativeObject.setRenderingHints(hints);
+ }
+ }
+
+ /// <summary>
+ /// Java does not have similar functionality
+ /// </summary>
+ public int TextContrast {
+ get {
+ return _textContrast;
+ }
+
+ set {
+ _textContrast = value;
+ }
+ }
+
+ public TextRenderingHint TextRenderingHint {
+ get {
+ return _textRenderingHint;
+// awt.RenderingHints hints = NativeObject.getRenderingHints();
+// if(hints.containsKey(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING)) {
+// if(hints.get(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING) ==
+// java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON)
+// return TextRenderingHint.AntiAlias;
+// if(hints.get(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING) ==
+// java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF)
+// return TextRenderingHint.SingleBitPerPixel;
+// }
+// //return TextRenderingHint.SystemDefault;
+// return TextRenderingHint.SingleBitPerPixelGridFit;
+ }
+
+ set {
+ _textRenderingHint = value;
+ awt.RenderingHints hints = NativeObject.getRenderingHints();
+ switch (value) {
+ case TextRenderingHint.AntiAlias:
+ case TextRenderingHint.AntiAliasGridFit:
+ case TextRenderingHint.ClearTypeGridFit:
+// case TextRenderingHint.SystemDefault:
+ hints.put(awt.RenderingHints.KEY_TEXT_ANTIALIASING,
+ awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+ break;
+
+ case TextRenderingHint.SingleBitPerPixelGridFit:
+ hints.put(awt.RenderingHints.KEY_TEXT_ANTIALIASING,
+ awt.RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
+ break;
+
+ case TextRenderingHint.SingleBitPerPixel:
+ hints.put(awt.RenderingHints.KEY_TEXT_ANTIALIASING,
+ awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
+ break;
+
+ case TextRenderingHint.SystemDefault:
+ hints.put(awt.RenderingHints.KEY_TEXT_ANTIALIASING,
+ awt.RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
+ break;
+ }
+
+ NativeObject.setRenderingHints(hints);
+ }
+ }
+
+ public Matrix Transform {
+ get {
+ return _transform.Clone();
+ }
+ set {
+ if (value == null)
+ throw new ArgumentNullException("matrix");
+
+ if (!value.IsInvertible)
+ throw new ArgumentException("Invalid parameter used.");
+
+ value.CopyTo(_transform);
+ }
+ }
+
+ internal Matrix BaseTransform {
+ get {
+ return new Matrix(NativeObject.getTransform());
+ }
+ set {
+ NativeObject.setTransform(value.NativeObject);
+ }
+ }
+
+ internal void PrependBaseTransform(geom.AffineTransform t) {
+ NativeObject.transform(t);
+ }
+
+ internal awt.Shape VisibleShape {
+ get {
+ return _windowRect;
+ }
+ }
+
+ public RectangleF VisibleClipBounds {
+ get {
+ if (_clip.IsEmpty(this))
+ return RectangleF.Empty;
+
+ geom.Rectangle2D r = _clip.NativeObject.getBounds2D();
+ awt.Shape clip = NativeObject.getClip();
+ geom.Rectangle2D clipBounds = (clip != null) ? clip.getBounds2D() : _windowRect;
+ geom.Rectangle2D.intersect(r, clipBounds, r);
+ if ((r.getWidth() <= 0) || (r.getHeight() <= 0))
+ return RectangleF.Empty;
+
+ geom.AffineTransform t = GetFinalTransform();
+ if (!t.isIdentity()) {
+ geom.AffineTransform it = t.createInverse();
+ r = it.createTransformedShape(r).getBounds2D();
+ }
+
+ return new RectangleF (r);
+ }
+ }
+
+ void ConcatenateTransform(geom.AffineTransform transform, MatrixOrder order) {
+ geom.AffineTransform at = _transform.NativeObject;
+ Matrix.Multiply(at, transform, order);
+ }
+ #endregion
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing/GraphicsUnit.cs b/mcs/class/System.Drawing/System.Drawing/GraphicsUnit.cs
new file mode 100644
index 00000000000..2210bdb2904
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/GraphicsUnit.cs
@@ -0,0 +1,42 @@
+//
+// System.Drawing.GraphicsUnit.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+namespace System.Drawing
+{
+ [Serializable]
+ public enum GraphicsUnit {
+ World = 0,
+ Display = 1,
+ Pixel = 2,
+ Point = 3,
+ Inch = 4,
+ Document = 5,
+ Millimeter = 6
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/IDeviceContext.cs b/mcs/class/System.Drawing/System.Drawing/IDeviceContext.cs
new file mode 100644
index 00000000000..ae63640479a
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/IDeviceContext.cs
@@ -0,0 +1,43 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+//
+// Jordi Mas i Hernandez <jordimash@gmail.com>
+//
+//
+
+#if NET_2_0
+
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ public interface IDeviceContext : IDisposable
+ {
+ IntPtr GetHdc ();
+ void ReleaseHdc ();
+ }
+}
+
+#endif
+
diff --git a/mcs/class/System.Drawing/System.Drawing/Icon.cs b/mcs/class/System.Drawing/System.Drawing/Icon.cs
new file mode 100644
index 00000000000..3c13cdef8d2
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Icon.cs
@@ -0,0 +1,572 @@
+//
+// System.Drawing.Icon.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Sanjay Gupta (gsanjay@novell.com)
+// Peter Dennis Bartok (pbartok@novell.com)
+//
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+#if !NET_2_0
+ [ComVisible (false)]
+#endif
+ [Serializable]
+ [Editor ("System.Drawing.Design.IconEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ [TypeConverter(typeof(IconConverter))]
+ public sealed class Icon : MarshalByRefObject, ISerializable, ICloneable, IDisposable
+ {
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct IconDirEntry {
+ internal byte width; // Width of icon
+ internal byte height; // Height of icon
+ internal byte colorCount; // colors in icon
+ internal byte reserved; // Reserved
+ internal ushort planes; // Color Planes
+ internal ushort bitCount; // Bits per pixel
+ internal uint bytesInRes; // bytes in resource
+ internal uint imageOffset; // position in file
+ };
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct IconDir {
+ internal ushort idReserved; // Reserved
+ internal ushort idType; // resource type (1 for icons)
+ internal ushort idCount; // how many images?
+ internal IconDirEntry [] idEntries; // the entries for each image
+ };
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct BitmapInfoHeader {
+ internal uint biSize;
+ internal int biWidth;
+ internal int biHeight;
+ internal ushort biPlanes;
+ internal ushort biBitCount;
+ internal uint biCompression;
+ internal uint biSizeImage;
+ internal int biXPelsPerMeter;
+ internal int biYPelsPerMeter;
+ internal uint biClrUsed;
+ internal uint biClrImportant;
+ };
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct IconImage {
+ internal BitmapInfoHeader iconHeader; //image header
+ internal uint [] iconColors; //colors table
+ internal byte [] iconXOR; // bits for XOR mask
+ internal byte [] iconAND; //bits for AND mask
+ };
+
+ private Size iconSize;
+ private IntPtr winHandle = IntPtr.Zero;
+ private IconDir iconDir;
+ private ushort id;
+ private IconImage [] imageData;
+ bool destroyIcon = true;
+
+ private Icon ()
+ {
+ }
+#if INTPTR_SUPPORTED
+ [MonoTODO ("Implement fully")]
+ private Icon (IntPtr handle)
+ {
+ this.winHandle = handle;
+
+ IconInfo ii;
+ GDIPlus.GetIconInfo (winHandle, out ii);
+ if (ii.IsIcon) {
+ // If this structure defines an icon, the hot spot is always in the center of the icon
+ iconSize = new Size (ii.xHotspot * 2, ii.yHotspot * 2);
+ }
+ else {
+ throw new NotImplementedException ();
+ }
+
+ this.destroyIcon = false;
+ }
+#endif
+ public Icon (Icon original, int width, int height) : this (original, new Size(width, height))
+ {
+ }
+
+ public Icon (Icon original, Size size)
+ {
+ this.iconSize = size;
+ this.winHandle = original.winHandle;
+ this.iconDir = original.iconDir;
+ this.imageData = original.imageData;
+
+ int count = iconDir.idCount;
+ bool sizeObtained = false;
+ for (int i=0; i<count; i++){
+ IconDirEntry ide = iconDir.idEntries [i];
+ if (!sizeObtained)
+ if (ide.height==size.Height && ide.width==size.Width) {
+ this.id = (ushort) i;
+ sizeObtained = true;
+ this.iconSize.Height = ide.height;
+ this.iconSize.Width = ide.width;
+ break;
+ }
+ }
+
+ if (!sizeObtained){
+ uint largestSize = 0;
+ for (int j=0; j<count; j++){
+ if (iconDir.idEntries [j].bytesInRes >= largestSize){
+ largestSize = iconDir.idEntries [j].bytesInRes;
+ this.id = (ushort) j;
+ this.iconSize.Height = iconDir.idEntries [j].height;
+ this.iconSize.Width = iconDir.idEntries [j].width;
+ }
+ }
+ }
+ }
+
+ public Icon (Stream stream) : this (stream, 32, 32)
+ {
+ }
+
+ public Icon (Stream stream, int width, int height)
+ {
+ InitFromStreamWithSize (stream, width, height);
+ }
+
+ public Icon (string fileName) : this (new FileStream (fileName, FileMode.Open))
+ {
+ }
+
+ public Icon (Type type, string resource)
+ {
+ using (Stream s = type.Assembly.GetManifestResourceStream (type, resource)) {
+ if (s == null) {
+ throw new FileNotFoundException ("Resource name was not found: `" + resource + "'");
+ }
+ InitFromStreamWithSize (s, 32, 32); // 32x32 is default
+ }
+ }
+
+ private Icon (SerializationInfo info, StreamingContext context)
+ {
+ MemoryStream dataStream = null;
+ int width=0;
+ int height=0;
+ foreach (SerializationEntry serEnum in info) {
+ if (String.Compare(serEnum.Name, "IconData", true) == 0) {
+ dataStream = new MemoryStream ((byte []) serEnum.Value);
+ }
+ if (String.Compare(serEnum.Name, "IconSize", true) == 0) {
+ Size iconSize = (Size) serEnum.Value;
+ width = iconSize.Width;
+ height = iconSize.Height;
+ }
+ }
+ if (dataStream != null && width != 0 && height != 0) {
+ dataStream.Seek (0, SeekOrigin.Begin);
+ InitFromStreamWithSize (dataStream, width, height);
+ }
+ }
+
+ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ MemoryStream ms = new MemoryStream ();
+ Save (ms);
+ info.AddValue ("IconSize", this.Size, typeof (Size));
+ info.AddValue ("IconData", ms.ToArray ());
+ }
+
+#if NET_2_0
+ public Icon (Stream stream, Size size) : this (stream, size.Width, size.Height) {}
+
+ public Icon (string fileName, int width, int height):
+ this (new FileStream (fileName, FileMode.Open), width, height) {}
+
+ public Icon (string fileName, Size size) :
+ this (new FileStream (fileName, FileMode.Open), size) {}
+
+ [MonoTODO]
+ public static Icon ExtractAssociatedIcon (string filePath)
+ {
+ throw new NotImplementedException ();
+ }
+
+#endif
+
+ public void Dispose ()
+ {
+#if !TARGET_JVM
+ DisposeIcon ();
+ GC.SuppressFinalize(this);
+#endif
+ }
+#if !TARGET_JVM
+ void DisposeIcon ()
+ {
+ if (winHandle ==IntPtr.Zero)
+ return;
+
+ if (destroyIcon) {
+ //TODO: will have to call some win32 icon stuff
+ winHandle = IntPtr.Zero;
+ }
+ }
+#endif
+
+ public object Clone ()
+ {
+ return new Icon (this, this.Width, this.Height);
+ }
+#if INTPTR_SUPPORTED
+ public static Icon FromHandle (IntPtr handle)
+ {
+ if (handle == IntPtr.Zero)
+ throw new ArgumentException ("handle");
+
+ return new Icon (handle);
+ }
+#else
+ public static Icon FromHandle (IntPtr handle)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+ public void Save (Stream outputStream)
+ {
+ if (iconDir.idEntries!=null){
+ BinaryWriter bw = new BinaryWriter (outputStream);
+ //write icondir
+ bw.Write (iconDir.idReserved);
+ bw.Write (iconDir.idType);
+ ushort count = iconDir.idCount;
+ bw.Write (count);
+
+ //now write iconDirEntries
+ for (int i=0; i<(int)count; i++){
+ IconDirEntry ide = iconDir.idEntries [i];
+ bw.Write (ide.width);
+ bw.Write (ide.height);
+ bw.Write (ide.colorCount);
+ bw.Write (ide.reserved);
+ bw.Write (ide.planes);
+ bw.Write (ide.bitCount);
+ bw.Write (ide.bytesInRes);
+ bw.Write (ide.imageOffset);
+ }
+
+ //now write iconImage data
+ for (int i=0; i<(int)count; i++){
+ BitmapInfoHeader bih = imageData [i].iconHeader;
+ bw.Write (bih.biSize);
+ bw.Write (bih.biWidth);
+ bw.Write (bih.biHeight);
+ bw.Write (bih.biPlanes);
+ bw.Write (bih.biBitCount);
+ bw.Write (bih.biCompression);
+ bw.Write (bih.biSizeImage);
+ bw.Write (bih.biXPelsPerMeter);
+ bw.Write (bih.biYPelsPerMeter);
+ bw.Write (bih.biClrUsed);
+ bw.Write (bih.biClrImportant);
+
+ //now write color table
+ int colCount = imageData [i].iconColors.Length;
+ for (int j=0; j<colCount; j++)
+ bw.Write (imageData [i].iconColors [j]);
+
+ //now write XOR Mask
+ bw.Write (imageData [i].iconXOR);
+
+ //now write AND Mask
+ bw.Write (imageData [i].iconAND);
+ }
+ bw.Flush();
+ }
+ }
+
+ public Bitmap ToBitmap() {
+ IconImage ii;
+ BitmapInfoHeader bih;
+ int ncolors;
+ Bitmap bmp;
+ BitmapData bits;
+ ColorPalette pal;
+ int biHeight;
+ int bytesPerLine;
+
+ if (imageData == null) {
+ return new Bitmap(32, 32);
+ }
+
+ ii = imageData[this.id];
+ bih = ii.iconHeader;
+ biHeight = bih.biHeight / 2;
+
+ ncolors = (int)bih.biClrUsed;
+ if (ncolors == 0) {
+ if (bih.biBitCount < 24) {
+ ncolors = (int)(1 << bih.biBitCount);
+ }
+ }
+
+ switch(bih.biBitCount) {
+ case 1: { // Monochrome
+ bmp = new Bitmap(bih.biWidth, biHeight, PixelFormat.Format1bppIndexed);
+ break;
+ }
+
+ case 4: { // 4bpp
+ bmp = new Bitmap(bih.biWidth, biHeight, PixelFormat.Format4bppIndexed);
+ break;
+ }
+
+ case 8: { // 8bpp
+ bmp = new Bitmap(bih.biWidth, biHeight, PixelFormat.Format8bppIndexed);
+ break;
+ }
+
+ case 24:
+ case 32: { // 32bpp
+ bmp = new Bitmap(bih.biWidth, biHeight, PixelFormat.Format32bppArgb);
+ break;
+ }
+
+ default: {
+ throw new Exception("Unexpected number of bits:" + bih.biBitCount.ToString());
+ }
+ }
+
+ if (bih.biBitCount < 24) {
+ pal = bmp.Palette; // Managed palette
+
+ for (int i = 0; i < ii.iconColors.Length; i++) {
+ pal.Entries[i] = Color.FromArgb((int)ii.iconColors[i] & unchecked((int)0xff000000));
+ }
+ }
+
+ bytesPerLine = (int)((((bih.biWidth * bih.biBitCount) + 31) & ~31) >> 3);
+ bits = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat);
+
+ for (int y = 0; y < biHeight; y++) {
+ Marshal.Copy(ii.iconXOR, bytesPerLine * y, (IntPtr)((int)bits.Scan0 + bits.Stride * (biHeight - 1 - y)), bytesPerLine);
+ }
+
+ bmp.UnlockBits(bits);
+
+ bmp = new Bitmap(bmp); // This makes a 32bpp image out of an indexed one
+ // Apply the mask to make properly transparent
+ for (int y = 0; y < biHeight; y++) {
+ for (int x = 0; x < bih.biWidth / 8; x++) {
+ for (int bit = 7; bit >= 0; bit--) {
+ if (((ii.iconAND[y * bih.biWidth / 8 +x] >> bit) & 1) != 0) {
+ bmp.SetPixel(x*8 + 7-bit, biHeight - y - 1, Color.Transparent);
+ }
+ }
+ }
+ }
+
+ return bmp;
+ }
+
+ public override string ToString ()
+ {
+ //is this correct, this is what returned by .Net
+ return "<Icon>";
+ }
+
+ [Browsable (false)]
+ public IntPtr Handle {
+ get {
+ return winHandle;
+ }
+ }
+
+ [Browsable (false)]
+ public int Height {
+ get {
+ return iconSize.Height;
+ }
+ }
+
+ public Size Size {
+ get {
+ return iconSize;
+ }
+ }
+
+ [Browsable (false)]
+ public int Width {
+ get {
+ return iconSize.Width;
+ }
+ }
+
+#if !TARGET_JVM
+ ~Icon ()
+ {
+ DisposeIcon ();
+ }
+#endif
+
+ private void InitFromStreamWithSize (Stream stream, int width, int height)
+ {
+ //read the icon header
+ if (stream == null || stream.Length == 0)
+ throw new System.ArgumentException ("The argument 'stream' must be a picture that can be used as a Icon", "stream");
+
+ BinaryReader reader = new BinaryReader (stream);
+
+ //iconDir = new IconDir ();
+ iconDir.idReserved = reader.ReadUInt16();
+ if (iconDir.idReserved != 0) //must be 0
+ throw new System.ArgumentException ("Invalid Argument", "stream");
+
+ iconDir.idType = reader.ReadUInt16();
+ if (iconDir.idType != 1) //must be 1
+ throw new System.ArgumentException ("Invalid Argument", "stream");
+
+ ushort dirEntryCount = reader.ReadUInt16();
+ iconDir.idCount = dirEntryCount;
+ iconDir.idEntries = new IconDirEntry [dirEntryCount];
+ imageData = new IconImage [dirEntryCount];
+ bool sizeObtained = false;
+ //now read in the IconDirEntry structures
+ for (int i=0; i<dirEntryCount; i++){
+ IconDirEntry ide;
+ ide.width = reader.ReadByte ();
+ ide.height = reader.ReadByte ();
+ ide.colorCount = reader.ReadByte ();
+ ide.reserved = reader.ReadByte ();
+ ide.planes = reader.ReadUInt16 ();
+ ide.bitCount = reader.ReadUInt16 ();
+ ide.bytesInRes = reader.ReadUInt32 ();
+ ide.imageOffset = reader.ReadUInt32 ();
+ iconDir.idEntries [i] = ide;
+ //is this is the best fit??
+ if (!sizeObtained)
+ if (ide.height==height && ide.width==width) {
+ this.id = (ushort) i;
+ sizeObtained = true;
+ this.iconSize.Height = ide.height;
+ this.iconSize.Width = ide.width;
+ }
+ }
+ //if we havent found the best match, return the one with the
+ //largest size. Is this approach correct??
+ if (!sizeObtained){
+ uint largestSize = 0;
+ for (int j=0; j<dirEntryCount; j++){
+ if (iconDir.idEntries [j].bytesInRes >= largestSize) {
+ largestSize = iconDir.idEntries [j].bytesInRes;
+ this.id = (ushort) j;
+ this.iconSize.Height = iconDir.idEntries [j].height;
+ this.iconSize.Width = iconDir.idEntries [j].width;
+ }
+ }
+ }
+
+ //now read in the icon data
+ for (int j = 0; j<dirEntryCount; j++)
+ {
+ IconImage iidata = new IconImage();
+ BitmapInfoHeader bih = new BitmapInfoHeader();
+ stream.Seek (iconDir.idEntries [j].imageOffset, SeekOrigin.Begin);
+ byte [] buffer = new byte [iconDir.idEntries [j].bytesInRes];
+ stream.Read (buffer, 0, buffer.Length);
+ BinaryReader bihReader = new BinaryReader (new MemoryStream(buffer));
+ bih.biSize = bihReader.ReadUInt32 ();
+ bih.biWidth = bihReader.ReadInt32 ();
+ bih.biHeight = bihReader.ReadInt32 ();
+ bih.biPlanes = bihReader.ReadUInt16 ();
+ bih.biBitCount = bihReader.ReadUInt16 ();
+ bih.biCompression = bihReader.ReadUInt32 ();
+ bih.biSizeImage = bihReader.ReadUInt32 ();
+ bih.biXPelsPerMeter = bihReader.ReadInt32 ();
+ bih.biYPelsPerMeter = bihReader.ReadInt32 ();
+ bih.biClrUsed = bihReader.ReadUInt32 ();
+ bih.biClrImportant = bihReader.ReadUInt32 ();
+
+ iidata.iconHeader = bih;
+ //Read the number of colors used and corresponding memory occupied by
+ //color table. Fill this memory chunk into rgbquad[]
+ int numColors;
+ switch (bih.biBitCount){
+ case 1: numColors = 2;
+ break;
+ case 4: numColors = 16;
+ break;
+ case 8: numColors = 256;
+ break;
+ default: numColors = 0;
+ break;
+ }
+
+ iidata.iconColors = new uint [numColors];
+ for (int i=0; i<numColors; i++)
+ iidata.iconColors [i] = bihReader.ReadUInt32 ();
+
+ //XOR mask is immediately after ColorTable and its size is
+ //icon height* no. of bytes per line
+
+ //icon height is half of BITMAPINFOHEADER.biHeight, since it contains
+ //both XOR as well as AND mask bytes
+ int iconHeight = bih.biHeight/2;
+
+ //bytes per line should should be uint aligned
+ int numBytesPerLine = ((((bih.biWidth * bih.biPlanes * bih.biBitCount)+ 31)>>5)<<2);
+
+ //Determine the XOR array Size
+ int xorSize = numBytesPerLine * iconHeight;
+ iidata.iconXOR = new byte [xorSize];
+ for (int i=0; i<xorSize; i++)
+ iidata.iconXOR[i] = bihReader.ReadByte();
+
+ //Determine the AND array size
+ //For this i subtract the current position from the length.
+ //ugly hack...
+ int andSize = (int) (bihReader.BaseStream.Length - bihReader.BaseStream.Position);
+ iidata.iconAND = new byte [andSize];
+ for (int i=0; i<andSize; i++)
+ iidata.iconAND[i] = bihReader.ReadByte();
+
+ imageData [j] = iidata;
+ bihReader.Close();
+ }
+
+ reader.Close();
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Icon.jvm.cs b/mcs/class/System.Drawing/System.Drawing/Icon.jvm.cs
new file mode 100755
index 00000000000..944ea0fd03b
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Icon.jvm.cs
@@ -0,0 +1,198 @@
+//
+// System.Drawing.Icon.cs
+//
+// Authors:
+// Andrew Skiba (andrews@mainsoft.com)
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Sanjay Gupta (gsanjay@novell.com)
+//
+// Copyright (C) 2005 Mainsoft, Corp. http://mainsoft.com
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Drawing.Imaging;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ [Serializable]
+ [ComVisible (false)]
+ [TypeConverter(typeof(IconConverter))]
+ public sealed class Icon
+ : MarshalByRefObject, ISerializable, ICloneable, IDisposable
+ {
+ private System.Drawing.Bitmap _bitmap;
+
+ #region Ctors
+ private void SelectSize (int width, int height) {
+ int count = _bitmap.GetFrameCount (FrameDimension.Resolution);
+ bool sizeObtained = false;
+ for (int i=0; i<count; i++){
+ _bitmap.SelectActiveFrame (
+ System.Drawing.Imaging.FrameDimension.Resolution, i);
+ if (!sizeObtained)
+ if (_bitmap.Height==height && _bitmap.Width==width) {
+ sizeObtained = true;
+ break;
+ }
+ }
+
+ if (!sizeObtained){
+ uint largestSize = 0;
+ Bitmap tmpBmp = _bitmap;
+ for (int j=0; j<count; j++){
+ tmpBmp.SelectActiveFrame (FrameDimension.Resolution, j);
+ uint thisSize = (uint)_bitmap.Height * (uint)_bitmap.Width;
+ if (thisSize >= largestSize){
+ largestSize = thisSize;
+ _bitmap = tmpBmp;
+ }
+ }
+ }
+ }
+
+ private Icon () {
+ }
+
+ internal Icon (Bitmap bitmap) {
+ _bitmap = bitmap;
+ }
+
+ public Icon (Icon original, int width, int height) {
+ _bitmap = original._bitmap;
+ SelectSize (width, height);
+ }
+
+ public Icon (Icon original, Size size)
+ :this (original, size.Width, size.Height) {
+ }
+
+ public Icon (Stream stream)
+ : this (stream, 32, 32) {
+ }
+
+ public Icon (Stream stream, int width, int height)
+ {
+ _bitmap = new Bitmap (stream, false, ImageFormat.Icon);
+ SelectSize (width, height);
+ }
+
+ public Icon (string fileName) {
+ _bitmap = new Bitmap (fileName, false, ImageFormat.Icon);
+ }
+
+ public Icon (Type type, string resource)
+ {
+ using (Stream s = type.Assembly.GetManifestResourceStream (resource)) {
+ if (s == null)
+ throw new FileNotFoundException ("Resource name was not found: `" + resource + "'");
+ _bitmap = new Bitmap (s, false, ImageFormat.Icon);
+ }
+ }
+
+ [MonoTODO]
+ private Icon (SerializationInfo info, StreamingContext context)
+ {
+ //FIXME, need to check how MS stores Icon structure
+ //Will serialized form help
+ throw new NotImplementedException ();
+ }
+ #endregion
+
+ [MonoTODO]
+ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Dispose ()
+ {
+#if INTPTR_SUPPORT
+ if (winHandle!=IntPtr.Zero)
+ winHandle = IntPtr.Zero;
+#endif
+ }
+
+ public object Clone ()
+ {
+ Icon newIcon = new Icon ();
+ newIcon._bitmap = (Bitmap)_bitmap.Clone ();
+ return newIcon;
+ }
+
+#if INTPTR_SUPPORT
+ [MonoTODO]
+ public static Icon FromHandle (IntPtr handle)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+ public void Save (Stream outputStream) {
+ _bitmap.Save (outputStream, System.Drawing.Imaging.ImageFormat.Icon);
+ }
+
+ public Bitmap ToBitmap () {
+ return _bitmap;
+ }
+
+ public override string ToString ()
+ {
+ //is this correct, this is what returned by .Net
+ return "<Icon>";
+ }
+
+#if INTPTR_SUPPORT
+ [Browsable (false)]
+ public IntPtr Handle {
+ get {
+ return winHandle;
+ }
+ }
+#endif
+
+ [Browsable (false)]
+ public int Height {
+ get {
+ return _bitmap.Height;
+ }
+ }
+
+ public Size Size {
+ get {
+ return _bitmap.Size;
+ }
+ }
+
+ [Browsable (false)]
+ public int Width {
+ get {
+ return _bitmap.Width;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/IconConverter.cs b/mcs/class/System.Drawing/System.Drawing/IconConverter.cs
new file mode 100644
index 00000000000..52710cf7b03
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/IconConverter.cs
@@ -0,0 +1,90 @@
+ //
+// System.Drawing.IconConverter.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+// Sanjay Gupta (gsanjay@novell.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.IO;
+
+namespace System.Drawing {
+ /// <summary>
+ /// Summary description for IconConverter.
+ /// </summary>
+ public class IconConverter : ExpandableObjectConverter
+ {
+ public IconConverter()
+ {
+ }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type srcType)
+ {
+ if (srcType == typeof (System.Byte[]))
+ return true;
+ else
+ return false;
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destType)
+ {
+ if ((destType == typeof (System.Byte[])) || (destType == typeof (System.String)))
+ return true;
+ else
+ return false;
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object val)
+ {
+ byte [] bytes = val as byte [];
+ if (bytes == null)
+ return base.ConvertFrom (context, culture, val);
+
+ MemoryStream ms = new MemoryStream (bytes);
+
+ return new Icon (ms);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object val, Type destType )
+ {
+ if ((val is Icon) && (destType == typeof (string)))
+ return val.ToString ();
+ else if (CanConvertTo (null, destType)) {
+ //came here means destType is byte array ;
+ MemoryStream ms = new MemoryStream ();
+ ((Icon)val).Save (ms);
+ return ms.GetBuffer ();
+ }else
+ return new NotSupportedException ("IconConverter can not convert from " + val.GetType ());
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Image.cs b/mcs/class/System.Drawing/System.Drawing/Image.cs
new file mode 100644
index 00000000000..b8895778a5c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Image.cs
@@ -0,0 +1,795 @@
+//
+// System.Drawing.Image.cs
+//
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+// Author: Christian Meyer (Christian.Meyer@cs.tum.edu)
+// Alexandre Pigolkine (pigolkine@gmx.de)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+// Sanjay Gupta (gsanjay@novell.com)
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.Remoting;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Reflection;
+
+namespace System.Drawing
+{
+[Serializable]
+[ComVisible (true)]
+[Editor ("System.Drawing.Design.ImageEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
+[TypeConverter (typeof(ImageConverter))]
+[ImmutableObject (true)]
+public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISerializable
+{
+ public delegate bool GetThumbnailImageAbort();
+ private object tag;
+
+ internal IntPtr nativeObject = IntPtr.Zero;
+
+
+ // constructor
+ internal Image()
+ {
+
+ }
+
+ private Image (SerializationInfo info, StreamingContext context)
+ {
+ foreach (SerializationEntry serEnum in info) {
+ if (String.Compare(serEnum.Name, "Data", true) == 0) {
+ byte[] bytes = (byte[]) serEnum.Value;
+
+ if (bytes != null) {
+ InitFromStream(new MemoryStream(bytes));
+ }
+ }
+ }
+ }
+
+ private static bool IsIndexedPixelFormat(PixelFormat pixfmt)
+ {
+ return ((pixfmt & PixelFormat.Indexed) != 0);
+ }
+
+
+ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ MemoryStream ms = new MemoryStream ();
+ this.Save (ms, ImageFormat.Bmp);
+ info.AddValue ("Data", ms.ToArray ());
+ }
+
+ // public methods
+ // static
+ public static Image FromFile(string filename)
+ {
+ return FromFile (filename, false);
+ }
+
+ public static Image FromFile(string filename, bool useEmbeddedColorManagement)
+ {
+ IntPtr imagePtr;
+ Status st;
+
+ if (!File.Exists (filename))
+ throw new FileNotFoundException (filename);
+
+ if (useEmbeddedColorManagement)
+ st = GDIPlus.GdipLoadImageFromFileICM (filename, out imagePtr);
+ else
+ st = GDIPlus.GdipLoadImageFromFile (filename, out imagePtr);
+
+ GDIPlus.CheckStatus (st);
+ return new Bitmap (imagePtr);
+ }
+
+ public static Bitmap FromHbitmap(IntPtr hbitmap)
+ {
+ return FromHbitmap (hbitmap, IntPtr.Zero);
+ }
+
+ public static Bitmap FromHbitmap(IntPtr hbitmap, IntPtr hpalette)
+ {
+ IntPtr imagePtr;
+ Status st;
+
+ st = GDIPlus.GdipCreateBitmapFromHBITMAP (hbitmap, hpalette, out imagePtr);
+
+ GDIPlus.CheckStatus (st);
+ return new Bitmap (imagePtr);
+ }
+
+ public static Image FromStream (Stream stream)
+ {
+ return new Bitmap (stream);
+ }
+
+ public static Image FromStream (Stream stream, bool useECM)
+ {
+ return new Bitmap (stream, useECM);
+ }
+
+#if NET_2_0
+
+ // See http://support.microsoft.com/default.aspx?scid=kb;en-us;831419 for performance discussion
+ public static Image FromStream (Stream stream, bool useECM, bool validateImageData)
+ {
+ return new Bitmap (stream, useECM);
+ }
+
+#endif
+ public static int GetPixelFormatSize(PixelFormat pixfmt)
+ {
+ int result = 0;
+ switch (pixfmt) {
+ case PixelFormat.Format16bppArgb1555:
+ case PixelFormat.Format16bppGrayScale:
+ case PixelFormat.Format16bppRgb555:
+ case PixelFormat.Format16bppRgb565:
+ result = 16;
+ break;
+ case PixelFormat.Format1bppIndexed:
+ result = 1;
+ break;
+ case PixelFormat.Format24bppRgb:
+ result = 24;
+ break;
+ case PixelFormat.Format32bppArgb:
+ case PixelFormat.Format32bppPArgb:
+ case PixelFormat.Format32bppRgb:
+ result = 32;
+ break;
+ case PixelFormat.Format48bppRgb:
+ result = 48;
+ break;
+ case PixelFormat.Format4bppIndexed:
+ result = 4;
+ break;
+ case PixelFormat.Format64bppArgb:
+ case PixelFormat.Format64bppPArgb:
+ result = 64;
+ break;
+ case PixelFormat.Format8bppIndexed:
+ result = 8;
+ break;
+ }
+ return result;
+ }
+
+ public static bool IsAlphaPixelFormat(PixelFormat pixfmt)
+ {
+ bool result = false;
+ switch (pixfmt) {
+ case PixelFormat.Format16bppArgb1555:
+ case PixelFormat.Format32bppArgb:
+ case PixelFormat.Format32bppPArgb:
+ case PixelFormat.Format64bppArgb:
+ case PixelFormat.Format64bppPArgb:
+ result = true;
+ break;
+ case PixelFormat.Format16bppGrayScale:
+ case PixelFormat.Format16bppRgb555:
+ case PixelFormat.Format16bppRgb565:
+ case PixelFormat.Format1bppIndexed:
+ case PixelFormat.Format24bppRgb:
+ case PixelFormat.Format32bppRgb:
+ case PixelFormat.Format48bppRgb:
+ case PixelFormat.Format4bppIndexed:
+ case PixelFormat.Format8bppIndexed:
+ result = false;
+ break;
+ }
+ return result;
+ }
+
+ public static bool IsCanonicalPixelFormat (PixelFormat pixfmt)
+ {
+ return ((pixfmt & PixelFormat.Canonical) != 0);
+ }
+
+ public static bool IsExtendedPixelFormat (PixelFormat pixfmt)
+ {
+ return ((pixfmt & PixelFormat.Extended) != 0);
+ }
+
+ internal void InitFromStream (Stream stream)
+ {
+ IntPtr imagePtr;
+ Status st;
+
+ // Seeking required
+ if (!stream.CanSeek) {
+ byte[] buffer = new byte[256];
+ int index = 0;
+ int count;
+
+ do {
+ if (buffer.Length < index + 256) {
+ byte[] newBuffer = new byte[buffer.Length * 2];
+ Array.Copy(buffer, newBuffer, buffer.Length);
+ buffer = newBuffer;
+ }
+ count = stream.Read(buffer, index, 256);
+ index += count;
+ }
+ while (count != 0);
+
+ stream = new MemoryStream(buffer, 0, index);
+ }
+
+ // check for Unix platforms - see FAQ for more details
+ // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
+ int platform = (int) Environment.OSVersion.Platform;
+ if ((platform == 4) || (platform == 128)) {
+ // Unix, with libgdiplus
+ // We use a custom API for this, because there's no easy way
+ // to get the Stream down to libgdiplus. So, we wrap the stream
+ // with a set of delegates.
+ GDIPlus.GdiPlusStreamHelper sh = new GDIPlus.GdiPlusStreamHelper (stream);
+
+ st = GDIPlus.GdipLoadImageFromDelegate_linux (sh.GetHeaderDelegate, sh.GetBytesDelegate,
+ sh.PutBytesDelegate, sh.SeekDelegate, sh.CloseDelegate, sh.SizeDelegate, out imagePtr);
+ } else {
+ // this is MS-land
+ st = GDIPlus.GdipLoadImageFromStream(new ComIStreamWrapper(stream), out imagePtr);
+ }
+
+ GDIPlus.CheckStatus (st);
+ nativeObject = imagePtr;
+ }
+
+ // non-static
+ public RectangleF GetBounds (ref GraphicsUnit pageUnit)
+ {
+ RectangleF source;
+
+ Status status = GDIPlus.GdipGetImageBounds (nativeObject, out source, ref pageUnit);
+ GDIPlus.CheckStatus (status);
+
+ return source;
+ }
+
+ public EncoderParameters GetEncoderParameterList(Guid format)
+ {
+ Status status;
+ uint sz;
+
+ status = GDIPlus.GdipGetEncoderParameterListSize (nativeObject, ref format, out sz);
+ GDIPlus.CheckStatus (status);
+
+ IntPtr rawEPList = Marshal.AllocHGlobal ((int) sz);
+ EncoderParameters eps;
+
+ try {
+ status = GDIPlus.GdipGetEncoderParameterList (nativeObject, ref format, sz, rawEPList);
+ eps = EncoderParameters.FromNativePtr (rawEPList);
+ GDIPlus.CheckStatus (status);
+ } catch {
+ Marshal.FreeHGlobal (rawEPList);
+ throw;
+ }
+
+ Marshal.FreeHGlobal (rawEPList);
+
+ return eps;
+ }
+
+ public int GetFrameCount(FrameDimension dimension)
+ {
+ int count;
+ Guid guid = dimension.Guid;
+ Status status = GDIPlus.GdipImageGetFrameCount (nativeObject, ref guid, out count);
+
+ GDIPlus.CheckStatus (status);
+
+ return count;
+
+ }
+
+ public PropertyItem GetPropertyItem(int propid)
+ {
+ int propSize;
+ IntPtr property;
+ PropertyItem item = new PropertyItem ();
+ GdipPropertyItem gdipProperty = new GdipPropertyItem ();
+ Status status;
+
+ status = GDIPlus.GdipGetPropertyItemSize (nativeObject, propid,
+ out propSize);
+ GDIPlus.CheckStatus (status);
+
+ /* Get PropertyItem */
+ property = Marshal.AllocHGlobal (propSize);
+ status = GDIPlus.GdipGetPropertyItem (nativeObject, propid, propSize,
+ property);
+ GDIPlus.CheckStatus (status);
+ gdipProperty = (GdipPropertyItem) Marshal.PtrToStructure ((IntPtr)property,
+ typeof (GdipPropertyItem));
+ GdipPropertyItem.MarshalTo (gdipProperty, item);
+
+ Marshal.FreeHGlobal (property);
+ return item;
+ }
+
+ public Image GetThumbnailImage(int thumbWidth, int thumbHeight, Image.GetThumbnailImageAbort callback, IntPtr callbackData)
+ {
+ Status status;
+ Image ThumbNail;
+ Graphics g;
+
+ ThumbNail=new Bitmap(thumbWidth, thumbHeight);
+ g=Graphics.FromImage(ThumbNail);
+
+ status = GDIPlus.GdipDrawImageRectRectI(g.nativeObject, nativeObject,
+ 0, 0, thumbWidth, thumbHeight,
+ 0, 0, this.Width, this.Height,
+ GraphicsUnit.Pixel, IntPtr.Zero, null, IntPtr.Zero);
+ GDIPlus.CheckStatus (status);
+ g.Dispose();
+
+ return(ThumbNail);
+ }
+
+
+ public void RemovePropertyItem (int propid)
+ {
+ Status status = GDIPlus.GdipRemovePropertyItem (nativeObject, propid);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void RotateFlip (RotateFlipType rotateFlipType)
+ {
+ Status status = GDIPlus.GdipImageRotateFlip (nativeObject, rotateFlipType);
+ GDIPlus.CheckStatus (status);
+ }
+
+ internal ImageCodecInfo findEncoderForFormat (ImageFormat format)
+ {
+ ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders();
+ ImageCodecInfo encoder = null;
+
+ if (format.Guid.Equals (ImageFormat.MemoryBmp.Guid))
+ format = ImageFormat.Png;
+
+ /* Look for the right encoder for our format*/
+ for (int i = 0; i < encoders.Length; i++) {
+ if (encoders[i].FormatID.Equals (format.Guid)) {
+ encoder = encoders[i];
+ break;
+ }
+ }
+
+ return encoder;
+ }
+
+ public void Save (string filename)
+ {
+ Save (filename, RawFormat);
+ }
+
+ public void Save(string filename, ImageFormat format)
+ {
+ ImageCodecInfo encoder = findEncoderForFormat (format);
+
+ if (encoder == null)
+ throw new ArgumentException ("No codec available for format:" + format.Guid);
+
+ Save (filename, encoder, null);
+ }
+
+ public void Save(string filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
+ {
+ Status st;
+ Guid guid = encoder.Clsid;
+
+ if (encoderParams == null) {
+ st = GDIPlus.GdipSaveImageToFile (nativeObject, filename, ref guid, IntPtr.Zero);
+ } else {
+ IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
+ st = GDIPlus.GdipSaveImageToFile (nativeObject, filename, ref guid, nativeEncoderParams);
+ Marshal.FreeHGlobal (nativeEncoderParams);
+ }
+
+ GDIPlus.CheckStatus (st);
+ }
+
+ public void Save (Stream stream, ImageFormat format)
+ {
+ ImageCodecInfo encoder = findEncoderForFormat (format);
+
+ if (encoder == null)
+ throw new ArgumentException ("No codec available for format:" + format.Guid);
+
+ Save (stream, encoder, null);
+ }
+
+ public void Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
+ {
+ Status st;
+ IntPtr nativeEncoderParams;
+ Guid guid = encoder.Clsid;
+
+ if (encoderParams == null)
+ nativeEncoderParams = IntPtr.Zero;
+ else
+ nativeEncoderParams = encoderParams.ToNativePtr ();
+
+ try {
+ // check for Unix platforms - see FAQ for more details
+ // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
+ int platform = (int) Environment.OSVersion.Platform;
+ if ((platform == 4) || (platform == 128)) {
+ GDIPlus.GdiPlusStreamHelper sh = new GDIPlus.GdiPlusStreamHelper (stream);
+ st = GDIPlus.GdipSaveImageToDelegate_linux (nativeObject, sh.GetBytesDelegate, sh.PutBytesDelegate,
+ sh.SeekDelegate, sh.CloseDelegate, sh.SizeDelegate, ref guid, nativeEncoderParams);
+ }
+ else
+ st = GDIPlus.GdipSaveImageToStream(new HandleRef(this, nativeObject), new ComIStreamWrapper(stream), ref guid, new HandleRef(encoderParams, nativeEncoderParams));
+ }
+ finally {
+ if (nativeEncoderParams != IntPtr.Zero)
+ Marshal.FreeHGlobal (nativeEncoderParams);
+ }
+
+ GDIPlus.CheckStatus (st);
+ }
+
+ public void SaveAdd (EncoderParameters encoderParams)
+ {
+ Status st;
+
+ IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
+ st = GDIPlus.GdipSaveAdd (nativeObject, nativeEncoderParams);
+ Marshal.FreeHGlobal (nativeEncoderParams);
+ GDIPlus.CheckStatus (st);
+ }
+
+ public void SaveAdd (Image image, EncoderParameters encoderParams)
+ {
+ Status st;
+
+ IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
+ st = GDIPlus.GdipSaveAddImage (nativeObject, image.NativeObject, nativeEncoderParams);
+ Marshal.FreeHGlobal (nativeEncoderParams);
+ GDIPlus.CheckStatus (st);
+ }
+
+ public int SelectActiveFrame(FrameDimension dimension, int frameIndex)
+ {
+ Guid guid = dimension.Guid;
+ Status st = GDIPlus.GdipImageSelectActiveFrame (nativeObject, ref guid, frameIndex);
+
+ GDIPlus.CheckStatus (st);
+
+ return frameIndex;
+ }
+
+ public void SetPropertyItem(PropertyItem propitem)
+ {
+ IntPtr property;
+ int size = Marshal.SizeOf (typeof(GdipPropertyItem));
+ property = Marshal.AllocHGlobal (size);
+
+ Marshal.StructureToPtr (propitem, property, true);
+ Status status = GDIPlus.GdipSetPropertyItem (nativeObject, property);
+ GDIPlus.CheckStatus (status);
+ }
+
+ // properties
+ [Browsable (false)]
+ public int Flags {
+ get {
+ int flags;
+
+ Status status = GDIPlus.GdipGetImageFlags (nativeObject, out flags);
+ GDIPlus.CheckStatus (status);
+ return flags;
+ }
+ }
+
+ [Browsable (false)]
+ public Guid[] FrameDimensionsList {
+ get {
+ uint found;
+ Status status = GDIPlus.GdipImageGetFrameDimensionsCount (nativeObject, out found);
+ GDIPlus.CheckStatus (status);
+ Guid [] guid = new Guid [found];
+ status = GDIPlus.GdipImageGetFrameDimensionsList (nativeObject, guid, found);
+ GDIPlus.CheckStatus (status);
+ return guid;
+ }
+ }
+
+ [DefaultValue (false)]
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public int Height {
+ get {
+ int height;
+ Status status = GDIPlus.GdipGetImageHeight (nativeObject, out height);
+ GDIPlus.CheckStatus (status);
+
+ return height;
+ }
+ }
+
+ public float HorizontalResolution {
+ get {
+ float resolution;
+
+ Status status = GDIPlus.GdipGetImageHorizontalResolution (nativeObject, out resolution);
+ GDIPlus.CheckStatus (status);
+
+ return resolution;
+ }
+ }
+
+ [Browsable (false)]
+ public ColorPalette Palette {
+ get {
+ return retrieveGDIPalette();
+ }
+ set {
+ storeGDIPalette(value);
+ }
+ }
+
+ internal ColorPalette retrieveGDIPalette()
+ {
+ ColorPalette ret = new ColorPalette();
+ if (!IsIndexedPixelFormat (PixelFormat)) {
+ return ret;
+ }
+ Status st;
+ int bytes;
+
+ st = GDIPlus.GdipGetImagePaletteSize (nativeObject, out bytes);
+ GDIPlus.CheckStatus (st);
+ IntPtr palette_data = Marshal.AllocHGlobal (bytes);
+ try {
+ st = GDIPlus.GdipGetImagePalette (nativeObject, palette_data, bytes);
+ GDIPlus.CheckStatus (st);
+ ret.setFromGDIPalette (palette_data);
+ return ret;
+ }
+
+ finally {
+ Marshal.FreeHGlobal (palette_data);
+ }
+ }
+
+ internal void storeGDIPalette(ColorPalette palette)
+ {
+ if (palette == null) {
+ throw new ArgumentNullException("palette");
+ }
+ IntPtr palette_data = palette.getGDIPalette();
+ if (palette_data == IntPtr.Zero) {
+ return;
+ }
+
+ try {
+ Status st = GDIPlus.GdipSetImagePalette (nativeObject, palette_data);
+ GDIPlus.CheckStatus (st);
+ }
+
+ finally {
+ Marshal.FreeHGlobal(palette_data);
+ }
+ }
+
+
+ public SizeF PhysicalDimension {
+ get {
+ float width, height;
+ Status status = GDIPlus.GdipGetImageDimension (nativeObject, out width, out height);
+ GDIPlus.CheckStatus (status);
+
+ return new SizeF (width, height);
+ }
+ }
+
+ public PixelFormat PixelFormat {
+ get {
+ PixelFormat pixFormat;
+ Status status = GDIPlus.GdipGetImagePixelFormat (nativeObject, out pixFormat);
+ GDIPlus.CheckStatus (status);
+
+ return pixFormat;
+ }
+ }
+
+ [Browsable (false)]
+ public int[] PropertyIdList {
+ get {
+ uint propNumbers;
+
+ Status status = GDIPlus.GdipGetPropertyCount (nativeObject,
+ out propNumbers);
+ GDIPlus.CheckStatus (status);
+
+ int [] idList = new int [propNumbers];
+ status = GDIPlus.GdipGetPropertyIdList (nativeObject,
+ propNumbers, idList);
+ GDIPlus.CheckStatus (status);
+
+ return idList;
+ }
+ }
+
+ [Browsable (false)]
+ public PropertyItem[] PropertyItems {
+ get {
+ int propNums, propsSize, propSize;
+ IntPtr properties, propPtr;
+ PropertyItem[] items;
+ GdipPropertyItem gdipProperty = new GdipPropertyItem ();
+ Status status;
+
+ status = GDIPlus.GdipGetPropertySize (nativeObject, out propsSize, out propNums);
+ GDIPlus.CheckStatus (status);
+
+ items = new PropertyItem [propNums];
+
+ if (propNums == 0)
+ return items;
+
+ /* Get PropertyItem list*/
+ properties = Marshal.AllocHGlobal (propsSize * propNums);
+
+ status = GDIPlus.GdipGetAllPropertyItems (nativeObject, propsSize,
+ propNums, properties);
+ GDIPlus.CheckStatus (status);
+
+ propSize = Marshal.SizeOf (gdipProperty);
+ propPtr = properties;
+
+ for (int i = 0; i < propNums; i++, propPtr = new IntPtr (propPtr.ToInt64 () + propSize))
+ {
+ gdipProperty = (GdipPropertyItem) Marshal.PtrToStructure
+ (propPtr, typeof (GdipPropertyItem));
+ items [i] = new PropertyItem ();
+ GdipPropertyItem.MarshalTo (gdipProperty, items [i]);
+ }
+
+ Marshal.FreeHGlobal (properties);
+ return items;
+ }
+ }
+
+ public ImageFormat RawFormat {
+ get {
+ Guid guid;
+ Status st = GDIPlus.GdipGetImageRawFormat (nativeObject, out guid);
+
+ GDIPlus.CheckStatus (st);
+ return new ImageFormat (guid);
+ }
+ }
+
+ public Size Size {
+ get {
+ return new Size(Width, Height);
+ }
+ }
+
+#if NET_2_0
+
+ [LocalizableAttribute(false)]
+ [BindableAttribute(true)]
+ [TypeConverter (typeof (StringConverter))]
+ public object Tag {
+ get { return tag; }
+ set { tag = value; }
+ }
+#endif
+ public float VerticalResolution {
+ get {
+ float resolution;
+
+ Status status = GDIPlus.GdipGetImageVerticalResolution (nativeObject, out resolution);
+ GDIPlus.CheckStatus (status);
+
+ return resolution;
+ }
+ }
+
+ [DefaultValue (false)]
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public int Width {
+ get {
+ int width;
+ Status status = GDIPlus.GdipGetImageWidth (nativeObject, out width);
+ GDIPlus.CheckStatus (status);
+
+ return width;
+ }
+ }
+
+ internal IntPtr NativeObject{
+ get{
+ return nativeObject;
+ }
+ set {
+ nativeObject = value;
+ }
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ ~Image ()
+ {
+ Dispose (false);
+ }
+
+ private void DisposeResources ()
+ {
+ Status status = GDIPlus.GdipDisposeImage (nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (nativeObject != IntPtr.Zero){
+ DisposeResources ();
+ nativeObject = IntPtr.Zero;
+ }
+ }
+
+ public virtual object Clone()
+ {
+
+ IntPtr newimage = IntPtr.Zero;
+
+ if (!(this is Bitmap))
+ throw new NotImplementedException ();
+
+ Status status = GDIPlus.GdipCloneImage (NativeObject, out newimage);
+ GDIPlus.CheckStatus (status);
+
+ if (this is Bitmap){
+ return new Bitmap (newimage);
+ }
+
+ throw new NotImplementedException ();
+ }
+
+}
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Image.jvm.cs b/mcs/class/System.Drawing/System.Drawing/Image.jvm.cs
new file mode 100644
index 00000000000..11be7601fc4
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Image.jvm.cs
@@ -0,0 +1,571 @@
+//
+// System.Drawing.Image.cs
+//
+// (C) 2002 Ximian, Inc. http://www.ximian.com
+// Author: Christian Meyer (Christian.Meyer@cs.tum.edu)
+// Alexandre Pigolkine (pigolkine@gmx.de)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+namespace System.Drawing {
+
+ using System;
+ using System.Runtime.Remoting;
+ using System.Runtime.Serialization;
+ using System.Runtime.InteropServices;
+ using System.ComponentModel;
+ using System.Drawing;
+ using System.Drawing.Imaging;
+ using System.IO;
+ using System.Xml;
+ using Mainsoft.Drawing.Imaging;
+
+ using BufferedImage = java.awt.image.BufferedImage;
+ using java.io;
+ using javax.imageio;
+ using javax.imageio.stream;
+ using vmw.common;
+ using awt = java.awt;
+ using image = java.awt.image;
+
+ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable {
+ #region Vars
+ PlainImageCollection _nativeObject = new PlainImageCollection();
+ protected int _flags = 0;
+
+ //consider using Image[] to support many thumbnails per Image
+ #endregion
+
+ #region flags enum
+ [Flags]
+ protected enum ImageFlags {
+ ImageFlagsNone = 0,
+ ImageFlagsScalable = 0x0001,
+ ImageFlagsHasAlpha = 0x0002,
+ ImageFlagsHasTranslucent = 0x0004,
+ ImageFlagsPartiallyScalable = 0x0008,
+ ImageFlagsColorSpaceRGB = 0x0010,
+ ImageFlagsColorSpaceCMYK = 0x0020,
+ ImageFlagsColorSpaceGRAY = 0x0040,
+ ImageFlagsColorSpaceYCBCR = 0x0080,
+ ImageFlagsColorSpaceYCCK = 0x0100,
+ ImageFlagsHasRealDPI = 0x1000,
+ ImageFlagsHasRealPixelSize = 0x2000,
+ ImageFlagsReadOnly = 0x00010000,
+ ImageFlagsCaching = 0x00020000
+ }
+ #endregion
+
+ #region Constructor
+ public void Dispose () {
+ }
+
+ protected virtual void DisposeResources () {
+ }
+
+ protected virtual void Dispose (bool disposing) {
+ }
+
+ // Derived classes must call Initialize () when they use this constructor
+ protected Image () {
+ }
+
+ protected Image (java.awt.Image nativeObject) : this(nativeObject, ImageFormat.MemoryBmp) {
+ }
+
+ protected Image (java.awt.Image nativeObject, ImageFormat format) {
+ PlainImage pi = new PlainImage( nativeObject, null, format, 0, 0, FrameDimension.Page );
+ Initialize( pi, false );
+ }
+
+ protected void Initialize (PlainImage pi, bool addToCollection) {
+ if (!addToCollection)
+ NativeObject.Clear();
+
+ NativeObject.Add( pi );
+ }
+
+ #endregion
+
+ #region Internals
+
+ internal PlainImageCollection NativeObject {
+ get {
+ return _nativeObject;
+ }
+ }
+
+ internal PlainImage CurrentImage {
+ get {
+ return NativeObject.CurrentImage;
+ }
+ }
+
+ #endregion
+
+ #region FromFile
+ [MonoTODO]
+ public static Image FromFile(string filename) {
+ //FIXME: check if it's not a metafile, throw NotImplementedException
+ return new Bitmap (filename);
+ }
+
+ [MonoTODO]
+ public static Image FromFile(string filename, bool useIcm) {
+ //FIXME: check if it's not a metafile, throw NotImplementedException
+ return new Bitmap (filename, useIcm);
+ }
+ #endregion
+
+ #region GetThumbnailImageAbort
+ [Serializable]
+ public delegate bool GetThumbnailImageAbort();
+ #endregion
+
+ #region Clone
+ public abstract object Clone();
+ #endregion
+
+ // static
+ #region FromStream
+ [MonoTODO]
+ public static Image FromStream (Stream stream) {
+ //FIXME: check if it's not a metafile, throw NotImplementedException
+ return new Bitmap (stream);
+ }
+
+ [MonoTODO]
+ public static Image FromStream (Stream stream, bool useIcm) {
+ //FIXME: check if it's not a metafile, throw NotImplementedException
+ return new Bitmap (stream, useIcm);
+ }
+ #endregion
+
+ #region GetPixelFormatSize
+ public static int GetPixelFormatSize(PixelFormat pixfmt) {
+
+ int result = 0;
+ switch (pixfmt) {
+ case PixelFormat.Format16bppArgb1555:
+ case PixelFormat.Format16bppGrayScale:
+ case PixelFormat.Format16bppRgb555:
+ case PixelFormat.Format16bppRgb565:
+ result = 16;
+ break;
+ case PixelFormat.Format1bppIndexed:
+ result = 1;
+ break;
+ case PixelFormat.Format24bppRgb:
+ result = 24;
+ break;
+ case PixelFormat.Format32bppArgb:
+ case PixelFormat.Format32bppPArgb:
+ case PixelFormat.Format32bppRgb:
+ result = 32;
+ break;
+ case PixelFormat.Format48bppRgb:
+ result = 48;
+ break;
+ case PixelFormat.Format4bppIndexed:
+ result = 4;
+ break;
+ case PixelFormat.Format64bppArgb:
+ case PixelFormat.Format64bppPArgb:
+ result = 64;
+ break;
+ case PixelFormat.Format8bppIndexed:
+ result = 8;
+ break;
+ }
+ return result;
+ }
+ #endregion
+
+ #region IsAlphaPixelFormat
+ public static bool IsAlphaPixelFormat(PixelFormat pixfmt) {
+ return (pixfmt & PixelFormat.Alpha) != PixelFormat.Undefined;
+ }
+ #endregion
+
+ #region IsCanonicalPixelFormat
+ // TBD: implement this
+ public static bool IsCanonicalPixelFormat (PixelFormat pixfmt) {
+ return (pixfmt & PixelFormat.Canonical) != PixelFormat.Undefined;
+ }
+ #endregion
+
+ #region IsExtendedPixelFormat
+ // TBD: implement this
+ public static bool IsExtendedPixelFormat (PixelFormat pixfmt) {
+ return (pixfmt & PixelFormat.Extended) != PixelFormat.Undefined;
+ }
+ #endregion
+
+ // non-static
+ #region GetBounds
+ public RectangleF GetBounds (ref GraphicsUnit pageUnit) {
+ pageUnit = GraphicsUnit.Pixel; //java.awt.Image always returns pixels
+ return new RectangleF((float)0,(float)0,(float)Width,(float)Height);
+ }
+ #endregion
+
+ #region GetEncoderParameterList
+ [MonoTODO]
+ public EncoderParameters GetEncoderParameterList(Guid encoder) {
+ throw new NotImplementedException ();
+ }
+ #endregion
+
+ #region GetFrameCount
+ public int GetFrameCount(FrameDimension dimension) {
+ // FALLBACK: now, only one dimension assigned for all frames
+ if (dimension.Guid != CurrentImage.Dimension.Guid)
+ throw new ArgumentException ("dimension");
+
+ return NativeObject.Count;
+ }
+ #endregion
+
+ #region GetPropertyItem
+ [MonoTODO]
+ public PropertyItem GetPropertyItem(int propid) {
+ throw new NotImplementedException ();
+ }
+ #endregion
+
+ #region RemovePropertyItem
+ [MonoTODO]
+ public void RemovePropertyItem (int propid) {
+ throw new NotImplementedException ();
+ }
+ #endregion
+
+ #region RotateFlip
+ public void RotateFlip (RotateFlipType rotateFlipType) {
+ awt.geom.AffineTransform tx;
+
+ if ( !(CurrentImage.NativeImage is image.BufferedImage) )
+ // TBD: This implementation is for raster formats only
+ throw new NotImplementedException("Only raster formats are supported");
+
+ switch (rotateFlipType) {
+ case RotateFlipType.RotateNoneFlipNone :
+ return;
+
+ case RotateFlipType.Rotate90FlipNone :
+ tx = awt.geom.AffineTransform.getRotateInstance(Math.PI / 2);
+ tx.translate( 0, -Height );
+ break;
+
+ case RotateFlipType.Rotate180FlipNone :
+ tx = awt.geom.AffineTransform.getScaleInstance(-1, -1);
+ tx.translate( -Width, -Height );
+ break;
+
+ case RotateFlipType.Rotate270FlipNone :
+ tx = awt.geom.AffineTransform.getRotateInstance(-Math.PI / 2);
+ tx.translate( -Width, 0 );
+ break;
+
+ case RotateFlipType.RotateNoneFlipX :
+ tx = awt.geom.AffineTransform.getScaleInstance(-1, 1);
+ tx.translate( -Width, 0 );
+ break;
+
+ case RotateFlipType.Rotate90FlipX :
+ tx = awt.geom.AffineTransform.getRotateInstance(Math.PI / 2);
+ tx.scale(1, -1);
+ break;
+
+ case RotateFlipType.Rotate180FlipX :
+ tx = awt.geom.AffineTransform.getScaleInstance(1, -1);
+ tx.translate( 0, -Height );
+ break;
+
+ case RotateFlipType.Rotate270FlipX :
+ tx = awt.geom.AffineTransform.getRotateInstance(Math.PI / 2);
+ tx.scale(-1, 1);
+ tx.translate( -Width, -Height );
+ break;
+
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ image.AffineTransformOp op = new image.AffineTransformOp(tx, image.AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
+ CurrentImage.NativeImage = op.filter((BufferedImage)CurrentImage.NativeImage, null);
+ }
+ #endregion
+
+ #region Save
+ protected abstract void InternalSave (ImageOutputStream output, Guid clsid);
+
+ [MonoTODO]
+ public void Save (Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) {
+ //TBD: implement encoderParams
+ if (encoder == null)
+ throw new ArgumentNullException("Value cannot be null.");
+
+ try {
+ java.io.OutputStream jos = vmw.common.IOUtils.ToOutputStream (stream);
+ MemoryCacheImageOutputStream output = new MemoryCacheImageOutputStream(jos);
+ InternalSave (output, encoder.Clsid);
+ output.flush();
+ }
+ catch (java.io.IOException ex) {
+ throw new System.IO.IOException(ex.Message, ex);
+ }
+ }
+
+ public void Save(string filename, ImageCodecInfo encoder, EncoderParameters encoderParams) {
+ using (Stream outputStream = new FileStream(filename, FileMode.Create))
+ Save(outputStream, encoder, encoderParams);
+ }
+
+ public void Save (string filename) {
+ Save (filename, ImageFormat.Png);
+ }
+
+ public void Save (Stream stream, ImageFormat format) {
+ ImageCodecInfo encoder = ImageCodec.FindEncoder ( ImageCodec.ImageFormatToClsid (format) );
+ Save (stream, encoder, null);
+ }
+
+ public void Save(string filename, ImageFormat format) {
+ using (Stream outputStream = new FileStream(filename, FileMode.Create))
+ Save(outputStream, format);
+ }
+ #endregion
+
+ #region SaveAdd
+ [MonoTODO]
+ public void SaveAdd(EncoderParameters encoderParams) {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SaveAdd(Image image, EncoderParameters encoderParams) {
+ throw new NotImplementedException ();
+ }
+ #endregion
+
+ #region SelectActiveFrame
+
+ // TBD: .Net does not load all frames at the initialization. New frames loaded by request.
+ [MonoTODO]
+ public int SelectActiveFrame(FrameDimension dimension, int frameIndex) {
+ // FALLBACK: now, only one dimension assigned for all frames
+ if (dimension.Guid != CurrentImage.Dimension.Guid)
+ throw new ArgumentException ("dimension");
+
+ if (frameIndex < NativeObject.Count)
+ NativeObject.CurrentImageIndex = frameIndex;
+
+ return frameIndex;
+ }
+ #endregion
+
+ #region SetPropertyItem
+ [MonoTODO]
+ public void SetPropertyItem(PropertyItem propitem) {
+ throw new NotImplementedException ();
+ }
+ #endregion
+
+ // properties
+ #region Flags
+ public int Flags {
+ // TDB: ImageFlagsScalable, ImageFlagsHasTranslucent, ImageFlagsPartiallyScalable, ImageFlagsCaching
+ [MonoTODO]
+ get {
+ image.ColorModel colorModel = ((BufferedImage)CurrentImage.NativeImage).getColorModel();
+ int t = colorModel.getColorSpace().getType();
+
+ if (t == awt.color.ColorSpace.TYPE_RGB)
+ _flags |= (int)ImageFlags.ImageFlagsColorSpaceRGB;
+ else if (t == awt.color.ColorSpace.TYPE_CMYK)
+ _flags |= (int)ImageFlags.ImageFlagsColorSpaceCMYK;
+ else if (t == awt.color.ColorSpace.TYPE_GRAY)
+ _flags |= (int)ImageFlags.ImageFlagsColorSpaceGRAY;
+ else if (t == awt.color.ColorSpace.TYPE_YCbCr)
+ _flags |= (int)ImageFlags.ImageFlagsColorSpaceYCBCR;
+
+ if (colorModel.hasAlpha())
+ _flags |= (int)ImageFlags.ImageFlagsHasAlpha;
+
+ if ((CurrentImage.HorizontalResolution > 0) || (CurrentImage.VerticalResolution > 0))
+ _flags |= (int)ImageFlags.ImageFlagsHasRealDPI;
+
+ return _flags;
+ }
+ }
+ #endregion
+
+ #region FrameDimensionsList
+ [MonoTODO]
+ public Guid[] FrameDimensionsList {
+ // TBD: look over all frames and build array of dimensions
+ // FALLBACK: now, only one dimension assigned for all frames
+ get {
+ Guid [] dimList = new Guid[]{CurrentImage.Dimension.Guid};
+ return dimList;
+ }
+ }
+ #endregion
+
+ #region Height
+ public int Height {
+ get {
+ return CurrentImage.NativeImage.getHeight(null);
+ }
+ }
+ #endregion
+
+ #region HorizontalResolution
+ public float HorizontalResolution {
+ get {
+ if (CurrentImage.HorizontalResolution <= 1)
+ return Graphics.DefaultScreenResolution;
+
+ return CurrentImage.HorizontalResolution;
+ }
+ }
+ #endregion
+
+ #region ColorPalette
+ [MonoTODO]
+ public ColorPalette Palette {
+ get {
+ if (!(CurrentImage.NativeImage is BufferedImage))
+ // TBD: This implementation is for raster formats only
+ throw new NotImplementedException("Only raster formats are supported");
+
+ image.ColorModel colorModel = ((BufferedImage)CurrentImage.NativeImage).getColorModel();
+ if (colorModel is image.IndexColorModel) {
+
+ Color [] colors = new Color[ ((image.IndexColorModel)colorModel).getMapSize() ];
+ for (int i=0; i<colors.Length; i++) {
+ colors[i] = Color.FromArgb( ((image.IndexColorModel)colorModel).getRGB(i) );
+ }
+ ColorPalette palette = new ColorPalette(0, colors);
+ return palette;
+ }
+ return new ColorPalette();
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+ #endregion
+
+ #region PhysicalDimension
+ public SizeF PhysicalDimension {
+ get {
+ return new Size(Width, Height);
+ }
+ }
+ #endregion
+
+ #region PixelFormat
+ abstract protected PixelFormat InternalPixelFormat {get;}
+
+ public PixelFormat PixelFormat {
+ get {
+ return InternalPixelFormat;
+ }
+ }
+ #endregion
+
+ #region PropertiIdList
+ [MonoTODO]
+ public int[] PropertyIdList {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+ #endregion
+
+ #region PropertItems
+ [MonoTODO]
+ public PropertyItem[] PropertyItems {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+ #endregion
+
+ #region RawFormat
+ public ImageFormat RawFormat {
+ get {
+ return CurrentImage.ImageFormat;
+ }
+ }
+ #endregion
+
+ #region Size
+ public Size Size {
+ get {
+ return new Size(Width, Height);
+ }
+ }
+ #endregion
+
+ #region VerticalResolution
+ public float VerticalResolution {
+ get {
+ if (CurrentImage.VerticalResolution <= 1)
+ return Graphics.DefaultScreenResolution;
+
+ return CurrentImage.VerticalResolution;
+ }
+ }
+ #endregion
+
+ #region Width
+ public int Width {
+ get {
+ return CurrentImage.NativeImage.getWidth(null);
+ }
+ }
+ #endregion
+
+ public Image GetThumbnailImage(int thumbWidth, int thumbHeight, Image.GetThumbnailImageAbort callback, IntPtr callbackData) {
+ awt.Image img;
+
+#if THUMBNAIL_SUPPORTED
+ if (CurrentImage.Thumbnails != null) {
+ for (int i=0; i < CurrentImage.Thumbnails.Length; i++)
+ if (CurrentImage.Thumbnails[i] != null) {
+ img = CurrentImage.Thumbnails[i];
+ if (img.getHeight(null) == thumbHeight && img.getWidth(null) == thumbWidth)
+ return ImageFromNativeImage(img, RawFormat);
+ }
+ }
+#endif
+ img = CurrentImage.NativeImage.getScaledInstance(thumbWidth, thumbHeight, awt.Image.SCALE_DEFAULT);
+
+ return ImageFromNativeImage(img, RawFormat);
+ }
+#if INTPTR_SUPPORT
+ [MonoTODO]
+ public static Bitmap FromHbitmap(IntPtr hbitmap)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static Bitmap FromHbitmap(IntPtr hbitmap, IntPtr hpalette)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
+ internal static Image ImageFromNativeImage(awt.Image nativeImage, ImageFormat format) {
+ if (nativeImage is BufferedImage)
+ return new Bitmap(nativeImage, format);
+
+ throw new ArgumentException("Invalid image type");
+ }
+
+ protected abstract awt.Image [] CloneNativeObjects(awt.Image [] src);
+ }
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs b/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs
new file mode 100644
index 00000000000..201e39e53de
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ImageAnimator.cs
@@ -0,0 +1,218 @@
+//
+// System.Drawing.ImageAnimator.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Sanjay Gupta (gsanjay@novell.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing.Imaging;
+using System.Threading;
+using System.Collections;
+
+namespace System.Drawing
+{
+ //AnimateEventArgs class
+ class AnimateEventArgs : EventArgs
+ {
+ private int frameCount;
+ private int activeFrameCount = 0;
+ private Thread thread;
+
+ //Constructor.
+ //
+ public AnimateEventArgs(Image img)
+ {
+ Guid[] dimensionList = img.FrameDimensionsList;
+ int length = dimensionList.Length;
+ for (int i=0; i<length; i++) {
+ if (dimensionList [i].Equals(FrameDimension.Time.Guid))
+ this.frameCount = img.GetFrameCount (FrameDimension.Time);
+ }
+ }
+
+ public int FrameCount {
+ get {
+ return frameCount;
+ }
+ }
+
+ public int ActiveFrameCount {
+ get {
+ return activeFrameCount;
+ }
+
+ set {
+ activeFrameCount = value;
+ }
+ }
+
+ public Thread RunThread{
+ get {
+ return thread;
+ }
+
+ set {
+ thread = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Summary description for ImageAnimator.
+ /// </summary>
+ ///
+ [MonoTODO]
+ public sealed class ImageAnimator
+ {
+ static Hashtable ht = new Hashtable ();
+
+ private ImageAnimator ()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+
+ public static void Animate (Image img, EventHandler onFrameChangeHandler)
+ {
+ if (img == null)
+ throw new System.NullReferenceException ("Object reference not set to an instance of an object.");
+
+ if (!ht.ContainsKey (img)) {
+ AnimateEventArgs evtArgs = new AnimateEventArgs (img);
+ WorkerThread WT = new WorkerThread(onFrameChangeHandler, evtArgs);
+ ThreadStart TS = new ThreadStart(WT.LoopHandler);
+ Thread thread = new Thread(TS);
+ thread.IsBackground = true;
+ evtArgs.RunThread = thread;
+ ht.Add (img, evtArgs);
+
+ thread.Start();
+ }
+ }
+
+ public static bool CanAnimate (Image img)
+ {
+ //An image can animate if it has multiple frame in
+ //time based FrameDimension else return false
+ //Doubt what if the image has multiple frame in page
+ //based FrameDimension
+ if (img == null)
+ return false;
+
+ //Need to check whether i can do this without iterating
+ //within the FrameDimensionsList, ie just call GetFrameCount
+ //with parameter FrameDimension.Time
+ Guid[] dimensionList = img.FrameDimensionsList;
+ int length = dimensionList.Length;
+ int frameCount;
+ for (int i=0; i<length; i++)
+ {
+ if (dimensionList [i].Equals(FrameDimension.Time.Guid))
+ {
+ frameCount = img.GetFrameCount (FrameDimension.Time);
+ if (frameCount > 1)
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static void StopAnimate (Image img, EventHandler onFrameChangeHandler)
+ {
+ if (img == null)
+ throw new System.NullReferenceException ("Object reference not set to an instance of an object.");
+
+ if (ht.ContainsKey (img)) {
+ AnimateEventArgs evtArgs = (AnimateEventArgs) ht [img];
+ evtArgs.RunThread.Abort ();
+ ht.Remove (img);
+ }
+ }
+
+ public static void UpdateFrames ()
+ {
+ foreach (Image img in ht.Keys) {
+ UpdateFrames (img);
+ }
+ }
+
+ public static void UpdateFrames (Image img)
+ {
+ if (img == null)
+ throw new System.NullReferenceException ("Object reference not set to an instance of an object.");
+
+ if (ht.ContainsKey (img)){
+ //Need a way to get the delay during animation
+ AnimateEventArgs evtArgs = (AnimateEventArgs) ht [img];
+ if (evtArgs.ActiveFrameCount < evtArgs.FrameCount-1){
+ evtArgs.ActiveFrameCount ++;
+ img.SelectActiveFrame (FrameDimension.Time, evtArgs.ActiveFrameCount);
+ }
+ else
+ evtArgs.ActiveFrameCount = 0;
+ ht [img] = evtArgs;
+ }
+ }
+ }
+
+ class WorkerThread
+ {
+ private EventHandler frameChangeHandler;
+ private AnimateEventArgs animateEventArgs;
+
+ public WorkerThread(EventHandler frmChgHandler, AnimateEventArgs aniEvtArgs)
+ {
+ frameChangeHandler = frmChgHandler;
+ animateEventArgs = aniEvtArgs;
+ }
+
+ public void LoopHandler()
+ {
+ try
+ {
+ while (true) {
+ //Need a way to get the delay during animation
+ Thread.Sleep (100);
+ frameChangeHandler (null, animateEventArgs);
+ }
+ }
+ catch(ThreadAbortException)
+ {
+ //lets not bother ourselves with tae
+ //it will be thrown anyway
+ }
+ catch(Exception er)
+ {
+ throw er;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/ImageConverter.cs b/mcs/class/System.Drawing/System.Drawing/ImageConverter.cs
new file mode 100644
index 00000000000..3367e207fb1
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ImageConverter.cs
@@ -0,0 +1,101 @@
+//
+// System.Drawing.ImageConverter.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Sanjay Gupta (gsanjay@novell.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.IO;
+using System.Drawing.Imaging;
+
+namespace System.Drawing
+{
+ /// <summary>
+ /// Summary description for ImageConverter.
+ /// </summary>
+ public class ImageConverter : TypeConverter
+ {
+ public ImageConverter ()
+ {
+ }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type srcType)
+ {
+ if (srcType == typeof (System.Byte[]))
+ return true;
+ else
+ return false;
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destType)
+ {
+ if ((destType == typeof (System.Byte[])) || (destType == typeof (System.String)))
+ return true;
+ else
+ return false;
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object val)
+ {
+ byte [] bytes = val as byte [];
+ if (bytes == null)
+ return base.ConvertFrom (context, culture, val);
+
+ MemoryStream ms = new MemoryStream (bytes);
+
+ return Image.FromStream (ms);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object val, Type destType )
+ {
+ if ((val is System.Drawing.Image) && (destType == typeof (System.String)))
+ return val.ToString ();
+ else if (CanConvertTo (null, destType)){
+ //came here means destType is byte array ;
+ MemoryStream ms = new MemoryStream ();
+ ((Image)val).Save (ms, ((Image)val).RawFormat);
+ return ms.GetBuffer ();
+ }else
+ return new NotSupportedException ("ImageConverter can not convert from " + val.GetType ());
+ }
+
+ public override PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context, object val, Attribute[] attribs)
+ {
+ return TypeDescriptor.GetProperties (typeof (Image), attribs);
+ }
+
+ public override bool GetPropertiesSupported (ITypeDescriptorContext context )
+ {
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/ImageFormatConverter.cs b/mcs/class/System.Drawing/System.Drawing/ImageFormatConverter.cs
new file mode 100644
index 00000000000..6100181ec82
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ImageFormatConverter.cs
@@ -0,0 +1,153 @@
+//
+// System.Drawing.ImageFormatConverter.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Sanjay Gupta (gsanjay@novell.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Drawing.Imaging;
+using System.ComponentModel.Design.Serialization;
+using System.Reflection;
+
+namespace System.Drawing
+{
+ /// <summary>
+ /// Summary description for ImageFormatConverter.
+ /// </summary>
+ public class ImageFormatConverter : TypeConverter
+ {
+ public ImageFormatConverter ()
+ {
+ }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type srcType)
+ {
+ if (srcType == typeof (string))
+ return true;
+
+ return base.CanConvertFrom (context, srcType);
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destType)
+ {
+ if (destType == typeof (string))
+ return true;
+
+ if (destType == typeof (InstanceDescriptor))
+ return true;
+
+ return base.CanConvertTo (context, destType);
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object val)
+ {
+ string strFormat = val as string;
+ if (strFormat == null)
+ return base.ConvertFrom (context, culture, val);
+
+ if (strFormat.Equals (ImageFormat.Bmp.ToString ()))
+ return ImageFormat.Bmp;
+ else if (strFormat.Equals (ImageFormat.Emf.ToString ()))
+ return ImageFormat.Emf;
+ else if (strFormat.Equals (ImageFormat.Exif.ToString ()))
+ return ImageFormat.Exif;
+ else if (strFormat.Equals (ImageFormat.Gif.ToString ()))
+ return ImageFormat.Gif;
+ else if (strFormat.Equals (ImageFormat.Icon.ToString ()))
+ return ImageFormat.Icon;
+ else if (strFormat.Equals (ImageFormat.Jpeg.ToString ()))
+ return ImageFormat.Jpeg;
+ else if (strFormat.Equals (ImageFormat.MemoryBmp.ToString ()))
+ return ImageFormat.MemoryBmp;
+ else if (strFormat.Equals (ImageFormat.Png.ToString ()))
+ return ImageFormat.Png;
+ else if (strFormat.Equals (ImageFormat.Tiff.ToString ()))
+ return ImageFormat.Tiff;
+ else if (strFormat.Equals (ImageFormat.Wmf.ToString ()))
+ return ImageFormat.Wmf;
+
+ return base.ConvertFrom (context, culture, val);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object val, Type destType )
+ {
+ if ((val is ImageFormat) && (destType == typeof (string)))
+ return val.ToString ();
+
+ if (destType == typeof (InstanceDescriptor) && val is ImageFormat) {
+ ImageFormat c = (ImageFormat) val;
+
+ string prop = null;
+ if (c.Guid.Equals (ImageFormat.Bmp.Guid))
+ prop = "Bmp";
+ else if (c.Guid.Equals (ImageFormat.Emf.Guid))
+ prop = "Emf";
+ else if (c.Guid.Equals (ImageFormat.Exif.Guid))
+ prop = "Exif";
+ else if (c.Guid.Equals (ImageFormat.Gif.Guid))
+ prop = "Gif";
+ else if (c.Guid.Equals (ImageFormat.Icon.Guid))
+ prop = "Icon";
+ else if (c.Guid.Equals (ImageFormat.Jpeg.Guid))
+ prop = "Jpeg";
+ else if (c.Guid.Equals (ImageFormat.MemoryBmp.Guid))
+ prop = "MemoryBmp";
+ else if (c.Guid.Equals (ImageFormat.Png.Guid))
+ prop = "Png";
+ else if (c.Guid.Equals (ImageFormat.Tiff.Guid))
+ prop = "Tiff";
+ else if (c.Guid.Equals (ImageFormat.Wmf.Guid))
+ prop = "Wmf";
+
+ if (prop != null){
+ return new InstanceDescriptor (typeof (ImageFormat).GetProperty (prop), null);
+ } else {
+ ConstructorInfo ctor = typeof(ImageFormat).GetConstructor (new Type[] {typeof(Guid)} );
+ return new InstanceDescriptor (ctor, new object[] {c.Guid});
+ }
+ }
+
+ return base.ConvertTo (context, culture, val, destType);
+ }
+
+ [MonoTODO ("Implement")]
+ public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context )
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool GetStandardValuesSupported (ITypeDescriptorContext context )
+ {
+ return false;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/KnownColor.cs b/mcs/class/System.Drawing/System.Drawing/KnownColor.cs
new file mode 100644
index 00000000000..65b78943b3a
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/KnownColor.cs
@@ -0,0 +1,215 @@
+//
+// System.Drawing.Color.cs
+//
+// (C) 2002 Dennis Hayes
+// Author:
+// Dennis Hayes (dennish@raytek.com)
+// Ben Houston (ben@exocortex.org)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+namespace System.Drawing
+{
+ [Serializable]
+ public enum KnownColor {
+ ActiveBorder = 1,
+ ActiveCaption = 2,
+ ActiveCaptionText = 3,
+ AppWorkspace = 4,
+ Control = 5,
+ ControlDark = 6,
+ ControlDarkDark = 7,
+ ControlLight = 8,
+ ControlLightLight = 9,
+ ControlText = 10,
+ Desktop = 11,
+ GrayText = 12,
+ Highlight = 13,
+ HighlightText = 14,
+ HotTrack = 15,
+ InactiveBorder = 16,
+ InactiveCaption = 17,
+ InactiveCaptionText = 18,
+ Info = 19,
+ InfoText = 20,
+ Menu = 21,
+ MenuText = 22,
+ ScrollBar = 23,
+ Window = 24,
+ WindowFrame = 25,
+ WindowText = 26,
+ Transparent = 27,
+ AliceBlue = 28,
+ AntiqueWhite = 29,
+ Aqua = 30,
+ Aquamarine = 31,
+ Azure = 32,
+ Beige = 33,
+ Bisque = 34,
+ Black = 35,
+ BlanchedAlmond = 36,
+ Blue = 37,
+ BlueViolet = 38,
+ Brown = 39,
+ BurlyWood = 40,
+ CadetBlue = 41,
+ Chartreuse = 42,
+ Chocolate = 43,
+ Coral = 44,
+ CornflowerBlue = 45,
+ Cornsilk = 46,
+ Crimson = 47,
+ Cyan = 48,
+ DarkBlue = 49,
+ DarkCyan = 50,
+ DarkGoldenrod = 51,
+ DarkGray = 52,
+ DarkGreen = 53,
+ DarkKhaki = 54,
+ DarkMagenta = 55,
+ DarkOliveGreen = 56,
+ DarkOrange = 57,
+ DarkOrchid = 58,
+ DarkRed = 59,
+ DarkSalmon = 60,
+ DarkSeaGreen = 61,
+ DarkSlateBlue = 62,
+ DarkSlateGray = 63,
+ DarkTurquoise = 64,
+ DarkViolet = 65,
+ DeepPink = 66,
+ DeepSkyBlue = 67,
+ DimGray = 68,
+ DodgerBlue = 69,
+ Firebrick = 70,
+ FloralWhite = 71,
+ ForestGreen = 72,
+ Fuchsia = 73,
+ Gainsboro = 74,
+ GhostWhite = 75,
+ Gold = 76,
+ Goldenrod = 77,
+ Gray = 78,
+ Green = 79,
+ GreenYellow = 80,
+ Honeydew = 81,
+ HotPink = 82,
+ IndianRed = 83,
+ Indigo = 84,
+ Ivory = 85,
+ Khaki = 86,
+ Lavender = 87,
+ LavenderBlush = 88,
+ LawnGreen = 89,
+ LemonChiffon = 90,
+ LightBlue = 91,
+ LightCoral = 92,
+ LightCyan = 93,
+ LightGoldenrodYellow = 94,
+ LightGray = 95,
+ LightGreen = 96,
+ LightPink = 97,
+ LightSalmon = 98,
+ LightSeaGreen = 99,
+ LightSkyBlue = 100,
+ LightSlateGray = 101,
+ LightSteelBlue = 102,
+ LightYellow = 103,
+ Lime = 104,
+ LimeGreen = 105,
+ Linen = 106,
+ Magenta = 107,
+ Maroon = 108,
+ MediumAquamarine = 109,
+ MediumBlue = 110,
+ MediumOrchid = 111,
+ MediumPurple = 112,
+ MediumSeaGreen = 113,
+ MediumSlateBlue = 114,
+ MediumSpringGreen = 115,
+ MediumTurquoise = 116,
+ MediumVioletRed = 117,
+ MidnightBlue = 118,
+ MintCream = 119,
+ MistyRose = 120,
+ Moccasin = 121,
+ NavajoWhite = 122,
+ Navy = 123,
+ OldLace = 124,
+ Olive = 125,
+ OliveDrab = 126,
+ Orange = 127,
+ OrangeRed = 128,
+ Orchid = 129,
+ PaleGoldenrod = 130,
+ PaleGreen = 131,
+ PaleTurquoise = 132,
+ PaleVioletRed = 133,
+ PapayaWhip = 134,
+ PeachPuff = 135,
+ Peru = 136,
+ Pink = 137,
+ Plum = 138,
+ PowderBlue = 139,
+ Purple = 140,
+ Red = 141,
+ RosyBrown = 142,
+ RoyalBlue = 143,
+ SaddleBrown = 144,
+ Salmon = 145,
+ SandyBrown = 146,
+ SeaGreen = 147,
+ SeaShell = 148,
+ Sienna = 149,
+ Silver = 150,
+ SkyBlue = 151,
+ SlateBlue = 152,
+ SlateGray = 153,
+ Snow = 154,
+ SpringGreen = 155,
+ SteelBlue = 156,
+ Tan = 157,
+ Teal = 158,
+ Thistle = 159,
+ Tomato = 160,
+ Turquoise = 161,
+ Violet = 162,
+ Wheat = 163,
+ White = 164,
+ WhiteSmoke = 165,
+ Yellow = 166,
+ YellowGreen = 167,
+#if NET_2_0
+ ButtonFace = 168,
+ ButtonHighlight = 169,
+ ButtonShadow = 170,
+ GradientActiveCaption = 171,
+ GradientInactiveCaption = 172,
+ MenuBar = 173,
+ MenuHighlight = 174
+#endif
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Pen.cs b/mcs/class/System.Drawing/System.Drawing/Pen.cs
new file mode 100644
index 00000000000..8c2740f0731
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Pen.cs
@@ -0,0 +1,521 @@
+//
+// System.Drawing.Pen.cs
+//
+// Authors:
+// Miguel de Icaza (miguel@ximian.com)
+// Alexandre Pigolkine (pigolkine@gmx.de)
+// Duncan Mak (duncan@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) Ximian, Inc. http://www.ximian.com
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing
+{
+ public sealed class Pen : MarshalByRefObject, ICloneable, IDisposable
+ {
+ internal IntPtr nativeObject;
+ internal bool isModifiable = true;
+ internal Brush brush;
+ internal Color color;
+ private CustomLineCap startCap;
+ private CustomLineCap endCap;
+
+ internal Pen (IntPtr p)
+ {
+ nativeObject = p;
+ }
+
+ public Pen (Brush brush) : this (brush, 1.0F)
+ {
+ }
+
+ public Pen (Color color) : this (color, 1.0F)
+ {
+ }
+
+ public Pen (Brush brush, float width)
+ {
+ Status status = GDIPlus.GdipCreatePen2 (brush.nativeObject, width, Unit.UnitWorld, out nativeObject);
+ GDIPlus.CheckStatus (status);
+
+ this.brush = brush;
+ }
+
+ public Pen (Color color, float width)
+ {
+ Status status = GDIPlus.GdipCreatePen1 (color.ToArgb (), width, Unit.UnitWorld, out nativeObject);
+ GDIPlus.CheckStatus (status);
+
+ this.color = color;
+ }
+
+ //
+ // Properties
+ //
+ public PenAlignment Alignment {
+ get {
+ PenAlignment retval;
+ Status status = GDIPlus.GdipGetPenMode (nativeObject, out retval);
+ GDIPlus.CheckStatus (status);
+ return retval;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenMode (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+
+ }
+ }
+
+ void GetSolidColorBrush ()
+ {
+ IntPtr native_pen_brush, cloned_brush;
+
+ Status status = GDIPlus.GdipGetPenBrushFill (nativeObject, out native_pen_brush);
+ GDIPlus.CheckStatus (status);
+ status = GDIPlus.GdipCloneBrush (native_pen_brush, out cloned_brush);
+ GDIPlus.CheckStatus (status);
+
+ //
+ // We know that the Color brushes are Solid.
+ //
+ brush = new SolidBrush (cloned_brush);
+ }
+
+ public Brush Brush {
+ get {
+ //
+ // Pens created with the color constructor have a brush,
+ // but we delay-load it, as few people need it.
+ //
+ if (brush == null)
+ GetSolidColorBrush ();
+ return brush;
+ }
+
+ set {
+ if (isModifiable) {
+ brush = value;
+ if (value is SolidBrush) {
+ Status status = GDIPlus.GdipSetPenBrushFill (nativeObject, value.nativeObject);
+ GDIPlus.CheckStatus (status);
+ color = ((SolidBrush) brush).Color;
+ status = GDIPlus.GdipSetPenColor (nativeObject, color.ToArgb ());
+ GDIPlus.CheckStatus (status);
+ } else {
+ // other brushes should clear the color property
+ Status status = GDIPlus.GdipSetPenBrushFill (nativeObject, value.nativeObject);
+ GDIPlus.CheckStatus (status);
+ status = GDIPlus.GdipSetPenColor (nativeObject, 0);
+ GDIPlus.CheckStatus (status);
+ color = Color.Empty;
+ }
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public Color Color {
+ get {
+ return color;
+ }
+
+ set {
+ if (isModifiable) {
+ color = value;
+ Status status = GDIPlus.GdipSetPenColor (nativeObject, value.ToArgb ());
+ GDIPlus.CheckStatus (status);
+ brush = new SolidBrush (color);
+ status = GDIPlus.GdipSetPenBrushFill (nativeObject, brush.nativeObject);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public float [] CompoundArray {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetPenCompoundCount (nativeObject, out count);
+ GDIPlus.CheckStatus (status);
+
+ float [] compArray = new float [count];
+ status = GDIPlus.GdipGetPenCompoundArray (nativeObject, compArray, count);
+ GDIPlus.CheckStatus (status);
+
+ return compArray;
+ }
+
+ set {
+ if (isModifiable) {
+ int length = value.Length;
+ if (length < 2)
+ throw new ArgumentException ("Invalid parameter.");
+ foreach (float val in value)
+ if (val < 0 || val > 1)
+ throw new ArgumentException ("Invalid parameter.");
+
+ Status status = GDIPlus.GdipSetPenCompoundArray (nativeObject, value, value.Length);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public CustomLineCap CustomEndCap {
+ get {
+ return endCap;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenCustomEndCap (nativeObject, value.nativeObject);
+ GDIPlus.CheckStatus (status);
+ endCap = value;
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public CustomLineCap CustomStartCap {
+ get {
+ return startCap;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenCustomStartCap (nativeObject, value.nativeObject);
+ GDIPlus.CheckStatus (status);
+ startCap = value;
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public DashCap DashCap {
+
+ get {
+ DashCap retval;
+ Status status = GDIPlus.GdipGetPenDashCap197819 (nativeObject, out retval);
+ GDIPlus.CheckStatus (status);
+ return retval;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenDashCap197819 (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public float DashOffset {
+
+ get {
+ float retval;
+ Status status = GDIPlus.GdipGetPenDashOffset (nativeObject, out retval);
+ GDIPlus.CheckStatus (status);
+ return retval;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenDashOffset (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public float [] DashPattern {
+ get {
+ int count;
+ Status status = GDIPlus.GdipGetPenDashCount (nativeObject, out count);
+ GDIPlus.CheckStatus (status);
+
+ float [] pattern = new float [count];
+ status = GDIPlus.GdipGetPenDashArray (nativeObject, pattern, count);
+ GDIPlus.CheckStatus (status);
+
+ return pattern;
+ }
+
+ set {
+ if (isModifiable) {
+ int length = value.Length;
+ if (length == 0)
+ throw new ArgumentException ("Invalid parameter.");
+ foreach (float val in value)
+ if (val <= 0)
+ throw new ArgumentException ("Invalid parameter.");
+ Status status = GDIPlus.GdipSetPenDashArray (nativeObject, value, value.Length);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public DashStyle DashStyle {
+ get {
+ DashStyle retval;
+ Status status = GDIPlus.GdipGetPenDashStyle (nativeObject, out retval);
+ GDIPlus.CheckStatus (status);
+ return retval;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenDashStyle (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public LineCap StartCap {
+ get {
+ LineCap retval;
+ Status status = GDIPlus.GdipGetPenStartCap (nativeObject, out retval);
+ GDIPlus.CheckStatus (status);
+
+ return retval;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenStartCap (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public LineCap EndCap {
+ get {
+ LineCap retval;
+ Status status = GDIPlus.GdipGetPenEndCap (nativeObject, out retval);
+ GDIPlus.CheckStatus (status);
+
+ return retval;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenEndCap (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public LineJoin LineJoin {
+
+ get {
+ LineJoin result;
+ Status status = GDIPlus.GdipGetPenLineJoin (nativeObject, out result);
+ GDIPlus.CheckStatus (status);
+ return result;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenLineJoin (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+
+ }
+
+ public float MiterLimit {
+
+ get {
+ float result;
+ Status status = GDIPlus.GdipGetPenMiterLimit (nativeObject, out result);
+ GDIPlus.CheckStatus (status);
+ return result;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenMiterLimit (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+
+ }
+
+ public PenType PenType {
+ get {
+ PenType type;
+ Status status = GDIPlus.GdipGetPenFillType (nativeObject, out type);
+ GDIPlus.CheckStatus (status);
+
+ return type;
+ }
+ }
+
+ public Matrix Transform {
+
+ get {
+ Matrix matrix = new Matrix ();
+ Status status = GDIPlus.GdipGetPenTransform (nativeObject, matrix.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+
+ return matrix;
+ }
+
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenTransform (nativeObject, value.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public float Width {
+ get {
+ float f;
+ Status status = GDIPlus.GdipGetPenWidth (nativeObject, out f);
+ GDIPlus.CheckStatus (status);
+ return f;
+ }
+ set {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenWidth (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+ }
+
+ public object Clone ()
+ {
+ IntPtr ptr;
+ Status status = GDIPlus.GdipClonePen (nativeObject, out ptr);
+ GDIPlus.CheckStatus (status);
+ Pen p = new Pen (ptr);
+ p.brush = brush;
+ p.color = color;
+ p.startCap = startCap;
+ p.endCap = endCap;
+
+ return p;
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ private void Dispose (bool disposing)
+ {
+ if (disposing == true && isModifiable == false) {
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+
+ if (nativeObject != IntPtr.Zero) {
+ Status status = GDIPlus.GdipDeletePen (nativeObject);
+ GDIPlus.CheckStatus (status);
+ nativeObject = IntPtr.Zero;
+ }
+ }
+
+ ~Pen ()
+ {
+ Dispose (false);
+ }
+
+ public void MultiplyTransform (Matrix matrix)
+ {
+ MultiplyTransform (matrix, MatrixOrder.Prepend);
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipMultiplyPenTransform (nativeObject, matrix.nativeMatrix, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ResetTransform ()
+ {
+ Status status = GDIPlus.GdipResetPenTransform (nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void RotateTransform (float angle)
+ {
+ RotateTransform (angle, MatrixOrder.Prepend);
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipRotatePenTransform (nativeObject, angle, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ScaleTransform (float sx, float sy)
+ {
+ ScaleTransform (sx, sy, MatrixOrder.Prepend);
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipScalePenTransform (nativeObject, sx, sy, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetLineCap (LineCap startCap, LineCap endCap, DashCap dashCap)
+ {
+ if (isModifiable) {
+ Status status = GDIPlus.GdipSetPenLineCap197819 (nativeObject, startCap, endCap, dashCap);
+ GDIPlus.CheckStatus (status);
+ } else
+ throw new ArgumentException ("This Pen object can't be modified.");
+ }
+
+ public void TranslateTransform (float dx, float dy)
+ {
+ TranslateTransform (dx, dy, MatrixOrder.Prepend);
+ }
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipTranslatePenTransform (nativeObject, dx, dy, order);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Pen.jvm.cs b/mcs/class/System.Drawing/System.Drawing/Pen.jvm.cs
new file mode 100755
index 00000000000..0536b9cb03b
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Pen.jvm.cs
@@ -0,0 +1,577 @@
+//
+// System.Drawing.Pen.cs
+//
+// Authors:
+// Miguel de Icaza (miguel@ximian.com)
+// Alexandre Pigolkine (pigolkine@gmx.de)
+// Duncan Mak (duncan@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+// (C) Novell, Inc. http://www.novell.com
+//
+
+using System;
+using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
+
+using awt = java.awt;
+using geom = java.awt.geom;
+
+namespace System.Drawing
+{
+
+ public sealed class Pen : MarshalByRefObject, ICloneable, IDisposable, awt.Stroke
+ {
+ #region Member Vars
+
+ static readonly float [] DASH_ARRAY = {4.0f,1.0f};
+ static readonly float [] DASHDOT_ARRAY = {4.0f,1.0f,1.0f,1.0f};
+ static readonly float [] DASHDOTDOT_ARRAY = {4.0f,1.0f,1.0f,1.0f,1.0f,1.0f};
+ static readonly float [] DOT_ARRAY = {1.0f,1.0f};
+
+ internal bool isModifiable = true;
+
+ Brush _brush;
+ DashStyle _dashStyle;
+ DashCap _dashCap;
+ LineCap _startCap;
+ LineCap _endCap;
+
+ LineJoin _lineJoin;
+
+ PenAlignment _alignment;
+ Matrix _transform;
+ float _width;
+ float _dashOffset;
+ float[] _dashPattern;
+ //float[] _compoundArray;
+
+ float _miterLimit;
+
+ #endregion
+
+ #region Ctors. and Dtor
+
+ public Pen (Brush brush) : this (brush, 1.0F)
+ {}
+
+ public Pen (Color color) : this (color, 1.0F)
+ {}
+
+ public Pen (Color color, float width) : this(new SolidBrush(color), width)
+ {}
+
+ public Pen (Brush brush, float width)
+ {
+ _brush = (Brush)brush.Clone();;
+ _width = width;
+ _dashStyle = DashStyle.Solid;
+ _startCap = LineCap.Flat;
+ _dashCap = DashCap.Flat;
+ _endCap = LineCap.Flat;
+ _alignment = PenAlignment.Center;
+ _lineJoin = LineJoin.Miter;
+ _miterLimit = 10f;
+ _transform = new Matrix();
+ }
+ #endregion
+ //
+ // Properties
+ //
+ #region Alignment [TODO]
+ public PenAlignment Alignment
+ {
+ get
+ {
+ return _alignment;
+ }
+
+ set
+ {
+ EnsureModifiable();
+ _alignment = value;
+ }
+ }
+ #endregion
+
+ #region Brush
+ public Brush Brush
+ {
+ get
+ {
+ return _brush;
+ }
+
+ set
+ {
+ EnsureModifiable();
+ if (value == null)
+ throw new ArgumentNullException("brush");
+ _brush = value;
+ }
+ }
+ #endregion
+
+ #region Color
+ public Color Color
+ {
+ get
+ {
+ if(Brush is SolidBrush)
+ return ((SolidBrush)Brush).Color;
+ else if(Brush is HatchBrush)
+ return ((HatchBrush)Brush).ForegroundColor;
+ else
+ return Color.Empty;
+ }
+
+ set
+ {
+ EnsureModifiable();
+ _brush = new SolidBrush (value);
+ }
+ }
+ #endregion
+
+ #region CompoundArray [TODO]
+ [MonoTODO]
+ public float[] CompoundArray {
+ get {
+ throw new NotImplementedException ();
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+ #endregion
+
+ #region CustomEndCap [TODO]
+ [MonoTODO]
+ public CustomLineCap CustomEndCap
+ {
+ get
+ {
+ throw new NotImplementedException ();
+ }
+ // do a check for isModifiable when implementing this property
+ set
+ {
+ throw new NotImplementedException ();
+ }
+ }
+ #endregion
+
+ #region CustomStartCap [TODO]
+ [MonoTODO]
+ public CustomLineCap CustomStartCap
+ {
+ get
+ {
+ throw new NotImplementedException ();
+ }
+
+ // do a check for isModifiable when implementing this property
+ set
+ {
+ throw new NotImplementedException ();
+ }
+ }
+ #endregion
+
+ #region DashCap
+ [MonoTODO]
+ public DashCap DashCap {
+ get {
+ return _dashCap;
+ }
+
+ set {
+ EnsureModifiable();
+ _dashCap = value;
+ }
+ }
+ #endregion
+
+ #region DashOffset
+ public float DashOffset
+ {
+
+ get
+ {
+ return _dashOffset;
+ }
+
+ set
+ {
+ EnsureModifiable();
+ _dashOffset = value;
+ }
+ }
+ #endregion
+
+ #region DashPattern
+
+ public float [] DashPattern
+ {
+ get
+ {
+ return (float [])_dashPattern.Clone();
+ }
+
+ set
+ {
+ EnsureModifiable();
+
+ _dashPattern = value;
+ DashStyle = (_dashPattern == null) ? DashStyle.Solid : DashStyle.Custom;
+ }
+ }
+ #endregion
+
+ #region DashStyle
+ public DashStyle DashStyle
+ {
+ get
+ {
+ return _dashStyle;
+ }
+
+ set
+ {
+ EnsureModifiable();
+ _dashStyle = value;
+ }
+ }
+ #endregion
+
+ #region StartCap [TODO - now allways endcap]
+ [MonoTODO]
+ public LineCap StartCap {
+ get {
+ return _startCap;
+ }
+
+ set {
+ EnsureModifiable();
+ _startCap = value;
+ }
+ }
+ #endregion
+
+ #region EndCap
+ [MonoTODO]
+ public LineCap EndCap
+ {
+ get
+ {
+ return _endCap;
+ }
+
+ set
+ {
+ EnsureModifiable();
+
+ _endCap = value;
+ }
+ }
+ #endregion
+
+ #region LineJoin [partial TODO - missed styles]
+ [MonoTODO]
+ public LineJoin LineJoin {
+ get {
+ return _lineJoin;
+ }
+
+ set {
+ EnsureModifiable();
+ _lineJoin = value;
+ }
+ }
+
+ #endregion
+
+ #region MiterLimit
+ public float MiterLimit
+ {
+
+ get
+ {
+ return _miterLimit;
+ }
+
+ set
+ {
+ EnsureModifiable();
+
+ _miterLimit = value;
+ }
+
+ }
+ #endregion
+
+ #region PenType
+ public PenType PenType
+ {
+ get
+ {
+ if (Brush is TextureBrush)
+ return PenType.TextureFill;
+ else if (Brush is HatchBrush)
+ return PenType.HatchFill;
+ else if (Brush is LinearGradientBrush)
+ return PenType.LinearGradient;
+ else if (Brush is PathGradientBrush)
+ return PenType.PathGradient;
+ else
+ return PenType.SolidColor;
+ }
+ }
+ #endregion
+
+ #region Transform
+ public Matrix Transform
+ {
+ get
+ {
+ return _transform.Clone();
+ }
+
+ set
+ {
+ EnsureModifiable();
+
+ value.CopyTo(_transform);
+ }
+ }
+ #endregion
+
+ #region Width
+ public float Width
+ {
+ get
+ {
+ return _width;
+ }
+ set
+ {
+ EnsureModifiable();
+
+ _width = value;
+ }
+ }
+ #endregion
+
+ #region Clone
+ public object Clone ()
+ {
+ Pen clone = (Pen)MemberwiseClone();
+ if (clone._transform != null)
+ clone._transform = clone._transform.Clone();
+ if (clone._dashPattern != null)
+ clone._dashPattern = (float[])clone._dashPattern.Clone();
+ return clone;
+ }
+ #endregion
+
+ #region Dispose
+ public void Dispose ()
+ {
+ Dispose (true);
+ }
+ void Dispose (bool disposing)
+ {
+ if (!isModifiable && disposing)
+ throw new ArgumentException ("You may not change this Pen because it does not belong to you.");
+ // Restore the dtor if adding anything below
+ }
+ #endregion
+
+ #region Transform Funcs
+ public void MultiplyTransform (Matrix matrix)
+ {
+ _transform.Multiply (matrix);
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order)
+ {
+ _transform.Multiply (matrix, order);
+ }
+
+ public void ResetTransform ()
+ {
+ _transform.Reset ();
+ }
+
+ public void RotateTransform (float angle)
+ {
+ _transform.Rotate (angle);
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order)
+ {
+ _transform.Rotate (angle, order);
+ }
+
+ public void ScaleTransform (float sx, float sy)
+ {
+ _transform.Scale (sx, sy);
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order)
+ {
+ _transform.Scale (sx, sy, order);
+ }
+
+ public void TranslateTransform (float dx, float dy) {
+ _transform.Translate (dx, dy);
+ }
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order) {
+ _transform.Translate (dx, dy, order);
+ }
+ #endregion
+
+ public void SetLineCap (LineCap startCap, LineCap endCap, DashCap dashCap)
+ {
+ StartCap = startCap;
+ DashCap = dashCap;
+ EndCap = endCap;
+ }
+
+ void EnsureModifiable() {
+ if (!isModifiable)
+ throw new ArgumentException ("You may not change this Pen because it does not belong to you.");
+ }
+
+ internal double GetSquaredTransformedWidth(geom.AffineTransform coordsTransform) {
+ geom.AffineTransform transform = _transform.NativeObject;
+ double A = transform.getScaleX(); // m00
+ double B = transform.getShearY(); // m10
+ double C = transform.getShearX(); // m01
+ double D = transform.getScaleY(); // m11
+
+ double K = coordsTransform.getScaleX(); // m00
+ double L = coordsTransform.getShearY(); // m10
+ double M = coordsTransform.getShearX(); // m01
+ double N = coordsTransform.getScaleY(); // m11
+
+ double AD = A*D, BC = B*C, KN = K*N, LM = L*M;
+ double KN_LM = KN-LM;
+ return Math.Abs(Width*Width * (AD*KN_LM - BC*KN_LM));
+ }
+
+
+ internal bool CanCreateBasicStroke {
+ get {
+ if (!_transform.IsIdentity)
+ return false;
+
+ //FIXME: add more logic when more features will
+ // be implemented.
+ return true;
+ }
+ }
+
+ internal awt.Stroke GetNativeObject(geom.AffineTransform outputTransform, PenFit penFit) {
+ return GetNativeObject(null, outputTransform, penFit);
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="outputTransform">transform which will be applied on the final shape</param>
+ /// <param name="fitPen">ensure the shape will wide enough to be visible</param>
+ /// <returns></returns>
+ internal awt.Stroke GetNativeObject(geom.AffineTransform penTransform, geom.AffineTransform outputTransform, PenFit penFit) {
+ float[] dashPattern = null;
+
+ switch (DashStyle) {
+ case DashStyle.Custom:
+ if (_dashPattern != null) {
+ dashPattern = new float[_dashPattern.Length];
+ for(int i = 0; i < _dashPattern.Length; i++) {
+
+ if (EndCap == LineCap.Flat)
+ dashPattern[i] = _dashPattern[i] * Width;
+ else {
+ if ((i & 1) == 0) {
+ // remove the size of caps from the opaque parts
+ dashPattern[i] = (_dashPattern[i] * Width) - Width;
+ if (_dashPattern[i] < 0)
+ dashPattern[i] = 0;
+ }
+ else
+ // add the size of caps to the transparent parts
+ dashPattern[i] = (_dashPattern[i] * Width) + Width;
+ }
+ }
+ }
+ break;
+ case DashStyle.Dash:
+ dashPattern = DASH_ARRAY;
+ break;
+ case DashStyle.DashDot:
+ dashPattern = DASHDOT_ARRAY;
+ break;
+ case DashStyle.DashDotDot:
+ dashPattern = DASHDOTDOT_ARRAY;
+ break;
+
+ // default:
+ // case DashStyle.Solid:
+ // break;
+ }
+
+ int join;
+ switch (LineJoin) {
+ case LineJoin.Bevel:
+ join = java.awt.BasicStroke.JOIN_BEVEL;
+ break;
+ default:
+ case LineJoin.Miter:
+ case LineJoin.MiterClipped:
+ join = java.awt.BasicStroke.JOIN_MITER;
+ break;
+ case LineJoin.Round:
+ join = java.awt.BasicStroke.JOIN_ROUND;
+ break;
+ }
+
+ // We go by End cap for now.
+ int cap;
+ switch (EndCap) {
+ default:
+ case LineCap.Square:
+ case LineCap.SquareAnchor:
+ cap = awt.BasicStroke.CAP_SQUARE;
+ break;
+ case LineCap.Round:
+ case LineCap.RoundAnchor:
+ cap = awt.BasicStroke.CAP_ROUND;
+ break;
+ case LineCap.Flat:
+ cap = awt.BasicStroke.CAP_BUTT;
+ break;
+ }
+
+ geom.AffineTransform penT = _transform.NativeObject;
+ if (penTransform != null && !penTransform.isIdentity()) {
+ penT = (geom.AffineTransform)penT.clone();
+ penT.concatenate(penTransform);
+ }
+
+ return StrokeFactory.CreateStroke(Width, cap,
+ join, MiterLimit, dashPattern, DashOffset,
+ penT, outputTransform, penFit);
+ }
+
+ #region Stroke Members
+
+ awt.Shape awt.Stroke.createStrokedShape(awt.Shape arg_0) {
+ return GetNativeObject(null, PenFit.NotThin).createStrokedShape(arg_0);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Pens.cs b/mcs/class/System.Drawing/System.Drawing/Pens.cs
new file mode 100644
index 00000000000..988c982163f
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Pens.cs
@@ -0,0 +1,1597 @@
+//
+// System.Drawing.Pens.cs
+//
+// Authors:
+// Matt Stump (mstump@swfo.arizona.edu)
+// Ravindra (rkumar@novell.com)
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004-2005 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing
+{
+ public sealed class Pens
+ {
+ private static Pen aliceblue;
+ private static Pen antiquewhite;
+ private static Pen aqua;
+ private static Pen aquamarine;
+ private static Pen azure;
+ private static Pen beige;
+ private static Pen bisque;
+ private static Pen black;
+ private static Pen blanchedalmond;
+ private static Pen blue;
+ private static Pen blueviolet;
+ private static Pen brown;
+ private static Pen burlywood;
+ private static Pen cadetblue;
+ private static Pen chartreuse;
+ private static Pen chocolate;
+ private static Pen coral;
+ private static Pen cornflowerblue;
+ private static Pen cornsilk;
+ private static Pen crimson;
+ private static Pen cyan;
+ private static Pen darkblue;
+ private static Pen darkcyan;
+ private static Pen darkgoldenrod;
+ private static Pen darkgray;
+ private static Pen darkgreen;
+ private static Pen darkkhaki;
+ private static Pen darkmagenta;
+ private static Pen darkolivegreen;
+ private static Pen darkorange;
+ private static Pen darkorchid;
+ private static Pen darkred;
+ private static Pen darksalmon;
+ private static Pen darkseagreen;
+ private static Pen darkslateblue;
+ private static Pen darkslategray;
+ private static Pen darkturquoise;
+ private static Pen darkviolet;
+ private static Pen deeppink;
+ private static Pen deepskyblue;
+ private static Pen dimgray;
+ private static Pen dodgerblue;
+ private static Pen firebrick;
+ private static Pen floralwhite;
+ private static Pen forestgreen;
+ private static Pen fuchsia;
+ private static Pen gainsboro;
+ private static Pen ghostwhite;
+ private static Pen gold;
+ private static Pen goldenrod;
+ private static Pen gray;
+ private static Pen green;
+ private static Pen greenyellow;
+ private static Pen honeydew;
+ private static Pen hotpink;
+ private static Pen indianred;
+ private static Pen indigo;
+ private static Pen ivory;
+ private static Pen khaki;
+ private static Pen lavender;
+ private static Pen lavenderblush;
+ private static Pen lawngreen;
+ private static Pen lemonchiffon;
+ private static Pen lightblue;
+ private static Pen lightcoral;
+ private static Pen lightcyan;
+ private static Pen lightgoldenrodyellow;
+ private static Pen lightgray;
+ private static Pen lightgreen;
+ private static Pen lightpink;
+ private static Pen lightsalmon;
+ private static Pen lightseagreen;
+ private static Pen lightskyblue;
+ private static Pen lightslategray;
+ private static Pen lightsteelblue;
+ private static Pen lightyellow;
+ private static Pen lime;
+ private static Pen limegreen;
+ private static Pen linen;
+ private static Pen magenta;
+ private static Pen maroon;
+ private static Pen mediumaquamarine;
+ private static Pen mediumblue;
+ private static Pen mediumorchid;
+ private static Pen mediumpurple;
+ private static Pen mediumseagreen;
+ private static Pen mediumslateblue;
+ private static Pen mediumspringgreen;
+ private static Pen mediumturquoise;
+ private static Pen mediumvioletred;
+ private static Pen midnightblue;
+ private static Pen mintcream;
+ private static Pen mistyrose;
+ private static Pen moccasin;
+ private static Pen navajowhite;
+ private static Pen navy;
+ private static Pen oldlace;
+ private static Pen olive;
+ private static Pen olivedrab;
+ private static Pen orange;
+ private static Pen orangered;
+ private static Pen orchid;
+ private static Pen palegoldenrod;
+ private static Pen palegreen;
+ private static Pen paleturquoise;
+ private static Pen palevioletred;
+ private static Pen papayawhip;
+ private static Pen peachpuff;
+ private static Pen peru;
+ private static Pen pink;
+ private static Pen plum;
+ private static Pen powderblue;
+ private static Pen purple;
+ private static Pen red;
+ private static Pen rosybrown;
+ private static Pen royalblue;
+ private static Pen saddlebrown;
+ private static Pen salmon;
+ private static Pen sandybrown;
+ private static Pen seagreen;
+ private static Pen seashell;
+ private static Pen sienna;
+ private static Pen silver;
+ private static Pen skyblue;
+ private static Pen slateblue;
+ private static Pen slategray;
+ private static Pen snow;
+ private static Pen springgreen;
+ private static Pen steelblue;
+ private static Pen tan;
+ private static Pen teal;
+ private static Pen thistle;
+ private static Pen tomato;
+ private static Pen transparent;
+ private static Pen turquoise;
+ private static Pen violet;
+ private static Pen wheat;
+ private static Pen white;
+ private static Pen whitesmoke;
+ private static Pen yellow;
+ private static Pen yellowgreen;
+
+ private Pens () { }
+
+ public static Pen AliceBlue {
+ get {
+ if (aliceblue == null) {
+ aliceblue = new Pen (Color.AliceBlue);
+ aliceblue.isModifiable = false;
+ }
+ return aliceblue;
+ }
+ }
+
+ public static Pen AntiqueWhite {
+ get {
+ if (antiquewhite == null) {
+ antiquewhite = new Pen (Color.AntiqueWhite);
+ antiquewhite.isModifiable = false;
+ }
+ return antiquewhite;
+ }
+ }
+
+ public static Pen Aqua {
+ get {
+ if (aqua == null) {
+ aqua = new Pen (Color.Aqua);
+ aqua.isModifiable = false;
+ }
+ return aqua;
+ }
+ }
+
+ public static Pen Aquamarine {
+ get {
+ if (aquamarine == null) {
+ aquamarine = new Pen (Color.Aquamarine);
+ aquamarine.isModifiable = false;
+ }
+ return aquamarine;
+ }
+ }
+
+ public static Pen Azure {
+ get {
+ if (azure == null) {
+ azure = new Pen (Color.Azure);
+ azure.isModifiable = false;
+ }
+ return azure;
+ }
+ }
+
+ public static Pen Beige {
+ get {
+ if (beige == null) {
+ beige = new Pen (Color.Beige);
+ beige.isModifiable = false;
+ }
+ return beige;
+ }
+ }
+
+ public static Pen Bisque {
+ get {
+ if (bisque == null) {
+ bisque = new Pen (Color.Bisque);
+ bisque.isModifiable = false;
+ }
+ return bisque;
+ }
+ }
+
+ public static Pen Black {
+ get {
+ if (black == null) {
+ black = new Pen (Color.Black);
+ black.isModifiable = false;
+ }
+ return black;
+ }
+ }
+
+ public static Pen BlanchedAlmond {
+ get {
+ if (blanchedalmond == null) {
+ blanchedalmond = new Pen (Color.BlanchedAlmond);
+ blanchedalmond.isModifiable = false;
+ }
+ return blanchedalmond;
+ }
+ }
+
+ public static Pen Blue {
+ get {
+ if (blue == null) {
+ blue = new Pen (Color.Blue);
+ blue.isModifiable = false;
+ }
+ return blue;
+ }
+ }
+
+ public static Pen BlueViolet {
+ get {
+ if (blueviolet == null) {
+ blueviolet = new Pen (Color.BlueViolet);
+ blueviolet.isModifiable = false;
+ }
+ return blueviolet;
+ }
+ }
+
+ public static Pen Brown {
+ get {
+ if (brown == null) {
+ brown = new Pen (Color.Brown);
+ brown.isModifiable = false;
+ }
+ return brown;
+ }
+ }
+
+ public static Pen BurlyWood {
+ get {
+ if (burlywood == null) {
+ burlywood = new Pen (Color.BurlyWood);
+ burlywood.isModifiable = false;
+ }
+ return burlywood;
+ }
+ }
+
+ public static Pen CadetBlue {
+ get {
+ if (cadetblue == null) {
+ cadetblue = new Pen (Color.CadetBlue);
+ cadetblue.isModifiable = false;
+ }
+ return cadetblue;
+ }
+ }
+
+ public static Pen Chartreuse {
+ get {
+ if (chartreuse == null) {
+ chartreuse = new Pen (Color.Chartreuse);
+ chartreuse.isModifiable = false;
+ }
+ return chartreuse;
+ }
+ }
+
+ public static Pen Chocolate {
+ get {
+ if (chocolate == null) {
+ chocolate = new Pen (Color.Chocolate);
+ chocolate.isModifiable = false;
+ }
+ return chocolate;
+ }
+ }
+
+ public static Pen Coral {
+ get {
+ if (coral == null) {
+ coral = new Pen (Color.Coral);
+ coral.isModifiable = false;
+ }
+ return coral;
+ }
+ }
+
+ public static Pen CornflowerBlue {
+ get {
+ if (cornflowerblue == null) {
+ cornflowerblue = new Pen (Color.CornflowerBlue);
+ cornflowerblue.isModifiable = false;
+ }
+ return cornflowerblue;
+ }
+ }
+
+ public static Pen Cornsilk {
+ get {
+ if (cornsilk == null) {
+ cornsilk = new Pen (Color.Cornsilk);
+ cornsilk.isModifiable = false;
+ }
+ return cornsilk;
+ }
+ }
+
+ public static Pen Crimson {
+ get {
+ if (crimson == null) {
+ crimson = new Pen (Color.Crimson);
+ crimson.isModifiable = false;
+ }
+ return crimson;
+ }
+ }
+
+ public static Pen Cyan {
+ get {
+ if (cyan == null) {
+ cyan = new Pen (Color.Cyan);
+ cyan.isModifiable = false;
+ }
+ return cyan;
+ }
+ }
+
+ public static Pen DarkBlue {
+ get {
+ if (darkblue == null) {
+ darkblue = new Pen (Color.DarkBlue);
+ darkblue.isModifiable = false;
+ }
+ return darkblue;
+ }
+ }
+
+ public static Pen DarkCyan {
+ get {
+ if (darkcyan == null) {
+ darkcyan = new Pen (Color.DarkCyan);
+ darkcyan.isModifiable = false;
+ }
+ return darkcyan;
+ }
+ }
+
+ public static Pen DarkGoldenrod {
+ get {
+ if (darkgoldenrod == null) {
+ darkgoldenrod = new Pen (Color.DarkGoldenrod);
+ darkgoldenrod.isModifiable = false;
+ }
+ return darkgoldenrod;
+ }
+ }
+
+ public static Pen DarkGray {
+ get {
+ if (darkgray == null) {
+ darkgray = new Pen (Color.DarkGray);
+ darkgray.isModifiable = false;
+ }
+ return darkgray;
+ }
+ }
+
+ public static Pen DarkGreen {
+ get {
+ if (darkgreen == null) {
+ darkgreen = new Pen (Color.DarkGreen);
+ darkgreen.isModifiable = false;
+ }
+ return darkgreen;
+ }
+ }
+
+ public static Pen DarkKhaki {
+ get {
+ if (darkkhaki == null) {
+ darkkhaki = new Pen (Color.DarkKhaki);
+ darkkhaki.isModifiable = false;
+ }
+ return darkkhaki;
+ }
+ }
+
+ public static Pen DarkMagenta {
+ get {
+ if (darkmagenta == null) {
+ darkmagenta = new Pen (Color.DarkMagenta);
+ darkmagenta.isModifiable = false;
+ }
+ return darkmagenta;
+ }
+ }
+
+ public static Pen DarkOliveGreen {
+ get {
+ if (darkolivegreen == null) {
+ darkolivegreen = new Pen (Color.DarkOliveGreen);
+ darkolivegreen.isModifiable = false;
+ }
+ return darkolivegreen;
+ }
+ }
+
+ public static Pen DarkOrange {
+ get {
+ if (darkorange == null) {
+ darkorange = new Pen (Color.DarkOrange);
+ darkorange.isModifiable = false;
+ }
+ return darkorange;
+ }
+ }
+
+ public static Pen DarkOrchid {
+ get {
+ if (darkorchid == null) {
+ darkorchid = new Pen (Color.DarkOrchid);
+ darkorchid.isModifiable = false;
+ }
+ return darkorchid;
+ }
+ }
+
+ public static Pen DarkRed {
+ get {
+ if (darkred == null) {
+ darkred = new Pen (Color.DarkRed);
+ darkred.isModifiable = false;
+ }
+ return darkred;
+ }
+ }
+
+ public static Pen DarkSalmon {
+ get {
+ if (darksalmon == null) {
+ darksalmon = new Pen (Color.DarkSalmon);
+ darksalmon.isModifiable = false;
+ }
+ return darksalmon;
+ }
+ }
+
+ public static Pen DarkSeaGreen {
+ get {
+ if (darkseagreen == null) {
+ darkseagreen = new Pen (Color.DarkSeaGreen);
+ darkseagreen.isModifiable = false;
+ }
+ return darkseagreen;
+ }
+ }
+
+ public static Pen DarkSlateBlue {
+ get {
+ if (darkslateblue == null) {
+ darkslateblue = new Pen (Color.DarkSlateBlue);
+ darkslateblue.isModifiable = false;
+ }
+ return darkslateblue;
+ }
+ }
+
+ public static Pen DarkSlateGray {
+ get {
+ if (darkslategray == null) {
+ darkslategray = new Pen (Color.DarkSlateGray);
+ darkslategray.isModifiable = false;
+ }
+ return darkslategray;
+ }
+ }
+
+ public static Pen DarkTurquoise {
+ get {
+ if (darkturquoise == null) {
+ darkturquoise = new Pen (Color.DarkTurquoise);
+ darkturquoise.isModifiable = false;
+ }
+ return darkturquoise;
+ }
+ }
+
+ public static Pen DarkViolet {
+ get {
+ if (darkviolet == null) {
+ darkviolet = new Pen (Color.DarkViolet);
+ darkviolet.isModifiable = false;
+ }
+ return darkviolet;
+ }
+ }
+
+ public static Pen DeepPink {
+ get {
+ if (deeppink == null) {
+ deeppink = new Pen (Color.DeepPink);
+ deeppink.isModifiable = false;
+ }
+ return deeppink;
+ }
+ }
+
+ public static Pen DeepSkyBlue {
+ get {
+ if (deepskyblue == null) {
+ deepskyblue = new Pen (Color.DeepSkyBlue);
+ deepskyblue.isModifiable = false;
+ }
+ return deepskyblue;
+ }
+ }
+
+ public static Pen DimGray {
+ get {
+ if (dimgray == null) {
+ dimgray = new Pen (Color.DimGray);
+ dimgray.isModifiable = false;
+ }
+ return dimgray;
+ }
+ }
+
+ public static Pen DodgerBlue {
+ get {
+ if (dodgerblue == null) {
+ dodgerblue = new Pen (Color.DodgerBlue);
+ dodgerblue.isModifiable = false;
+ }
+ return dodgerblue;
+ }
+ }
+
+ public static Pen Firebrick {
+ get {
+ if (firebrick == null) {
+ firebrick = new Pen (Color.Firebrick);
+ firebrick.isModifiable = false;
+ }
+ return firebrick;
+ }
+ }
+
+ public static Pen FloralWhite {
+ get {
+ if (floralwhite == null) {
+ floralwhite = new Pen (Color.FloralWhite);
+ floralwhite.isModifiable = false;
+ }
+ return floralwhite;
+ }
+ }
+
+ public static Pen ForestGreen {
+ get {
+ if (forestgreen == null) {
+ forestgreen = new Pen (Color.ForestGreen);
+ forestgreen.isModifiable = false;
+ }
+ return forestgreen;
+ }
+ }
+
+ public static Pen Fuchsia {
+ get {
+ if (fuchsia == null) {
+ fuchsia = new Pen (Color.Fuchsia);
+ fuchsia.isModifiable = false;
+ }
+ return fuchsia;
+ }
+ }
+
+ public static Pen Gainsboro {
+ get {
+ if (gainsboro == null) {
+ gainsboro = new Pen (Color.Gainsboro);
+ gainsboro.isModifiable = false;
+ }
+ return gainsboro;
+ }
+ }
+
+ public static Pen GhostWhite {
+ get {
+ if (ghostwhite == null) {
+ ghostwhite = new Pen (Color.GhostWhite);
+ ghostwhite.isModifiable = false;
+ }
+ return ghostwhite;
+ }
+ }
+
+ public static Pen Gold {
+ get {
+ if (gold == null) {
+ gold = new Pen (Color.Gold);
+ gold.isModifiable = false;
+ }
+ return gold;
+ }
+ }
+
+ public static Pen Goldenrod {
+ get {
+ if (goldenrod == null) {
+ goldenrod = new Pen (Color.Goldenrod);
+ goldenrod.isModifiable = false;
+ }
+ return goldenrod;
+ }
+ }
+
+ public static Pen Gray {
+ get {
+ if (gray == null) {
+ gray = new Pen (Color.Gray);
+ gray.isModifiable = false;
+ }
+ return gray;
+ }
+ }
+
+ public static Pen Green {
+ get {
+ if (green == null) {
+ green = new Pen (Color.Green);
+ green.isModifiable = false;
+ }
+ return green;
+ }
+ }
+
+ public static Pen GreenYellow {
+ get {
+ if (greenyellow == null) {
+ greenyellow = new Pen (Color.GreenYellow);
+ greenyellow.isModifiable = false;
+ }
+ return greenyellow;
+ }
+ }
+
+ public static Pen Honeydew {
+ get {
+ if (honeydew == null) {
+ honeydew = new Pen (Color.Honeydew);
+ honeydew.isModifiable = false;
+ }
+ return honeydew;
+ }
+ }
+
+ public static Pen HotPink {
+ get {
+ if (hotpink == null) {
+ hotpink = new Pen (Color.HotPink);
+ hotpink.isModifiable = false;
+ }
+ return hotpink;
+ }
+ }
+
+ public static Pen IndianRed {
+ get {
+ if (indianred == null) {
+ indianred = new Pen (Color.IndianRed);
+ indianred.isModifiable = false;
+ }
+ return indianred;
+ }
+ }
+
+ public static Pen Indigo {
+ get {
+ if (indigo == null) {
+ indigo = new Pen (Color.Indigo);
+ indigo.isModifiable = false;
+ }
+ return indigo;
+ }
+ }
+
+ public static Pen Ivory {
+ get {
+ if (ivory == null) {
+ ivory = new Pen (Color.Ivory);
+ ivory.isModifiable = false;
+ }
+ return ivory;
+ }
+ }
+
+ public static Pen Khaki {
+ get {
+ if (khaki == null) {
+ khaki = new Pen (Color.Khaki);
+ khaki.isModifiable = false;
+ }
+ return khaki;
+ }
+ }
+
+ public static Pen Lavender {
+ get {
+ if (lavender == null) {
+ lavender = new Pen (Color.Lavender);
+ lavender.isModifiable = false;
+ }
+ return lavender;
+ }
+ }
+
+ public static Pen LavenderBlush {
+ get {
+ if (lavenderblush == null) {
+ lavenderblush = new Pen (Color.LavenderBlush);
+ lavenderblush.isModifiable = false;
+ }
+ return lavenderblush;
+ }
+ }
+
+ public static Pen LawnGreen {
+ get {
+ if (lawngreen == null) {
+ lawngreen = new Pen (Color.LawnGreen);
+ lawngreen.isModifiable = false;
+ }
+ return lawngreen;
+ }
+ }
+
+ public static Pen LemonChiffon {
+ get {
+ if (lemonchiffon == null) {
+ lemonchiffon = new Pen (Color.LemonChiffon);
+ lemonchiffon.isModifiable = false;
+ }
+ return lemonchiffon;
+ }
+ }
+
+ public static Pen LightBlue {
+ get {
+ if (lightblue == null) {
+ lightblue = new Pen (Color.LightBlue);
+ lightblue.isModifiable = false;
+ }
+ return lightblue;
+ }
+ }
+
+ public static Pen LightCoral {
+ get {
+ if (lightcoral == null) {
+ lightcoral = new Pen (Color.LightCoral);
+ lightcoral.isModifiable = false;
+ }
+ return lightcoral;
+ }
+ }
+
+ public static Pen LightCyan {
+ get {
+ if (lightcyan == null) {
+ lightcyan = new Pen (Color.LightCyan);
+ lightcyan.isModifiable = false;
+ }
+ return lightcyan;
+ }
+ }
+
+ public static Pen LightGoldenrodYellow {
+ get {
+ if (lightgoldenrodyellow == null) {
+ lightgoldenrodyellow = new Pen (Color.LightGoldenrodYellow);
+ lightgoldenrodyellow.isModifiable = false;
+ }
+ return lightgoldenrodyellow;
+ }
+ }
+
+ public static Pen LightGray {
+ get {
+ if (lightgray == null) {
+ lightgray = new Pen (Color.LightGray);
+ lightgray.isModifiable = false;
+ }
+ return lightgray;
+ }
+ }
+
+ public static Pen LightGreen {
+ get {
+ if (lightgreen == null) {
+ lightgreen = new Pen (Color.LightGreen);
+ lightgreen.isModifiable = false;
+ }
+ return lightgreen;
+ }
+ }
+
+ public static Pen LightPink {
+ get {
+ if (lightpink == null) {
+ lightpink = new Pen (Color.LightPink);
+ lightpink.isModifiable = false;
+ }
+ return lightpink;
+ }
+ }
+
+ public static Pen LightSalmon {
+ get {
+ if (lightsalmon == null) {
+ lightsalmon = new Pen (Color.LightSalmon);
+ lightsalmon.isModifiable = false;
+ }
+ return lightsalmon;
+ }
+ }
+
+ public static Pen LightSeaGreen {
+ get {
+ if (lightseagreen == null) {
+ lightseagreen = new Pen (Color.LightSeaGreen);
+ lightseagreen.isModifiable = false;
+ }
+ return lightseagreen;
+ }
+ }
+
+ public static Pen LightSkyBlue {
+ get {
+ if (lightskyblue == null) {
+ lightskyblue = new Pen (Color.LightSkyBlue);
+ lightskyblue.isModifiable = false;
+ }
+ return lightskyblue;
+ }
+ }
+
+ public static Pen LightSlateGray {
+ get {
+ if (lightslategray == null) {
+ lightslategray = new Pen (Color.LightSlateGray);
+ lightslategray.isModifiable = false;
+ }
+ return lightslategray;
+ }
+ }
+
+ public static Pen LightSteelBlue {
+ get {
+ if (lightsteelblue == null) {
+ lightsteelblue = new Pen (Color.LightSteelBlue);
+ lightsteelblue.isModifiable = false;
+ }
+ return lightsteelblue;
+ }
+ }
+
+ public static Pen LightYellow {
+ get {
+ if (lightyellow == null) {
+ lightyellow = new Pen (Color.LightYellow);
+ lightyellow.isModifiable = false;
+ }
+ return lightyellow;
+ }
+ }
+
+ public static Pen Lime {
+ get {
+ if (lime == null) {
+ lime = new Pen (Color.Lime);
+ lime.isModifiable = false;
+ }
+ return lime;
+ }
+ }
+
+ public static Pen LimeGreen {
+ get {
+ if (limegreen == null) {
+ limegreen = new Pen (Color.LimeGreen);
+ limegreen.isModifiable = false;
+ }
+ return limegreen;
+ }
+ }
+
+ public static Pen Linen {
+ get {
+ if (linen == null) {
+ linen = new Pen (Color.Linen);
+ linen.isModifiable = false;
+ }
+ return linen;
+ }
+ }
+
+ public static Pen Magenta {
+ get {
+ if (magenta == null) {
+ magenta = new Pen (Color.Magenta);
+ magenta.isModifiable = false;
+ }
+ return magenta;
+ }
+ }
+
+ public static Pen Maroon {
+ get {
+ if (maroon == null) {
+ maroon = new Pen (Color.Maroon);
+ maroon.isModifiable = false;
+ }
+ return maroon;
+ }
+ }
+
+ public static Pen MediumAquamarine {
+ get {
+ if (mediumaquamarine == null) {
+ mediumaquamarine = new Pen (Color.MediumAquamarine);
+ mediumaquamarine.isModifiable = false;
+ }
+ return mediumaquamarine;
+ }
+ }
+
+ public static Pen MediumBlue {
+ get {
+ if (mediumblue == null) {
+ mediumblue = new Pen (Color.MediumBlue);
+ mediumblue.isModifiable = false;
+ }
+ return mediumblue;
+ }
+ }
+
+ public static Pen MediumOrchid {
+ get {
+ if (mediumorchid == null) {
+ mediumorchid = new Pen (Color.MediumOrchid);
+ mediumorchid.isModifiable = false;
+ }
+ return mediumorchid;
+ }
+ }
+
+ public static Pen MediumPurple {
+ get {
+ if (mediumpurple == null) {
+ mediumpurple = new Pen (Color.MediumPurple);
+ mediumpurple.isModifiable = false;
+ }
+ return mediumpurple;
+ }
+ }
+
+ public static Pen MediumSeaGreen {
+ get {
+ if (mediumseagreen == null) {
+ mediumseagreen = new Pen (Color.MediumSeaGreen);
+ mediumseagreen.isModifiable = false;
+ }
+ return mediumseagreen;
+ }
+ }
+
+ public static Pen MediumSlateBlue {
+ get {
+ if (mediumslateblue == null) {
+ mediumslateblue = new Pen (Color.MediumSlateBlue);
+ mediumslateblue.isModifiable = false;
+ }
+ return mediumslateblue;
+ }
+ }
+
+ public static Pen MediumSpringGreen {
+ get {
+ if (mediumspringgreen == null) {
+ mediumspringgreen = new Pen (Color.MediumSpringGreen);
+ mediumspringgreen.isModifiable = false;
+ }
+ return mediumspringgreen;
+ }
+ }
+
+ public static Pen MediumTurquoise {
+ get {
+ if (mediumturquoise == null) {
+ mediumturquoise = new Pen (Color.MediumTurquoise);
+ mediumturquoise.isModifiable = false;
+ }
+ return mediumturquoise;
+ }
+ }
+
+ public static Pen MediumVioletRed {
+ get {
+ if (mediumvioletred == null) {
+ mediumvioletred = new Pen (Color.MediumVioletRed);
+ mediumvioletred.isModifiable = false;
+ }
+ return mediumvioletred;
+ }
+ }
+
+ public static Pen MidnightBlue {
+ get {
+ if (midnightblue == null) {
+ midnightblue = new Pen (Color.MidnightBlue);
+ midnightblue.isModifiable = false;
+ }
+ return midnightblue;
+ }
+ }
+
+ public static Pen MintCream {
+ get {
+ if (mintcream == null) {
+ mintcream = new Pen (Color.MintCream);
+ mintcream.isModifiable = false;
+ }
+ return mintcream;
+ }
+ }
+
+ public static Pen MistyRose {
+ get {
+ if (mistyrose == null) {
+ mistyrose = new Pen (Color.MistyRose);
+ mistyrose.isModifiable = false;
+ }
+ return mistyrose;
+ }
+ }
+
+ public static Pen Moccasin {
+ get {
+ if (moccasin == null) {
+ moccasin = new Pen (Color.Moccasin);
+ moccasin.isModifiable = false;
+ }
+ return moccasin;
+ }
+ }
+
+ public static Pen NavajoWhite {
+ get {
+ if (navajowhite == null) {
+ navajowhite = new Pen (Color.NavajoWhite);
+ navajowhite.isModifiable = false;
+ }
+ return navajowhite;
+ }
+ }
+
+ public static Pen Navy {
+ get {
+ if (navy == null) {
+ navy = new Pen (Color.Navy);
+ navy.isModifiable = false;
+ }
+ return navy;
+ }
+ }
+
+ public static Pen OldLace {
+ get {
+ if (oldlace == null) {
+ oldlace = new Pen (Color.OldLace);
+ oldlace.isModifiable = false;
+ }
+ return oldlace;
+ }
+ }
+
+ public static Pen Olive {
+ get {
+ if (olive == null) {
+ olive = new Pen (Color.Olive);
+ olive.isModifiable = false;
+ }
+ return olive;
+ }
+ }
+
+ public static Pen OliveDrab {
+ get {
+ if (olivedrab == null) {
+ olivedrab = new Pen (Color.OliveDrab);
+ olivedrab.isModifiable = false;
+ }
+ return olivedrab;
+ }
+ }
+
+ public static Pen Orange {
+ get {
+ if (orange == null) {
+ orange = new Pen (Color.Orange);
+ orange.isModifiable = false;
+ }
+ return orange;
+ }
+ }
+
+ public static Pen OrangeRed {
+ get {
+ if (orangered == null) {
+ orangered = new Pen (Color.OrangeRed);
+ orangered.isModifiable = false;
+ }
+ return orangered;
+ }
+ }
+
+ public static Pen Orchid {
+ get {
+ if (orchid == null) {
+ orchid = new Pen (Color.Orchid);
+ orchid.isModifiable = false;
+ }
+ return orchid;
+ }
+ }
+
+ public static Pen PaleGoldenrod {
+ get {
+ if (palegoldenrod == null) {
+ palegoldenrod = new Pen (Color.PaleGoldenrod);
+ palegoldenrod.isModifiable = false;
+ }
+ return palegoldenrod;
+ }
+ }
+
+ public static Pen PaleGreen {
+ get {
+ if (palegreen == null) {
+ palegreen = new Pen (Color.PaleGreen);
+ palegreen.isModifiable = false;
+ }
+ return palegreen;
+ }
+ }
+
+ public static Pen PaleTurquoise {
+ get {
+ if (paleturquoise == null) {
+ paleturquoise = new Pen (Color.PaleTurquoise);
+ paleturquoise.isModifiable = false;
+ }
+ return paleturquoise;
+ }
+ }
+
+ public static Pen PaleVioletRed {
+ get {
+ if (palevioletred == null) {
+ palevioletred = new Pen (Color.PaleVioletRed);
+ palevioletred.isModifiable = false;
+ }
+ return palevioletred;
+ }
+ }
+
+ public static Pen PapayaWhip {
+ get {
+ if (papayawhip == null) {
+ papayawhip = new Pen (Color.PapayaWhip);
+ papayawhip.isModifiable = false;
+ }
+ return papayawhip;
+ }
+ }
+
+ public static Pen PeachPuff {
+ get {
+ if (peachpuff == null) {
+ peachpuff = new Pen (Color.PeachPuff);
+ peachpuff.isModifiable = false;
+ }
+ return peachpuff;
+ }
+ }
+
+ public static Pen Peru {
+ get {
+ if (peru == null) {
+ peru = new Pen (Color.Peru);
+ peru.isModifiable = false;
+ }
+ return peru;
+ }
+ }
+
+ public static Pen Pink {
+ get {
+ if (pink == null) {
+ pink = new Pen (Color.Pink);
+ pink.isModifiable = false;
+ }
+ return pink;
+ }
+ }
+
+ public static Pen Plum {
+ get {
+ if (plum == null) {
+ plum = new Pen (Color.Plum);
+ plum.isModifiable = false;
+ }
+ return plum;
+ }
+ }
+
+ public static Pen PowderBlue {
+ get {
+ if (powderblue == null) {
+ powderblue = new Pen (Color.PowderBlue);
+ powderblue.isModifiable = false;
+ }
+ return powderblue;
+ }
+ }
+
+ public static Pen Purple {
+ get {
+ if (purple == null) {
+ purple = new Pen (Color.Purple);
+ purple.isModifiable = false;
+ }
+ return purple;
+ }
+ }
+
+ public static Pen Red {
+ get {
+ if (red == null) {
+ red = new Pen (Color.Red);
+ red.isModifiable = false;
+ }
+ return red;
+ }
+ }
+
+ public static Pen RosyBrown {
+ get {
+ if (rosybrown == null) {
+ rosybrown = new Pen (Color.RosyBrown);
+ rosybrown.isModifiable = false;
+ }
+ return rosybrown;
+ }
+ }
+
+ public static Pen RoyalBlue {
+ get {
+ if (royalblue == null) {
+ royalblue = new Pen (Color.RoyalBlue);
+ royalblue.isModifiable = false;
+ }
+ return royalblue;
+ }
+ }
+
+ public static Pen SaddleBrown {
+ get {
+ if (saddlebrown == null) {
+ saddlebrown = new Pen (Color.SaddleBrown);
+ saddlebrown.isModifiable = false;
+ }
+ return saddlebrown;
+ }
+ }
+
+ public static Pen Salmon {
+ get {
+ if (salmon == null) {
+ salmon = new Pen (Color.Salmon);
+ salmon.isModifiable = false;
+ }
+ return salmon;
+ }
+ }
+
+ public static Pen SandyBrown {
+ get {
+ if (sandybrown == null) {
+ sandybrown = new Pen (Color.SandyBrown);
+ sandybrown.isModifiable = false;
+ }
+ return sandybrown;
+ }
+ }
+
+ public static Pen SeaGreen {
+ get {
+ if (seagreen == null) {
+ seagreen = new Pen (Color.SeaGreen);
+ seagreen.isModifiable = false;
+ }
+ return seagreen;
+ }
+ }
+
+ public static Pen SeaShell {
+ get {
+ if (seashell == null) {
+ seashell = new Pen (Color.SeaShell);
+ seashell.isModifiable = false;
+ }
+ return seashell;
+ }
+ }
+
+ public static Pen Sienna {
+ get {
+ if (sienna == null) {
+ sienna = new Pen (Color.Sienna);
+ sienna.isModifiable = false;
+ }
+ return sienna;
+ }
+ }
+
+ public static Pen Silver {
+ get {
+ if (silver == null) {
+ silver = new Pen (Color.Silver);
+ silver.isModifiable = false;
+ }
+ return silver;
+ }
+ }
+
+ public static Pen SkyBlue {
+ get {
+ if (skyblue == null) {
+ skyblue = new Pen (Color.SkyBlue);
+ skyblue.isModifiable = false;
+ }
+ return skyblue;
+ }
+ }
+
+ public static Pen SlateBlue {
+ get {
+ if (slateblue == null) {
+ slateblue = new Pen (Color.SlateBlue);
+ slateblue.isModifiable = false;
+ }
+ return slateblue;
+ }
+ }
+
+ public static Pen SlateGray {
+ get {
+ if (slategray == null) {
+ slategray = new Pen (Color.SlateGray);
+ slategray.isModifiable = false;
+ }
+ return slategray;
+ }
+ }
+
+ public static Pen Snow {
+ get {
+ if (snow == null) {
+ snow = new Pen (Color.Snow);
+ snow.isModifiable = false;
+ }
+ return snow;
+ }
+ }
+
+ public static Pen SpringGreen {
+ get {
+ if (springgreen == null) {
+ springgreen = new Pen (Color.SpringGreen);
+ springgreen.isModifiable = false;
+ }
+ return springgreen;
+ }
+ }
+
+ public static Pen SteelBlue {
+ get {
+ if (steelblue == null) {
+ steelblue = new Pen (Color.SteelBlue);
+ steelblue.isModifiable = false;
+ }
+ return steelblue;
+ }
+ }
+
+ public static Pen Tan {
+ get {
+ if (tan == null) {
+ tan = new Pen (Color.Tan);
+ tan.isModifiable = false;
+ }
+ return tan;
+ }
+ }
+
+ public static Pen Teal {
+ get {
+ if (teal == null) {
+ teal = new Pen (Color.Teal);
+ teal.isModifiable = false;
+ }
+ return teal;
+ }
+ }
+
+ public static Pen Thistle {
+ get {
+ if (thistle == null) {
+ thistle = new Pen (Color.Thistle);
+ thistle.isModifiable = false;
+ }
+ return thistle;
+ }
+ }
+
+ public static Pen Tomato {
+ get {
+ if (tomato == null) {
+ tomato = new Pen (Color.Tomato);
+ tomato.isModifiable = false;
+ }
+ return tomato;
+ }
+ }
+
+ public static Pen Transparent {
+ get {
+ if (transparent == null) {
+ transparent = new Pen (Color.Transparent);
+ transparent.isModifiable = false;
+ }
+ return transparent;
+ }
+ }
+
+ public static Pen Turquoise {
+ get {
+ if (turquoise == null) {
+ turquoise = new Pen (Color.Turquoise);
+ turquoise.isModifiable = false;
+ }
+ return turquoise;
+ }
+ }
+
+ public static Pen Violet {
+ get {
+ if (violet == null) {
+ violet = new Pen (Color.Violet);
+ violet.isModifiable = false;
+ }
+ return violet;
+ }
+ }
+
+ public static Pen Wheat {
+ get {
+ if (wheat == null) {
+ wheat = new Pen (Color.Wheat);
+ wheat.isModifiable = false;
+ }
+ return wheat;
+ }
+ }
+
+ public static Pen White {
+ get {
+ if (white == null) {
+ white = new Pen (Color.White);
+ white.isModifiable = false;
+ }
+ return white;
+ }
+ }
+
+ public static Pen WhiteSmoke {
+ get {
+ if (whitesmoke == null) {
+ whitesmoke = new Pen (Color.WhiteSmoke);
+ whitesmoke.isModifiable = false;
+ }
+ return whitesmoke;
+ }
+ }
+
+ public static Pen Yellow {
+ get {
+ if (yellow == null) {
+ yellow = new Pen (Color.Yellow);
+ yellow.isModifiable = false;
+ }
+ return yellow;
+ }
+ }
+
+ public static Pen YellowGreen {
+ get {
+ if (yellowgreen == null) {
+ yellowgreen = new Pen (Color.YellowGreen);
+ yellowgreen.isModifiable = false;
+ }
+ return yellowgreen;
+
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/PlainImage.jvm.cs b/mcs/class/System.Drawing/System.Drawing/PlainImage.jvm.cs
new file mode 100644
index 00000000000..aad9478bdb7
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/PlainImage.jvm.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Drawing.Imaging;
+using System.Xml;
+
+using Mainsoft.Drawing.Imaging;
+
+using awt = java.awt;
+using java.awt.image;
+using imageio = javax.imageio;
+
+namespace Mainsoft.Drawing.Imaging
+{
+ /// <summary>
+ /// Summary description for PlainImage.
+ /// </summary>
+ public class PlainImage : ICloneable {
+
+ #region Members
+
+ awt.Image _nativeObject;
+ awt.Image [] _thumbnails;
+ FrameDimension _dimension;
+ XmlDocument _metadata;
+ imageio.metadata.IIOMetadata _nativeMetadata;
+ ImageFormat _imageFormat;
+
+ float _xResolution;
+ float _yResolution;
+
+
+ #endregion
+
+ #region Constructors
+
+ public PlainImage() {
+ }
+
+ public PlainImage(awt.Image image, awt.Image [] thumbnails, ImageFormat format, float xRes, float yRes, FrameDimension dimension) {
+ _nativeObject = image;
+ _thumbnails = thumbnails;
+ _imageFormat = format;
+
+ _xResolution = xRes;
+ _yResolution = yRes;
+
+ _dimension = dimension;
+ }
+
+ #endregion
+
+
+ private awt.Image NativeObject {
+ get { return _nativeObject; }
+ set { _nativeObject = value; }
+ }
+
+ #region PlainImage properties
+
+ public awt.Image NativeImage {
+ get { return NativeObject; }
+ set { NativeObject = value; }
+ }
+
+ internal imageio.metadata.IIOMetadata NativeMetadata {
+ get { return _nativeMetadata; }
+ set { _nativeMetadata = value; }
+ }
+
+ public XmlDocument Metadata {
+ get { return _metadata; }
+ set { _metadata = value; }
+ }
+
+ public ImageFormat ImageFormat {
+ get { return _imageFormat; }
+ }
+
+ public FrameDimension Dimension {
+ get { return _dimension; }
+ set { _dimension = value; }
+ }
+
+ public awt.Image [] Thumbnails {
+ get { return _thumbnails; }
+ }
+
+ public float HorizontalResolution {
+ get { return _xResolution; }
+ set { _xResolution = value; }
+ }
+
+ public float VerticalResolution {
+ get { return _yResolution; }
+ set { _yResolution = value; }
+ }
+
+ #endregion
+
+ #region ICloneable members
+
+ public object Clone() {
+ return Clone(true);
+ }
+
+ public PlainImage Clone(bool cloneImage) {
+ awt.Image img = NativeImage;
+ awt.Image [] th = _thumbnails;
+
+ if (cloneImage) {
+ img = new BufferedImage(
+ ((BufferedImage)NativeObject).getColorModel(),
+ ((BufferedImage)NativeObject).copyData(null),
+ ((BufferedImage)NativeObject).isAlphaPremultiplied(), null);
+
+ if (Thumbnails != null) {
+ th = new java.awt.Image[ Thumbnails.Length ];
+ for (int i=0; i < Thumbnails.Length; i++) {
+ th[i] = new BufferedImage(
+ ((BufferedImage)Thumbnails[i]).getColorModel(),
+ ((BufferedImage)Thumbnails[i]).copyData(null),
+ ((BufferedImage)Thumbnails[i]).isAlphaPremultiplied(), null);
+ }
+ }
+ }
+
+ return new PlainImage(
+ img,
+ th,
+ ImageFormat,
+ HorizontalResolution,
+ VerticalResolution,
+ Dimension );
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/PlainImageCollection.jvm.cs b/mcs/class/System.Drawing/System.Drawing/PlainImageCollection.jvm.cs
new file mode 100644
index 00000000000..1274948840f
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/PlainImageCollection.jvm.cs
@@ -0,0 +1,101 @@
+using System;
+using System.Collections;
+
+namespace Mainsoft.Drawing.Imaging
+{
+ /// <summary>
+ /// Summary description for PlainImageCollection.
+ /// </summary>
+ public class PlainImageCollection : ICollection, IEnumerable
+ {
+ ArrayList collection = new ArrayList();
+ int _position = 0;
+
+ public PlainImageCollection()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+
+ #region ICollection members
+
+ public bool IsSynchronized {
+ get {
+ return collection.IsSynchronized;
+ }
+ }
+
+ public int Count {
+ get {
+ return collection.Count;
+ }
+ }
+
+ public void CopyTo(Array array, int index) {
+ collection.CopyTo(array, index);
+ }
+
+ public object SyncRoot {
+ get {
+ return collection.SyncRoot;
+ }
+ }
+
+ #endregion
+
+ #region IEnumerable members
+
+ public IEnumerator GetEnumerator() {
+ return collection.GetEnumerator();
+ }
+
+ #endregion
+
+ #region Collection members
+
+ public int Add(PlainImage plainImage) {
+ return collection.Add( plainImage );
+ }
+
+ public void Clear() {
+ collection.Clear();
+ }
+
+ public bool Contains(PlainImage plainImage) {
+ return collection.Contains(plainImage);
+ }
+
+ public int IndexOf(PlainImage plainImage) {
+ return collection.IndexOf( plainImage );
+ }
+
+ public void Insert(int index, PlainImage value) {
+ collection.Insert( index, value );
+ }
+
+ public void Remove(PlainImage value) {
+ collection.Remove( value );
+ }
+
+ public void RemoveAt(int index) {
+ collection.RemoveAt( index );
+ }
+
+ public PlainImage this[int index] {
+ get { return (PlainImage) collection[ index ]; }
+ }
+
+ public PlainImage CurrentImage {
+ get { return (PlainImage) collection[ _position ]; }
+ set { collection[ _position ] = value; }
+ }
+
+ public int CurrentImageIndex {
+ get { return _position; }
+ set { _position = value; }
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Point.cs b/mcs/class/System.Drawing/System.Drawing/Point.cs
new file mode 100644
index 00000000000..2a3e80ee0e2
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Point.cs
@@ -0,0 +1,387 @@
+//
+// System.Drawing.Point.cs
+//
+// Author:
+// Mike Kestner (mkestner@speakeasy.net)
+//
+// Copyright (C) 2001 Mike Kestner
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ [Serializable]
+ [ComVisible (true)]
+ [TypeConverter (typeof (PointConverter))]
+ public struct Point
+ {
+ // Private x and y coordinate fields.
+ private int x, y;
+
+ // -----------------------
+ // Public Shared Members
+ // -----------------------
+
+ /// <summary>
+ /// Empty Shared Field
+ /// </summary>
+ ///
+ /// <remarks>
+ /// An uninitialized Point Structure.
+ /// </remarks>
+
+ public static readonly Point Empty;
+
+ /// <summary>
+ /// Ceiling Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a Point structure from a PointF structure by
+ /// taking the ceiling of the X and Y properties.
+ /// </remarks>
+
+ public static Point Ceiling (PointF value)
+ {
+ int x, y;
+ checked {
+ x = (int) Math.Ceiling (value.X);
+ y = (int) Math.Ceiling (value.Y);
+ }
+
+ return new Point (x, y);
+ }
+
+ /// <summary>
+ /// Round Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a Point structure from a PointF structure by
+ /// rounding the X and Y properties.
+ /// </remarks>
+
+ public static Point Round (PointF value)
+ {
+ int x, y;
+ checked {
+ x = (int) Math.Round (value.X);
+ y = (int) Math.Round (value.Y);
+ }
+
+ return new Point (x, y);
+ }
+
+ /// <summary>
+ /// Truncate Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a Point structure from a PointF structure by
+ /// truncating the X and Y properties.
+ /// </remarks>
+
+ // LAMESPEC: Should this be floor, or a pure cast to int?
+
+ public static Point Truncate (PointF value)
+ {
+ int x, y;
+ checked {
+ x = (int) value.X;
+ y = (int) value.Y;
+ }
+
+ return new Point (x, y);
+ }
+
+ /// <summary>
+ /// Addition Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Translates a Point using the Width and Height
+ /// properties of the given <typeref>Size</typeref>.
+ /// </remarks>
+
+ public static Point operator + (Point pt, Size sz)
+ {
+ return new Point (pt.X + sz.Width, pt.Y + sz.Height);
+ }
+
+ /// <summary>
+ /// Equality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two Point objects. The return value is
+ /// based on the equivalence of the X and Y properties
+ /// of the two points.
+ /// </remarks>
+
+ public static bool operator == (Point pt_a, Point pt_b)
+ {
+ return ((pt_a.X == pt_b.X) && (pt_a.Y == pt_b.Y));
+ }
+
+ /// <summary>
+ /// Inequality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two Point objects. The return value is
+ /// based on the equivalence of the X and Y properties
+ /// of the two points.
+ /// </remarks>
+
+ public static bool operator != (Point pt_a, Point pt_b)
+ {
+ return ((pt_a.X != pt_b.X) || (pt_a.Y != pt_b.Y));
+ }
+
+ /// <summary>
+ /// Subtraction Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Translates a Point using the negation of the Width
+ /// and Height properties of the given Size.
+ /// </remarks>
+
+ public static Point operator - (Point pt, Size sz)
+ {
+ return new Point (pt.X - sz.Width, pt.Y - sz.Height);
+ }
+
+ /// <summary>
+ /// Point to Size Conversion
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Returns a Size based on the Coordinates of a given
+ /// Point. Requires explicit cast.
+ /// </remarks>
+
+ public static explicit operator Size (Point pt)
+ {
+ return new Size (pt.X, pt.Y);
+ }
+
+ /// <summary>
+ /// Point to PointF Conversion
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a PointF based on the coordinates of a given
+ /// Point. No explicit cast is required.
+ /// </remarks>
+
+ public static implicit operator PointF (Point pt)
+ {
+ return new PointF (pt.X, pt.Y);
+ }
+
+
+ // -----------------------
+ // Public Constructors
+ // -----------------------
+
+ /// <summary>
+ /// Point Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a Point from an integer which holds the X
+ /// coordinate in the high order 16 bits and the Y
+ /// coordinate in the low order 16 bits.
+ /// </remarks>
+
+ public Point (int dw)
+ {
+ x = dw >> 16;
+ y = dw & 0xffff;
+ }
+
+ /// <summary>
+ /// Point Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a Point from a Size value.
+ /// </remarks>
+
+ public Point (Size sz)
+ {
+ x = sz.Width;
+ y = sz.Height;
+ }
+
+ /// <summary>
+ /// Point Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a Point from a specified x,y coordinate pair.
+ /// </remarks>
+
+ public Point (int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ // -----------------------
+ // Public Instance Members
+ // -----------------------
+
+ /// <summary>
+ /// IsEmpty Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Indicates if both X and Y are zero.
+ /// </remarks>
+
+ [Browsable (false)]
+ public bool IsEmpty {
+ get {
+ return ((x == 0) && (y == 0));
+ }
+ }
+
+ /// <summary>
+ /// X Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The X coordinate of the Point.
+ /// </remarks>
+
+ public int X {
+ get {
+ return x;
+ }
+ set {
+ x = value;
+ }
+ }
+
+ /// <summary>
+ /// Y Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Y coordinate of the Point.
+ /// </remarks>
+
+ public int Y {
+ get {
+ return y;
+ }
+ set {
+ y = value;
+ }
+ }
+
+ /// <summary>
+ /// Equals Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks equivalence of this Point and another object.
+ /// </remarks>
+
+ public override bool Equals (object o)
+ {
+ if (!(o is Point))
+ return false;
+
+ return (this == (Point) o);
+ }
+
+ /// <summary>
+ /// GetHashCode Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Calculates a hashing value.
+ /// </remarks>
+
+ public override int GetHashCode ()
+ {
+ return x^y;
+ }
+
+ /// <summary>
+ /// Offset Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Moves the Point a specified distance.
+ /// </remarks>
+
+ public void Offset (int dx, int dy)
+ {
+ x += dx;
+ y += dy;
+ }
+
+ /// <summary>
+ /// ToString Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Formats the Point as a string in coordinate notation.
+ /// </remarks>
+
+ public override string ToString ()
+ {
+ return string.Format ("{{X={0},Y={1}}}", x.ToString (CultureInfo.InvariantCulture),
+ y.ToString (CultureInfo.InvariantCulture));
+ }
+#if NET_2_0
+ public static Point Add (Point pt, Size sz)
+ {
+ return new Point (pt.X + sz.Width, pt.Y + sz.Height);
+ }
+
+ public void Offset (Point p)
+ {
+ Offset (p.X, p.Y);
+ }
+
+ public static Point Subtract (Point pt, Size sz)
+ {
+ return new Point (pt.X - sz.Width, pt.Y - sz.Height);
+ }
+#endif
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/PointConverter.cs b/mcs/class/System.Drawing/System.Drawing/PointConverter.cs
new file mode 100644
index 00000000000..56b7ec0e99c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/PointConverter.cs
@@ -0,0 +1,144 @@
+//
+// System.Drawing.PointConverter.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.ComponentModel.Design.Serialization;
+using System.Reflection;
+
+namespace System.Drawing
+{
+ /// <summary>
+ /// Summary description for PointConverter.
+ /// </summary>
+ public class PointConverter : TypeConverter
+ {
+ public PointConverter() { }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context,
+ Type sourceType)
+ {
+ if (sourceType == typeof (string))
+ return true;
+
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context,
+ Type destinationType)
+ {
+ if (destinationType == typeof (string))
+ return true;
+
+ if (destinationType == typeof (InstanceDescriptor))
+ return true;
+
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value)
+ {
+ string s = value as string;
+ if (s == null)
+ return base.ConvertFrom (context, culture, value);
+
+ string [] subs = s.Split (culture.TextInfo.ListSeparator.ToCharArray ());
+
+ Int32Converter converter = new Int32Converter ();
+ int[] numSubs = new int[subs.Length];
+ for (int i = 0; i < numSubs.Length; i++) {
+ numSubs[i] = (int) converter.ConvertFromString (context, culture, subs[i]);
+ }
+
+ if (subs.Length != 2)
+ throw new ArgumentException ("Failed to parse Text(" + s + ") expected text in the format \"x, y.\"");
+
+ return new Point (numSubs[0], numSubs[1]);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value,
+ Type destinationType)
+ {
+ // LAMESPEC: "The default implementation calls the object's
+ // ToString method if the object is valid and if the destination
+ // type is string." MS does not behave as per the specs.
+ // Oh well, we have to be compatible with MS.
+ if ((destinationType == typeof (string)) && (value is Point))
+ return ((Point) value).X.ToString(culture) + culture.TextInfo.ListSeparator
+ + " " + ((Point) value).Y.ToString(culture);
+
+ if (destinationType == typeof (InstanceDescriptor) && value is Point) {
+ Point c = (Point)value;
+ ConstructorInfo ctor = typeof(Point).GetConstructor (new Type[] {typeof(int), typeof(int)} );
+ return new InstanceDescriptor (ctor, new object[] {c.X, c.Y });
+ }
+
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ public override object CreateInstance (ITypeDescriptorContext context,
+ IDictionary propertyValues)
+ {
+ int x = (int) propertyValues ["X"];
+ int y = (int) propertyValues ["Y"];
+
+ return new Point (x, y);
+ }
+
+
+ public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ public override PropertyDescriptorCollection GetProperties (
+ ITypeDescriptorContext context,
+ object value, Attribute[] attributes)
+ {
+ if (value is Point)
+ return TypeDescriptor.GetProperties (value, attributes);
+
+ return base.GetProperties (context, value, attributes);
+ }
+
+ public override bool GetPropertiesSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/PointF.cs b/mcs/class/System.Drawing/System.Drawing/PointF.cs
new file mode 100644
index 00000000000..7019947d9a1
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/PointF.cs
@@ -0,0 +1,257 @@
+//
+// System.Drawing.PointF.cs
+//
+// Author:
+// Mike Kestner (mkestner@speakeasy.net)
+//
+// Copyright (C) 2001 Mike Kestner
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ [Serializable]
+ [ComVisible (true)]
+ public struct PointF
+ {
+ // Private x and y coordinate fields.
+ private float x, y;
+
+ // -----------------------
+ // Public Shared Members
+ // -----------------------
+
+ /// <summary>
+ /// Empty Shared Field
+ /// </summary>
+ ///
+ /// <remarks>
+ /// An uninitialized PointF Structure.
+ /// </remarks>
+
+ public static readonly PointF Empty;
+
+ /// <summary>
+ /// Addition Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Translates a PointF using the Width and Height
+ /// properties of the given Size.
+ /// </remarks>
+
+ public static PointF operator + (PointF pt, Size sz)
+ {
+ return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
+ }
+
+ /// <summary>
+ /// Equality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two PointF objects. The return value is
+ /// based on the equivalence of the X and Y properties
+ /// of the two points.
+ /// </remarks>
+
+ public static bool operator == (PointF pt_a, PointF pt_b)
+ {
+ return ((pt_a.X == pt_b.X) && (pt_a.Y == pt_b.Y));
+ }
+
+ /// <summary>
+ /// Inequality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two PointF objects. The return value is
+ /// based on the equivalence of the X and Y properties
+ /// of the two points.
+ /// </remarks>
+
+ public static bool operator != (PointF pt_a, PointF pt_b)
+ {
+ return ((pt_a.X != pt_b.X) || (pt_a.Y != pt_b.Y));
+ }
+
+ /// <summary>
+ /// Subtraction Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Translates a PointF using the negation of the Width
+ /// and Height properties of the given Size.
+ /// </remarks>
+
+ public static PointF operator - (PointF pt, Size sz)
+ {
+ return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
+ }
+
+ // -----------------------
+ // Public Constructor
+ // -----------------------
+
+ /// <summary>
+ /// PointF Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a PointF from a specified x,y coordinate pair.
+ /// </remarks>
+
+ public PointF (float x, float y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ // -----------------------
+ // Public Instance Members
+ // -----------------------
+
+ /// <summary>
+ /// IsEmpty Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Indicates if both X and Y are zero.
+ /// </remarks>
+
+ [Browsable (false)]
+ public bool IsEmpty {
+ get {
+ return ((x == 0.0) && (y == 0.0));
+ }
+ }
+
+ /// <summary>
+ /// X Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The X coordinate of the PointF.
+ /// </remarks>
+
+ public float X {
+ get {
+ return x;
+ }
+ set {
+ x = value;
+ }
+ }
+
+ /// <summary>
+ /// Y Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Y coordinate of the PointF.
+ /// </remarks>
+
+ public float Y {
+ get {
+ return y;
+ }
+ set {
+ y = value;
+ }
+ }
+
+ /// <summary>
+ /// Equals Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks equivalence of this PointF and another object.
+ /// </remarks>
+
+ public override bool Equals (object o)
+ {
+ if (!(o is PointF))
+ return false;
+
+ return (this == (PointF) o);
+ }
+
+ /// <summary>
+ /// GetHashCode Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Calculates a hashing value.
+ /// </remarks>
+
+ public override int GetHashCode ()
+ {
+ return (int) x ^ (int) y;
+ }
+
+ /// <summary>
+ /// ToString Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Formats the PointF as a string in coordinate notation.
+ /// </remarks>
+
+ public override string ToString ()
+ {
+ return String.Format ("{{X={0}, Y={1}}}", x.ToString (CultureInfo.CurrentCulture),
+ y.ToString (CultureInfo.CurrentCulture));
+ }
+
+#if NET_2_0
+ public static PointF Add (PointF pt, Size sz)
+ {
+ return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
+ }
+
+ public static PointF Add (PointF pt, SizeF sz)
+ {
+ return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
+ }
+
+ public static PointF Subtract (PointF pt, Size sz)
+ {
+ return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
+ }
+
+ public static PointF Subtract (PointF pt, SizeF sz)
+ {
+ return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
+ }
+#endif
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Rectangle.cs b/mcs/class/System.Drawing/System.Drawing/Rectangle.cs
new file mode 100644
index 00000000000..6b96fe4f4f9
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Rectangle.cs
@@ -0,0 +1,638 @@
+//
+// System.Drawing.Rectangle.cs
+//
+// Author:
+// Mike Kestner (mkestner@speakeasy.net)
+//
+// Copyright (C) 2001 Mike Kestner
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ [Serializable]
+ [ComVisible (true)]
+ [TypeConverter (typeof (RectangleConverter))]
+ public struct Rectangle
+ {
+ private int x, y, width, height;
+
+ /// <summary>
+ /// Empty Shared Field
+ /// </summary>
+ ///
+ /// <remarks>
+ /// An uninitialized Rectangle Structure.
+ /// </remarks>
+
+ public static readonly Rectangle Empty;
+
+#if TARGET_JVM
+ internal java.awt.Rectangle NativeObject {
+ get {
+ return new java.awt.Rectangle(X,Y,Width,Height);
+ }
+ }
+#endif
+
+ /// <summary>
+ /// Ceiling Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a Rectangle structure from a RectangleF
+ /// structure by taking the ceiling of the X, Y, Width,
+ /// and Height properties.
+ /// </remarks>
+
+ public static Rectangle Ceiling (RectangleF value)
+ {
+ int x, y, w, h;
+ checked {
+ x = (int) Math.Ceiling (value.X);
+ y = (int) Math.Ceiling (value.Y);
+ w = (int) Math.Ceiling (value.Width);
+ h = (int) Math.Ceiling (value.Height);
+ }
+
+ return new Rectangle (x, y, w, h);
+ }
+
+ /// <summary>
+ /// FromLTRB Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a Rectangle structure from left, top, right,
+ /// and bottom coordinates.
+ /// </remarks>
+
+ public static Rectangle FromLTRB (int left, int top,
+ int right, int bottom)
+ {
+ return new Rectangle (left, top, right - left,
+ bottom - top);
+ }
+
+ /// <summary>
+ /// Inflate Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a new Rectangle by inflating an existing
+ /// Rectangle by the specified coordinate values.
+ /// </remarks>
+
+ public static Rectangle Inflate (Rectangle rect, int x, int y)
+ {
+ Rectangle r = new Rectangle (rect.Location, rect.Size);
+ r.Inflate (x, y);
+ return r;
+ }
+
+ /// <summary>
+ /// Inflate Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Inflates the Rectangle by a specified width and height.
+ /// </remarks>
+
+ public void Inflate (int width, int height)
+ {
+ Inflate (new Size (width, height));
+ }
+
+ /// <summary>
+ /// Inflate Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Inflates the Rectangle by a specified Size.
+ /// </remarks>
+
+ public void Inflate (Size sz)
+ {
+ x -= sz.Width;
+ y -= sz.Height;
+ Width += sz.Width * 2;
+ Height += sz.Height * 2;
+ }
+
+ /// <summary>
+ /// Intersect Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a new Rectangle by intersecting 2 existing
+ /// Rectangles. Returns null if there is no intersection.
+ /// </remarks>
+
+ public static Rectangle Intersect (Rectangle r1, Rectangle r2)
+ {
+ // MS.NET returns a non-empty rectangle if the two rectangles
+ // touch each other
+ if (!r1.IntersectsWithInclusive (r2))
+ return Empty;
+
+ return Rectangle.FromLTRB (
+ Math.Max (r1.Left, r2.Left),
+ Math.Max (r1.Top, r2.Top),
+ Math.Min (r1.Right, r2.Right),
+ Math.Min (r1.Bottom, r2.Bottom));
+ }
+
+ /// <summary>
+ /// Intersect Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Replaces the Rectangle with the intersection of itself
+ /// and another Rectangle.
+ /// </remarks>
+
+ public void Intersect (Rectangle r)
+ {
+ this = Rectangle.Intersect (this, r);
+ }
+
+ /// <summary>
+ /// Round Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a Rectangle structure from a RectangleF by
+ /// rounding the X, Y, Width, and Height properties.
+ /// </remarks>
+
+ public static Rectangle Round (RectangleF value)
+ {
+ int x, y, w, h;
+ checked {
+ x = (int) Math.Round (value.X);
+ y = (int) Math.Round (value.Y);
+ w = (int) Math.Round (value.Width);
+ h = (int) Math.Round (value.Height);
+ }
+
+ return new Rectangle (x, y, w, h);
+ }
+
+ /// <summary>
+ /// Truncate Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a Rectangle structure from a RectangleF by
+ /// truncating the X, Y, Width, and Height properties.
+ /// </remarks>
+
+ // LAMESPEC: Should this be floor, or a pure cast to int?
+
+ public static Rectangle Truncate (RectangleF value)
+ {
+ int x, y, w, h;
+ checked {
+ x = (int) value.X;
+ y = (int) value.Y;
+ w = (int) value.Width;
+ h = (int) value.Height;
+ }
+
+ return new Rectangle (x, y, w, h);
+ }
+
+ /// <summary>
+ /// Union Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a new Rectangle from the union of 2 existing
+ /// Rectangles.
+ /// </remarks>
+
+ public static Rectangle Union (Rectangle r1, Rectangle r2)
+ {
+ return FromLTRB (Math.Min (r1.Left, r2.Left),
+ Math.Min (r1.Top, r2.Top),
+ Math.Max (r1.Right, r2.Right),
+ Math.Max (r1.Bottom, r2.Bottom));
+ }
+
+ /// <summary>
+ /// Equality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two Rectangle objects. The return value is
+ /// based on the equivalence of the Location and Size
+ /// properties of the two Rectangles.
+ /// </remarks>
+
+ public static bool operator == (Rectangle r1, Rectangle r2)
+ {
+ return ((r1.Location == r2.Location) &&
+ (r1.Size == r2.Size));
+ }
+
+ /// <summary>
+ /// Inequality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two Rectangle objects. The return value is
+ /// based on the equivalence of the Location and Size
+ /// properties of the two Rectangles.
+ /// </remarks>
+
+ public static bool operator != (Rectangle r1, Rectangle r2)
+ {
+ return ((r1.Location != r2.Location) ||
+ (r1.Size != r2.Size));
+ }
+
+
+ // -----------------------
+ // Public Constructors
+ // -----------------------
+
+ /// <summary>
+ /// Rectangle Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a Rectangle from Point and Size values.
+ /// </remarks>
+
+ public Rectangle (Point loc, Size sz)
+ {
+ x = loc.X;
+ y = loc.Y;
+ width = sz.Width;
+ height = sz.Height;
+ }
+
+ /// <summary>
+ /// Rectangle Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a Rectangle from a specified x,y location and
+ /// width and height values.
+ /// </remarks>
+
+ public Rectangle (int x, int y, int width, int height)
+ {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+
+
+ /// <summary>
+ /// Bottom Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Y coordinate of the bottom edge of the Rectangle.
+ /// Read only.
+ /// </remarks>
+
+ [Browsable (false)]
+ public int Bottom {
+ get {
+ return y + height;
+ }
+ }
+
+ /// <summary>
+ /// Height Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Height of the Rectangle.
+ /// </remarks>
+
+ public int Height {
+ get {
+ return height;
+ }
+ set {
+ height = value;
+ }
+ }
+
+ /// <summary>
+ /// IsEmpty Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Indicates if the width or height are zero. Read only.
+ /// </remarks>
+ [Browsable (false)]
+ public bool IsEmpty {
+ get {
+ return ((x == 0) && (y == 0) && (width == 0) && (height == 0));
+ }
+ }
+
+ /// <summary>
+ /// Left Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The X coordinate of the left edge of the Rectangle.
+ /// Read only.
+ /// </remarks>
+
+ [Browsable (false)]
+ public int Left {
+ get {
+ return X;
+ }
+ }
+
+ /// <summary>
+ /// Location Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Location of the top-left corner of the Rectangle.
+ /// </remarks>
+
+ [Browsable (false)]
+ public Point Location {
+ get {
+ return new Point (x, y);
+ }
+ set {
+ x = value.X;
+ y = value.Y;
+ }
+ }
+
+ /// <summary>
+ /// Right Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The X coordinate of the right edge of the Rectangle.
+ /// Read only.
+ /// </remarks>
+
+ [Browsable (false)]
+ public int Right {
+ get {
+ return X + Width;
+ }
+ }
+
+ /// <summary>
+ /// Size Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Size of the Rectangle.
+ /// </remarks>
+
+ [Browsable (false)]
+ public Size Size {
+ get {
+ return new Size (Width, Height);
+ }
+ set {
+ Width = value.Width;
+ Height = value.Height;
+ }
+ }
+
+ /// <summary>
+ /// Top Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Y coordinate of the top edge of the Rectangle.
+ /// Read only.
+ /// </remarks>
+
+ [Browsable (false)]
+ public int Top {
+ get {
+ return y;
+ }
+ }
+
+ /// <summary>
+ /// Width Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Width of the Rectangle.
+ /// </remarks>
+
+ public int Width {
+ get {
+ return width;
+ }
+ set {
+ width = value;
+ }
+ }
+
+ /// <summary>
+ /// X Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The X coordinate of the Rectangle.
+ /// </remarks>
+
+ public int X {
+ get {
+ return x;
+ }
+ set {
+ x = value;
+ }
+ }
+
+ /// <summary>
+ /// Y Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Y coordinate of the Rectangle.
+ /// </remarks>
+
+ public int Y {
+ get {
+ return y;
+ }
+ set {
+ y = value;
+ }
+ }
+
+ /// <summary>
+ /// Contains Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks if an x,y coordinate lies within this Rectangle.
+ /// </remarks>
+
+ public bool Contains (int x, int y)
+ {
+ return ((x >= Left) && (x < Right) &&
+ (y >= Top) && (y < Bottom));
+ }
+
+ /// <summary>
+ /// Contains Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks if a Point lies within this Rectangle.
+ /// </remarks>
+
+ public bool Contains (Point pt)
+ {
+ return Contains (pt.X, pt.Y);
+ }
+
+ /// <summary>
+ /// Contains Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks if a Rectangle lies entirely within this
+ /// Rectangle.
+ /// </remarks>
+
+ public bool Contains (Rectangle rect)
+ {
+ return (rect == Intersect (this, rect));
+ }
+
+ /// <summary>
+ /// Equals Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks equivalence of this Rectangle and another object.
+ /// </remarks>
+
+ public override bool Equals (object o)
+ {
+ if (!(o is Rectangle))
+ return false;
+
+ return (this == (Rectangle) o);
+ }
+
+ /// <summary>
+ /// GetHashCode Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Calculates a hashing value.
+ /// </remarks>
+
+ public override int GetHashCode ()
+ {
+ return (height + width) ^ x + y;
+ }
+
+ /// <summary>
+ /// IntersectsWith Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks if a Rectangle intersects with this one.
+ /// </remarks>
+
+ public bool IntersectsWith (Rectangle r)
+ {
+ return !((Left >= r.Right) || (Right <= r.Left) ||
+ (Top >= r.Bottom) || (Bottom <= r.Top));
+ }
+
+ private bool IntersectsWithInclusive (Rectangle r)
+ {
+ return !((Left > r.Right) || (Right < r.Left) ||
+ (Top > r.Bottom) || (Bottom < r.Top));
+ }
+
+ /// <summary>
+ /// Offset Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Moves the Rectangle a specified distance.
+ /// </remarks>
+
+ public void Offset (int dx, int dy)
+ {
+ x += dx;
+ y += dy;
+ }
+
+ /// <summary>
+ /// Offset Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Moves the Rectangle a specified distance.
+ /// </remarks>
+
+ public void Offset (Point pt)
+ {
+ x += pt.X;
+ y += pt.Y;
+ }
+
+ /// <summary>
+ /// ToString Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Formats the Rectangle as a string in (x,y,w,h) notation.
+ /// </remarks>
+
+ public override string ToString ()
+ {
+ return String.Format ("{{X={0},Y={1},Width={2},Height={3}}}",
+ x, y, width, height);
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/RectangleConverter.cs b/mcs/class/System.Drawing/System.Drawing/RectangleConverter.cs
new file mode 100644
index 00000000000..d7fffbe6e3d
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/RectangleConverter.cs
@@ -0,0 +1,164 @@
+//
+// System.Drawing.RectangleConverter.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Jordi Mas (jordi@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+using System.Collections;
+using System.Globalization;
+using System.Text;
+using System.ComponentModel.Design.Serialization;
+using System.Reflection;
+
+namespace System.Drawing
+{
+ /// <summary>
+ /// Summary description for RectangleConverter.
+ /// </summary>
+ public class RectangleConverter : TypeConverter
+ {
+ public RectangleConverter ()
+ {
+ }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context,
+ Type sourceType)
+ {
+ if (sourceType == typeof (string))
+ return true;
+
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context,
+ Type destinationType)
+ {
+ if (destinationType == typeof (string))
+ return true;
+
+ if (destinationType == typeof (InstanceDescriptor))
+ return true;
+
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value)
+ {
+ string s = value as string;
+ if (s == null)
+ return base.ConvertFrom (context, culture, value);
+
+ string [] subs = s.Split (culture.TextInfo.ListSeparator.ToCharArray ());
+
+ Int32Converter converter = new Int32Converter ();
+ int[] numSubs = new int[subs.Length];
+ for (int i = 0; i < numSubs.Length; i++) {
+ numSubs[i] = (int) converter.ConvertFromString (context, culture, subs[i]);
+ }
+
+ if (subs.Length != 4)
+ throw new ArgumentException ("Failed to parse Text(" + s + ") expected text in the format \"x,y,Width,Height.\"");
+
+ return new Rectangle (numSubs[0], numSubs[1], numSubs[2], numSubs[3]);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value,
+ Type destinationType)
+ {
+ // LAMESPEC: "The default implementation calls the object's
+ // ToString method if the object is valid and if the destination
+ // type is string." MS does not behave as per the specs.
+ // Oh well, we have to be compatible with MS.
+ if ((destinationType == typeof (string)) && (value is Rectangle)) {
+ string separator = culture.TextInfo.ListSeparator;
+ Rectangle rect = (Rectangle) value;
+ StringBuilder sb = new StringBuilder ();
+ sb.Append (rect.X.ToString (culture));
+ sb.Append (separator);
+ sb.Append (" ");
+ sb.Append (rect.Y.ToString (culture));
+ sb.Append (separator);
+ sb.Append (" ");
+ sb.Append (rect.Width.ToString (culture));
+ sb.Append (separator);
+ sb.Append (" ");
+ sb.Append (rect.Height.ToString (culture));
+ return sb.ToString ();
+ }
+
+ if (destinationType == typeof (InstanceDescriptor) && value is Rectangle) {
+ Rectangle c = (Rectangle) value;
+ ConstructorInfo ctor = typeof(Rectangle).GetConstructor (new Type[] {typeof(int), typeof(int), typeof(int), typeof(int)} );
+ return new InstanceDescriptor (ctor, new object[] {c.X, c.Y, c.Width, c.Height});
+ }
+
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ public override object CreateInstance (ITypeDescriptorContext context,
+ IDictionary propertyValues)
+ {
+ int x = (int) propertyValues ["X"];
+ int y = (int) propertyValues ["Y"];
+ int width = (int) propertyValues ["Width"];
+ int height = (int) propertyValues ["Height"];
+
+ return new Rectangle (x, y, width, height);
+ }
+
+ public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ public override PropertyDescriptorCollection GetProperties (
+ ITypeDescriptorContext context,
+ object value, Attribute[] attributes)
+ {
+ if (value is Rectangle)
+ return TypeDescriptor.GetProperties (value, attributes);
+
+ return base.GetProperties (context, value, attributes);
+ }
+
+ public override bool GetPropertiesSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/RectangleF.cs b/mcs/class/System.Drawing/System.Drawing/RectangleF.cs
new file mode 100644
index 00000000000..3d34b67efdc
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/RectangleF.cs
@@ -0,0 +1,580 @@
+//
+// System.Drawing.RectangleF.cs
+//
+// Author:
+// Mike Kestner (mkestner@speakeasy.net)
+//
+// Copyright (C) 2001 Mike Kestner
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ [Serializable]
+ public struct RectangleF
+ {
+ private float x, y, width, height;
+
+ /// <summary>
+ /// Empty Shared Field
+ /// </summary>
+ ///
+ /// <remarks>
+ /// An uninitialized RectangleF Structure.
+ /// </remarks>
+
+ public static readonly RectangleF Empty;
+
+#if TARGET_JVM
+ internal java.awt.geom.Rectangle2D NativeObject {
+ get {
+ return new java.awt.geom.Rectangle2D.Float(X,Y,Width,Height);
+ }
+ }
+#endif
+
+ /// <summary>
+ /// FromLTRB Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a RectangleF structure from left, top, right,
+ /// and bottom coordinates.
+ /// </remarks>
+
+ public static RectangleF FromLTRB (float left, float top,
+ float right, float bottom)
+ {
+ return new RectangleF (left, top, right - left, bottom - top);
+ }
+
+ /// <summary>
+ /// Inflate Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a new RectangleF by inflating an existing
+ /// RectangleF by the specified coordinate values.
+ /// </remarks>
+
+ public static RectangleF Inflate (RectangleF r,
+ float x, float y)
+ {
+ RectangleF ir = new RectangleF (r.X, r.Y, r.Width, r.Height);
+ ir.Inflate (x, y);
+ return ir;
+ }
+
+ /// <summary>
+ /// Inflate Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Inflates the RectangleF by a specified width and height.
+ /// </remarks>
+
+ public void Inflate (float width, float height)
+ {
+ Inflate (new SizeF (width, height));
+ }
+
+ /// <summary>
+ /// Inflate Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Inflates the RectangleF by a specified Size.
+ /// </remarks>
+
+ public void Inflate (SizeF sz)
+ {
+ x -= sz.Width;
+ y -= sz.Height;
+ width += sz.Width * 2;
+ height += sz.Height * 2;
+ }
+
+ /// <summary>
+ /// Intersect Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a new RectangleF by intersecting 2 existing
+ /// RectangleFs. Returns null if there is no intersection.
+ /// </remarks>
+
+ public static RectangleF Intersect (RectangleF r1,
+ RectangleF r2)
+ {
+ if (!r1.IntersectsWith (r2))
+ return Empty;
+
+ return FromLTRB (
+ Math.Max (r1.Left, r2.Left),
+ Math.Max (r1.Top, r2.Top),
+ Math.Min (r1.Right, r2.Right),
+ Math.Min (r1.Bottom, r2.Bottom));
+ }
+
+ /// <summary>
+ /// Intersect Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Replaces the RectangleF with the intersection of itself
+ /// and another RectangleF.
+ /// </remarks>
+
+ public void Intersect (RectangleF r)
+ {
+ this = RectangleF.Intersect (this, r);
+ }
+
+ /// <summary>
+ /// Union Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a new RectangleF from the union of 2 existing
+ /// RectangleFs.
+ /// </remarks>
+
+ public static RectangleF Union (RectangleF r1, RectangleF r2)
+ {
+ return FromLTRB (Math.Min (r1.Left, r2.Left),
+ Math.Min (r1.Top, r2.Top),
+ Math.Max (r1.Right, r2.Right),
+ Math.Max (r1.Bottom, r2.Bottom));
+ }
+
+ /// <summary>
+ /// Equality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two RectangleF objects. The return value is
+ /// based on the equivalence of the Location and Size
+ /// properties of the two RectangleFs.
+ /// </remarks>
+
+ public static bool operator == (RectangleF r1, RectangleF r2)
+ {
+ return (r1.X == r2.X) && (r1.Y == r2.Y) &&
+ (r1.Width == r2.Width) && (r1.Height == r2.Height);
+ }
+
+ /// <summary>
+ /// Inequality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two RectangleF objects. The return value is
+ /// based on the equivalence of the Location and Size
+ /// properties of the two RectangleFs.
+ /// </remarks>
+
+ public static bool operator != (RectangleF r1, RectangleF r2)
+ {
+ return (r1.X != r2.X) && (r1.Y != r2.Y) &&
+ (r1.Width != r2.Width) && (r1.Height != r2.Height);
+ }
+
+ /// <summary>
+ /// Rectangle to RectangleF Conversion
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Converts a Rectangle object to a RectangleF.
+ /// </remarks>
+
+ public static implicit operator RectangleF (Rectangle r)
+ {
+ return new RectangleF (r.X, r.Y, r.Width, r.Height);
+ }
+
+
+ // -----------------------
+ // Public Constructors
+ // -----------------------
+
+ /// <summary>
+ /// RectangleF Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a RectangleF from PointF and SizeF values.
+ /// </remarks>
+
+ public RectangleF (PointF loc, SizeF sz)
+ {
+ x = loc.X;
+ y = loc.Y;
+ width = sz.Width;
+ height = sz.Height;
+ }
+
+ /// <summary>
+ /// RectangleF Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a RectangleF from a specified x,y location and
+ /// width and height values.
+ /// </remarks>
+
+ public RectangleF (float x, float y, float width, float height)
+ {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+
+#if TARGET_JVM
+ internal RectangleF (java.awt.geom.RectangularShape r2d) {
+ this.x = (float) r2d.getX ();
+ this.y = (float) r2d.getY ();
+ this.width = (float) r2d.getWidth ();
+ this.height = (float) r2d.getHeight ();
+ }
+#endif
+
+ /// <summary>
+ /// Bottom Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Y coordinate of the bottom edge of the RectangleF.
+ /// Read only.
+ /// </remarks>
+
+ [Browsable (false)]
+ public float Bottom {
+ get {
+ return Y + Height;
+ }
+ }
+
+ /// <summary>
+ /// Height Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Height of the RectangleF.
+ /// </remarks>
+
+ public float Height {
+ get {
+ return height;
+ }
+ set {
+ height = value;
+ }
+ }
+
+ /// <summary>
+ /// IsEmpty Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Indicates if the width or height are zero. Read only.
+ /// </remarks>
+ //
+ [Browsable (false)]
+ public bool IsEmpty {
+ get {
+ return (width == 0 || height == 0);
+ }
+ }
+
+ /// <summary>
+ /// Left Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The X coordinate of the left edge of the RectangleF.
+ /// Read only.
+ /// </remarks>
+
+ [Browsable (false)]
+ public float Left {
+ get {
+ return X;
+ }
+ }
+
+ /// <summary>
+ /// Location Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Location of the top-left corner of the RectangleF.
+ /// </remarks>
+
+ [Browsable (false)]
+ public PointF Location {
+ get {
+ return new PointF (x, y);
+ }
+ set {
+ x = value.X;
+ y = value.Y;
+ }
+ }
+
+ /// <summary>
+ /// Right Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The X coordinate of the right edge of the RectangleF.
+ /// Read only.
+ /// </remarks>
+
+ [Browsable (false)]
+ public float Right {
+ get {
+ return X + Width;
+ }
+ }
+
+ /// <summary>
+ /// Size Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Size of the RectangleF.
+ /// </remarks>
+
+ [Browsable (false)]
+ public SizeF Size {
+ get {
+ return new SizeF (width, height);
+ }
+ set {
+ width = value.Width;
+ height = value.Height;
+ }
+ }
+
+ /// <summary>
+ /// Top Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Y coordinate of the top edge of the RectangleF.
+ /// Read only.
+ /// </remarks>
+
+ [Browsable (false)]
+ public float Top {
+ get {
+ return Y;
+ }
+ }
+
+ /// <summary>
+ /// Width Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Width of the RectangleF.
+ /// </remarks>
+
+ public float Width {
+ get {
+ return width;
+ }
+ set {
+ width = value;
+ }
+ }
+
+ /// <summary>
+ /// X Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The X coordinate of the RectangleF.
+ /// </remarks>
+
+ public float X {
+ get {
+ return x;
+ }
+ set {
+ x = value;
+ }
+ }
+
+ /// <summary>
+ /// Y Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Y coordinate of the RectangleF.
+ /// </remarks>
+
+ public float Y {
+ get {
+ return y;
+ }
+ set {
+ y = value;
+ }
+ }
+
+ /// <summary>
+ /// Contains Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks if an x,y coordinate lies within this RectangleF.
+ /// </remarks>
+
+ public bool Contains (float x, float y)
+ {
+ return ((x >= Left) && (x < Right) &&
+ (y >= Top) && (y < Bottom));
+ }
+
+ /// <summary>
+ /// Contains Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks if a Point lies within this RectangleF.
+ /// </remarks>
+
+ public bool Contains (PointF pt)
+ {
+ return Contains (pt.X, pt.Y);
+ }
+
+ /// <summary>
+ /// Contains Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks if a RectangleF lies entirely within this
+ /// RectangleF.
+ /// </remarks>
+
+ public bool Contains (RectangleF rect)
+ {
+ return (rect == Intersect (this, rect));
+ }
+
+ /// <summary>
+ /// Equals Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks equivalence of this RectangleF and an object.
+ /// </remarks>
+
+ public override bool Equals (object o)
+ {
+ if (!(o is RectangleF))
+ return false;
+
+ return (this == (RectangleF) o);
+ }
+
+ /// <summary>
+ /// GetHashCode Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Calculates a hashing value.
+ /// </remarks>
+
+ public override int GetHashCode ()
+ {
+ return (int) (x + y + width + height);
+ }
+
+ /// <summary>
+ /// IntersectsWith Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks if a RectangleF intersects with this one.
+ /// </remarks>
+
+ public bool IntersectsWith (RectangleF r)
+ {
+ return !((Left >= r.Right) || (Right <= r.Left) ||
+ (Top >= r.Bottom) || (Bottom <= r.Top));
+ }
+
+ /// <summary>
+ /// Offset Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Moves the RectangleF a specified distance.
+ /// </remarks>
+
+ public void Offset (float dx, float dy)
+ {
+ X += dx;
+ Y += dy;
+ }
+
+ /// <summary>
+ /// Offset Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Moves the RectangleF a specified distance.
+ /// </remarks>
+
+ public void Offset (PointF pt)
+ {
+ Offset(pt.X, pt.Y);
+ }
+
+ /// <summary>
+ /// ToString Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Formats the RectangleF in (x,y,w,h) notation.
+ /// </remarks>
+
+ public override string ToString ()
+ {
+ return String.Format ("{{X={0},Y={1},Width={2},Height={3}}}",
+ x, y, width, height);
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Region.cs b/mcs/class/System.Drawing/System.Drawing/Region.cs
new file mode 100644
index 00000000000..b53aaa37cf6
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Region.cs
@@ -0,0 +1,640 @@
+//
+// System.Drawing.Region.cs
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+// Copyright (C) 2003 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004,2006 Novell, Inc. http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
+using System.Security.Permissions;
+
+namespace System.Drawing
+{
+#if !NET_2_0
+ [ComVisible (false)]
+#endif
+ public sealed class Region : MarshalByRefObject, IDisposable
+ {
+ private IntPtr nativeRegion = IntPtr.Zero;
+
+ public Region()
+ {
+ Status status = GDIPlus.GdipCreateRegion (out nativeRegion);
+ GDIPlus.CheckStatus (status);
+ }
+
+ internal Region(IntPtr native)
+ {
+ nativeRegion = native;
+ }
+
+ [MonoTODO ("GdipCreateRegionPath is not implemented in libgdiplus")]
+ public Region (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException ("path");
+ Status status = GDIPlus.GdipCreateRegionPath (path.NativeObject, out nativeRegion);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Region (Rectangle rect)
+ {
+ Status status = GDIPlus.GdipCreateRegionRectI (ref rect, out nativeRegion);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Region (RectangleF rect)
+ {
+ Status status = GDIPlus.GdipCreateRegionRect (ref rect, out nativeRegion);
+ GDIPlus.CheckStatus (status);
+ }
+
+ [MonoTODO ("GdipCreateRegionRgnData is not implemented in libgdiplus")]
+ public Region (RegionData rgnData)
+ {
+ if (rgnData == null)
+ throw new ArgumentNullException ("rgnData");
+ // a NullReferenceException can be throw for rgnData.Data.Length (if rgnData.Data is null) just like MS
+ Status status = GDIPlus.GdipCreateRegionRgnData (rgnData.Data, rgnData.Data.Length, out nativeRegion);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // Union
+ //
+
+ public void Union (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException ("path");
+ Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.NativeObject, CombineMode.Union);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ public void Union (Rectangle rect)
+ {
+ Status status = GDIPlus.GdipCombineRegionRectI (nativeRegion, ref rect, CombineMode.Union);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Union (RectangleF rect)
+ {
+ Status status = GDIPlus.GdipCombineRegionRect (nativeRegion, ref rect, CombineMode.Union);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Union (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException ("region");
+ Status status = GDIPlus.GdipCombineRegionRegion (nativeRegion, region.NativeObject, CombineMode.Union);
+ GDIPlus.CheckStatus (status);
+ }
+
+
+ //
+ // Intersect
+ //
+ public void Intersect (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException ("path");
+ Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.NativeObject, CombineMode.Intersect);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Intersect (Rectangle rect)
+ {
+ Status status = GDIPlus.GdipCombineRegionRectI (nativeRegion, ref rect, CombineMode.Intersect);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Intersect (RectangleF rect)
+ {
+ Status status = GDIPlus.GdipCombineRegionRect (nativeRegion, ref rect, CombineMode.Intersect);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Intersect (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException ("region");
+ Status status = GDIPlus.GdipCombineRegionRegion (nativeRegion, region.NativeObject, CombineMode.Intersect);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // Complement
+ //
+ public void Complement (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException ("path");
+ Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.NativeObject, CombineMode.Complement);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Complement (Rectangle rect)
+ {
+ Status status = GDIPlus.GdipCombineRegionRectI (nativeRegion, ref rect, CombineMode.Complement);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Complement (RectangleF rect)
+ {
+ Status status = GDIPlus.GdipCombineRegionRect (nativeRegion, ref rect, CombineMode.Complement);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Complement (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException ("region");
+ Status status = GDIPlus.GdipCombineRegionRegion (nativeRegion, region.NativeObject, CombineMode.Complement);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // Exclude
+ //
+ public void Exclude (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException ("path");
+ Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.NativeObject, CombineMode.Exclude);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Exclude (Rectangle rect)
+ {
+ Status status = GDIPlus.GdipCombineRegionRectI (nativeRegion, ref rect, CombineMode.Exclude);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Exclude (RectangleF rect)
+ {
+ Status status = GDIPlus.GdipCombineRegionRect (nativeRegion, ref rect, CombineMode.Exclude);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Exclude (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException ("region");
+ Status status = GDIPlus.GdipCombineRegionRegion (nativeRegion, region.NativeObject, CombineMode.Exclude);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // Xor
+ //
+ public void Xor (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException ("path");
+ Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.NativeObject, CombineMode.Xor);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Xor (Rectangle rect)
+ {
+ Status status = GDIPlus.GdipCombineRegionRectI (nativeRegion, ref rect, CombineMode.Xor);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Xor (RectangleF rect)
+ {
+ Status status = GDIPlus.GdipCombineRegionRect (nativeRegion, ref rect, CombineMode.Xor);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Xor (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException ("region");
+ Status status = GDIPlus.GdipCombineRegionRegion (nativeRegion, region.NativeObject, CombineMode.Xor);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // GetBounds
+ //
+ public RectangleF GetBounds (Graphics graphics)
+ {
+ if (graphics == null)
+ throw new ArgumentNullException ("graphics");
+
+ RectangleF rect = new Rectangle();
+
+ Status status = GDIPlus.GdipGetRegionBounds (nativeRegion, graphics.NativeObject, ref rect);
+ GDIPlus.CheckStatus (status);
+
+ return rect;
+ }
+
+ //
+ // Translate
+ //
+ public void Translate (int dx, int dy)
+ {
+ Status status = GDIPlus.GdipTranslateRegionI (nativeRegion, dx, dy);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void Translate (float dx, float dy)
+ {
+ Status status = GDIPlus.GdipTranslateRegion (nativeRegion, dx, dy);
+ GDIPlus.CheckStatus (status);
+ }
+
+ //
+ // IsVisible
+ //
+ public bool IsVisible (int x, int y, Graphics g)
+ {
+ IntPtr ptr = (g == null) ? IntPtr.Zero : g.NativeObject;
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionPointI (nativeRegion, x, y, ptr, out result);
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (int x, int y, int width, int height)
+ {
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionRectI (nativeRegion, x, y,
+ width, height, IntPtr.Zero, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (int x, int y, int width, int height, Graphics g)
+ {
+ IntPtr ptr = (g == null) ? IntPtr.Zero : g.NativeObject;
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionRectI (nativeRegion, x, y,
+ width, height, ptr, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (Point point)
+ {
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionPointI (nativeRegion, point.X, point.Y,
+ IntPtr.Zero, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (PointF point)
+ {
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionPoint (nativeRegion, point.X, point.Y,
+ IntPtr.Zero, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (Point point, Graphics g)
+ {
+ IntPtr ptr = (g == null) ? IntPtr.Zero : g.NativeObject;
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionPointI (nativeRegion, point.X, point.Y,
+ ptr, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (PointF point, Graphics g)
+ {
+ IntPtr ptr = (g == null) ? IntPtr.Zero : g.NativeObject;
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionPoint (nativeRegion, point.X, point.Y,
+ ptr, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (Rectangle rect)
+ {
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionRectI (nativeRegion, rect.X, rect.Y,
+ rect.Width, rect.Height, IntPtr.Zero, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (RectangleF rect)
+ {
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionRect (nativeRegion, rect.X, rect.Y,
+ rect.Width, rect.Height, IntPtr.Zero, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (Rectangle rect, Graphics g)
+ {
+ IntPtr ptr = (g == null) ? IntPtr.Zero : g.NativeObject;
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionRectI (nativeRegion, rect.X, rect.Y,
+ rect.Width, rect.Height, ptr, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (RectangleF rect, Graphics g)
+ {
+ IntPtr ptr = (g == null) ? IntPtr.Zero : g.NativeObject;
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionRect (nativeRegion, rect.X, rect.Y,
+ rect.Width, rect.Height, ptr, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (float x, float y)
+ {
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionPoint (nativeRegion, x, y, IntPtr.Zero, out result);
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (float x, float y, Graphics g)
+ {
+ IntPtr ptr = (g == null) ? IntPtr.Zero : g.NativeObject;
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionPoint (nativeRegion, x, y, ptr, out result);
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (float x, float y, float width, float height)
+ {
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionRect (nativeRegion, x, y, width, height, IntPtr.Zero, out result);
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsVisible (float x, float y, float width, float height, Graphics g)
+ {
+ IntPtr ptr = (g == null) ? IntPtr.Zero : g.NativeObject;
+ bool result;
+
+ Status status = GDIPlus.GdipIsVisibleRegionRect (nativeRegion, x, y, width, height, ptr, out result);
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+
+ //
+ // Miscellaneous
+ //
+
+ public bool IsEmpty(Graphics g)
+ {
+ if (g == null)
+ throw new ArgumentNullException ("g");
+
+ bool result;
+
+ Status status = GDIPlus.GdipIsEmptyRegion (nativeRegion, g.NativeObject, out result);
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public bool IsInfinite(Graphics g)
+ {
+ if (g == null)
+ throw new ArgumentNullException ("g");
+
+ bool result;
+
+ Status status = GDIPlus.GdipIsInfiniteRegion (nativeRegion, g.NativeObject, out result);
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ public void MakeEmpty()
+ {
+ Status status = GDIPlus.GdipSetEmpty (nativeRegion);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void MakeInfinite()
+ {
+ Status status = GDIPlus.GdipSetInfinite (nativeRegion);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public bool Equals(Region region, Graphics g)
+ {
+ if (region == null)
+ throw new ArgumentNullException ("region");
+ if (g == null)
+ throw new ArgumentNullException ("g");
+
+ bool result;
+
+ Status status = GDIPlus.GdipIsEqualRegion (nativeRegion, region.NativeObject,
+ g.NativeObject, out result);
+
+ GDIPlus.CheckStatus (status);
+
+ return result;
+ }
+
+ [SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
+ public static Region FromHrgn (IntPtr hrgn)
+ {
+ if (hrgn == IntPtr.Zero)
+ throw new ArgumentException ("hrgn");
+ return new Region (hrgn);
+ }
+
+
+ public IntPtr GetHrgn(Graphics g)
+ {
+#if false
+ //
+ // Our WindowsForms implementation uses null to avoid
+ // creating a Graphics context when not needed
+ //
+ if (g == null)
+ throw new ArgumentNullException ("g");
+#endif
+ return nativeRegion;
+ }
+
+
+ public RegionData GetRegionData()
+ {
+ int size, filled;
+
+ Status status = GDIPlus.GdipGetRegionDataSize (nativeRegion, out size);
+ GDIPlus.CheckStatus (status);
+
+ byte[] buff = new byte [size];
+
+ status = GDIPlus.GdipGetRegionData (nativeRegion, buff, size, out filled);
+ GDIPlus.CheckStatus (status);
+
+ RegionData rgndata = new RegionData();
+ rgndata.Data = buff;
+
+ return rgndata;
+ }
+
+
+ public RectangleF[] GetRegionScans(Matrix matrix)
+ {
+ if (matrix == null)
+ throw new ArgumentNullException ("matrix");
+
+ int cnt;
+
+ Status status = GDIPlus.GdipGetRegionScansCount (nativeRegion, out cnt, matrix.NativeObject);
+ GDIPlus.CheckStatus (status);
+
+ if (cnt == 0)
+ return new RectangleF[0];
+
+ RectangleF[] rects = new RectangleF [cnt];
+ int size = Marshal.SizeOf (rects[0]);
+
+ IntPtr dest = Marshal.AllocHGlobal (size * cnt);
+
+ status = GDIPlus.GdipGetRegionScans (nativeRegion, dest, out cnt, matrix.NativeObject);
+ GDIPlus.CheckStatus (status);
+
+ GDIPlus.FromUnManagedMemoryToRectangles (dest, rects);
+ return rects;
+ }
+
+ public void Transform(Matrix matrix)
+ {
+ if (matrix == null)
+ throw new ArgumentNullException ("matrix");
+
+ Status status = GDIPlus.GdipTransformRegion (nativeRegion, matrix.NativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Region Clone()
+ {
+ IntPtr cloned;
+
+ Status status = GDIPlus.GdipCloneRegion (nativeRegion, out cloned);
+ GDIPlus.CheckStatus (status);
+
+ return new Region (cloned);
+ }
+
+ public void Dispose ()
+ {
+ DisposeHandle ();
+ System.GC.SuppressFinalize (this);
+ }
+
+ private void DisposeHandle ()
+ {
+ if (nativeRegion != IntPtr.Zero) {
+ GDIPlus.GdipDeleteRegion (nativeRegion);
+ nativeRegion = IntPtr.Zero;
+ }
+ }
+
+ ~Region ()
+ {
+ DisposeHandle ();
+ }
+
+ internal IntPtr NativeObject
+ {
+ get{
+ return nativeRegion;
+ }
+ set {
+ nativeRegion = value;
+ }
+ }
+#if NET_2_0
+ [MonoTODO]
+ [SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
+ public void ReleaseHrgn (IntPtr regionHandle)
+ {
+ if (regionHandle == IntPtr.Zero)
+ throw new ArgumentNullException ("regionHandle");
+ }
+#endif
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Region.jvm.cs b/mcs/class/System.Drawing/System.Drawing/Region.jvm.cs
new file mode 100644
index 00000000000..77da63c7ad8
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Region.jvm.cs
@@ -0,0 +1,384 @@
+
+using System;
+using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
+
+using awt = java.awt;
+using geom = java.awt.geom;
+
+namespace System.Drawing
+{
+ [ComVisible (false)]
+ public sealed class Region : BasicShape
+ {
+ #region Member Vars
+ internal static readonly Region InfiniteRegion = new Region(new Rectangle(-0x400000, -0x400000, 0x800000, 0x800000));
+ #endregion
+
+ #region Internals
+ internal geom.Area NativeObject
+ {
+ get
+ {
+ return (geom.Area)Shape;
+ }
+ }
+ #endregion
+
+ #region Ctors. and Dtor
+
+
+ public Region() : this((geom.Area)InfiniteRegion.NativeObject.clone())
+ {
+ }
+
+ internal Region(geom.Area native) : base(native)
+ {
+ }
+
+
+ public Region (GraphicsPath path) : this(new geom.Area(path.NativeObject))
+ {
+ }
+
+ public Region (Rectangle rect) : this(new geom.Area(rect.NativeObject))
+ {
+ }
+
+ public Region (RectangleF rect) : this(new geom.Area(rect.NativeObject))
+ {
+ }
+
+ [MonoTODO]
+ public Region (RegionData region_data) : this((geom.Area)null)
+ {
+ throw new NotImplementedException ();
+ }
+ #endregion
+
+ #region Union
+ public void Union (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException("path");
+ NativeObject.add(new geom.Area(path.NativeObject));
+ }
+
+
+ public void Union (Rectangle rect)
+ {
+ NativeObject.add(new geom.Area(rect.NativeObject));
+ }
+
+ public void Union (RectangleF rect)
+ {
+ NativeObject.add(new geom.Area(rect.NativeObject));
+ }
+
+ public void Union (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException("region");
+ NativeObject.add(region.NativeObject);
+ }
+ #endregion
+
+ #region Intersect
+ //
+ public void Intersect (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException("path");
+ NativeObject.intersect(new geom.Area(path.NativeObject));
+ }
+
+ public void Intersect (Rectangle rect)
+ {
+ NativeObject.intersect(new geom.Area(rect.NativeObject));
+ }
+
+ public void Intersect (RectangleF rect)
+ {
+ NativeObject.intersect(new geom.Area(rect.NativeObject));
+ }
+
+ public void Intersect (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException("region");
+ NativeObject.intersect(region.NativeObject);
+ }
+ #endregion
+
+ #region Complement
+ //
+ public void Complement (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException("path");
+ geom.Area a = new geom.Area(path.NativeObject);
+ a.subtract(NativeObject);
+ Shape = a;
+ }
+
+ public void Complement (Rectangle rect)
+ {
+ geom.Area a = new geom.Area(rect.NativeObject);
+ a.subtract(NativeObject);
+ Shape = a;
+ }
+
+ public void Complement (RectangleF rect)
+ {
+ geom.Area a = new geom.Area(rect.NativeObject);
+ a.subtract(NativeObject);
+ Shape = a;
+ }
+
+ public void Complement (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException("region");
+ geom.Area a = (geom.Area)region.NativeObject.clone();
+ a.subtract(NativeObject);
+ Shape = a;
+ }
+ #endregion
+
+ #region Exclude
+ //
+ public void Exclude (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException("path");
+ NativeObject.subtract(new geom.Area(path.NativeObject));
+ }
+
+ public void Exclude (Rectangle rect)
+ {
+ NativeObject.subtract(new geom.Area(rect.NativeObject));
+ }
+
+ public void Exclude (RectangleF rect)
+ {
+ NativeObject.subtract(new geom.Area(rect.NativeObject));
+ }
+
+ public void Exclude (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException("region");
+ NativeObject.subtract(region.NativeObject);
+ }
+ #endregion
+
+ #region Xor
+ //
+ public void Xor (GraphicsPath path)
+ {
+ if (path == null)
+ throw new ArgumentNullException("path");
+ NativeObject.exclusiveOr(new geom.Area(path.NativeObject));
+ }
+
+ public void Xor (Rectangle rect)
+ {
+ NativeObject.exclusiveOr(new geom.Area(rect.NativeObject));
+ }
+
+ public void Xor (RectangleF rect)
+ {
+ NativeObject.exclusiveOr(new geom.Area(rect.NativeObject));
+ }
+
+ public void Xor (Region region)
+ {
+ if (region == null)
+ throw new ArgumentNullException("region");
+ NativeObject.exclusiveOr(region.NativeObject);
+ }
+ #endregion
+
+ #region GetBounds
+ //
+ public RectangleF GetBounds (Graphics graphics)
+ {
+ if (graphics == null)
+ throw new ArgumentNullException("graphics");
+ return new RectangleF(NativeObject.getBounds2D());
+ }
+ #endregion
+
+ #region Translate
+ //
+ public void Translate (int dx, int dy)
+ {
+ Translate((float)dx, (float)dy);
+ }
+
+ public void Translate (float dx, float dy)
+ {
+ NativeObject.transform(geom.AffineTransform.getTranslateInstance(
+ dx,
+ dy));
+ }
+ #endregion
+
+ #region IsVisible [TODO]
+ //
+ public bool IsVisible (int x, int y, Graphics g)
+ {
+ return IsVisible((float)x, (float)y, g);
+ }
+
+ public bool IsVisible (int x, int y, int width, int height)
+ {
+ return IsVisible((float)x, (float)y, (float)width, (float)height);
+ }
+
+ public bool IsVisible (int x, int y, int width, int height, Graphics g)
+ {
+ return IsVisible((float)x, (float)y, (float)width, (float)height, g);
+ }
+
+ public bool IsVisible (Point point)
+ {
+ return IsVisible(point.X, point.Y);
+ }
+
+ public bool IsVisible (PointF point)
+ {
+ return IsVisible(point.X, point.Y);
+ }
+
+ public bool IsVisible (Point point, Graphics g)
+ {
+ return IsVisible(point.X, point.Y, g);
+ }
+
+ public bool IsVisible (PointF point, Graphics g)
+ {
+ return IsVisible(point.X, point.Y, g);
+ }
+
+ public bool IsVisible (Rectangle rect)
+ {
+ return IsVisible(rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public bool IsVisible (RectangleF rect)
+ {
+ return IsVisible(rect.X, rect.Y, rect.Width, rect.Height);
+ }
+
+ public bool IsVisible (Rectangle rect, Graphics g)
+ {
+ return IsVisible(rect.X, rect.Y, rect.Width, rect.Height, g);
+ }
+
+ public bool IsVisible (RectangleF rect, Graphics g)
+ {
+ return IsVisible(rect.X, rect.Y, rect.Width, rect.Height, g);
+ }
+
+ public bool IsVisible (float x, float y)
+ {
+ return NativeObject.contains(x,y);
+ }
+
+ public bool IsVisible (float x, float y, Graphics g)
+ {
+ if (g == null)
+ throw new ArgumentNullException("graphics");
+ return NativeObject.contains(x,y);
+ }
+
+ public bool IsVisible (float x, float y, float width, float height)
+ {
+ return NativeObject.intersects(x,y,width,height);
+ }
+
+ public bool IsVisible (float x, float y, float width, float height, Graphics g)
+ {
+ if (g == null)
+ throw new ArgumentNullException("graphics");
+ return NativeObject.intersects(x,y,width,height);
+ }
+ #endregion
+
+ #region IsEmpty
+ public bool IsEmpty(Graphics g)
+ {
+ if (g == null)
+ throw new ArgumentNullException("graphics");
+ return NativeObject.isEmpty();
+ }
+ #endregion
+
+ #region IsInfinite
+ public bool IsInfinite(Graphics g)
+ {
+ if (g == null)
+ throw new ArgumentNullException("graphics");
+ //probably too naive.
+ return NativeObject.equals(InfiniteRegion.NativeObject);
+ }
+ #endregion
+
+ #region MakeEmpty
+ public void MakeEmpty()
+ {
+ NativeObject.reset();
+ }
+ #endregion
+
+ #region MakeInfinite
+ public void MakeInfinite()
+ {
+ Shape = (geom.Area)InfiniteRegion.NativeObject.clone();
+ }
+ #endregion
+
+ #region Equals
+ public bool Equals(Region region, Graphics g)
+ {
+ if (g == null)
+ throw new ArgumentNullException("graphics");
+ return NativeObject.equals(region.NativeObject);
+ }
+ #endregion
+
+ [MonoTODO]
+ public RegionData GetRegionData()
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO]
+ public IntPtr GetHrgn(Graphics g) {
+ throw new NotImplementedException();
+ }
+
+
+ public RectangleF[] GetRegionScans(Matrix matrix)
+ {
+ throw new NotSupportedException();
+ }
+
+ #region Transform
+ public void Transform(Matrix matrix)
+ {
+ if (matrix == null)
+ throw new ArgumentNullException("matrix");
+ NativeObject.transform(matrix.NativeObject);
+ }
+ #endregion
+
+ #region Clone
+ public Region Clone()
+ {
+ return new Region((geom.Area)NativeObject.clone());
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/RotateFlipType.cs b/mcs/class/System.Drawing/System.Drawing/RotateFlipType.cs
new file mode 100644
index 00000000000..9be021a7774
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/RotateFlipType.cs
@@ -0,0 +1,53 @@
+//
+// System.Drawing.RotateFlipType .cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+namespace System.Drawing
+{
+ [Serializable]
+ public enum RotateFlipType {
+ RotateNoneFlipNone = 0,
+ Rotate180FlipXY = 0,
+ Rotate90FlipNone = 1,
+ Rotate270FlipXY = 1,
+ Rotate180FlipNone = 2,
+ RotateNoneFlipXY = 2,
+ Rotate270FlipNone = 3,
+ Rotate90FlipXY = 3,
+ RotateNoneFlipX = 4,
+ Rotate180FlipY = 4,
+ Rotate90FlipX = 5,
+ Rotate270FlipY = 5,
+ Rotate180FlipX = 6,
+ RotateNoneFlipY = 6,
+ Rotate270FlipX = 7,
+ Rotate90FlipY = 7,
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/SRDescriptionAttribute.cs b/mcs/class/System.Drawing/System.Drawing/SRDescriptionAttribute.cs
new file mode 100644
index 00000000000..ec279f7c232
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SRDescriptionAttribute.cs
@@ -0,0 +1,58 @@
+//
+// System.Drawing.SRDescriptionAttribute.cs
+//
+// Authors:
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2004 Andreas Nahr
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ [AttributeUsage(AttributeTargets.All)]
+ internal class SRDescriptionAttribute : DescriptionAttribute
+ {
+ private bool isReplaced = false;
+
+ public SRDescriptionAttribute (string description)
+ : base (description)
+ {
+ }
+
+ public override string Description {
+ get {
+ if (!isReplaced) {
+ isReplaced = true;
+ DescriptionValue = Locale.GetText (DescriptionValue);
+ }
+ return DescriptionValue;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/Size.cs b/mcs/class/System.Drawing/System.Drawing/Size.cs
new file mode 100644
index 00000000000..fb763d6869e
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/Size.cs
@@ -0,0 +1,356 @@
+//
+// System.Drawing.Size.cs
+//
+// Author:
+// Mike Kestner (mkestner@speakeasy.net)
+//
+// Copyright (C) 2001 Mike Kestner
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ [Serializable]
+ [ComVisible (true)]
+ [TypeConverter (typeof (SizeConverter))]
+ public struct Size
+ {
+
+ // Private Height and width fields.
+ private int width, height;
+
+ // -----------------------
+ // Public Shared Members
+ // -----------------------
+
+ /// <summary>
+ /// Empty Shared Field
+ /// </summary>
+ ///
+ /// <remarks>
+ /// An uninitialized Size Structure.
+ /// </remarks>
+
+ public static readonly Size Empty;
+
+ /// <summary>
+ /// Ceiling Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a Size structure from a SizeF structure by
+ /// taking the ceiling of the Width and Height properties.
+ /// </remarks>
+
+ public static Size Ceiling (SizeF value)
+ {
+ int w, h;
+ checked {
+ w = (int) Math.Ceiling (value.Width);
+ h = (int) Math.Ceiling (value.Height);
+ }
+
+ return new Size (w, h);
+ }
+
+ /// <summary>
+ /// Round Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a Size structure from a SizeF structure by
+ /// rounding the Width and Height properties.
+ /// </remarks>
+
+ public static Size Round (SizeF value)
+ {
+ int w, h;
+ checked {
+ w = (int) Math.Round (value.Width);
+ h = (int) Math.Round (value.Height);
+ }
+
+ return new Size (w, h);
+ }
+
+ /// <summary>
+ /// Truncate Shared Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Produces a Size structure from a SizeF structure by
+ /// truncating the Width and Height properties.
+ /// </remarks>
+
+ public static Size Truncate (SizeF value)
+ {
+ int w, h;
+ checked {
+ w = (int) value.Width;
+ h = (int) value.Height;
+ }
+
+ return new Size (w, h);
+ }
+
+ /// <summary>
+ /// Addition Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Addition of two Size structures.
+ /// </remarks>
+
+ public static Size operator + (Size sz1, Size sz2)
+ {
+ return new Size (sz1.Width + sz2.Width,
+ sz1.Height + sz2.Height);
+ }
+
+ /// <summary>
+ /// Equality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two Size objects. The return value is
+ /// based on the equivalence of the Width and Height
+ /// properties of the two Sizes.
+ /// </remarks>
+
+ public static bool operator == (Size sz_a, Size sz_b)
+ {
+ return ((sz_a.Width == sz_b.Width) &&
+ (sz_a.Height == sz_b.Height));
+ }
+
+ /// <summary>
+ /// Inequality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two Size objects. The return value is
+ /// based on the equivalence of the Width and Height
+ /// properties of the two Sizes.
+ /// </remarks>
+
+ public static bool operator != (Size sz_a, Size sz_b)
+ {
+ return ((sz_a.Width != sz_b.Width) ||
+ (sz_a.Height != sz_b.Height));
+ }
+
+ /// <summary>
+ /// Subtraction Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Subtracts two Size structures.
+ /// </remarks>
+
+ public static Size operator - (Size sz1, Size sz2)
+ {
+ return new Size (sz1.Width - sz2.Width,
+ sz1.Height - sz2.Height);
+ }
+
+ /// <summary>
+ /// Size to Point Conversion
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Returns a Point based on the dimensions of a given
+ /// Size. Requires explicit cast.
+ /// </remarks>
+
+ public static explicit operator Point (Size sz)
+ {
+ return new Point (sz.Width, sz.Height);
+ }
+
+ /// <summary>
+ /// Size to SizeF Conversion
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a SizeF based on the dimensions of a given
+ /// Size. No explicit cast is required.
+ /// </remarks>
+
+ public static implicit operator SizeF (Size sz)
+ {
+ return new SizeF (sz.Width, sz.Height);
+ }
+
+
+ // -----------------------
+ // Public Constructors
+ // -----------------------
+
+ /// <summary>
+ /// Size Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a Size from a Point value.
+ /// </remarks>
+
+ public Size (Point pt)
+ {
+ width = pt.X;
+ height = pt.Y;
+ }
+
+ /// <summary>
+ /// Size Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a Size from specified dimensions.
+ /// </remarks>
+
+ public Size (int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ }
+
+ // -----------------------
+ // Public Instance Members
+ // -----------------------
+
+ /// <summary>
+ /// IsEmpty Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Indicates if both Width and Height are zero.
+ /// </remarks>
+
+ [Browsable (false)]
+ public bool IsEmpty {
+ get {
+ return ((width == 0) && (height == 0));
+ }
+ }
+
+ /// <summary>
+ /// Width Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Width coordinate of the Size.
+ /// </remarks>
+
+ public int Width {
+ get {
+ return width;
+ }
+ set {
+ width = value;
+ }
+ }
+
+ /// <summary>
+ /// Height Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Height coordinate of the Size.
+ /// </remarks>
+
+ public int Height {
+ get {
+ return height;
+ }
+ set {
+ height = value;
+ }
+ }
+
+ /// <summary>
+ /// Equals Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks equivalence of this Size and another object.
+ /// </remarks>
+
+ public override bool Equals (object o)
+ {
+ if (!(o is Size))
+ return false;
+
+ return (this == (Size) o);
+ }
+
+ /// <summary>
+ /// GetHashCode Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Calculates a hashing value.
+ /// </remarks>
+
+ public override int GetHashCode ()
+ {
+ return width^height;
+ }
+
+ /// <summary>
+ /// ToString Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Formats the Size as a string in coordinate notation.
+ /// </remarks>
+
+ public override string ToString ()
+ {
+ return String.Format ("{{Width={0}, Height={1}}}", width, height);
+ }
+
+#if NET_2_0
+ public static Size Add (Size sz1, Size sz2)
+ {
+ return new Size (sz1.Width + sz2.Width,
+ sz1.Height + sz2.Height);
+
+ }
+
+ public static Size Subtract (Size sz1, Size sz2)
+ {
+ return new Size (sz1.Width - sz2.Width,
+ sz1.Height - sz2.Height);
+ }
+#endif
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/SizeConverter.cs b/mcs/class/System.Drawing/System.Drawing/SizeConverter.cs
new file mode 100644
index 00000000000..6b01d88f571
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SizeConverter.cs
@@ -0,0 +1,148 @@
+//
+// System.Drawing.SizeConverter.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2003 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.ComponentModel.Design.Serialization;
+using System.Reflection;
+
+namespace System.Drawing
+{
+ /// <summary>
+ /// Summary description for SizeConverter.
+ /// </summary>
+ public class SizeConverter : TypeConverter
+ {
+ public SizeConverter()
+ {
+ }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context,
+ Type sourceType)
+ {
+ if (sourceType == typeof (string))
+ return true;
+
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context,
+ Type destinationType)
+ {
+ if (destinationType == typeof (string))
+ return true;
+
+ if (destinationType == typeof (InstanceDescriptor))
+ return true;
+
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value)
+ {
+ string s = value as string;
+ if (s == null)
+ return base.ConvertFrom (context, culture, value);
+
+ string[] subs = s.Split (culture.TextInfo.ListSeparator.ToCharArray ());
+
+ Int32Converter converter = new Int32Converter ();
+ int[] numSubs = new int[subs.Length];
+ for (int i = 0; i < numSubs.Length; i++) {
+ numSubs[i] = (int) converter.ConvertFromString (context, culture, subs[i]);
+ }
+
+ if (subs.Length != 2)
+ throw new ArgumentException ("Failed to parse Text(" + s + ") expected text in the format \"Width,Height.\"");
+
+ return new Size (numSubs[0], numSubs[1]);
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context,
+ CultureInfo culture,
+ object value,
+ Type destinationType)
+ {
+ // LAMESPEC: "The default implementation calls the ToString method
+ // of the object if the object is valid and if the destination
+ // type is string." MS does not behave as per the specs.
+ // Oh well, we have to be compatible with MS.
+ if ((destinationType == typeof (string)) && (value is Size))
+ return ((Size) value).Width.ToString(culture) + culture.TextInfo.ListSeparator
+ + " " + ((Size) value).Height.ToString(culture);
+
+ if (destinationType == typeof (InstanceDescriptor) && value is Size) {
+ Size s = (Size) value;
+ ConstructorInfo ctor = typeof(Size).GetConstructor (new Type[] {typeof(int), typeof(int)});
+ return new InstanceDescriptor (ctor, new object[] {s.Width, s.Height});
+ }
+
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ public override object CreateInstance (ITypeDescriptorContext context,
+ IDictionary propertyValues)
+ {
+ int width = (int) propertyValues ["Width"];
+ int height = (int) propertyValues ["Height"];
+
+ return new Size (width, height);
+ }
+
+ public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ public override PropertyDescriptorCollection GetProperties (
+ ITypeDescriptorContext context,
+ object value, Attribute[] attributes)
+ {
+ if (value is Size)
+ return TypeDescriptor.GetProperties (value, attributes);
+
+ return base.GetProperties (context, value, attributes);
+ }
+
+ public override bool GetPropertiesSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/SizeF.cs b/mcs/class/System.Drawing/System.Drawing/SizeF.cs
new file mode 100644
index 00000000000..1737ae64bac
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SizeF.cs
@@ -0,0 +1,312 @@
+//
+// System.Drawing.SizeF.cs
+//
+// Author:
+// Mike Kestner (mkestner@speakeasy.net)
+//
+// Copyright (C) 2001 Mike Kestner
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ [Serializable]
+ [ComVisible (true)]
+#if NET_2_0
+ [TypeConverter (typeof (SizeFConverter))]
+#endif
+ public struct SizeF
+ {
+ // Private height and width fields.
+ private float wd, ht;
+
+ // -----------------------
+ // Public Shared Members
+ // -----------------------
+
+ /// <summary>
+ /// Empty Shared Field
+ /// </summary>
+ ///
+ /// <remarks>
+ /// An uninitialized SizeF Structure.
+ /// </remarks>
+
+ public static readonly SizeF Empty;
+
+ /// <summary>
+ /// Addition Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Addition of two SizeF structures.
+ /// </remarks>
+
+ public static SizeF operator + (SizeF sz1, SizeF sz2)
+ {
+ return new SizeF (sz1.Width + sz2.Width,
+ sz1.Height + sz2.Height);
+ }
+
+ /// <summary>
+ /// Equality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two SizeF objects. The return value is
+ /// based on the equivalence of the Width and Height
+ /// properties of the two Sizes.
+ /// </remarks>
+
+ public static bool operator == (SizeF sz_a, SizeF sz_b)
+ {
+ return ((sz_a.Width == sz_b.Width) &&
+ (sz_a.Height == sz_b.Height));
+ }
+
+ /// <summary>
+ /// Inequality Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Compares two SizeF objects. The return value is
+ /// based on the equivalence of the Width and Height
+ /// properties of the two Sizes.
+ /// </remarks>
+
+ public static bool operator != (SizeF sz_a, SizeF sz_b)
+ {
+ return ((sz_a.Width != sz_b.Width) ||
+ (sz_a.Height != sz_b.Height));
+ }
+
+ /// <summary>
+ /// Subtraction Operator
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Subtracts two SizeF structures.
+ /// </remarks>
+
+ public static SizeF operator - (SizeF sz1, SizeF sz2)
+ {
+ return new SizeF (sz1.Width - sz2.Width,
+ sz1.Height - sz2.Height);
+ }
+
+ /// <summary>
+ /// SizeF to PointF Conversion
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Returns a PointF based on the dimensions of a given
+ /// SizeF. Requires explicit cast.
+ /// </remarks>
+
+ public static explicit operator PointF (SizeF sz)
+ {
+ return new PointF (sz.Width, sz.Height);
+ }
+
+
+ // -----------------------
+ // Public Constructors
+ // -----------------------
+
+ /// <summary>
+ /// SizeF Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a SizeF from a PointF value.
+ /// </remarks>
+
+ public SizeF (PointF pt)
+ {
+ wd = pt.X;
+ ht = pt.Y;
+ }
+
+ /// <summary>
+ /// SizeF Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a SizeF from an existing SizeF value.
+ /// </remarks>
+
+ public SizeF (SizeF sz)
+ {
+ wd = sz.Width;
+ ht = sz.Height;
+ }
+
+ /// <summary>
+ /// SizeF Constructor
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Creates a SizeF from specified dimensions.
+ /// </remarks>
+
+ public SizeF (float width, float height)
+ {
+ wd = width;
+ ht = height;
+ }
+
+ // -----------------------
+ // Public Instance Members
+ // -----------------------
+
+ /// <summary>
+ /// IsEmpty Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Indicates if both Width and Height are zero.
+ /// </remarks>
+
+ [Browsable (false)]
+ public bool IsEmpty {
+ get {
+ return ((wd == 0.0) && (ht == 0.0));
+ }
+ }
+
+ /// <summary>
+ /// Width Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Width coordinate of the SizeF.
+ /// </remarks>
+
+ public float Width {
+ get {
+ return wd;
+ }
+ set {
+ wd = value;
+ }
+ }
+
+ /// <summary>
+ /// Height Property
+ /// </summary>
+ ///
+ /// <remarks>
+ /// The Height coordinate of the SizeF.
+ /// </remarks>
+
+ public float Height {
+ get {
+ return ht;
+ }
+ set {
+ ht = value;
+ }
+ }
+
+ /// <summary>
+ /// Equals Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Checks equivalence of this SizeF and another object.
+ /// </remarks>
+
+ public override bool Equals (object o)
+ {
+ if (!(o is SizeF))
+ return false;
+
+ return (this == (SizeF) o);
+ }
+
+ /// <summary>
+ /// GetHashCode Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Calculates a hashing value.
+ /// </remarks>
+
+ public override int GetHashCode ()
+ {
+ return (int) wd ^ (int) ht;
+ }
+
+ public PointF ToPointF ()
+ {
+ return new PointF (wd, ht);
+ }
+
+ public Size ToSize ()
+ {
+ int w, h;
+ checked {
+ w = (int) wd;
+ h = (int) ht;
+ }
+
+ return new Size (w, h);
+ }
+
+ /// <summary>
+ /// ToString Method
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Formats the SizeF as a string in coordinate notation.
+ /// </remarks>
+
+ public override string ToString ()
+ {
+ return string.Format ("{{Width={0}, Height={1}}}", wd.ToString (CultureInfo.CurrentCulture),
+ ht.ToString (CultureInfo.CurrentCulture));
+ }
+
+#if NET_2_0
+ public static SizeF Add (SizeF sz1, SizeF sz2)
+ {
+ return new SizeF (sz1.Width + sz2.Width,
+ sz1.Height + sz2.Height);
+ }
+
+ public static SizeF Subtract (SizeF sz1, SizeF sz2)
+ {
+ return new SizeF (sz1.Width - sz2.Width,
+ sz1.Height - sz2.Height);
+ }
+#endif
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/SizeFConverter.cs b/mcs/class/System.Drawing/System.Drawing/SizeFConverter.cs
new file mode 100644
index 00000000000..bdb97eb7674
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SizeFConverter.cs
@@ -0,0 +1,134 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+//
+// Dennis Hayes (dennish@Raytek.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+// Ravindra (rkumar@novell.com)
+// Jordi Mas i Hernandez <jordimash@gmail.com>
+//
+//
+
+#if NET_2_0
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.ComponentModel.Design.Serialization;
+using System.Reflection;
+
+namespace System.Drawing
+{
+ public class SizeFConverter : TypeConverter
+ {
+ public SizeFConverter ()
+ {
+
+ }
+
+ public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof (string))
+ return true;
+
+ return base.CanConvertFrom (context, sourceType);
+ }
+
+ public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
+ {
+ if (destinationType == typeof (string))
+ return true;
+
+ if (destinationType == typeof (InstanceDescriptor))
+ return true;
+
+ return base.CanConvertTo (context, destinationType);
+ }
+
+ public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ string s = value as string;
+ if (s == null)
+ return base.ConvertFrom (context, culture, value);
+
+ string[] subs = s.Split (culture.TextInfo.ListSeparator.ToCharArray ());
+
+ SingleConverter converter = new SingleConverter ();
+ float[] numSubs = new float[subs.Length];
+ for (int i = 0; i < numSubs.Length; i++) {
+ numSubs[i] = (float) converter.ConvertFromString (context, culture, subs[i]);
+ }
+
+ if (subs.Length != 2)
+ throw new ArgumentException ("Failed to parse Text(" + s + ") expected text in the format \"Width,Height.\"");
+
+ return new SizeF (numSubs[0], numSubs[1]);
+
+ }
+
+ public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if ((destinationType == typeof (string)) && (value is SizeF))
+ return ((SizeF) value).Width.ToString(culture) + culture.TextInfo.ListSeparator
+ + " " + ((SizeF) value).Height.ToString(culture);
+
+ if (destinationType == typeof (InstanceDescriptor) && value is SizeF) {
+ SizeF s = (SizeF) value;
+ ConstructorInfo ctor = typeof(SizeF).GetConstructor (new Type[] {typeof(int), typeof(int)});
+ return new InstanceDescriptor (ctor, new object[] {s.Width, s.Height});
+ }
+
+ return base.ConvertTo (context, culture, value, destinationType);
+ }
+
+ public override object CreateInstance (ITypeDescriptorContext context, IDictionary propertyValues)
+ {
+ int width = (int) propertyValues ["Width"];
+ int height = (int) propertyValues ["Height"];
+
+ return new SizeF (width, height);
+ }
+
+ public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ public override PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context, object value, Attribute[] attributes)
+ {
+ if (value is SizeF)
+ return TypeDescriptor.GetProperties (value, attributes);
+
+ return base.GetProperties (context, value, attributes);
+ }
+
+ public override bool GetPropertiesSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+ }
+}
+
+#endif
+
diff --git a/mcs/class/System.Drawing/System.Drawing/SolidBrush.cs b/mcs/class/System.Drawing/System.Drawing/SolidBrush.cs
new file mode 100644
index 00000000000..fbe2a763ecb
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SolidBrush.cs
@@ -0,0 +1,98 @@
+//
+// System.Drawing.SolidBrush.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Alexandre Pigolkine(pigolkine@gmx.de)
+// Ravindra (rkumar@novell.com)
+//
+// (C) 2002 Ximian, Inc.
+// (C) 2004 Novell, Inc.
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing
+{
+ public sealed class SolidBrush : Brush {
+
+ internal bool isModifiable = true;
+ private Color color;
+
+ internal SolidBrush (IntPtr ptr)
+ : base (ptr)
+ {
+ int val;
+ Status status = GDIPlus.GdipGetSolidFillColor (ptr, out val);
+ GDIPlus.CheckStatus (status);
+ color = Color.FromArgb (val);
+ }
+
+ public SolidBrush (Color color)
+ {
+ this.color = color;
+ Status status = GDIPlus.GdipCreateSolidFill (color.ToArgb (), out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public Color Color {
+ get {
+ return color;
+ }
+ set {
+ if (isModifiable) {
+ color = value;
+ Status status = GDIPlus.GdipSetSolidFillColor (nativeObject, value.ToArgb ());
+ GDIPlus.CheckStatus (status);
+ }
+ else
+ throw new ArgumentException ("This SolidBrush object can't be modified.");
+ }
+ }
+
+ public override object Clone()
+ {
+ IntPtr clonePtr;
+ Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
+ GDIPlus.CheckStatus (status);
+
+ SolidBrush clone = new SolidBrush (clonePtr);
+ clone.color = color;
+
+ return clone;
+
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing == true && isModifiable == false) {
+ throw new ArgumentException ("This SolidBrush object can't be modified.");
+ }
+
+ base.Dispose (disposing);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing/SolidBrush.jvm.cs b/mcs/class/System.Drawing/System.Drawing/SolidBrush.jvm.cs
new file mode 100644
index 00000000000..ed9a06f99be
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SolidBrush.jvm.cs
@@ -0,0 +1,77 @@
+//
+// System.Drawing.SolidBrush.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Alexandre Pigolkine(pigolkine@gmx.de)
+// Ravindra (rkumar@novell.com)
+//
+// (C) 2002 Ximian, Inc.
+// (C) 2004 Novell, Inc.
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+namespace System.Drawing
+{
+ public sealed class SolidBrush : Brush
+ {
+ internal bool isModifiable = true;
+ Color _color;
+
+ protected override java.awt.Paint NativeObject {
+ get {
+ return _color.NativeObject;
+ }
+ }
+
+ public SolidBrush (Color color)
+ {
+ _color = color;
+ }
+
+ public Color Color {
+ get {
+ return _color;
+ }
+ set {
+ if (isModifiable)
+ _color = value;
+ else
+ throw new ArgumentException ("This SolidBrush object can't be modified.");
+ }
+ }
+
+ public override object Clone()
+ {
+ return new SolidBrush(_color);
+ }
+
+ protected override void Dispose (bool disposing)
+ {
+ if (!isModifiable && disposing)
+ throw new ArgumentException ("This SolidBrush object can't be modified.");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringAligment.cs b/mcs/class/System.Drawing/System.Drawing/StringAligment.cs
new file mode 100644
index 00000000000..61db3fbf608
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/StringAligment.cs
@@ -0,0 +1,41 @@
+//
+// System.Drawing.StringAligment.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+namespace System.Drawing
+{
+ [Serializable]
+ public enum StringAlignment {
+ Near = 0,
+ Center = 1,
+ Far = 2
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringDigitSubstitute.cs b/mcs/class/System.Drawing/System.Drawing/StringDigitSubstitute.cs
new file mode 100644
index 00000000000..97f7c2b0c45
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/StringDigitSubstitute.cs
@@ -0,0 +1,42 @@
+//
+// System.Drawing.StringDigitSubstitute.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+namespace System.Drawing
+{
+ [Serializable]
+ public enum StringDigitSubstitute {
+ User = 0,
+ None = 1,
+ National = 2,
+ Traditional = 3
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringFormat.cs b/mcs/class/System.Drawing/System.Drawing/StringFormat.cs
new file mode 100644
index 00000000000..1344cd2e25c
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/StringFormat.cs
@@ -0,0 +1,291 @@
+//
+// System.Drawing.StringFormat.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Miguel de Icaza (miguel@ximian.com)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+// Copyright (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing.Text;
+
+namespace System.Drawing
+{
+ /// <summary>
+ /// Summary description for StringFormat.
+ /// </summary>
+ public sealed class StringFormat : MarshalByRefObject, IDisposable, ICloneable
+ {
+ private static StringFormat genericDefault;
+ private IntPtr nativeStrFmt = IntPtr.Zero;
+ private int language = GDIPlus.LANG_NEUTRAL;
+
+ public StringFormat() : this (0, GDIPlus.LANG_NEUTRAL)
+ {
+
+ }
+
+ public StringFormat(StringFormatFlags options, int lang)
+ {
+ Status status = GDIPlus.GdipCreateStringFormat (options, lang, out nativeStrFmt);
+ GDIPlus.CheckStatus (status);
+
+ LineAlignment = StringAlignment.Near;
+ Alignment = StringAlignment.Near;
+ language = lang;
+ }
+
+ internal StringFormat(IntPtr native)
+ {
+ nativeStrFmt = native;
+ }
+
+ ~StringFormat ()
+ {
+ Dispose (false);
+ }
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ void Dispose (bool disposing)
+ {
+ if (nativeStrFmt != IntPtr.Zero) {
+ Status status = GDIPlus.GdipDeleteStringFormat (nativeStrFmt);
+ GDIPlus.CheckStatus (status);
+
+ nativeStrFmt = IntPtr.Zero;
+ }
+ }
+
+ public StringFormat (StringFormat source)
+ {
+ Status status = GDIPlus.GdipCloneStringFormat (source.NativeObject, out nativeStrFmt);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public StringFormat (StringFormatFlags flags)
+ {
+ Status status = GDIPlus.GdipCreateStringFormat (flags, GDIPlus.LANG_NEUTRAL, out nativeStrFmt);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public StringAlignment Alignment {
+ get {
+ StringAlignment align;
+ Status status = GDIPlus.GdipGetStringFormatAlign (nativeStrFmt, out align);
+ GDIPlus.CheckStatus (status);
+
+ return align;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetStringFormatAlign (nativeStrFmt, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public StringAlignment LineAlignment {
+ get {
+ StringAlignment align;
+ Status status = GDIPlus.GdipGetStringFormatLineAlign (nativeStrFmt, out align);
+ GDIPlus.CheckStatus (status);
+
+ return align;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetStringFormatLineAlign (nativeStrFmt, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public StringFormatFlags FormatFlags {
+ get {
+ StringFormatFlags flags;
+ Status status = GDIPlus.GdipGetStringFormatFlags (nativeStrFmt, out flags);
+ GDIPlus.CheckStatus (status);
+
+ return flags;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetStringFormatFlags (nativeStrFmt, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public HotkeyPrefix HotkeyPrefix {
+ get {
+ HotkeyPrefix hotkeyPrefix;
+ Status status = GDIPlus.GdipGetStringFormatHotkeyPrefix (nativeStrFmt, out hotkeyPrefix);
+ GDIPlus.CheckStatus (status);
+
+ return hotkeyPrefix;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetStringFormatHotkeyPrefix (nativeStrFmt, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+
+ public StringTrimming Trimming {
+ get {
+ StringTrimming trimming;
+ Status status = GDIPlus.GdipGetStringFormatTrimming (nativeStrFmt, out trimming);
+ GDIPlus.CheckStatus (status);
+ return trimming;
+ }
+
+ set {
+ Status status = GDIPlus.GdipSetStringFormatTrimming (nativeStrFmt, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public static StringFormat GenericDefault {
+ get {
+ IntPtr ptr;
+
+ Status status = GDIPlus.GdipStringFormatGetGenericDefault (out ptr);
+ GDIPlus.CheckStatus (status);
+
+ return new StringFormat (ptr);
+
+ }
+ }
+
+
+ public int DigitSubstitutionLanguage {
+ get{
+ return language;
+ }
+ }
+
+
+ public static StringFormat GenericTypographic {
+ get {
+
+ IntPtr ptr;
+
+ Status status = GDIPlus.GdipStringFormatGetGenericTypographic (out ptr);
+ GDIPlus.CheckStatus (status);
+
+ return new StringFormat (ptr);
+ }
+ }
+
+ public StringDigitSubstitute DigitSubstitutionMethod {
+ get {
+ StringDigitSubstitute substitute;
+
+ Status status = GDIPlus.GdipGetStringFormatDigitSubstitution(nativeStrFmt, language, out substitute);
+ GDIPlus.CheckStatus (status);
+
+ return substitute;
+ }
+ }
+
+
+ public void SetMeasurableCharacterRanges (CharacterRange [] range)
+ {
+ Status status = GDIPlus.GdipSetStringFormatMeasurableCharacterRanges (nativeStrFmt,
+ range.Length, range);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ internal int GetMeasurableCharacterRangeCount ()
+ {
+ int cnt;
+ Status status = GDIPlus.GdipGetStringFormatMeasurableCharacterRangeCount (nativeStrFmt, out cnt);
+
+ GDIPlus.CheckStatus (status);
+ return cnt;
+ }
+
+ public object Clone()
+ {
+ IntPtr native;
+
+ Status status = GDIPlus.GdipCloneStringFormat (nativeStrFmt, out native);
+ GDIPlus.CheckStatus (status);
+
+ return new StringFormat (native);
+ }
+
+ public override string ToString()
+ {
+ return "[StringFormat, FormatFlags=" + this.FormatFlags.ToString() + "]";
+ }
+
+ internal IntPtr NativeObject
+ {
+ get{
+ return nativeStrFmt;
+ }
+ set {
+ nativeStrFmt = value;
+ }
+ }
+
+ public void SetTabStops(float firstTabOffset, float[] tabStops)
+ {
+ Status status = GDIPlus.GdipSetStringFormatTabStops(nativeStrFmt, firstTabOffset, tabStops.Length, tabStops);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void SetDigitSubstitution(int language, StringDigitSubstitute substitute)
+ {
+ Status status = GDIPlus.GdipSetStringFormatDigitSubstitution(nativeStrFmt, this.language, substitute);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public float[] GetTabStops(out float firstTabOffset)
+ {
+ int count = 0;
+ firstTabOffset = 0;
+
+ Status status = GDIPlus.GdipGetStringFormatTabStopCount(nativeStrFmt, out count);
+ GDIPlus.CheckStatus (status);
+
+ float[] tabStops = new float[count];
+
+ if (count != 0) {
+ status = GDIPlus.GdipGetStringFormatTabStops(nativeStrFmt, count, out firstTabOffset, tabStops);
+ GDIPlus.CheckStatus (status);
+ }
+
+ return tabStops;
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringFormat.jvm.cs b/mcs/class/System.Drawing/System.Drawing/StringFormat.jvm.cs
new file mode 100644
index 00000000000..b63870a1bcb
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/StringFormat.jvm.cs
@@ -0,0 +1,270 @@
+//
+// System.Drawing.StringFormat.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Miguel de Icaza (miguel@ximian.com)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+// Copyright (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing.Text;
+
+namespace System.Drawing {
+ /// <summary>
+ /// Summary description for StringFormat.
+ /// </summary>
+ public sealed class StringFormat : MarshalByRefObject, IDisposable, ICloneable {
+
+
+ private CharacterRange [] _charRanges;
+ private StringAlignment _alignment;
+ private StringAlignment _lineAlignment;
+ private HotkeyPrefix _hotkeyPrefix;
+ private StringFormatFlags _flags;
+ private StringDigitSubstitute _digitSubstituteMethod;
+ private int _digitSubstituteLanguage;
+ private StringTrimming _trimming;
+
+ private float _firstTabOffset;
+ private float [] _tabStops;
+
+ #region Constructors
+
+ public StringFormat() : this(0, 0) {
+ }
+
+ public StringFormat(StringFormatFlags options) : this(options,0) {
+ }
+
+ public StringFormat(StringFormatFlags options, int lang) {
+ _alignment = StringAlignment.Near;
+ _digitSubstituteLanguage = lang;
+ _digitSubstituteMethod = StringDigitSubstitute.User;
+ _flags = options;
+ _hotkeyPrefix = HotkeyPrefix.None;
+ _lineAlignment = StringAlignment.Near;
+ _trimming = StringTrimming.Character;
+ }
+
+ public StringFormat (StringFormat source) {
+ if (source == null)
+ throw new ArgumentNullException("format");
+
+ _alignment = source.LineAlignment;
+ _digitSubstituteLanguage = source.DigitSubstitutionLanguage;
+ _digitSubstituteMethod = source.DigitSubstitutionMethod;
+ _flags = source.FormatFlags;
+ _hotkeyPrefix = source.HotkeyPrefix;
+ _lineAlignment = source.LineAlignment;
+ _trimming = source.Trimming;
+ }
+
+
+ #endregion
+
+ #region IDisposable
+
+ public void Dispose() {
+ }
+
+ #endregion
+
+ #region Public properties
+
+ public StringAlignment Alignment {
+ get {
+ return _alignment;
+ }
+
+ set {
+ _alignment = value;
+ }
+ }
+
+ public StringAlignment LineAlignment {
+ get {
+ return _lineAlignment;
+ }
+ set {
+ _lineAlignment = value;
+ }
+ }
+
+ [MonoTODO]
+ public StringFormatFlags FormatFlags {
+ get {
+ return _flags;
+ }
+
+ set {
+ _flags = value;
+ }
+ }
+
+ [MonoTODO]
+ public HotkeyPrefix HotkeyPrefix {
+ get {
+ return _hotkeyPrefix;
+ }
+
+ set {
+ _hotkeyPrefix = value;
+ }
+ }
+
+ [MonoTODO]
+ public StringTrimming Trimming {
+ get {
+ return _trimming;
+ }
+
+ set {
+ _trimming = value;
+ }
+ }
+
+ public int DigitSubstitutionLanguage {
+ get {
+ return _digitSubstituteLanguage;
+ }
+ }
+
+ public StringDigitSubstitute DigitSubstitutionMethod {
+ get {
+ return _digitSubstituteMethod;
+ }
+ }
+
+
+ #endregion
+
+ #region static properties
+
+ public static StringFormat GenericDefault {
+ get {
+ StringFormat genericDefault = new StringFormat();
+ return genericDefault;
+ }
+ }
+
+ public static StringFormat GenericTypographic {
+ get {
+ StringFormat genericTypographic = new StringFormat(
+ StringFormatFlags.FitBlackBox |
+ StringFormatFlags.LineLimit |
+ StringFormatFlags.NoClip,
+ 0 );
+ genericTypographic.Trimming = StringTrimming.None;
+ return genericTypographic;
+ }
+ }
+
+ #endregion
+
+ #region internal accessors
+ internal bool NoWrap {
+ get {
+ return (FormatFlags & StringFormatFlags.NoWrap) != 0;
+ }
+ }
+
+ internal bool IsVertical {
+ get {
+ return (FormatFlags & StringFormatFlags.DirectionVertical) != 0;
+ }
+ }
+
+ internal bool MeasureTrailingSpaces {
+ get {
+ return (FormatFlags & StringFormatFlags.MeasureTrailingSpaces) != 0;
+ }
+ }
+
+ internal bool LineLimit {
+ get {
+ return (FormatFlags & StringFormatFlags.LineLimit) != 0;
+ }
+ }
+
+ internal bool NoClip {
+ get {
+ return (FormatFlags & StringFormatFlags.NoClip) != 0;
+ }
+ }
+
+ internal bool IsRightToLeft {
+ get {
+ return (FormatFlags & StringFormatFlags.DirectionRightToLeft) != 0;
+ }
+ }
+
+ internal CharacterRange [] CharRanges {
+ get {
+ return _charRanges;
+ }
+ }
+ #endregion
+
+ #region public methods
+
+ public void SetMeasurableCharacterRanges (CharacterRange [] range) {
+ _charRanges = range != null ? (CharacterRange [])range.Clone() : null;
+ }
+
+ public object Clone() {
+ StringFormat copy = (StringFormat)MemberwiseClone();
+ if (_charRanges != null)
+ copy._charRanges = (CharacterRange [])_charRanges.Clone();
+ if (_tabStops != null)
+ copy._tabStops = (float[])_tabStops.Clone();
+ return copy;
+ }
+
+ public override string ToString() {
+ return "[StringFormat, FormatFlags=" + this.FormatFlags.ToString() + "]";
+ }
+
+ public void SetTabStops(float firstTabOffset, float[] tabStops) {
+// _firstTabOffset = firstTabOffset;
+// _tabStops = tabStops != null ? (float[])tabStops.Clone() : null;
+ throw new NotSupportedException();
+ }
+
+ public void SetDigitSubstitution(int language, StringDigitSubstitute substitute) {
+// _digitSubstituteMethod = substitute;
+// _digitSubstituteLanguage = language;
+ throw new NotSupportedException();
+ }
+
+ [MonoTODO]
+ public float[] GetTabStops(out float firstTabOffset) {
+ firstTabOffset = _firstTabOffset;
+ return _tabStops != null ? (float[])_tabStops.Clone() : null;
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringFormatFlags.cs b/mcs/class/System.Drawing/System.Drawing/StringFormatFlags.cs
new file mode 100644
index 00000000000..5cf2bf57406
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/StringFormatFlags.cs
@@ -0,0 +1,48 @@
+//
+// System.Drawing.StringFormatFlags.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+namespace System.Drawing
+{
+ [Flags]
+ [Serializable]
+ public enum StringFormatFlags {
+ DirectionRightToLeft = 0x0001,
+ DirectionVertical = 0x0002,
+ FitBlackBox = 0x0004,
+ DisplayFormatControl = 0x0020,
+ NoFontFallback = 0x0400,
+ MeasureTrailingSpaces = 0x0800,
+ NoWrap = 0x1000,
+ LineLimit = 0x2000,
+ NoClip = 0x4000
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringTrimming.cs b/mcs/class/System.Drawing/System.Drawing/StringTrimming.cs
new file mode 100644
index 00000000000..45cf2de1f4e
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/StringTrimming.cs
@@ -0,0 +1,44 @@
+//
+// System.Drawing.StringTrimming.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+namespace System.Drawing
+{
+ [Serializable]
+ public enum StringTrimming {
+ None = 0,
+ Character = 1,
+ Word = 2,
+ EllipsisCharacter = 3,
+ EllipsisWord = 4,
+ EllipsisPath = 5
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringUnit.cs b/mcs/class/System.Drawing/System.Drawing/StringUnit.cs
new file mode 100644
index 00000000000..645f21155d7
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/StringUnit.cs
@@ -0,0 +1,46 @@
+//
+// System.Drawing.StringUnit.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+// Author: Dennis Hayes (dennish@raytek.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+namespace System.Drawing
+{
+ [Serializable]
+ public enum StringUnit{
+ World = 0x00,
+ Display = 0x01,
+ Pixel = 0x02,
+ Point = 0x03,
+ Inch = 0x04,
+ Document = 0x05,
+ Millimeter = 0x06,
+ Em = 0x20
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/StrokeFactory.jvm.cs b/mcs/class/System.Drawing/System.Drawing/StrokeFactory.jvm.cs
new file mode 100755
index 00000000000..8878ac73f1b
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/StrokeFactory.jvm.cs
@@ -0,0 +1,67 @@
+using System;
+using awt = java.awt;
+using geom = java.awt.geom;
+
+namespace System.Drawing {
+ internal sealed class StrokeFactory {
+
+ StrokeFactory() {}
+
+ interface StrokeCreator {
+ awt.Stroke Create(float width, int cap, int join, float miterlimit,
+ float[] dash, float dash_phase, geom.AffineTransform penTransform,
+ geom.AffineTransform outputTransform, PenFit penFit);
+ }
+
+ sealed class AdvancedCreator : StrokeCreator {
+ #region StrokeCreator Members
+
+ public awt.Stroke Create(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase, geom.AffineTransform penTransform,
+ geom.AffineTransform outputTransform, PenFit penFit) {
+ if ((penFit == PenFit.NotThin) &&
+ (outputTransform == null || outputTransform.isIdentity()) &&
+ (penTransform == null || penTransform.isIdentity()))
+ return new awt.BasicStroke(width, cap, join, miterlimit, dash, dash_phase);
+ return new System.Drawing.AdvancedStroke(width, cap, join, miterlimit, dash, dash_phase, penTransform, outputTransform, penFit);
+ }
+
+ #endregion
+ }
+
+ sealed class DefaultCreator : StrokeCreator {
+ #region StrokeCreator Members
+
+ public awt.Stroke Create(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase, geom.AffineTransform penTransform,
+ geom.AffineTransform outputTransform, PenFit penFit) {
+ return new awt.BasicStroke(width, cap, join, miterlimit, dash, dash_phase);
+ }
+
+ #endregion
+ }
+
+ static readonly StrokeCreator Creator;
+ static StrokeFactory() {
+ try {
+ Type type = typeof(System.Drawing.AdvancedStroke);
+ Activator.CreateInstance(type);
+ Creator = new AdvancedCreator();
+ }
+ catch{
+ Creator = new DefaultCreator();
+ }
+ }
+
+ static public bool CanCreateAdvancedStroke {
+ get {
+ return !(Creator is DefaultCreator);
+ }
+ }
+
+ static public awt.Stroke CreateStroke(float width, int cap, int join, float miterlimit,
+ float[] dash, float dash_phase, geom.AffineTransform penTransform,
+ geom.AffineTransform outputTransform, PenFit penFit) {
+
+ return Creator.Create(width, cap, join, miterlimit, dash, dash_phase, penTransform, outputTransform, penFit);
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs b/mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs
new file mode 100644
index 00000000000..95587f533fb
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs
@@ -0,0 +1,462 @@
+//
+// System.Drawing.SystemBrushes.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+// Jordi Mas i Hernandez <jordimash@gmail.com>
+//
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing
+{
+ /// <summary>
+ /// Summary description for SystemBrushes.
+ /// </summary>
+ public sealed class SystemBrushes
+ {
+ static SolidBrush active_border;
+ static SolidBrush active_caption;
+ static SolidBrush active_caption_text;
+ static SolidBrush app_workspace;
+ static SolidBrush control;
+ static SolidBrush control_dark;
+ static SolidBrush control_dark_dark;
+ static SolidBrush control_light;
+ static SolidBrush control_light_light;
+ static SolidBrush control_text;
+ static SolidBrush desktop;
+ static SolidBrush highlight;
+ static SolidBrush highlight_text;
+ static SolidBrush hot_track;
+ static SolidBrush inactive_border;
+ static SolidBrush inactive_caption;
+ static SolidBrush info;
+ static SolidBrush menu;
+ static SolidBrush scroll_bar;
+ static SolidBrush window;
+ static SolidBrush window_text;
+ static SolidBrush button_face;
+ static SolidBrush button_highlight;
+ static SolidBrush button_shadow;
+ static SolidBrush gradient_activecaption;
+ static SolidBrush gradient_inactivecaption;
+ static SolidBrush graytext;
+ static SolidBrush inactive_captiontext;
+ static SolidBrush infotext;
+ static SolidBrush menubar;
+ static SolidBrush menu_highlight;
+ static SolidBrush menu_text;
+ static SolidBrush window_fame;
+
+ private SystemBrushes() { }
+
+ public static Brush ActiveBorder
+ {
+ get {
+ if (active_border == null) {
+ active_border = new SolidBrush (SystemColors.ActiveBorder);
+ active_border.isModifiable = false;
+ }
+
+ return active_border;
+ }
+ }
+
+ public static Brush ActiveCaption
+ {
+ get {
+ if (active_caption == null) {
+ active_caption = new SolidBrush (SystemColors.ActiveCaption);
+ active_caption.isModifiable = false;
+ }
+
+ return active_caption;
+ }
+ }
+
+ public static Brush ActiveCaptionText
+ {
+ get {
+ if (active_caption_text == null) {
+ active_caption_text = new SolidBrush (SystemColors.ActiveCaptionText);
+ active_caption_text.isModifiable = false;
+ }
+
+ return active_caption_text;
+ }
+ }
+
+ public static Brush AppWorkspace
+ {
+ get {
+ if (app_workspace == null) {
+ app_workspace = new SolidBrush (SystemColors.AppWorkspace);
+ app_workspace.isModifiable = false;
+ }
+
+ return app_workspace;
+ }
+ }
+
+ public static Brush Control {
+ get {
+ if (control == null) {
+ control = new SolidBrush (SystemColors.Control);
+ control.isModifiable = false;
+ }
+
+ return control;
+ }
+ }
+
+ public static Brush ControlLight {
+ get {
+ if (control_light == null) {
+ control_light = new SolidBrush (SystemColors.ControlLight);
+ control_light.isModifiable = false;
+ }
+
+ return control_light;
+ }
+ }
+
+ public static Brush ControlLightLight {
+ get {
+ if (control_light_light == null) {
+ control_light_light = new SolidBrush (SystemColors.ControlLightLight);
+ control_light_light.isModifiable = false;
+ }
+
+ return control_light_light;
+ }
+ }
+
+ public static Brush ControlDark {
+ get {
+ if (control_dark == null) {
+ control_dark = new SolidBrush (SystemColors.ControlDark);
+ control_dark.isModifiable = false;
+ }
+
+ return control_dark;
+ }
+ }
+
+ public static Brush ControlDarkDark {
+ get {
+ if (control_dark_dark == null) {
+ control_dark_dark = new SolidBrush (SystemColors.ControlDarkDark);
+ control_dark_dark.isModifiable = false;
+ }
+
+ return control_dark_dark;
+ }
+ }
+
+ public static Brush ControlText {
+ get {
+ if (control_text == null) {
+ control_text = new SolidBrush (SystemColors.ControlText);
+ control_text.isModifiable = false;
+ }
+
+ return control_text;
+ }
+ }
+
+ public static Brush Highlight {
+ get {
+ if (highlight == null) {
+ highlight = new SolidBrush (SystemColors.Highlight);
+ highlight.isModifiable = false;
+ }
+
+ return highlight;
+ }
+ }
+
+ public static Brush HighlightText {
+ get {
+ if (highlight_text == null) {
+ highlight_text = new SolidBrush (SystemColors.HighlightText);
+ highlight_text.isModifiable = false;
+ }
+
+ return highlight_text;
+ }
+ }
+
+ public static Brush Window {
+ get {
+ if (window == null) {
+ window = new SolidBrush (SystemColors.Window);
+ window.isModifiable = false;
+ }
+
+ return window;
+ }
+ }
+ public static Brush WindowText {
+ get {
+ if (window_text == null) {
+ window_text = new SolidBrush (SystemColors.WindowText);
+ window_text.isModifiable = false;
+ }
+
+ return window_text;
+ }
+ }
+
+ public static Brush InactiveBorder {
+ get {
+ if (inactive_border == null) {
+ inactive_border = new SolidBrush (SystemColors.InactiveBorder);
+ inactive_border.isModifiable = false;
+ }
+
+ return inactive_border;
+ }
+ }
+
+ public static Brush Desktop {
+ get {
+ if (desktop == null) {
+ desktop = new SolidBrush (SystemColors.Desktop);
+ desktop.isModifiable = false;
+ }
+
+ return desktop;
+ }
+ }
+
+ public static Brush HotTrack {
+ get {
+ if (hot_track == null) {
+ hot_track = new SolidBrush (SystemColors.HotTrack);
+ hot_track.isModifiable = false;
+ }
+
+ return hot_track;
+ }
+ }
+
+ public static Brush InactiveCaption {
+ get {
+ if (inactive_caption == null) {
+ inactive_caption = new SolidBrush (SystemColors.InactiveCaption);
+ inactive_caption.isModifiable = false;
+ }
+
+ return inactive_caption;
+ }
+ }
+
+ public static Brush Info {
+ get {
+ if (info == null) {
+ info = new SolidBrush (SystemColors.Info);
+ info.isModifiable = false;
+ }
+
+ return info;
+ }
+ }
+
+ public static Brush Menu {
+ get {
+ if (menu == null) {
+ menu = new SolidBrush (SystemColors.Menu);
+ menu.isModifiable = false;
+ }
+
+ return menu;
+ }
+ }
+
+ public static Brush ScrollBar {
+ get {
+ if (scroll_bar == null) {
+ scroll_bar = new SolidBrush (SystemColors.ScrollBar);
+ scroll_bar.isModifiable = false;
+ }
+
+ return scroll_bar;
+ }
+ }
+
+ public static Brush FromSystemColor (Color c)
+ {
+ if (c.IsSystemColor) {
+ SolidBrush newBrush = new SolidBrush (c);
+ newBrush.isModifiable = false;
+ return newBrush;
+ }
+
+ String message = String.Format ("The color {0} is not a system color.", c);
+ throw new ArgumentException (message);
+ }
+
+#if NET_2_0
+ public static Brush ButtonFace {
+ get {
+ if (button_face == null) {
+ button_face = new SolidBrush (SystemColors.ButtonFace);
+ button_face.isModifiable = false;
+ }
+
+ return button_face;
+ }
+ }
+
+ public static Brush ButtonHighlight {
+ get {
+ if (button_highlight == null) {
+ button_highlight = new SolidBrush (SystemColors.ButtonHighlight);
+ button_highlight.isModifiable = false;
+ }
+
+ return button_highlight;
+ }
+ }
+
+ public static Brush ButtonShadow {
+ get {
+ if (button_shadow == null) {
+ button_shadow = new SolidBrush (SystemColors.ButtonShadow);
+ button_shadow.isModifiable = false;
+ }
+
+ return button_shadow;
+ }
+ }
+
+ public static Brush GradientActiveCaption {
+ get {
+ if (gradient_activecaption == null) {
+ gradient_activecaption = new SolidBrush (SystemColors.GradientActiveCaption);
+ gradient_activecaption.isModifiable = false;
+ }
+
+ return gradient_activecaption;
+ }
+ }
+
+ public static Brush GradientInactiveCaption {
+ get {
+ if (gradient_inactivecaption == null) {
+ gradient_inactivecaption = new SolidBrush (SystemColors.GradientInactiveCaption);
+ gradient_inactivecaption.isModifiable = false;
+ }
+
+ return gradient_inactivecaption;
+ }
+ }
+
+ public static Brush GrayText {
+ get {
+ if (graytext == null) {
+ graytext = new SolidBrush (SystemColors.GrayText);
+ graytext.isModifiable = false;
+ }
+
+ return graytext;
+ }
+ }
+
+ public static Brush InactiveCaptionText {
+ get {
+ if (inactive_captiontext == null) {
+ inactive_captiontext = new SolidBrush (SystemColors.InactiveCaptionText);
+ inactive_captiontext.isModifiable = false;
+ }
+
+ return inactive_captiontext;
+ }
+ }
+
+ public static Brush InfoText {
+ get {
+ if (infotext == null) {
+ infotext = new SolidBrush (SystemColors.InfoText);
+ infotext.isModifiable = false;
+ }
+
+ return infotext;
+ }
+ }
+
+ public static Brush MenuBar {
+ get {
+ if (menubar == null) {
+ menubar = new SolidBrush (SystemColors.MenuBar);
+ menubar.isModifiable = false;
+ }
+
+ return menubar;
+ }
+ }
+
+ public static Brush MenuHighlight {
+ get {
+ if (menu_highlight == null) {
+ menu_highlight = new SolidBrush (SystemColors.MenuHighlight);
+ menu_highlight.isModifiable = false;
+ }
+
+ return menu_highlight;
+ }
+ }
+
+ public static Brush MenuText {
+ get {
+ if (menu_text == null) {
+ menu_text = new SolidBrush (SystemColors.MenuText);
+ menu_text.isModifiable = false;
+ }
+
+ return menu_text;
+ }
+ }
+
+ public static Brush WindowFrame {
+ get {
+ if (window_fame == null) {
+ window_fame = new SolidBrush (SystemColors.WindowFrame);
+ window_fame.isModifiable = false;
+ }
+
+ return window_fame;
+ }
+ }
+#endif
+
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemColors.cs b/mcs/class/System.Drawing/System.Drawing/SystemColors.cs
new file mode 100644
index 00000000000..e239cb088d4
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SystemColors.cs
@@ -0,0 +1,498 @@
+//
+// System.Drawing.SystemColors.cs
+//
+// Copyright (C) 2002 Ximian, Inc (http://www.ximian.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+// Peter Dennis Bartok (pbartok@novell.com)
+//
+
+
+// The following method can be (and was) used to generate the defaults for the properties
+//private static void GenerateColorTable (Type type) {
+// PropertyInfo [] props = type.GetProperties ();
+// foreach (PropertyInfo prop in props){
+// if (prop.PropertyType != typeof (Color))
+// continue;
+//
+// MethodInfo getget = prop.GetGetMethod ();
+// if (getget == null || getget.IsStatic == false)
+// continue;
+//
+// object o = prop.GetValue (null, null);
+//
+// Color c = (Color) o;
+//
+// StringBuilder name = new StringBuilder(prop.Name);
+// name[0] = Char.ToLower(name[0]);
+// for (int i = 1; i < name.Length; i++) {
+// if (Char.IsUpper(name[i])) {
+// name[i] = Char.ToLower(name[i]);
+// name.Insert(i, '_');
+// }
+// }
+//
+// Console.WriteLine("static private Color " + name.ToString() + " = Color.FromArgbSystem (" +
+// c.A.ToString() + ", " +
+// c.R.ToString() + ", " +
+// c.G.ToString() + ", " +
+// c.B.ToString() + ", " +
+// "\"" + prop.Name + "\", " +
+// "KnownColor." + prop.Name + ");");
+// }
+//}
+
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing {
+ public sealed class SystemColors
+ {
+ // Default Windows XP color table
+ static private Color active_border = Color.FromArgbSystem (255, 212, 208, 200, "ActiveBorder", KnownColor.ActiveBorder);
+ static private Color active_caption = Color.FromArgbSystem (255, 0, 164, 164, "ActiveCaption", KnownColor.ActiveCaption);
+ static private Color active_caption_text = Color.FromArgbSystem (255, 255, 255, 255, "ActiveCaptionText", KnownColor.ActiveCaptionText);
+ static private Color app_workspace = Color.FromArgbSystem (255, 128, 128, 128, "AppWorkspace", KnownColor.AppWorkspace);
+ static private Color control = Color.FromArgbSystem (255, 212, 208, 200, "Control", KnownColor.Control);
+ static private Color control_dark = Color.FromArgbSystem (255, 128, 128, 128, "ControlDark", KnownColor.ControlDark);
+ static private Color control_dark_dark = Color.FromArgbSystem (255, 64, 64, 64, "ControlDarkDark", KnownColor.ControlDarkDark);
+ static private Color control_light = Color.FromArgbSystem (255, 212, 208, 200, "ControlLight", KnownColor.ControlLight);
+ static private Color control_light_light = Color.FromArgbSystem (255, 255, 255, 255, "ControlLightLight", KnownColor.ControlLightLight);
+ static private Color control_text = Color.FromArgbSystem (255, 0, 0, 0, "ControlText", KnownColor.ControlText);
+ static private Color desktop = Color.FromArgbSystem (255, 0, 0, 0, "Desktop", KnownColor.Desktop);
+ static private Color gray_text = Color.FromArgbSystem (255, 128, 128, 128, "GrayText", KnownColor.GrayText);
+ static private Color highlight = Color.FromArgbSystem (255, 10, 36, 106, "Highlight", KnownColor.Highlight);
+ static private Color highlight_text = Color.FromArgbSystem (255, 255, 255, 255, "HighlightText", KnownColor.HighlightText);
+ static private Color hot_track = Color.FromArgbSystem (255, 0, 0, 128, "HotTrack", KnownColor.HotTrack);
+ static private Color inactive_border = Color.FromArgbSystem (255, 212, 208, 200, "InactiveBorder", KnownColor.InactiveBorder);
+ static private Color inactive_caption = Color.FromArgbSystem (255, 128, 128, 128, "InactiveCaption", KnownColor.InactiveCaption);
+ static private Color inactive_caption_text = Color.FromArgbSystem (255, 212, 208, 200, "InactiveCaptionText", KnownColor.InactiveCaptionText);
+ static private Color info = Color.FromArgbSystem (255, 255, 255, 225, "Info", KnownColor.Info);
+ static private Color info_text = Color.FromArgbSystem (255, 0, 0, 0, "InfoText", KnownColor.InfoText);
+ static private Color menu = Color.FromArgbSystem (255, 212, 208, 200, "Menu", KnownColor.Menu);
+ static private Color menu_text = Color.FromArgbSystem (255, 0, 0, 0, "MenuText", KnownColor.MenuText);
+ static private Color scroll_bar = Color.FromArgbSystem (255, 212, 208, 200, "ScrollBar", KnownColor.ScrollBar);
+ // This would give a better looking gray background instead of the high-contrast white background
+ //static private Color window = Color.FromArgbSystem (255, 212, 208, 200, "Window", KnownColor.Window);
+ static private Color window = Color.FromArgbSystem (255, 255, 255, 255, "Window", KnownColor.Window);
+ static private Color window_frame = Color.FromArgbSystem (255, 0, 0, 0, "WindowFrame", KnownColor.WindowFrame);
+ static private Color window_text = Color.FromArgbSystem (255, 0, 0, 0, "WindowText", KnownColor.WindowText);
+
+#if NET_2_0
+ static private Color button_face = Color.FromArgbSystem (255, 192, 192, 192, "ButtonFace", KnownColor.ButtonFace);
+ static private Color button_highlight = Color.FromArgbSystem (255, 255, 255, 255, "ButtonHighlight", KnownColor.ButtonHighlight);
+ static private Color button_shadow = Color.FromArgbSystem (255, 128, 128, 128, "ButtonShadow", KnownColor.ButtonShadow);
+ static private Color gradient_activecaption = Color.FromArgbSystem (255, 16, 132, 208, "GradientActiveCaption", KnownColor.GradientActiveCaption);
+ static private Color gradient_inactivecaption = Color.FromArgbSystem (255, 181, 181, 181, "GradientInactiveCaption", KnownColor.GradientInactiveCaption);
+ static private Color menubar = Color.FromArgbSystem (255, 192, 192, 192, "MenuBar", KnownColor.MenuBar);
+ static private Color menu_highlight = Color.FromArgbSystem (255, 0, 0, 0, "MenuHighlight", KnownColor.MenuHighlight);
+#endif
+
+#if old
+ static private Color active_border = Color.FromArgbSystem (255, 131, 153, 177, "ActiveBorder", KnownColor.ActiveBorder);
+ static private Color active_caption = Color.FromArgbSystem (255, 79, 101, 125, "ActiveCaption", KnownColor.ActiveCaption);
+ static private Color active_caption_text = Color.FromArgbSystem (255, 255, 255, 255, "ActiveCaptionText", KnownColor.ActiveCaptionText);
+ static private Color app_workspace = Color.FromArgbSystem (255, 128, 128, 128, "AppWorkspace", KnownColor.AppWorkspace);
+ static private Color control = Color.FromArgbSystem (255, 192, 192, 192, "Control", KnownColor.Control);
+ static private Color control_dark = Color.FromArgbSystem (255, 79, 101, 125, "ControlDark", KnownColor.ControlDark);
+ static private Color control_dark_dark = Color.FromArgbSystem (255, 0, 0, 0, "ControlDarkDark", KnownColor.ControlDarkDark);
+ static private Color control_light = Color.FromArgbSystem (255, 131, 153, 177, "ControlLight", KnownColor.ControlLight);
+ static private Color control_light_light = Color.FromArgbSystem (255, 193, 204, 217, "ControlLightLight", KnownColor.ControlLightLight);
+ static private Color control_text = Color.FromArgbSystem (255, 0, 0, 0, "ControlText", KnownColor.ControlText);
+ static private Color desktop = Color.FromArgbSystem (255, 0, 0, 0, "Desktop", KnownColor.Desktop);
+ static private Color gray_text = Color.FromArgbSystem (255, 79, 101, 125, "GrayText", KnownColor.GrayText);
+ static private Color highlight = Color.FromArgbSystem (255, 0, 0, 128, "Highlight", KnownColor.Highlight);
+ static private Color highlight_text = Color.FromArgbSystem (255, 255, 255, 255, "HighlightText", KnownColor.HighlightText);
+ static private Color hot_track = Color.FromArgbSystem (255, 0, 0, 255, "HotTrack", KnownColor.HotTrack);
+ static private Color inactive_border = Color.FromArgbSystem (255, 131, 153, 177, "InactiveBorder", KnownColor.InactiveBorder);
+ static private Color inactive_caption = Color.FromArgbSystem (255, 128, 128, 128, "InactiveCaption", KnownColor.InactiveCaption);
+ static private Color inactive_caption_text = Color.FromArgbSystem (255, 193, 204, 217, "InactiveCaptionText", KnownColor.InactiveCaptionText);
+ static private Color info = Color.FromArgbSystem (255, 255, 255, 255, "Info", KnownColor.Info);
+ static private Color info_text = Color.FromArgbSystem (255, 0, 0, 0, "InfoText", KnownColor.InfoText);
+ static private Color menu = Color.FromArgbSystem (255, 131, 153, 177, "Menu", KnownColor.Menu);
+ static private Color menu_text = Color.FromArgbSystem (255, 0, 0, 0, "MenuText", KnownColor.MenuText);
+ static private Color scroll_bar = Color.FromArgbSystem (255, 193, 204, 217, "ScrollBar", KnownColor.ScrollBar);
+ static private Color window = Color.FromArgbSystem (255, 255, 255, 255, "Window", KnownColor.Window);
+ static private Color window_frame = Color.FromArgbSystem (255, 0, 0, 0, "WindowFrame", KnownColor.WindowFrame);
+ static private Color window_text = Color.FromArgbSystem (255, 0, 0, 0, "WindowText", KnownColor.WindowText);
+#endif
+ private enum GetSysColorIndex {
+ COLOR_SCROLLBAR = 0,
+ COLOR_BACKGROUND = 1,
+ COLOR_ACTIVECAPTION = 2,
+ COLOR_INACTIVECAPTION = 3,
+ COLOR_MENU = 4,
+ COLOR_WINDOW = 5,
+ COLOR_WINDOWFRAME = 6,
+ COLOR_MENUTEXT = 7,
+ COLOR_WINDOWTEXT = 8,
+ COLOR_CAPTIONTEXT = 9,
+ COLOR_ACTIVEBORDER = 10,
+ COLOR_INACTIVEBORDER = 11,
+ COLOR_APPWORKSPACE = 12,
+ COLOR_HIGHLIGHT = 13,
+ COLOR_HIGHLIGHTTEXT = 14,
+ COLOR_BTNFACE = 15,
+ COLOR_BTNSHADOW = 16,
+ COLOR_GRAYTEXT = 17,
+ COLOR_BTNTEXT = 18,
+ COLOR_INACTIVECAPTIONTEXT = 19,
+ COLOR_BTNHIGHLIGHT = 20,
+ COLOR_3DDKSHADOW = 21,
+ COLOR_3DLIGHT = 22,
+ COLOR_INFOTEXT = 23,
+ COLOR_INFOBK = 24,
+
+ COLOR_HOTLIGHT = 26,
+ COLOR_GRADIENTACTIVECAPTION = 27,
+ COLOR_GRADIENTINACTIVECAPTION = 28,
+ COLOR_MENUHIGHLIGHT = 29,
+ COLOR_MENUBAR = 30,
+
+ COLOR_DESKTOP = 1,
+ COLOR_3DFACE = 16,
+ COLOR_3DSHADOW = 16,
+ COLOR_3DHIGHLIGHT = 20,
+ COLOR_3DHILIGHT = 20,
+ COLOR_BTNHILIGHT = 20,
+
+ COLOR_MAXVALUE = 30,/* Maximum value */
+ }
+
+ [DllImport ("user32.dll", EntryPoint="GetSysColor", CallingConvention=CallingConvention.StdCall)]
+ private extern static uint Win32GetSysColor(GetSysColorIndex index);
+
+ private static Color GetSysColor(GetSysColorIndex index, string name, KnownColor knownColor) {
+ uint color;
+
+ color = Win32GetSysColor(index);
+
+ return Color.FromArgbSystem(255, (byte)(color & 0xff), (byte)((color >> 8) & 0xff), (byte)((color >> 16) & 0xff), name, knownColor);
+ }
+
+ // When this method is called, we teach any new color(s) to the Color class
+ private static void UpdateColors() {
+ Color.UpdateKnownColor (active_border.A, active_border.R, active_border.G, active_border.B, "ActiveBorder", KnownColor.ActiveBorder);
+ Color.UpdateKnownColor (active_caption.A, active_caption.R, active_caption.G, active_caption.B, "ActiveCaption", KnownColor.ActiveCaption);
+ Color.UpdateKnownColor (active_caption_text.A, active_caption_text.R, active_caption_text.G, active_caption_text.B, "ActiveCaptionText", KnownColor.ActiveCaptionText);
+ Color.UpdateKnownColor (app_workspace.A, app_workspace.R, app_workspace.G, app_workspace.B, "AppWorkspace", KnownColor.AppWorkspace);
+ Color.UpdateKnownColor (control.A, control.R, control.G, control.B, "Control", KnownColor.Control);
+ Color.UpdateKnownColor (control_dark.A, control_dark.R, control_dark.G, control_dark.B, "ControlDark", KnownColor.ControlDark);
+ Color.UpdateKnownColor (control_dark_dark.A, control_dark_dark.R, control_dark_dark.G, control_dark_dark.B, "ControlDarkDark", KnownColor.ControlDarkDark);
+ Color.UpdateKnownColor (control_light.A, control_light.R, control_light.G, control_light.B, "ControlLight", KnownColor.ControlLight);
+ Color.UpdateKnownColor (control_light_light.A, control_light_light.R, control_light_light.G, control_light_light.B, "ControlLightLight", KnownColor.ControlLightLight);
+ Color.UpdateKnownColor (control_text.A, control_text.R, control_text.G, control_text.B, "ControlText", KnownColor.ControlText);
+ Color.UpdateKnownColor (desktop.A, desktop.R, desktop.G, desktop.B, "Desktop", KnownColor.Desktop);
+ Color.UpdateKnownColor (gray_text.A, gray_text.R, gray_text.G, gray_text.B, "GrayText", KnownColor.GrayText);
+ Color.UpdateKnownColor (highlight.A, highlight.R, highlight.G, highlight.B, "Highlight", KnownColor.Highlight);
+ Color.UpdateKnownColor (highlight_text.A, highlight_text.R, highlight_text.G, highlight_text.B, "HighlightText", KnownColor.HighlightText);
+ Color.UpdateKnownColor (hot_track.A, hot_track.R, hot_track.G, hot_track.B, "HotTrack", KnownColor.HotTrack);
+ Color.UpdateKnownColor (inactive_border.A, inactive_border.R, inactive_border.G, inactive_border.B, "InactiveBorder", KnownColor.InactiveBorder);
+ Color.UpdateKnownColor (inactive_caption.A, inactive_caption.R, inactive_caption.G, inactive_caption.B, "InactiveCaption", KnownColor.InactiveCaption);
+ Color.UpdateKnownColor (inactive_caption_text.A, inactive_caption_text.R, inactive_caption_text.G, inactive_caption_text.B, "InactiveCaptionText", KnownColor.InactiveCaptionText);
+ Color.UpdateKnownColor (info.A, info.R, info.G, info.B, "Info", KnownColor.Info);
+ Color.UpdateKnownColor (info_text.A, info_text.R, info_text.G, info_text.B, "InfoText", KnownColor.InfoText);
+ Color.UpdateKnownColor (menu.A, menu.R, menu.G, menu.B, "Menu", KnownColor.Menu);
+ Color.UpdateKnownColor (menu_text.A, menu_text.R, menu_text.G, menu_text.B, "MenuText", KnownColor.MenuText);
+ Color.UpdateKnownColor (scroll_bar.A, scroll_bar.R, scroll_bar.G, scroll_bar.B, "ScrollBar", KnownColor.ScrollBar);
+ Color.UpdateKnownColor (window.A, window.R, window.G, window.B, "Window", KnownColor.Window);
+ Color.UpdateKnownColor (window_frame.A, window_frame.R, window_frame.G, window_frame.B, "WindowFrame", KnownColor.WindowFrame);
+ Color.UpdateKnownColor (window_text.A, window_text.R, window_text.G, window_text.B, "WindowText", KnownColor.WindowText);
+ }
+
+ static SystemColors () {
+ // If we're on a Win32 platform we should behave like MS and pull the colors
+ if (((int)Environment.OSVersion.Platform != 4) && ((int)Environment.OSVersion.Platform != 128)) {
+ active_border = GetSysColor(GetSysColorIndex.COLOR_ACTIVEBORDER, "ActiveBorder", KnownColor.ActiveBorder);
+ active_caption = GetSysColor(GetSysColorIndex.COLOR_ACTIVECAPTION, "ActiveCaption", KnownColor.ActiveCaption);
+ active_caption_text = GetSysColor(GetSysColorIndex.COLOR_CAPTIONTEXT, "ActiveCaptionText", KnownColor.ActiveCaptionText);
+ app_workspace = GetSysColor(GetSysColorIndex.COLOR_APPWORKSPACE, "AppWorkspace", KnownColor.AppWorkspace);
+ control = GetSysColor(GetSysColorIndex.COLOR_BTNFACE, "Control", KnownColor.Control);
+ control_dark = GetSysColor(GetSysColorIndex.COLOR_BTNSHADOW, "ControlDark", KnownColor.ControlDark);
+ control_dark_dark = GetSysColor(GetSysColorIndex.COLOR_3DDKSHADOW, "ControlDarkDark", KnownColor.ControlDarkDark);
+ control_light = GetSysColor(GetSysColorIndex.COLOR_3DLIGHT, "ControlLight", KnownColor.ControlLight);
+ control_light_light = GetSysColor(GetSysColorIndex.COLOR_BTNHIGHLIGHT, "ControlLightLight", KnownColor.ControlLightLight);
+ control_text = GetSysColor(GetSysColorIndex.COLOR_BTNTEXT, "ControlText", KnownColor.ControlText);
+ desktop = GetSysColor(GetSysColorIndex.COLOR_DESKTOP, "Desktop", KnownColor.Desktop);
+ gray_text = GetSysColor(GetSysColorIndex.COLOR_GRAYTEXT, "GrayText", KnownColor.GrayText);
+ highlight = GetSysColor(GetSysColorIndex.COLOR_HIGHLIGHT, "Highlight", KnownColor.Highlight);
+ highlight_text = GetSysColor(GetSysColorIndex.COLOR_HIGHLIGHTTEXT, "HighlightText", KnownColor.HighlightText);
+ hot_track = GetSysColor(GetSysColorIndex.COLOR_HOTLIGHT, "HotTrack", KnownColor.HotTrack);
+ inactive_border = GetSysColor(GetSysColorIndex.COLOR_INACTIVEBORDER, "InactiveBorder", KnownColor.InactiveBorder);
+ inactive_caption = GetSysColor(GetSysColorIndex.COLOR_INACTIVECAPTION, "InactiveCaption", KnownColor.InactiveCaption);
+ inactive_caption_text = GetSysColor(GetSysColorIndex.COLOR_INACTIVECAPTIONTEXT, "InactiveCaptionText", KnownColor.InactiveCaptionText);
+ info = GetSysColor(GetSysColorIndex.COLOR_INFOBK, "Info", KnownColor.Info);
+ info_text = GetSysColor(GetSysColorIndex.COLOR_INFOTEXT, "InfoText", KnownColor.InfoText);
+ menu = GetSysColor(GetSysColorIndex.COLOR_MENU, "Menu", KnownColor.Menu);
+ menu_text = GetSysColor(GetSysColorIndex.COLOR_MENUTEXT, "MenuText", KnownColor.MenuText);
+ scroll_bar = GetSysColor(GetSysColorIndex.COLOR_SCROLLBAR, "ScrollBar", KnownColor.ScrollBar);
+ window = GetSysColor(GetSysColorIndex.COLOR_WINDOW, "Window", KnownColor.Window);
+ window_frame = GetSysColor(GetSysColorIndex.COLOR_WINDOWFRAME, "WindowFrame", KnownColor.WindowFrame);
+ window_text = GetSysColor(GetSysColorIndex.COLOR_WINDOWTEXT, "WindowText", KnownColor.WindowText);
+ }
+ }
+
+
+ private SystemColors ()
+ {
+ }
+
+ static public Color ActiveBorder
+ {
+ get {
+ return active_border;
+ }
+ }
+
+ static public Color ActiveCaption
+ {
+ get {
+ return active_caption;
+ }
+ }
+
+ static public Color ActiveCaptionText
+ {
+ get {
+ return active_caption_text;
+ }
+ }
+
+ static public Color AppWorkspace
+ {
+ get {
+ return app_workspace;
+ }
+ }
+
+ static public Color Control
+ {
+ get {
+ return control;
+ }
+ }
+
+ static public Color ControlDark
+ {
+ get {
+ return control_dark;
+ }
+ }
+
+ static public Color ControlDarkDark
+ {
+ get {
+ return control_dark_dark;
+ }
+ }
+
+ static public Color ControlLight
+ {
+ get {
+ return control_light;
+ }
+ }
+
+ static public Color ControlLightLight
+ {
+ get {
+ return control_light_light;
+ }
+ }
+
+ static public Color ControlText
+ {
+ get {
+ return control_text;
+ }
+ }
+
+ static public Color Desktop
+ {
+ get {
+ return desktop;
+ }
+ }
+
+ static public Color GrayText
+ {
+ get {
+ return gray_text;
+ }
+ }
+
+ static public Color Highlight
+ {
+ get {
+ return highlight;
+ }
+ }
+
+ static public Color HighlightText
+ {
+ get {
+ return highlight_text;
+ }
+ }
+
+ static public Color HotTrack
+ {
+ get {
+ return hot_track;
+ }
+ }
+
+ static public Color InactiveBorder
+ {
+ get {
+ return inactive_border;
+ }
+ }
+
+ static public Color InactiveCaption
+ {
+ get {
+ return inactive_caption;
+ }
+ }
+
+ static public Color InactiveCaptionText
+ {
+ get {
+ return inactive_caption_text;
+ }
+ }
+
+ static public Color Info
+ {
+ get {
+ return info;
+ }
+ }
+
+ static public Color InfoText
+ {
+ get {
+ return info_text;
+ }
+ }
+
+ static public Color Menu
+ {
+ get {
+ return menu;
+ }
+ }
+
+ static public Color MenuText
+ {
+ get {
+ return menu_text;
+ }
+ }
+
+ static public Color ScrollBar
+ {
+ get {
+ return scroll_bar;
+ }
+ }
+
+ static public Color Window
+ {
+ get {
+ return window;
+ }
+ }
+
+ static public Color WindowFrame
+ {
+ get {
+ return window_frame;
+ }
+ }
+
+ static public Color WindowText
+ {
+ get {
+ return window_text;
+ }
+ }
+#if NET_2_0
+
+ static public Color ButtonFace
+ {
+ get {
+ return button_face;
+ }
+ }
+
+ static public Color ButtonHighlight
+ {
+ get {
+ return button_highlight;
+ }
+ }
+
+ static public Color ButtonShadow
+ {
+ get {
+ return button_shadow;
+ }
+ }
+
+ static public Color GradientActiveCaption
+ {
+ get {
+ return gradient_activecaption;
+ }
+ }
+
+ static public Color GradientInactiveCaption
+ {
+ get {
+ return gradient_inactivecaption;
+ }
+ }
+
+ static public Color MenuBar
+ {
+ get {
+ return menubar;
+ }
+ }
+
+ static public Color MenuHighlight
+ {
+ get {
+ return menu_highlight;
+ }
+ }
+#endif
+
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemColors.jvm.cs b/mcs/class/System.Drawing/System.Drawing/SystemColors.jvm.cs
new file mode 100755
index 00000000000..3c47123330d
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SystemColors.jvm.cs
@@ -0,0 +1,296 @@
+//
+// System.Drawing.SystemColors.cs
+//
+// Authors:
+// Andrew Skiba (andrews@mainsoft.com)
+// Konstantin Triger (kostat@mainsoft.com)
+//
+// Copyright (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using awt = java.awt;
+namespace System.Drawing {
+
+ public sealed class SystemColors
+ {
+ static readonly Color[] SystemColorsCache;
+
+ private SystemColors (){}
+
+ static SystemColors ()
+ {
+ SystemColorsCache = new Color[27]; //enough for all system color indices
+
+ if (Graphics.IsHeadless) {
+ SystemColorsCache[(int)KnownColor.ActiveBorder] = Color.FromArgbSystem (255, 212, 208, 200, "ActiveBorder", KnownColor.ActiveBorder);
+ SystemColorsCache[(int)KnownColor.ActiveCaption] = Color.FromArgbSystem (255, 10, 36, 106, "ActiveCaption", KnownColor.ActiveCaption);
+ SystemColorsCache[(int)KnownColor.ActiveCaptionText] = Color.FromArgbSystem (255, 255, 255, 255, "ActiveCaptionText", KnownColor.ActiveCaptionText);
+ //TODO: find a more close approximation
+ SystemColorsCache[(int)KnownColor.AppWorkspace] = Color.FromArgbSystem (255, 128, 128, 128, "AppWorkspace", KnownColor.AppWorkspace);
+ SystemColorsCache[(int)KnownColor.Control] = Color.FromArgbSystem (255, 212, 208, 200, "Control", KnownColor.Control);
+ SystemColorsCache[(int)KnownColor.ControlDark] = Color.FromArgbSystem (255, 128, 128, 128, "ControlDark", KnownColor.ControlDark);
+ SystemColorsCache[(int)KnownColor.ControlDarkDark] = Color.FromArgbSystem (255, 64, 64, 64, "ControlDarkDark", KnownColor.ControlDarkDark);
+ SystemColorsCache[(int)KnownColor.ControlLight] = Color.FromArgbSystem (255, 212, 208, 200, "ControlLight", KnownColor.ControlLight);
+ SystemColorsCache[(int)KnownColor.ControlLightLight] = Color.FromArgbSystem (255, 255, 255, 255, "ControlLightLight", KnownColor.ControlLightLight);
+ SystemColorsCache[(int)KnownColor.ControlText] = Color.FromArgbSystem (255, 0, 0, 0, "ControlText", KnownColor.ControlText);
+ SystemColorsCache[(int)KnownColor.Desktop] = Color.FromArgbSystem (255, 58, 110, 165, "Desktop", KnownColor.Desktop);
+ SystemColorsCache[(int)KnownColor.GrayText] = Color.FromArgbSystem (255, 128, 128, 128, "GrayText", KnownColor.GrayText);
+ SystemColorsCache[(int)KnownColor.Highlight] = Color.FromArgbSystem (255, 10, 36, 106, "Highlight", KnownColor.Highlight);
+ SystemColorsCache[(int)KnownColor.HighlightText] = Color.FromArgbSystem (255, 255, 255, 255, "HighlightText", KnownColor.HighlightText);
+ //TODO: find a more close approximation
+ SystemColorsCache[(int)KnownColor.HotTrack] = Color.FromArgbSystem (255, 0, 0, 128, "HotTrack", KnownColor.HotTrack);
+ SystemColorsCache[(int)KnownColor.InactiveBorder] = Color.FromArgbSystem (255, 212, 208, 200, "InactiveBorder", KnownColor.InactiveBorder);
+ SystemColorsCache[(int)KnownColor.InactiveCaption] = Color.FromArgbSystem (255, 128, 128, 128, "InactiveCaption", KnownColor.InactiveCaption);
+ SystemColorsCache[(int)KnownColor.InactiveCaptionText] = Color.FromArgbSystem (255, 212, 208, 200, "InactiveCaptionText", KnownColor.InactiveCaptionText);
+ SystemColorsCache[(int)KnownColor.Info] = Color.FromArgbSystem (255, 255, 255, 225, "Info", KnownColor.Info);
+ SystemColorsCache[(int)KnownColor.InfoText] = Color.FromArgbSystem (255, 0, 0, 0, "InfoText", KnownColor.InfoText);
+ SystemColorsCache[(int)KnownColor.Menu] = Color.FromArgbSystem (255, 212, 208, 200, "Menu", KnownColor.Menu);
+ SystemColorsCache[(int)KnownColor.MenuText] = Color.FromArgbSystem (255, 0, 0, 0, "MenuText", KnownColor.MenuText);
+ SystemColorsCache[(int)KnownColor.ScrollBar] = Color.FromArgbSystem (255, 212, 208, 200, "ScrollBar", KnownColor.ScrollBar);
+ SystemColorsCache[(int)KnownColor.Window] = Color.FromArgbSystem (255, 255, 255, 255, "Window", KnownColor.Window);
+ SystemColorsCache[(int)KnownColor.WindowFrame] = Color.FromArgbSystem (255, 0, 0, 0, "WindowFrame", KnownColor.WindowFrame);
+ SystemColorsCache[(int)KnownColor.WindowText] = Color.FromArgbSystem (255, 0, 0, 0, "WindowText", KnownColor.WindowText);
+ }
+ else {
+ SystemColorsCache[(int)KnownColor.ActiveBorder] = FromNativeColor (awt.SystemColor.activeCaptionBorder, "ActiveBorder", KnownColor.ActiveBorder);
+ SystemColorsCache[(int)KnownColor.ActiveCaption] = FromNativeColor (awt.SystemColor.activeCaption, "ActiveCaption", KnownColor.ActiveCaption);
+ SystemColorsCache[(int)KnownColor.ActiveCaptionText] = FromNativeColor (awt.SystemColor.activeCaptionText, "ActiveCaptionText", KnownColor.ActiveCaptionText);
+ //TODO: find a more close approximation
+ SystemColorsCache[(int)KnownColor.AppWorkspace] = FromNativeColor (awt.SystemColor.desktop, "AppWorkspace", KnownColor.AppWorkspace);
+ SystemColorsCache[(int)KnownColor.Control] = FromNativeColor (awt.SystemColor.control, "Control", KnownColor.Control);
+ SystemColorsCache[(int)KnownColor.ControlDark] = FromNativeColor (awt.SystemColor.controlShadow, "ControlDark", KnownColor.ControlDark);
+ SystemColorsCache[(int)KnownColor.ControlDarkDark] = FromNativeColor (awt.SystemColor.controlDkShadow, "ControlDarkDark", KnownColor.ControlDarkDark);
+ SystemColorsCache[(int)KnownColor.ControlLight] = FromNativeColor (awt.SystemColor.controlHighlight, "ControlLight", KnownColor.ControlLight);
+ SystemColorsCache[(int)KnownColor.ControlLightLight] = FromNativeColor (awt.SystemColor.controlLtHighlight, "ControlLightLight", KnownColor.ControlLightLight);
+ SystemColorsCache[(int)KnownColor.ControlText] = FromNativeColor (awt.SystemColor.controlText, "ControlText", KnownColor.ControlText);
+ SystemColorsCache[(int)KnownColor.Desktop] = FromNativeColor (awt.SystemColor.desktop, "Desktop", KnownColor.Desktop);
+ SystemColorsCache[(int)KnownColor.GrayText] = FromNativeColor (awt.SystemColor.textInactiveText, "GrayText", KnownColor.GrayText);
+ SystemColorsCache[(int)KnownColor.Highlight] = FromNativeColor (awt.SystemColor.textHighlight, "Highlight", KnownColor.Highlight);
+ SystemColorsCache[(int)KnownColor.HighlightText] = FromNativeColor (awt.SystemColor.textHighlightText, "HighlightText", KnownColor.HighlightText);
+ //TODO: find a more close approximation
+ SystemColorsCache[(int)KnownColor.HotTrack] = FromNativeColor (awt.SystemColor.textText, "HotTrack", KnownColor.HotTrack);
+ SystemColorsCache[(int)KnownColor.InactiveBorder] = FromNativeColor (awt.SystemColor.inactiveCaptionBorder, "InactiveBorder", KnownColor.InactiveBorder);
+ SystemColorsCache[(int)KnownColor.InactiveCaption] = FromNativeColor (awt.SystemColor.inactiveCaption, "InactiveCaption", KnownColor.InactiveCaption);
+ SystemColorsCache[(int)KnownColor.InactiveCaptionText] = FromNativeColor (awt.SystemColor.inactiveCaptionText, "InactiveCaptionText", KnownColor.InactiveCaptionText);
+ SystemColorsCache[(int)KnownColor.Info] = FromNativeColor (awt.SystemColor.info, "Info", KnownColor.Info);
+ SystemColorsCache[(int)KnownColor.InfoText] = FromNativeColor (awt.SystemColor.infoText, "InfoText", KnownColor.InfoText);
+ SystemColorsCache[(int)KnownColor.Menu] = FromNativeColor (awt.SystemColor.menu, "Menu", KnownColor.Menu);
+ SystemColorsCache[(int)KnownColor.MenuText] = FromNativeColor (awt.SystemColor.menuText, "MenuText", KnownColor.MenuText);
+ SystemColorsCache[(int)KnownColor.ScrollBar] = FromNativeColor (awt.SystemColor.scrollbar, "ScrollBar", KnownColor.ScrollBar);
+ SystemColorsCache[(int)KnownColor.Window] = FromNativeColor (awt.SystemColor.window, "Window", KnownColor.Window);
+ SystemColorsCache[(int)KnownColor.WindowFrame] = FromNativeColor (awt.SystemColor.windowBorder, "WindowFrame", KnownColor.WindowFrame);
+ SystemColorsCache[(int)KnownColor.WindowText] = FromNativeColor (awt.SystemColor.windowText, "WindowText", KnownColor.WindowText);
+ }
+ }
+
+ static private Color FromNativeColor (
+ awt.Color awtColor, string name, KnownColor knownColor) {
+ return Color.FromArgbSystem (awtColor.getAlpha(),
+ awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue(),
+ name, knownColor);
+ }
+
+ static public Color ActiveBorder
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.ActiveBorder];
+ }
+ }
+
+ static public Color ActiveCaption
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.ActiveCaption];
+ }
+ }
+
+ static public Color ActiveCaptionText
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.ActiveCaptionText];
+ }
+ }
+
+ static public Color AppWorkspace
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.AppWorkspace];
+ }
+ }
+
+ static public Color Control
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.Control];
+ }
+ }
+
+ static public Color ControlDark
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.ControlDark];
+ }
+ }
+
+ static public Color ControlDarkDark
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.ControlDarkDark];
+ }
+ }
+
+ static public Color ControlLight
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.ControlLight];
+ }
+ }
+
+ static public Color ControlLightLight
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.ControlLightLight];
+ }
+ }
+
+ static public Color ControlText
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.ControlText];
+ }
+ }
+
+ static public Color Desktop
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.Desktop];
+ }
+ }
+
+ static public Color GrayText
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.GrayText];
+ }
+ }
+
+ static public Color Highlight
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.Highlight];
+ }
+ }
+
+ static public Color HighlightText
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.HighlightText];
+ }
+ }
+
+ static public Color HotTrack
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.HotTrack];
+ }
+ }
+
+ static public Color InactiveBorder
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.InactiveBorder];
+ }
+ }
+
+ static public Color InactiveCaption
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.InactiveCaption];
+ }
+ }
+
+ static public Color InactiveCaptionText
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.InactiveCaptionText];
+ }
+ }
+
+ static public Color Info
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.Info];
+ }
+ }
+
+ static public Color InfoText
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.InfoText];
+ }
+ }
+
+ static public Color Menu
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.Menu];
+ }
+ }
+
+ static public Color MenuText
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.MenuText];
+ }
+ }
+
+ static public Color ScrollBar
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.ScrollBar];
+ }
+ }
+
+ static public Color Window
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.Window];
+ }
+ }
+
+ static public Color WindowFrame
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.WindowFrame];
+ }
+ }
+
+ static public Color WindowText
+ {
+ get {
+ return SystemColorsCache[(int)KnownColor.WindowText];
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemFonts.cs b/mcs/class/System.Drawing/System.Drawing/SystemFonts.cs
new file mode 100644
index 00000000000..1b1a9ed337e
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SystemFonts.cs
@@ -0,0 +1,170 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+//
+// Jordi Mas i Hernandez <jordimash@gmail.com>
+//
+//
+
+#if NET_2_0
+
+using System;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+ public sealed class SystemFonts
+ {
+ private static Font caption = null;
+ private static Font defaultfnt = null;
+ private static Font dialog = null;
+ private static Font icon = null;
+ private static Font menu = null;
+ private static Font message = null;
+ private static Font smallcaption = null;
+ private static Font status = null;
+
+ static SystemFonts ()
+ {
+
+ }
+
+ private SystemFonts()
+ {
+
+ }
+
+ public static Font GetFontByName (string name)
+ {
+ if (name == "CaptionFont")
+ return CaptionFont;
+
+ if (name == "DefaultFont")
+ return DefaultFont;
+
+ if (name == "DialogFont")
+ return DialogFont;
+
+ if (name == "IconTitleFont")
+ return IconTitleFont;
+
+ if (name == "MenuFont")
+ return MenuFont;
+
+ if (name == "MessageBoxFont")
+ return MessageBoxFont;
+
+ if (name == "SmallCaptionFont")
+ return SmallCaptionFont;
+
+ if (name == "StatusFont")
+ return StatusFont;
+
+ return null;
+ }
+
+ public static Font CaptionFont {
+ get {
+ if (caption == null) {
+ caption = new Font ("Microsoft Sans Serif", 11);
+ caption.SysFontName = "CaptionFont";
+ }
+ return caption;
+ }
+ }
+
+ public static Font DefaultFont {
+ get {
+ if (defaultfnt == null) {
+ defaultfnt = new Font ("Microsoft Sans Serif", 8.25f);
+ defaultfnt.SysFontName = "DefaultFont";
+ }
+ return defaultfnt;
+ }
+ }
+
+ public static Font DialogFont {
+ get {
+ if (dialog == null) {
+ dialog = new Font ("Tahoma", 8);
+ dialog.SysFontName = "DialogFont";
+ }
+ return dialog;
+ }
+ }
+
+ public static Font IconTitleFont {
+ get {
+ if (icon == null) {
+ icon = new Font ("Microsoft Sans Serif", 11);
+ icon.SysFontName = "IconTitleFont";
+ }
+ return icon;
+ }
+ }
+
+ public static Font MenuFont {
+ get {
+ if (menu == null) {
+ menu = new Font ("Microsoft Sans Serif", 11);
+ menu.SysFontName = "MenuFont";
+ }
+ return menu;
+ }
+ }
+
+ public static Font MessageBoxFont {
+ get {
+ if (message == null) {
+ message = new Font ("Microsoft Sans Serif", 11);
+ message.SysFontName = "MessageBoxFont";
+ }
+ return message;
+ }
+ }
+
+ public static Font SmallCaptionFont {
+ get {
+ if (smallcaption == null) {
+ smallcaption = new Font ("Microsoft Sans Serif", 11);
+ smallcaption.SysFontName = "SmallCaptionFont";
+ }
+ return smallcaption;
+ }
+ }
+
+ public static Font StatusFont {
+ get {
+ if (status == null) {
+ status = new Font ("Microsoft Sans Serif", 11);
+ status.SysFontName = "StatusFont";
+ }
+ return status;
+ }
+ }
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemIcons.cs b/mcs/class/System.Drawing/System.Drawing/SystemIcons.cs
new file mode 100644
index 00000000000..04f9fbc03b8
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SystemIcons.cs
@@ -0,0 +1,61 @@
+//
+// System.Drawing.SystemIcons.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2002 Ximian, Inc
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing
+{
+ [MonoTODO ("not implemented")]
+ public sealed class SystemIcons
+ {
+ private SystemIcons()
+ {
+ }
+
+ public static Icon Application { get { return LoadIcon();} }
+ public static Icon Asterisk { get { return LoadIcon();} }
+ public static Icon Error { get { return LoadIcon();} }
+ public static Icon Exclamation { get { return LoadIcon();} }
+ public static Icon Hand { get { return LoadIcon();} }
+ public static Icon Information { get { return LoadIcon();} }
+ public static Icon Question { get { return LoadIcon();} }
+ public static Icon Warning { get { return LoadIcon();} }
+ public static Icon WinLogo { get { return LoadIcon();} }
+
+ [MonoTODO]
+ private static Icon LoadIcon ()
+ {
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemIcons.jvm.cs b/mcs/class/System.Drawing/System.Drawing/SystemIcons.jvm.cs
new file mode 100644
index 00000000000..e3fdbade025
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SystemIcons.jvm.cs
@@ -0,0 +1,73 @@
+//
+// System.Drawing.systemIcons.cs
+//
+// Authors:
+// Vladimir Krasnov (vladimirk@mainsoft.com)
+// Konstantin Triger (kostat@mainsoft.com)
+//
+// Copyright (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Configuration;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Reflection;
+
+namespace System.Drawing {
+ public sealed class SystemIcons {
+ static readonly Icon[] systemIcons;
+
+ enum IconName {
+ Application, Asterisk, Error,
+ Exclamation, Hand, Information,
+ Question, Warning, WinLogo
+ }
+
+ static SystemIcons() {
+
+ Type nameType = typeof(IconName);
+ string [] iconNames = Enum.GetNames(nameType);
+ systemIcons = new Icon[iconNames.Length];
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ for (int i = 0; i < iconNames.Length; i++)
+ systemIcons[(int)(IconName)Enum.Parse(nameType, iconNames[i])] =
+ new Icon(assembly.GetManifestResourceStream(String.Format("System.Drawing.Assembly.{0}.ico", iconNames[i])));
+ }
+
+ private SystemIcons() {
+ }
+
+ public static Icon Application { get { return systemIcons[(int)IconName.Application];} }
+ public static Icon Asterisk { get { return systemIcons[(int)IconName.Asterisk];} }
+ public static Icon Error { get { return systemIcons[(int)IconName.Error];} }
+ public static Icon Exclamation { get { return systemIcons[(int)IconName.Exclamation];} }
+ public static Icon Hand { get { return systemIcons[(int)IconName.Hand];} }
+ public static Icon Information { get { return systemIcons[(int)IconName.Information];} }
+ public static Icon Question { get { return systemIcons[(int)IconName.Question];} }
+ public static Icon Warning { get { return systemIcons[(int)IconName.Warning];} }
+ public static Icon WinLogo { get { return systemIcons[(int)IconName.WinLogo];} }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemPens.cs b/mcs/class/System.Drawing/System.Drawing/SystemPens.cs
new file mode 100644
index 00000000000..e10091a46fd
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/SystemPens.cs
@@ -0,0 +1,456 @@
+//
+// System.Drawing.SystemPens.cs
+//
+// Authors:
+// Miguel de Icaza (miguel@ximian.com)
+// Ravindra (rkumar@novell.com)
+// Jordi Mas i Hernandez <jordimash@gmail.com>
+//
+// Copyright (C) 2003-2005 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing
+{
+ public sealed class SystemPens
+ {
+ static private Pen active_caption_text;
+ static private Pen control;
+ static private Pen control_dark;
+ static private Pen control_dark_dark;
+ static private Pen control_light;
+ static private Pen control_light_light;
+ static private Pen control_text;
+ static private Pen gray_text;
+ static private Pen highlight;
+ static private Pen highlight_text;
+ static private Pen inactive_caption_text;
+ static private Pen info_text;
+ static private Pen menu_text;
+ static private Pen window_frame;
+ static private Pen window_text;
+ static private Pen active_border;
+ static private Pen active_caption;
+ static private Pen app_workspace;
+ static private Pen button_face;
+ static private Pen button_highlight;
+ static private Pen button_shadow;
+ static private Pen desktop;
+ static private Pen gradient_activecaption;
+ static private Pen gradient_inactivecaption;
+ static private Pen hot_track;
+ static private Pen inactive_border;
+ static private Pen inactive_caption;
+ static private Pen info;
+ static private Pen menu;
+ static private Pen menu_bar;
+ static private Pen menu_highlight;
+ static private Pen scroll_bar;
+ static private Pen window;
+
+ private SystemPens () { }
+
+ public static Pen ActiveCaptionText {
+ get {
+ if (active_caption_text == null) {
+ active_caption_text = new Pen (SystemColors.ActiveCaptionText);
+ active_caption_text.isModifiable = false;
+ }
+
+ return active_caption_text;
+ }
+ }
+
+ public static Pen Control {
+ get {
+ if (control == null) {
+ control = new Pen (SystemColors.Control);
+ control.isModifiable = false;
+ }
+
+ return control;
+ }
+ }
+
+ public static Pen ControlDark {
+ get {
+ if (control_dark == null) {
+ control_dark = new Pen (SystemColors.ControlDark);
+ control_dark.isModifiable = false;
+ }
+
+ return control_dark;
+ }
+ }
+
+ public static Pen ControlDarkDark {
+ get {
+ if (control_dark_dark == null) {
+ control_dark_dark = new Pen (SystemColors.ControlDarkDark);
+ control_dark_dark.isModifiable = false;
+ }
+
+ return control_dark_dark;
+ }
+ }
+
+ public static Pen ControlLight {
+ get {
+ if (control_light == null) {
+ control_light = new Pen (SystemColors.ControlLight);
+ control_light.isModifiable = false;
+ }
+
+ return control_light;
+ }
+ }
+
+ public static Pen ControlLightLight {
+ get {
+ if (control_light_light == null) {
+ control_light_light = new Pen (SystemColors.ControlLightLight);
+ control_light_light.isModifiable = false;
+ }
+
+ return control_light_light;
+ }
+ }
+
+ public static Pen ControlText {
+ get {
+ if (control_text == null) {
+ control_text = new Pen (SystemColors.ControlText);
+ control_text.isModifiable = false;
+ }
+
+ return control_text;
+ }
+ }
+
+ public static Pen GrayText {
+ get {
+ if (gray_text == null) {
+ gray_text = new Pen (SystemColors.GrayText);
+ gray_text.isModifiable = false;
+ }
+
+ return gray_text;
+ }
+ }
+
+ public static Pen Highlight {
+ get {
+ if (highlight == null) {
+ highlight = new Pen (SystemColors.Highlight);
+ highlight.isModifiable = false;
+ }
+
+ return highlight;
+ }
+ }
+
+ public static Pen HighlightText {
+ get {
+ if (highlight_text == null) {
+ highlight_text = new Pen (SystemColors.HighlightText);
+ highlight_text.isModifiable = false;
+ }
+
+ return highlight_text;
+ }
+ }
+
+ public static Pen InactiveCaptionText {
+ get {
+ if (inactive_caption_text == null) {
+ inactive_caption_text = new Pen (SystemColors.InactiveCaptionText);
+ inactive_caption_text.isModifiable = false;
+ }
+
+ return inactive_caption_text;
+ }
+ }
+
+ public static Pen InfoText {
+ get {
+ if (info_text == null) {
+ info_text = new Pen (SystemColors.InfoText);
+ info_text.isModifiable = false;
+ }
+
+ return info_text;
+ }
+ }
+
+ public static Pen MenuText {
+ get {
+ if (menu_text == null) {
+ menu_text = new Pen (SystemColors.MenuText);
+ menu_text.isModifiable = false;
+ }
+
+ return menu_text;
+ }
+ }
+
+ public static Pen WindowFrame {
+ get {
+ if (window_frame == null) {
+ window_frame = new Pen (SystemColors.WindowFrame);
+ window_frame.isModifiable = false;
+ }
+
+ return window_frame;
+ }
+ }
+
+ public static Pen WindowText {
+ get {
+ if (window_text == null) {
+ window_text = new Pen (SystemColors.WindowText);
+ window_text.isModifiable = false;
+ }
+
+ return window_text;
+ }
+ }
+
+ public static Pen FromSystemColor (Color c)
+ {
+ if (c.IsSystemColor) {
+ Pen newPen = new Pen (c);
+ newPen.isModifiable = false;
+ return newPen;
+ }
+
+ String message = String.Format ("The color {0} is not a system color.", c);
+ throw new ArgumentException (message);
+ }
+
+#if NET_2_0
+ public static Pen ActiveBorder {
+ get {
+ if (active_border == null) {
+ active_border = new Pen (SystemColors.ActiveBorder);
+ active_border.isModifiable = false;
+ }
+
+ return active_border;
+ }
+ }
+
+ public static Pen ActiveCaption {
+ get {
+ if (active_caption == null) {
+ active_caption = new Pen (SystemColors.ActiveCaption);
+ active_caption.isModifiable = false;
+ }
+
+ return active_caption;
+ }
+ }
+
+ public static Pen AppWorkspace {
+ get {
+ if (app_workspace == null) {
+ app_workspace = new Pen (SystemColors.AppWorkspace);
+ app_workspace.isModifiable = false;
+ }
+
+ return app_workspace;
+ }
+ }
+
+ public static Pen ButtonFace {
+ get {
+ if (button_face == null) {
+ button_face = new Pen (SystemColors.ButtonFace);
+ button_face.isModifiable = false;
+ }
+
+ return button_face;
+ }
+ }
+
+ public static Pen ButtonHighlight {
+ get {
+ if (button_highlight == null) {
+ button_highlight = new Pen (SystemColors.ButtonHighlight);
+ button_highlight.isModifiable = false;
+ }
+
+ return button_highlight;
+ }
+ }
+
+ public static Pen ButtonShadow {
+ get {
+ if (button_shadow == null) {
+ button_shadow = new Pen (SystemColors.ButtonShadow);
+ button_shadow.isModifiable = false;
+ }
+
+ return button_shadow;
+ }
+ }
+
+ public static Pen Desktop {
+ get {
+ if (desktop == null) {
+ desktop = new Pen (SystemColors.Desktop);
+ desktop.isModifiable = false;
+ }
+
+ return desktop;
+ }
+ }
+
+ public static Pen GradientActiveCaption {
+ get {
+ if (gradient_activecaption == null) {
+ gradient_activecaption = new Pen (SystemColors.GradientActiveCaption);
+ gradient_activecaption.isModifiable = false;
+ }
+
+ return gradient_activecaption;
+ }
+ }
+
+ public static Pen GradientInactiveCaption {
+ get {
+ if (gradient_inactivecaption == null) {
+ gradient_inactivecaption = new Pen (SystemColors.GradientInactiveCaption);
+ gradient_inactivecaption.isModifiable = false;
+ }
+
+ return gradient_inactivecaption;
+ }
+ }
+
+ public static Pen HotTrack {
+ get {
+ if (hot_track == null) {
+ hot_track = new Pen (SystemColors.HotTrack);
+ hot_track.isModifiable = false;
+ }
+
+ return hot_track;
+ }
+ }
+
+ public static Pen InactiveBorder {
+ get {
+ if (inactive_border == null) {
+ inactive_border = new Pen (SystemColors.InactiveBorder);
+ inactive_border.isModifiable = false;
+ }
+
+ return inactive_border;
+ }
+ }
+
+ public static Pen InactiveCaption {
+ get {
+ if (inactive_caption == null) {
+ inactive_caption = new Pen (SystemColors.InactiveCaption);
+ inactive_caption.isModifiable = false;
+ }
+
+ return inactive_caption;
+ }
+ }
+
+ public static Pen Info {
+ get {
+ if (info == null) {
+ info = new Pen (SystemColors.Info);
+ info.isModifiable = false;
+ }
+
+ return info;
+ }
+ }
+
+ public static Pen Menu {
+ get {
+ if (menu == null) {
+ menu = new Pen (SystemColors.Menu);
+ menu.isModifiable = false;
+ }
+
+ return menu;
+ }
+ }
+
+ public static Pen MenuBar {
+ get {
+ if (menu_bar == null) {
+ menu_bar = new Pen (SystemColors.MenuBar);
+ menu_bar.isModifiable = false;
+ }
+
+ return menu_bar;
+ }
+ }
+
+ public static Pen MenuHighlight {
+ get {
+ if (menu_highlight == null) {
+ menu_highlight = new Pen (SystemColors.MenuHighlight);
+ menu_highlight.isModifiable = false;
+ }
+
+ return menu_highlight;
+ }
+ }
+
+ public static Pen ScrollBar {
+ get {
+ if (scroll_bar == null) {
+ scroll_bar = new Pen (SystemColors.ScrollBar);
+ scroll_bar.isModifiable = false;
+ }
+
+ return scroll_bar;
+ }
+ }
+
+ public static Pen Window {
+ get {
+ if (window == null) {
+ window = new Pen (SystemColors.Window);
+ window.isModifiable = false;
+ }
+
+ return window;
+ }
+ }
+#endif
+
+ }
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing/TextureBrush.cs b/mcs/class/System.Drawing/System.Drawing/TextureBrush.cs
new file mode 100644
index 00000000000..efd5cbc8399
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/TextureBrush.cs
@@ -0,0 +1,214 @@
+//
+// System.Drawing.TextureBrush.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) 2002 Ximian, Inc
+// (C) 2004 Novell, Inc.
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+namespace System.Drawing
+{
+ /// <summary>
+ /// Summary description for TextureBrush.
+ /// </summary>
+ public sealed class TextureBrush : Brush
+ {
+ private Image image;
+
+ internal TextureBrush (IntPtr ptr) : base (ptr)
+ {
+ // get image from IntPtr
+ // image could be Bitmap or Metafile
+ image = Image;
+ }
+
+ public TextureBrush (Image image) : this (image, WrapMode.Tile)
+ {
+ }
+
+ public TextureBrush (Image image, Rectangle dstRect)
+ {
+ this.image = image;
+ Status status = GDIPlus.GdipCreateTextureIAI (image.nativeObject, IntPtr.Zero, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public TextureBrush (Image image, RectangleF dstRect)
+ {
+ this.image = image;
+ Status status = GDIPlus.GdipCreateTextureIA (image.nativeObject, IntPtr.Zero, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public TextureBrush (Image image, WrapMode wrapMode)
+ {
+ this.image = image;
+ Status status = GDIPlus.GdipCreateTexture (image.nativeObject, wrapMode, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public TextureBrush (Image image, Rectangle dstRect, ImageAttributes imageAttr)
+ {
+ this.image = image;
+ Status status = GDIPlus.GdipCreateTextureIAI (image.nativeObject, imageAttr.NativeObject, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public TextureBrush (Image image, RectangleF dstRect, ImageAttributes imageAttr)
+ {
+ this.image = image;
+ Status status = GDIPlus.GdipCreateTextureIA (image.nativeObject, imageAttr.NativeObject, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public TextureBrush (Image image, WrapMode wrapMode, Rectangle dstRect)
+ {
+ this.image = image;
+ Status status = GDIPlus.GdipCreateTexture2I (image.nativeObject, wrapMode, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public TextureBrush (Image image, WrapMode wrapMode, RectangleF dstRect)
+ {
+ this.image = image;
+ Status status = GDIPlus.GdipCreateTexture2 (image.nativeObject, wrapMode, dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height, out nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ // properties
+
+ public Image Image {
+ get {
+ if (image == null) {
+ IntPtr img;
+ Status status = GDIPlus.GdipGetTextureImage (nativeObject, out img);
+ GDIPlus.CheckStatus (status);
+ image = new Bitmap (img);
+ }
+ return image;
+ }
+ }
+
+ public Matrix Transform {
+ get {
+ Matrix matrix = new Matrix ();
+ Status status = GDIPlus.GdipGetTextureTransform (nativeObject, matrix.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+
+ return matrix;
+ }
+ set {
+ Status status = GDIPlus.GdipSetTextureTransform (nativeObject, value.nativeMatrix);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ public WrapMode WrapMode {
+ get {
+ WrapMode mode = WrapMode.Tile;
+ Status status = GDIPlus.GdipGetTextureWrapMode (nativeObject, out mode);
+ GDIPlus.CheckStatus (status);
+ return mode;
+ }
+ set {
+ Status status = GDIPlus.GdipSetTextureWrapMode (nativeObject, value);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+
+ // public methods
+
+ public override object Clone ()
+ {
+ IntPtr clonePtr;
+ Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
+ GDIPlus.CheckStatus (status);
+
+ TextureBrush clone = new TextureBrush (clonePtr);
+ if (image != null)
+ clone.image = (Image) image.Clone ();
+
+ return clone;
+ }
+
+ public void MultiplyTransform (Matrix matrix)
+ {
+ MultiplyTransform (matrix, MatrixOrder.Prepend);
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipMultiplyTextureTransform (nativeObject, matrix.nativeMatrix, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ResetTransform ()
+ {
+ Status status = GDIPlus.GdipResetTextureTransform (nativeObject);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void RotateTransform (float angle)
+ {
+ RotateTransform (angle, MatrixOrder.Prepend);
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipRotateTextureTransform (nativeObject, angle, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void ScaleTransform (float sx, float sy)
+ {
+ ScaleTransform (sx, sy, MatrixOrder.Prepend);
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipScaleTextureTransform (nativeObject, sx, sy, order);
+ GDIPlus.CheckStatus (status);
+ }
+
+ public void TranslateTransform (float dx, float dy)
+ {
+ TranslateTransform (dx, dy, MatrixOrder.Prepend);
+ }
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order)
+ {
+ Status status = GDIPlus.GdipTranslateTextureTransform (nativeObject, dx, dy, order);
+ GDIPlus.CheckStatus (status);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/TextureBrush.jvm.cs b/mcs/class/System.Drawing/System.Drawing/TextureBrush.jvm.cs
new file mode 100644
index 00000000000..f940dfb7423
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/TextureBrush.jvm.cs
@@ -0,0 +1,226 @@
+//
+// System.Drawing.TextureBrush.cs
+//
+// Author:
+// Dennis Hayes (dennish@Raytek.com)
+// Ravindra (rkumar@novell.com)
+//
+// (C) 2002 Ximian, Inc
+// (C) 2004 Novell, Inc.
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+
+using awt = java.awt;
+using geom = java.awt.geom;
+using image = java.awt.image;
+
+namespace System.Drawing {
+ /// <summary>
+ /// Summary description for TextureBrush.
+ /// </summary>
+ public sealed class TextureBrush : Brush {
+ readonly awt.TexturePaint _nativeObject;
+ RectangleF _sourceRectangle;
+ Image _texture = null;
+ WrapMode _wrapMode;
+
+ protected override java.awt.Paint NativeObject {
+ get {
+ return _nativeObject;
+ }
+ }
+
+ #region ctors
+
+ public TextureBrush (Image image) : this (image, WrapMode.Tile) {
+ }
+
+ public TextureBrush (Image image, WrapMode wrapMode) :
+ this( image, wrapMode, new RectangleF(0, 0, image.Width, image.Height )){
+ }
+
+ public TextureBrush (Image image, Rectangle dstRect) :
+ this( image, WrapMode.Tile, dstRect ) {
+ }
+
+ public TextureBrush (Image image, RectangleF dstRect) :
+ this( image, WrapMode.Tile, dstRect ) {
+ }
+
+ [MonoTODO]
+ public TextureBrush (Image image, Rectangle dstRect, ImageAttributes imageAttr) : this( image, dstRect ) {
+ // TBD: Implement ImageAttributes
+ }
+
+ [MonoTODO]
+ public TextureBrush (Image image, RectangleF dstRect, ImageAttributes imageAttr) : this( image, dstRect ) {
+ // TBD: Implement ImageAttributes
+ }
+
+ public TextureBrush (Image image, WrapMode wrapMode, Rectangle dstRect) :
+ this( image, wrapMode, new RectangleF(dstRect.X, dstRect.Y, dstRect.Width, dstRect.Height )){
+ }
+
+ [MonoTODO]
+ public TextureBrush (Image image, WrapMode wrapMode, RectangleF dstRect) {
+ // TBD: check if not metafile
+ _sourceRectangle = dstRect;
+ _texture = (Image)((Bitmap)image).Clone(dstRect, image.PixelFormat);
+ _wrapMode = wrapMode;
+
+ if (wrapMode != Drawing2D.WrapMode.Tile)
+ image = CreateWrappedImage(_texture, wrapMode);
+ else
+ image = _texture;
+
+ _nativeObject = new awt.TexturePaint((image.BufferedImage)image.NativeObject.CurrentImage.NativeImage,
+ new geom.Rectangle2D.Float(0, 0, image.Width, image.Height));
+ }
+
+ #endregion
+
+ #region CreateWrappedImage
+
+ private Image CreateWrappedImage(Image image, WrapMode wrapMode) {
+ Image b = null;
+ Graphics g = null;
+
+ switch (wrapMode) {
+ case Drawing2D.WrapMode.TileFlipX :
+ b = new Bitmap(image.Width * 2, image.Height);
+ g = Graphics.FromImage( b );
+ g.DrawImage(image, new Matrix());
+ g.DrawImage(image, new Matrix(-1, 0, 0, 1, image.Width * 2 - 1, 0));
+ break;
+ case Drawing2D.WrapMode.TileFlipY :
+ b = new Bitmap(image.Width, image.Height * 2);
+ g = Graphics.FromImage( b );
+ g.DrawImage(image, new Matrix());
+ g.DrawImage(image, new Matrix(1, 0, 0, -1, 0, image.Height * 2 - 1));
+ break;
+ case Drawing2D.WrapMode.TileFlipXY :
+ b = new Bitmap(image.Width * 2, image.Height * 2);
+ g = Graphics.FromImage( b );
+ g.DrawImage(image, new Matrix());
+ g.DrawImage(image, new Matrix(-1, 0, 0, 1, image.Width * 2 - 1, 0));
+ g.DrawImage(image, new Matrix(1, 0, 0, -1, 0, image.Height * 2 - 1));
+ g.DrawImage(image, new Matrix(-1, 0, 0, -1, image.Width * 2 - 1, image.Height * 2 - 1));
+ break;
+ case Drawing2D.WrapMode.Clamp :
+ // TBD: Implement WrapMode.Clamp
+ return image;
+ default :
+ b = image;
+ break;
+ }
+
+ return b;
+ }
+
+ #endregion
+
+ #region properties
+
+ public Image Image {
+ get {
+ return (Image)_texture.Clone();
+ }
+ }
+
+ public Matrix Transform {
+ get {
+ return BrushTransform;
+ }
+ set {
+ BrushTransform = value;
+ }
+ }
+
+ [MonoTODO]
+ public WrapMode WrapMode {
+ get {
+ return _wrapMode;
+ }
+ set {
+ _wrapMode = value;
+ }
+ }
+
+ #endregion
+
+ #region public methods
+
+ public override object Clone () {
+ TextureBrush copy = (TextureBrush)InternalClone();
+
+ if (_texture != null)
+ copy._texture = (Image)_texture.Clone();
+
+ return copy;
+ }
+
+ public void MultiplyTransform (Matrix matrix) {
+ base.BrushMultiplyTransform( matrix );
+ }
+
+ public void MultiplyTransform (Matrix matrix, MatrixOrder order) {
+ base.BrushMultiplyTransform( matrix, order );
+ }
+
+ public void ResetTransform () {
+ base.BrushResetTransform();
+ }
+
+ public void RotateTransform (float angle) {
+ base.BrushRotateTransform( angle );
+ }
+
+ public void RotateTransform (float angle, MatrixOrder order) {
+ base.BrushRotateTransform( angle, order );
+ }
+
+ public void ScaleTransform (float sx, float sy) {
+ base.BrushScaleTransform( sx, sy );
+ }
+
+ public void ScaleTransform (float sx, float sy, MatrixOrder order) {
+ base.BrushScaleTransform( sx, sy, order );
+ }
+
+ public void TranslateTransform (float dx, float dy) {
+ base.BrushTranslateTransform( dx, dy );
+ }
+
+ public void TranslateTransform (float dx, float dy, MatrixOrder order) {
+ base.BrushTranslateTransform( dx, dy, order );
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/ToolboxBitmapAttribute.cs b/mcs/class/System.Drawing/System.Drawing/ToolboxBitmapAttribute.cs
new file mode 100644
index 00000000000..9737b48e1dc
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/ToolboxBitmapAttribute.cs
@@ -0,0 +1,139 @@
+//
+// System.Drawing.ToolboxBitmapAttribute.cs
+//
+// Authors:
+// Dennis Hayes (dennish@Raytek.com)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.Drawing
+{
+ [AttributeUsage (AttributeTargets.Class)]
+ public class ToolboxBitmapAttribute : Attribute
+ {
+ private Image smallImage = null;
+ private Image bigImage = null;
+ public static readonly ToolboxBitmapAttribute Default = new ToolboxBitmapAttribute();
+
+ private ToolboxBitmapAttribute ()
+ {
+ }
+
+ public ToolboxBitmapAttribute (string imageFile)
+ {
+ }
+
+ public ToolboxBitmapAttribute (Type t)
+ {
+ smallImage = GetImageFromResource (t, null, false);
+ }
+
+ public ToolboxBitmapAttribute (Type t, string name)
+ {
+ smallImage = GetImageFromResource (t, name, false);
+ }
+
+ public override bool Equals (object value)
+ {
+ if (!(value is ToolboxBitmapAttribute))
+ return false;
+ if (value == this)
+ return true;
+ return ((ToolboxBitmapAttribute) value).smallImage == this.smallImage;
+ }
+
+ public override int GetHashCode ()
+ {
+ return (smallImage.GetHashCode () ^ bigImage.GetHashCode ());
+ }
+
+ public Image GetImage (object component)
+ {
+ return GetImage (component.GetType(), null, false);
+ }
+
+ public Image GetImage (object component, bool large)
+ {
+ return GetImage (component.GetType(), null, large);
+ }
+
+ public Image GetImage (Type type)
+ {
+ return GetImage (type, null, false);
+ }
+
+ public Image GetImage (Type type, bool large)
+ {
+ return GetImage (type, null, large);
+ }
+
+ public Image GetImage (Type type, string imgName, bool large)
+ {
+ if (smallImage == null)
+ smallImage = GetImageFromResource (type, imgName, false);
+
+ if (large) {
+ if (bigImage == null)
+ bigImage = new Bitmap (smallImage, 32, 32);
+ return bigImage;
+ }
+ else
+ return smallImage;
+ }
+
+ public static Image GetImageFromResource (Type t, string imageName, bool large)
+ {
+ Bitmap bitmap;
+ if (imageName == null)
+ imageName = t.Name + ".bmp";
+
+ try {
+ using (System.IO.Stream s = t.Assembly.GetManifestResourceStream (t.Namespace + "." + imageName)){
+ if (s == null) {
+ return null;
+ } else {
+ bitmap = new Bitmap (s, false);
+ }
+ }
+
+ //FIXME: thrown too easily
+ //if (bitmap.Width != 16 || bitmap.Height != 16)
+ // throw new Exception ("ToolboxBitmap must be 16x16 pixels");
+
+ if (large)
+ return new Bitmap (bitmap, 32, 32);
+ return bitmap;
+ } catch {
+ return null;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/carbonFunctions.cs b/mcs/class/System.Drawing/System.Drawing/carbonFunctions.cs
new file mode 100644
index 00000000000..40e36825b70
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/carbonFunctions.cs
@@ -0,0 +1,149 @@
+//
+// System.Drawing.carbonFunctions.cs
+//
+// Authors:
+// Geoff Norton (gnorton@customerdna.com>
+//
+// Copyright (C) 2004 Novell, Inc. (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Runtime.InteropServices;
+using System.Security;
+
+namespace System.Drawing {
+
+ [SuppressUnmanagedCodeSecurity]
+ internal class Carbon {
+
+ internal static CarbonContext GetCGContextForNSView (IntPtr hwnd) {
+ IntPtr cgContext = IntPtr.Zero;
+
+ cgContext = objc_msgSend (objc_msgSend (objc_getClass ("NSGraphicsContext"), sel_registerName ("currentContext")), sel_registerName ("graphicsPort"));
+ HIRect rect = new HIRect ();
+ objc_msgSend_stret (ref rect, hwnd, sel_registerName ("bounds"));
+ return new CarbonContext (cgContext, (int)rect.size.width, (int)rect.size.height);
+ }
+ internal static CarbonContext GetCGContextForView (IntPtr hwnd) {
+ IntPtr cgContext = IntPtr.Zero;
+ // Grab the window we're in
+ IntPtr window = Carbon.GetControlOwner (hwnd);
+ // Get the port of the window
+ IntPtr port = Carbon.GetWindowPort (window);
+ // Create a CGContext ref
+ Carbon.CreateCGContextForPort (port, ref cgContext);
+
+ // Get the bounds of the window
+ QRect wBounds = new QRect ();
+ Carbon.GetWindowBounds (window, 32, ref wBounds);
+
+ // Get the bounds of the view
+ HIRect vBounds = new HIRect ();
+ Carbon.HIViewGetBounds (hwnd, ref vBounds);
+
+ // Convert the view local bounds to window coordinates
+ Carbon.HIViewConvertRect (ref vBounds, hwnd, IntPtr.Zero);
+ Carbon.CGContextTranslateCTM (cgContext, vBounds.origin.x, (wBounds.bottom-wBounds.top)-(vBounds.origin.y+vBounds.size.height));
+ /* FIXME: Do we need this or is it inherintly clipped */
+ HIRect rcClip = new HIRect ();
+ rcClip.origin.x = 0;
+ rcClip.origin.y = 0;
+ rcClip.size.width = vBounds.size.width;
+ rcClip.size.height = vBounds.size.height;
+ Carbon.CGContextClipToRect (cgContext, rcClip);
+ return new CarbonContext (cgContext, (int)vBounds.size.width, (int)vBounds.size.height);
+ }
+ #region Cocoa Methods
+ [DllImport("libobjc.dylib")]
+ public static extern IntPtr objc_getClass(string className);
+ [DllImport("libobjc.dylib")]
+ public static extern IntPtr objc_msgSend(IntPtr basePtr, IntPtr selector, string argument);
+ [DllImport("libobjc.dylib")]
+ public static extern IntPtr objc_msgSend(IntPtr basePtr, IntPtr selector);
+ [DllImport("libobjc.dylib")]
+ public static extern void objc_msgSend_stret(ref HIRect arect, IntPtr basePtr, IntPtr selector);
+ [DllImport("libobjc.dylib")]
+ public static extern IntPtr sel_registerName(string selectorName);
+ #endregion
+
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewGetBounds (IntPtr vHnd, ref HIRect r);
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int HIViewConvertRect (ref HIRect r, IntPtr a, IntPtr b);
+
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr GetControlOwner (IntPtr aView);
+
+ [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int GetWindowBounds (IntPtr wHnd, uint reg, ref QRect rect);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern IntPtr GetWindowPort (IntPtr hWnd);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern int CGContextClipToRect (IntPtr cgContext, HIRect clip);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void CreateCGContextForPort (IntPtr port, ref IntPtr cgc);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void CGContextTranslateCTM (IntPtr cgc, double tx, double ty);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void CGContextScaleCTM (IntPtr cgc, double x, double y);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void CGContextFlush (IntPtr cgc);
+ [DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ internal static extern void CGContextSynchronize (IntPtr cgc);
+ }
+
+ internal struct CGSize {
+ public float width;
+ public float height;
+ }
+
+ internal struct CGPoint {
+ public float x;
+ public float y;
+ }
+
+ internal struct HIRect {
+ public CGPoint origin;
+ public CGSize size;
+ }
+
+ internal struct QRect
+ {
+ public short top;
+ public short left;
+ public short bottom;
+ public short right;
+ }
+
+ internal struct CarbonContext
+ {
+ public IntPtr ctx;
+ public int width;
+ public int height;
+
+ public CarbonContext (IntPtr ctx, int width, int height)
+ {
+ this.ctx = ctx;
+ this.width = width;
+ this.height = height;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/gdipEnums.cs b/mcs/class/System.Drawing/System.Drawing/gdipEnums.cs
new file mode 100644
index 00000000000..d108f93cfca
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/gdipEnums.cs
@@ -0,0 +1,87 @@
+//
+// System.Drawing.gdipEnums.cs
+//
+// Author:
+// Alexandre Pigolkine (pigolkine@gmx.de)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.Drawing {
+ /// <summary>
+ /// GDI+ API enumerations
+ /// </summary>
+
+ #region Status
+ internal enum Status {
+ Ok = 0,
+ GenericError = 1,
+ InvalidParameter = 2,
+ OutOfMemory = 3,
+ ObjectBusy = 4,
+ InsufficientBuffer = 5,
+ NotImplemented = 6,
+ Win32Error = 7,
+ WrongState = 8,
+ Aborted = 9,
+ FileNotFound = 10,
+ ValueOverflow = 11,
+ AccessDenied = 12,
+ UnknownImageFormat = 13,
+ FontFamilyNotFound = 14,
+ FontStyleNotFound = 15,
+ NotTrueTypeFont = 16,
+ UnsupportedGdiplusVersion = 17,
+ GdiplusNotInitialized = 18,
+ PropertyNotFound = 19,
+ PropertyNotSupported = 20,
+ ProfileNotFound = 21
+ }
+ #endregion
+
+ #region Unit
+ internal enum Unit
+ {
+ UnitWorld = 0,
+ UnitDisplay = 1,
+ UnitPixel = 2,
+ UnitPoint = 3,
+ UnitInch = 4,
+ UnitDocument = 5,
+ UnitMillimeter = 6
+ };
+ #endregion
+
+ #region BrushType
+ internal enum BrushType {
+ BrushTypeSolidColor = 0,
+ BrushTypeHatchFill = 1,
+ BrushTypeTextureFill = 2,
+ BrushTypePathGradient = 3,
+ BrushTypeLinearGradient = 4
+ }
+ #endregion
+
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs b/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
new file mode 100644
index 00000000000..d3a3226cb43
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
@@ -0,0 +1,1795 @@
+//
+// System.Drawing.gdipFunctions.cs
+//
+// Authors:
+// Alexandre Pigolkine (pigolkine@gmx.de)
+// Jordi Mas i Hernandez (jordi@ximian.com)
+// Sanjay Gupta (gsanjay@novell.com)
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Drawing.Text;
+using System.Security;
+#if NET_2_0
+using System.Runtime.InteropServices.ComTypes;
+#else
+using IStream = System.Runtime.InteropServices.UCOMIStream;
+#endif
+
+namespace System.Drawing
+{
+ /// <summary>
+ /// GDI+ API Functions
+ /// </summary>
+ [SuppressUnmanagedCodeSecurity]
+ internal class GDIPlus
+ {
+ public const int FACESIZE = 32;
+ public const int LANG_NEUTRAL = 0;
+ public static IntPtr Display = IntPtr.Zero;
+ public static bool UseX11Drawable;
+ public static bool UseQuartzDrawable = (Environment.GetEnvironmentVariable ("MONO_MWF_USE_QUARTZ_BACKEND") != null);
+ public static bool UseCocoaDrawable = (Environment.GetEnvironmentVariable ("MONO_GDIP_USE_COCOA_BACKEND") != null);
+
+ #region gdiplus.dll functions
+
+ // startup / shutdown
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdiplusStartup(ref ulong token, ref GdiplusStartupInput input, ref GdiplusStartupOutput output);
+ [DllImport("gdiplus.dll")]
+ static internal extern void GdiplusShutdown(ref ulong token);
+
+ static ulong GdiPlusToken;
+
+ static void ProcessExit (object sender, EventArgs e)
+ {
+ // Called all pending objects and claim any pending handle before
+ // shutting down
+ GC.Collect ();
+ GC.WaitForPendingFinalizers ();
+ // This causes crashes in MS GDI+ because this call occurs before
+ // all managed GDI objects are finalized. When they are finalized they call
+ // into a shutdown GDI+ and we crash.
+ //GdiplusShutdown (ref GdiPlusToken);
+
+ if (UseX11Drawable && Display != IntPtr.Zero) {
+ XCloseDisplay (Display);
+ }
+
+ }
+
+ static GDIPlus ()
+ {
+ // check for Unix platforms - see FAQ for more details
+ // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
+ int platform = (int) Environment.OSVersion.Platform;
+ UseX11Drawable = ((platform == 4) || (platform == 128));
+
+ GdiplusStartupInput input = GdiplusStartupInput.MakeGdiplusStartupInput();
+ GdiplusStartupOutput output = GdiplusStartupOutput.MakeGdiplusStartupOutput();
+ GdiplusStartup (ref GdiPlusToken, ref input, ref output);
+ AppDomain.CurrentDomain.ProcessExit += new EventHandler (ProcessExit);
+ }
+
+ // Copies a Ptr to an array of Points and releases the memory
+ static public void FromUnManagedMemoryToPointI(IntPtr prt, Point [] pts)
+ {
+ int nPointSize = Marshal.SizeOf(pts[0]);
+ IntPtr pos = prt;
+ for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
+ pts[i] = (Point) Marshal.PtrToStructure(pos, typeof(Point));
+
+ Marshal.FreeHGlobal(prt);
+ }
+
+ // Copies a Ptr to an array of Points and releases the memory
+ static public void FromUnManagedMemoryToPoint (IntPtr prt, PointF [] pts)
+ {
+ int nPointSize = Marshal.SizeOf(pts[0]);
+ IntPtr pos = prt;
+ for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
+ pts[i] = (PointF) Marshal.PtrToStructure(pos, typeof(Point));
+
+ Marshal.FreeHGlobal(prt);
+ }
+
+ // Copies an array of Points to unmanaged memory
+ static public IntPtr FromPointToUnManagedMemoryI(Point [] pts)
+ {
+ int nPointSize = Marshal.SizeOf(pts[0]);
+ IntPtr dest = Marshal.AllocHGlobal(nPointSize* pts.Length);
+ IntPtr pos = dest;
+ for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
+ Marshal.StructureToPtr(pts[i], pos, false);
+
+ return dest;
+ }
+
+ // Copies a Ptr to an array of v and releases the memory
+ static public void FromUnManagedMemoryToRectangles (IntPtr prt, RectangleF [] pts)
+ {
+ int nPointSize = Marshal.SizeOf (pts[0]);
+ IntPtr pos = prt;
+ for (int i = 0; i < pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
+ pts[i] = (RectangleF) Marshal.PtrToStructure(pos, typeof(RectangleF));
+
+ Marshal.FreeHGlobal(prt);
+ }
+
+ // Copies an array of Points to unmanaged memory
+ static public IntPtr FromPointToUnManagedMemory(PointF [] pts)
+ {
+ int nPointSize = Marshal.SizeOf(pts[0]);
+ IntPtr dest = Marshal.AllocHGlobal(nPointSize* pts.Length);
+ IntPtr pos = dest;
+ for (int i=0; i<pts.Length; i++, pos = new IntPtr (pos.ToInt64 () + nPointSize))
+ Marshal.StructureToPtr(pts[i], pos, false);
+
+ return dest;
+ }
+
+ // Converts a status into exception
+ static internal void CheckStatus (Status status)
+ {
+ switch (status) {
+
+ case Status.Ok:
+ return;
+
+ // TODO: Add more status code mappings here
+
+ case Status.GenericError:
+ throw new Exception ("Generic Error.");
+
+ case Status.InvalidParameter:
+ throw new ArgumentException ("Invalid Parameter. A null reference or invalid value was found.");
+
+ case Status.OutOfMemory:
+ throw new OutOfMemoryException ("Out of memory.");
+
+ case Status.ObjectBusy:
+ throw new MemberAccessException ("Object busy.");
+
+ case Status.InsufficientBuffer:
+ throw new IO.InternalBufferOverflowException ("Insufficient buffer.");
+
+ case Status.PropertyNotSupported:
+ throw new NotSupportedException ("Property not supported.");
+
+ case Status.FileNotFound:
+ throw new IO.FileNotFoundException ("File not found.");
+
+ case Status.AccessDenied:
+ throw new UnauthorizedAccessException ("Access denied.");
+
+ case Status.UnknownImageFormat:
+ throw new NotSupportedException ("Either image format is unknown or you don't have the required libraries for this format.");
+
+ case Status.NotImplemented:
+ throw new NotImplementedException ("Feature not implemented.");
+
+ case Status.WrongState:
+ throw new ArgumentException ("Properties not set properly.");
+
+ default:
+ throw new Exception ("Unknown Error.");
+ }
+ }
+
+
+ // Memory functions
+ [DllImport("gdiplus.dll")]
+ static internal extern IntPtr GdipAlloc (int size);
+ [DllImport("gdiplus.dll")]
+ static internal extern void GdipFree (IntPtr ptr);
+
+
+ // Brush functions
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCloneBrush (IntPtr brush, out IntPtr clonedBrush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDeleteBrush (IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetBrushType (IntPtr brush, out BrushType type);
+
+
+ // Region functions
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateRegion (out IntPtr region);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateRegionRgnData (byte[] data, int size, out IntPtr region);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDeleteRegion (IntPtr region);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCloneRegion (IntPtr region, out IntPtr cloned);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateRegionRect (ref RectangleF rect, out IntPtr region);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateRegionRectI (ref Rectangle rect, out IntPtr region);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateRegionPath (IntPtr path, out IntPtr region);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipTranslateRegion (IntPtr region, float dx, float dy);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipTranslateRegionI (IntPtr region, int dx, int dy);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipIsVisibleRegionPoint (IntPtr region, float x, float y,
+ IntPtr graphics, out bool result);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipIsVisibleRegionPointI (IntPtr region, int x, int y,
+ IntPtr graphics, out bool result);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipIsVisibleRegionRect (IntPtr region, float x, float y, float width,
+ float height, IntPtr graphics, out bool result);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipIsVisibleRegionRectI (IntPtr region, int x, int y, int width,
+ int height, IntPtr graphics, out bool result);
+
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCombineRegionRect (IntPtr region, ref RectangleF rect,
+ CombineMode combineMode);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCombineRegionRectI (IntPtr region, ref Rectangle rect,
+ CombineMode combineMode);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCombineRegionPath (IntPtr region, IntPtr path, CombineMode combineMode);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetRegionBounds (IntPtr region, IntPtr graphics, ref RectangleF rect);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetInfinite (IntPtr region);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetEmpty (IntPtr region);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipIsEmptyRegion (IntPtr region, IntPtr graphics, out bool result);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipIsInfiniteRegion (IntPtr region, IntPtr graphics, out bool result);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCombineRegionRegion (IntPtr region, IntPtr region2,
+ CombineMode combineMode);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipIsEqualRegion (IntPtr region, IntPtr region2,
+ IntPtr graphics, out bool result);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetRegionDataSize (IntPtr region, out int bufferSize);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetRegionData (IntPtr region, byte[] buffer, int bufferSize,
+ out int sizeFilled);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetRegionScansCount (IntPtr region, out int count, IntPtr matrix);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetRegionScans (IntPtr region, IntPtr rects, out int count,
+ IntPtr matrix);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipTransformRegion(IntPtr region, IntPtr matrix);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipFillRegion(IntPtr graphics, IntPtr brush, IntPtr region);
+
+ // Solid brush functions
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateSolidFill (int color, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetSolidFillColor (IntPtr brush, out int color);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetSolidFillColor (IntPtr brush, int color);
+
+ // Hatch Brush functions
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateHatchBrush (HatchStyle hatchstyle, int foreColor, int backColor, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetHatchStyle (IntPtr brush, out HatchStyle hatchstyle);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetHatchForegroundColor (IntPtr brush, out int foreColor);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetHatchBackgroundColor (IntPtr brush, out int backColor);
+
+ // Texture brush functions
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetTextureImage (IntPtr texture, out IntPtr image);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateTexture (IntPtr image, WrapMode wrapMode, out IntPtr texture);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateTextureIAI (IntPtr image, IntPtr imageAttributes, int x, int y, int width, int height, out IntPtr texture);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateTextureIA (IntPtr image, IntPtr imageAttributes, float x, float y, float width, float height, out IntPtr texture);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateTexture2I (IntPtr image, WrapMode wrapMode, int x, int y, int width, int height, out IntPtr texture);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateTexture2 (IntPtr image, WrapMode wrapMode, float x, float y, float width, float height, out IntPtr texture);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetTextureTransform (IntPtr texture, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetTextureTransform (IntPtr texture, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetTextureWrapMode (IntPtr texture, out WrapMode wrapMode);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetTextureWrapMode (IntPtr texture, WrapMode wrapMode);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipMultiplyTextureTransform (IntPtr texture, IntPtr matrix, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipResetTextureTransform (IntPtr texture);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipRotateTextureTransform (IntPtr texture, float angle, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipScaleTextureTransform (IntPtr texture, float sx, float sy, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipTranslateTextureTransform (IntPtr texture, float dx, float dy, MatrixOrder order);
+
+ // PathGradientBrush functions
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreatePathGradientFromPath (IntPtr path, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreatePathGradientI (Point [] points, int count, WrapMode wrapMode, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreatePathGradient (PointF [] points, int count, WrapMode wrapMode, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientBlendCount (IntPtr brush, out int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientBlend (IntPtr brush, float [] blend, float [] positions, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetPathGradientBlend (IntPtr brush, float [] blend, float [] positions, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientCenterColor (IntPtr brush, out int color);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetPathGradientCenterColor (IntPtr brush, int color);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientCenterPoint (IntPtr brush, out PointF point);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetPathGradientCenterPoint (IntPtr brush, ref PointF point);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientFocusScales (IntPtr brush, out float xScale, out float yScale);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetPathGradientFocusScales (IntPtr brush, float xScale, float yScale);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientPresetBlendCount (IntPtr brush, out int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientPresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetPathGradientPresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientRect (IntPtr brush, out RectangleF rect);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientSurroundColorCount (IntPtr brush, out int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientSurroundColorsWithCount (IntPtr brush, int [] color, ref int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetPathGradientSurroundColorsWithCount (IntPtr brush, int [] color, ref int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientTransform (IntPtr brush, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetPathGradientTransform (IntPtr brush, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetPathGradientWrapMode (IntPtr brush, out WrapMode wrapMode);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetPathGradientWrapMode (IntPtr brush, WrapMode wrapMode);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetPathGradientLinearBlend (IntPtr brush, float focus, float scale);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetPathGradientSigmaBlend (IntPtr brush, float focus, float scale);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipMultiplyPathGradientTransform (IntPtr texture, IntPtr matrix, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipResetPathGradientTransform (IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipRotatePathGradientTransform (IntPtr brush, float angle, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipScalePathGradientTransform (IntPtr brush, float sx, float sy, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipTranslatePathGradientTransform (IntPtr brush, float dx, float dy, MatrixOrder order);
+
+ // LinearGradientBrush functions
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateLineBrushI (ref Point point1, ref Point point2, int color1, int color2, WrapMode wrapMode, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateLineBrush (ref PointF point1, ref PointF point2, int color1, int color2, WrapMode wrapMode, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateLineBrushFromRectI (ref Rectangle rect, int color1, int color2, LinearGradientMode linearGradientMode, WrapMode wrapMode, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateLineBrushFromRect (ref RectangleF rect, int color1, int color2, LinearGradientMode linearGradientMode, WrapMode wrapMode, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateLineBrushFromRectWithAngleI (ref Rectangle rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateLineBrushFromRectWithAngle (ref RectangleF rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetLineBlendCount (IntPtr brush, out int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetLineBlend (IntPtr brush, float [] blend, float [] positions, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetLineBlend (IntPtr brush, float [] blend, float [] positions, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetLineGammaCorrection (IntPtr brush, bool useGammaCorrection);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetLineGammaCorrection (IntPtr brush, out bool useGammaCorrection);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetLinePresetBlendCount (IntPtr brush, out int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetLinePresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetLinePresetBlend (IntPtr brush, int [] blend, float [] positions, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetLineColors (IntPtr brush, int color1, int color2);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetLineColors (IntPtr brush, int [] colors);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetLineRectI (IntPtr brush, out Rectangle rect);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetLineRect (IntPtr brush, out RectangleF rect);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetLineTransform (IntPtr brush, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetLineTransform (IntPtr brush, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetLineWrapMode (IntPtr brush, WrapMode wrapMode);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetLineWrapMode (IntPtr brush, out WrapMode wrapMode);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetLineLinearBlend (IntPtr brush, float focus, float scale);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSetLineSigmaBlend (IntPtr brush, float focus, float scale);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipMultiplyLineTransform (IntPtr brush, IntPtr matrix, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipResetLineTransform (IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipRotateLineTransform (IntPtr brush, float angle, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipScaleLineTransform (IntPtr brush, float sx, float sy, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipTranslateLineTransform (IntPtr brush, float dx, float dy, MatrixOrder order);
+
+ // Graphics functions
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipCreateFromHDC(IntPtr hDC, out IntPtr graphics);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDeleteGraphics(IntPtr graphics);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipRestoreGraphics(IntPtr graphics, uint graphicsState);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSaveGraphics(IntPtr graphics, out uint state);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipMultiplyWorldTransform (IntPtr graphics, IntPtr matrix, MatrixOrder order);
+
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipRotateWorldTransform(IntPtr graphics, float angle, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipTranslateWorldTransform(IntPtr graphics, float dx, float dy, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDrawArc (IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDrawArcI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDrawBezier (IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDrawBezierI (IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDrawEllipseI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDrawEllipse (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDrawLine (IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDrawLineI (IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawLines (IntPtr graphics, IntPtr pen, PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawLinesI (IntPtr graphics, IntPtr pen, Point [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawPath (IntPtr graphics, IntPtr pen, IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawPie (IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawPieI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawPolygon (IntPtr graphics, IntPtr pen, PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawPolygonI (IntPtr graphics, IntPtr pen, Point [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawRectangle (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawRectangleI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawRectangles (IntPtr graphics, IntPtr pen, RectangleF [] rects, int count);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipDrawRectanglesI (IntPtr graphics, IntPtr pen, Rectangle [] rects, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipFillEllipseI (IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipFillEllipse (IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipFillPolygon (IntPtr graphics, IntPtr brush, PointF [] points, int count, FillMode fillMode);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipFillPolygonI (IntPtr graphics, IntPtr brush, Point [] points, int count, FillMode fillMode);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipFillPolygon2 (IntPtr graphics, IntPtr brush, PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipFillPolygon2I (IntPtr graphics, IntPtr brush, Point [] points, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipFillRectangle (IntPtr graphics, IntPtr brush, float x1, float y1, float x2, float y2);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipFillRectangleI (IntPtr graphics, IntPtr brush, int x1, int y1, int x2, int y2);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipFillRectangles (IntPtr graphics, IntPtr brush, RectangleF [] rects, int count);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipFillRectanglesI (IntPtr graphics, IntPtr brush, Rectangle [] rects, int count);
+ [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
+ static internal extern Status GdipDrawString (IntPtr graphics, string text, int len, IntPtr font, ref RectangleF rc, IntPtr format, IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetDC (IntPtr graphics, out IntPtr hdc);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipReleaseDC (IntPtr graphics, IntPtr hdc);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipDrawImageRectI (IntPtr graphics, IntPtr image, int x, int y, int width, int height);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipGetRenderingOrigin (IntPtr graphics, out int x, out int y);
+ [DllImport ("gdiplus.dll")]
+ static internal extern Status GdipSetRenderingOrigin (IntPtr graphics, int x, int y);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCloneBitmapArea (float x, float y, float width, float height, PixelFormat format, IntPtr original, out IntPtr bitmap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCloneBitmapAreaI (int x, int y, int width, int height, PixelFormat format, IntPtr original, out IntPtr bitmap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipResetWorldTransform (IntPtr graphics);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetWorldTransform (IntPtr graphics, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetWorldTransform (IntPtr graphics, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipScaleWorldTransform (IntPtr graphics, float sx, float sy, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGraphicsClear(IntPtr graphics, int argb);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawClosedCurve(IntPtr graphics, IntPtr pen, PointF [] points, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawClosedCurveI(IntPtr graphics, IntPtr pen, Point [] points, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawClosedCurve2(IntPtr graphics, IntPtr pen, PointF [] points, int count, float tension);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawClosedCurve2I(IntPtr graphics, IntPtr pen, Point [] points, int count, float tension);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawCurve(IntPtr graphics, IntPtr pen, PointF [] points, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawCurveI(IntPtr graphics, IntPtr pen, Point [] points, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawCurve2(IntPtr graphics, IntPtr pen, PointF [] points, int count, float tension);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawCurve2I(IntPtr graphics, IntPtr pen, Point [] points, int count, float tension);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawCurve3(IntPtr graphics, IntPtr pen, PointF [] points, int count, int offset, int numberOfSegments, float tension);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawCurve3I(IntPtr graphics, IntPtr pen, Point [] points, int count, int offset, int numberOfSegments, float tension);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetClipRect(IntPtr graphics, float x, float y, float width, float height, CombineMode combineMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetClipRectI(IntPtr graphics, int x, int y, int width, int height, CombineMode combineMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetClipPath(IntPtr graphics, IntPtr path, CombineMode combineMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetClipRegion(IntPtr graphics, IntPtr region, CombineMode combineMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetClipGraphics(IntPtr graphics, IntPtr srcgraphics, CombineMode combineMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipResetClip(IntPtr graphics);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipEndContainer(IntPtr graphics, int state);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetClip (IntPtr graphics, IntPtr region);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipFillClosedCurve(IntPtr graphics, IntPtr brush, PointF [] points, int count);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipFillClosedCurveI(IntPtr graphics, IntPtr brush, Point [] points, int count);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipFillClosedCurve2(IntPtr graphics, IntPtr brush,
+ PointF [] points, int count, float tension, FillMode fillMode);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipFillClosedCurve2I(IntPtr graphics, IntPtr brush,
+ Point [] points, int count, float tension, FillMode fillMode);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipFillPie(IntPtr graphics, IntPtr brush, float x, float y,
+ float width, float height, float startAngle, float sweepAngle);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipFillPieI(IntPtr graphics, IntPtr brush, int x, int y,
+ int width, int height, float startAngle, float sweepAngle);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipFillPath(IntPtr graphics, IntPtr brush, IntPtr path);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetNearestColor(IntPtr graphics, out int argb);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipIsVisiblePoint(IntPtr graphics, float x, float y, out bool result);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipIsVisiblePointI(IntPtr graphics, int x, int y, out bool result);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipIsVisibleRect(IntPtr graphics, float x, float y,
+ float width, float height, out bool result);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipIsVisibleRectI(IntPtr graphics, int x, int y,
+ int width, int height, out bool result);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipTransformPoints(IntPtr graphics, CoordinateSpace destSpace,
+ CoordinateSpace srcSpace, IntPtr points, int count);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipTransformPointsI(IntPtr graphics, CoordinateSpace destSpace,
+ CoordinateSpace srcSpace, IntPtr points, int count);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipTranslateClip(IntPtr graphics, float dx, float dy);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipTranslateClipI(IntPtr graphics, int dx, int dy);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetClipBounds(IntPtr graphics, out RectangleF rect);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetCompositingMode(IntPtr graphics, CompositingMode compositingMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetCompositingMode(IntPtr graphics, out CompositingMode compositingMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetCompositingQuality(IntPtr graphics, CompositingQuality compositingQuality);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetCompositingQuality(IntPtr graphics, out CompositingQuality compositingQuality);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetInterpolationMode(IntPtr graphics, InterpolationMode interpolationMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetInterpolationMode(IntPtr graphics, out InterpolationMode interpolationMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetDpiX(IntPtr graphics, out float dpi);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetDpiY(IntPtr graphics, out float dpi);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipIsClipEmpty(IntPtr graphics, out bool result);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipIsVisibleClipEmpty(IntPtr graphics, out bool result);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPageUnit(IntPtr graphics, out GraphicsUnit unit);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPageScale(IntPtr graphics, out float scale);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPageUnit(IntPtr graphics, GraphicsUnit unit);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPageScale(IntPtr graphics, float scale);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPixelOffsetMode(IntPtr graphics, PixelOffsetMode pixelOffsetMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPixelOffsetMode(IntPtr graphics, out PixelOffsetMode pixelOffsetMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetSmoothingMode(IntPtr graphics, SmoothingMode smoothingMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetSmoothingMode(IntPtr graphics, out SmoothingMode smoothingMode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetTextContrast(IntPtr graphics, int contrast);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetTextContrast(IntPtr graphics, out int contrast);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetTextRenderingHint(IntPtr graphics, TextRenderingHint mode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetTextRenderingHint(IntPtr graphics, out TextRenderingHint mode);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetVisibleClipBounds(IntPtr graphics, out RectangleF rect);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipFlush(IntPtr graphics, FlushIntention intention);
+
+
+ // Pen functions
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreatePen1 (int argb, float width, Unit unit, out IntPtr pen);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreatePen2 (IntPtr brush, float width, Unit unit, out IntPtr pen);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipClonePen (IntPtr pen, out IntPtr clonepen);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDeletePen(IntPtr pen);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenBrushFill (IntPtr pen, IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenBrushFill (IntPtr pen, out IntPtr brush);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenFillType (IntPtr pen, out PenType type);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenColor (IntPtr pen, int color);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenColor (IntPtr pen, out int color);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenCompoundArray (IntPtr pen, float[] dash, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenCompoundArray (IntPtr pen, float[] dash, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenCompoundCount (IntPtr pen, out int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenDashCap197819 (IntPtr pen, DashCap dashCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenDashCap197819 (IntPtr pen, out DashCap dashCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenDashStyle (IntPtr pen, DashStyle dashStyle);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenDashStyle (IntPtr pen, out DashStyle dashStyle);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenDashOffset (IntPtr pen, float offset);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenDashOffset (IntPtr pen, out float offset);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenDashCount (IntPtr pen, out int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenDashArray (IntPtr pen, float[] dash, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenDashArray (IntPtr pen, float[] dash, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenMiterLimit (IntPtr pen, float miterLimit);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenMiterLimit (IntPtr pen, out float miterLimit);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenLineJoin (IntPtr pen, LineJoin lineJoin);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenLineJoin (IntPtr pen, out LineJoin lineJoin);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenLineCap197819 (IntPtr pen, LineCap startCap, LineCap endCap, DashCap dashCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenMode (IntPtr pen, PenAlignment alignment);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenMode (IntPtr pen, out PenAlignment alignment);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenStartCap (IntPtr pen, LineCap startCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenStartCap (IntPtr pen, out LineCap startCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenEndCap (IntPtr pen, LineCap endCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenEndCap (IntPtr pen, out LineCap endCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenCustomStartCap (IntPtr pen, IntPtr customCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenCustomStartCap (IntPtr pen, out IntPtr customCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenCustomEndCap (IntPtr pen, IntPtr customCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenCustomEndCap (IntPtr pen, out IntPtr customCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenTransform (IntPtr pen, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenTransform (IntPtr pen, IntPtr matrix);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPenWidth (IntPtr pen, float width);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPenWidth (IntPtr pen, out float width);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipResetPenTransform (IntPtr pen);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipMultiplyPenTransform (IntPtr pen, IntPtr matrix, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipRotatePenTransform (IntPtr pen, float angle, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipScalePenTransform (IntPtr pen, float sx, float sy, MatrixOrder order);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipTranslatePenTransform (IntPtr pen, float dx, float dy, MatrixOrder order);
+
+ // CustomLineCap functions
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateCustomLineCap (IntPtr fillPath, IntPtr strokePath, LineCap baseCap, float baseInset, out IntPtr customCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDeleteCustomLineCap (IntPtr customCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCloneCustomLineCap (IntPtr customCap, out IntPtr clonedCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetCustomLineCapStrokeCaps (IntPtr customCap, LineCap startCap, LineCap endCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetCustomLineCapStrokeCaps (IntPtr customCap, out LineCap startCap, out LineCap endCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetCustomLineCapStrokeJoin (IntPtr customCap, LineJoin lineJoin);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetCustomLineCapStrokeJoin (IntPtr customCap, out LineJoin lineJoin);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetCustomLineCapBaseCap (IntPtr customCap, LineCap baseCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetCustomLineCapBaseCap (IntPtr customCap, out LineCap baseCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetCustomLineCapBaseInset (IntPtr customCap, float inset);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetCustomLineCapBaseInset (IntPtr customCap, out float inset);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetCustomLineCapWidthScale (IntPtr customCap, float widthScale);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetCustomLineCapWidthScale (IntPtr customCap, out float widthScale);
+
+ // AdjustableArrowCap functions
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateAdjustableArrowCap (float height, float width, bool isFilled, out IntPtr arrowCap);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetAdjustableArrowCapHeight (IntPtr arrowCap, float height);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetAdjustableArrowCapHeight (IntPtr arrowCap, out float height);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetAdjustableArrowCapWidth (IntPtr arrowCap, float width);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetAdjustableArrowCapWidth (IntPtr arrowCap, out float width);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetAdjustableArrowCapMiddleInset (IntPtr arrowCap, float middleInset);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetAdjustableArrowCapMiddleInset (IntPtr arrowCap, out float middleInset);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetAdjustableArrowCapFillState (IntPtr arrowCap, bool isFilled);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetAdjustableArrowCapFillState (IntPtr arrowCap, out bool isFilled);
+
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateFromHWND (IntPtr hwnd, out IntPtr graphics);
+
+ [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
+ internal static extern Status GdipMeasureString(IntPtr graphics, string str, int length, IntPtr font,
+ ref RectangleF layoutRect, IntPtr stringFormat, out RectangleF boundingBox, out int codepointsFitted,
+ out int linesFilled);
+
+ [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
+ internal static extern Status GdipMeasureCharacterRanges (IntPtr graphics, string str, int length, IntPtr font,
+ ref RectangleF layoutRect, IntPtr stringFormat, int regcount, out IntPtr regions);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetStringFormatMeasurableCharacterRanges (IntPtr native,
+ int cnt, CharacterRange [] range);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetStringFormatMeasurableCharacterRangeCount (IntPtr native,
+ out int cnt);
+
+ // Bitmap functions
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateBitmapFromScan0 (int width, int height, int stride, PixelFormat format, IntPtr scan0, out IntPtr bmp);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateBitmapFromGraphics (int width, int height, IntPtr target, out IntPtr bitmap);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipBitmapLockBits (IntPtr bmp, ref Rectangle rc, ImageLockMode flags, PixelFormat format, [In, Out] BitmapData bmpData);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipBitmapSetResolution(IntPtr bmp, float xdpi, float ydpi);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipBitmapUnlockBits (IntPtr bmp, [In,Out] BitmapData bmpData);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipBitmapGetPixel (IntPtr bmp, int x, int y, out int argb);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipBitmapSetPixel (IntPtr bmp, int x, int y, int argb);
+
+ // Image functions
+ [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
+ internal static extern Status GdipLoadImageFromFile ( [MarshalAs(UnmanagedType.LPWStr)] string filename, out IntPtr image );
+
+ // Stream functions for Win32 (original Win32 ones)
+ [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
+ internal static extern Status GdipLoadImageFromStream([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, out IntPtr image);
+
+ [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
+ internal static extern Status GdipSaveImageToStream(HandleRef image, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, [In()] ref Guid clsidEncoder, HandleRef encoderParams);
+
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCloneImage(IntPtr image, out IntPtr imageclone);
+
+ [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
+ internal static extern Status GdipLoadImageFromFileICM ( [MarshalAs(UnmanagedType.LPWStr)] string filename, out IntPtr image );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateBitmapFromHBITMAP ( IntPtr hBitMap, IntPtr gdiPalette, out IntPtr image );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDisposeImage ( IntPtr image );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImageFlags(IntPtr image, out int flag);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipImageGetFrameDimensionsCount ( IntPtr image, out uint count );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipImageGetFrameDimensionsList ( IntPtr image, [Out] Guid [] dimensionIDs, uint count );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImageHeight (IntPtr image, out int height);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImageHorizontalResolution ( IntPtr image, out float resolution );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImagePaletteSize ( IntPtr image, out int size );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImagePalette (IntPtr image, IntPtr palette, int size);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetImagePalette (IntPtr image, IntPtr palette);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImageDimension ( IntPtr image, out float width, out float height );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImagePixelFormat ( IntPtr image, out PixelFormat format );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPropertyCount (IntPtr image, out uint propNumbers);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPropertyIdList (IntPtr image, uint propNumbers, [Out] int [] list);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPropertySize (IntPtr image, out int bufferSize, out int propNumbers);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetAllPropertyItems (IntPtr image, int bufferSize, int propNumbers, IntPtr items);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImageRawFormat ( IntPtr image, out Guid format );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImageVerticalResolution ( IntPtr image, out float resolution );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImageWidth ( IntPtr image, out int width);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImageBounds ( IntPtr image, out RectangleF source, ref GraphicsUnit unit );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetEncoderParameterListSize ( IntPtr image, ref Guid encoder, out uint size );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetEncoderParameterList ( IntPtr image, ref Guid encoder, uint size, IntPtr buffer );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipImageGetFrameCount (IntPtr image, ref Guid guidDimension, out int count );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipImageSelectActiveFrame (IntPtr image, ref Guid guidDimension, int frameIndex);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPropertyItemSize (IntPtr image, int propertyID, out int propertySize);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetPropertyItem (IntPtr image, int propertyID, int propertySize, IntPtr buffer);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipRemovePropertyItem (IntPtr image, int propertyId);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetPropertyItem (IntPtr image, IntPtr propertyItem);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImageThumbnail ( IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipImageRotateFlip ( IntPtr image, RotateFlipType rotateFlipType );
+
+ [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
+ internal static extern Status GdipSaveImageToFile (IntPtr image, string filename, ref Guid encoderClsID, IntPtr encoderParameters);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSaveAdd ( IntPtr image, IntPtr encoderParameters );
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSaveAddImage (IntPtr image, IntPtr imagenew, IntPtr encoderParameters);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImageI (IntPtr graphics, IntPtr image, int x, int y);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetImageGraphicsContext (IntPtr image, out IntPtr graphics);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImage (IntPtr graphics, IntPtr image, float x, float y);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipBeginContainer (IntPtr graphics, RectangleF dstrect,
+ RectangleF srcrect, GraphicsUnit unit, out int state);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipBeginContainerI (IntPtr graphics, Rectangle dstrect,
+ Rectangle srcrect, GraphicsUnit unit, out int state);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipBeginContainer2 (IntPtr graphics, out int state);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImagePoints (IntPtr graphics, IntPtr image, PointF [] destPoints, int count);
+
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImagePointsI (IntPtr graphics, IntPtr image, Point [] destPoints, int count);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImageRectRectI (IntPtr graphics, IntPtr image,
+ int dstx, int dsty, int dstwidth, int dstheight,
+ int srcx, int srcy, int srcwidth, int srcheight,
+ GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImageRectRect (IntPtr graphics, IntPtr image,
+ float dstx, float dsty, float dstwidth, float dstheight,
+ float srcx, float srcy, float srcwidth, float srcheight,
+ GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImagePointsRectI (IntPtr graphics, IntPtr image,
+ Point [] destPoints, int count, int srcx, int srcy, int srcwidth, int srcheight,
+ GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImagePointsRect (IntPtr graphics, IntPtr image,
+ PointF [] destPoints, int count, float srcx, float srcy, float srcwidth, float srcheight,
+ GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImageRect(IntPtr graphics, IntPtr image, float x, float y, float width, float height);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImagePointRect(IntPtr graphics, IntPtr image, float x,
+ float y, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDrawImagePointRectI(IntPtr graphics, IntPtr image, int x,
+ int y, int srcx, int srcy, int srcwidth,
+ int srcheight, GraphicsUnit srcUnit);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateStringFormat(StringFormatFlags formatAttributes, int language, out IntPtr native);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateHBITMAPFromBitmap (IntPtr bmp, out IntPtr HandleBmp, int clrbackground);
+
+ [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
+ internal static extern Status GdipCreateBitmapFromFile ([MarshalAs (UnmanagedType.LPWStr)] string filename, out IntPtr bitmap);
+
+ [DllImport("gdiplus.dll", CharSet=CharSet.Auto)]
+ internal static extern Status GdipCreateBitmapFromFileICM ([MarshalAs (UnmanagedType.LPWStr)] string filename, out IntPtr bitmap);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateHICONFromBitmap (IntPtr bmp, out IntPtr HandleIcon);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateBitmapFromHICON (IntPtr hicon, out IntPtr bitmap);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateBitmapFromResource (IntPtr hInstance,
+ string lpBitmapName, out IntPtr bitmap);
+
+ // Matrix functions
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreateMatrix (out IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreateMatrix2 (float m11, float m12, float m21, float m22, float dx, float dy, out IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreateMatrix3 (RectangleF rect, PointF [] dstplg, out IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreateMatrix3I (Rectangle rect, Point [] dstplg, out IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipDeleteMatrix (IntPtr matrix);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCloneMatrix (IntPtr matrix, out IntPtr cloneMatrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetMatrixElements (IntPtr matrix, float m11, float m12, float m21, float m22, float dx, float dy);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetMatrixElements (IntPtr matrix, IntPtr matrixOut);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipMultiplyMatrix (IntPtr matrix, IntPtr matrix2, MatrixOrder order);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipTranslateMatrix (IntPtr matrix, float offsetX, float offsetY, MatrixOrder order);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipScaleMatrix (IntPtr matrix, float scaleX, float scaleY, MatrixOrder order);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipRotateMatrix (IntPtr matrix, float angle, MatrixOrder order);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipShearMatrix (IntPtr matrix, float shearX, float shearY, MatrixOrder order);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipInvertMatrix (IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipTransformMatrixPoints (IntPtr matrix, PointF [] pts, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipTransformMatrixPointsI (IntPtr matrix, Point [] pts, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipVectorTransformMatrixPoints (IntPtr matrix, PointF [] pts, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipVectorTransformMatrixPointsI (IntPtr matrix, Point [] pts, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsMatrixInvertible (IntPtr matrix, out bool result);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsMatrixIdentity (IntPtr matrix, out bool result);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsMatrixEqual (IntPtr matrix, IntPtr matrix2, out bool result);
+
+ // GraphicsPath functions
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreatePath (FillMode brushMode, out IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreatePath2 (PointF [] points, byte [] types, int count, FillMode brushMode, out IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreatePath2I (Point [] points, byte [] types, int count, FillMode brushMode, out IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipClonePath (IntPtr path, out IntPtr clonePath);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipDeletePath (IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipResetPath (IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPointCount (IntPtr path, out int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPathTypes (IntPtr path, [Out] byte [] types, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPathPoints (IntPtr path, [Out] PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPathPointsI (IntPtr path, [Out] Point [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPathFillMode (IntPtr path, out FillMode fillMode);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetPathFillMode (IntPtr path, FillMode fillMode);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipStartPathFigure (IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipClosePathFigure (IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipClosePathFigures (IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetPathMarker (IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipClearPathMarkers (IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipReversePath (IntPtr path);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPathLastPoint (IntPtr path, out PointF lastPoint);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathLine (IntPtr path, float x1, float y1, float x2, float y2);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathArc (IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathBezier (IntPtr path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathBeziers (IntPtr path, PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathCurve (IntPtr path, PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathCurveI (IntPtr path, Point [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathCurve2 (IntPtr path, PointF [] points, int count, float tension);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathCurve2I (IntPtr path, Point [] points, int count, float tension);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathCurve3 (IntPtr path, PointF [] points, int count, int offset, int numberOfSegments, float tension);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathCurve3I (IntPtr path, Point [] points, int count, int offset, int numberOfSegments, float tension);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathClosedCurve (IntPtr path, PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathClosedCurveI (IntPtr path, Point [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathClosedCurve2 (IntPtr path, PointF [] points, int count, float tension);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathClosedCurve2I (IntPtr path, Point [] points, int count, float tension);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathRectangle (IntPtr path, float x, float y, float width, float height);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathRectangles (IntPtr path, RectangleF [] rects, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathEllipse (IntPtr path, float x, float y, float width, float height);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathEllipseI (IntPtr path, int x, int y, int width, int height);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathPie (IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathPieI (IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathPolygon (IntPtr path, PointF [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathPath (IntPtr path, IntPtr addingPath, bool connect);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathLineI (IntPtr path, int x1, int y1, int x2, int y2);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathArcI (IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathBezierI (IntPtr path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathBeziersI (IntPtr path, Point [] points, int count);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathPolygonI (IntPtr path, Point [] points, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathRectangleI (IntPtr path, int x, int y, int width, int height);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipAddPathRectanglesI (IntPtr path, Rectangle [] rects, int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipFlattenPath (IntPtr path, IntPtr matrix, float floatness);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipTransformPath (IntPtr path, IntPtr matrix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipWarpPath (IntPtr path, IntPtr matrix,
+ PointF [] points, int count,
+ float srcx, float srcy, float srcwidth, float srcheight,
+ WarpMode mode, float flatness);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipWidenPath (IntPtr path, IntPtr pen, IntPtr matrix, float flatness);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPathWorldBounds (IntPtr path, out RectangleF bounds, IntPtr matrix, IntPtr pen);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetPathWorldBoundsI (IntPtr path, out Rectangle bounds, IntPtr matrix, IntPtr pen);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsVisiblePathPoint (IntPtr path, float x, float y, IntPtr graphics, out bool result);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsVisiblePathPointI (IntPtr path, int x, int y, IntPtr graphics, out bool result);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsOutlineVisiblePathPoint (IntPtr path, float x, float y, IntPtr graphics, out bool result);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsOutlineVisiblePathPointI (IntPtr path, int x, int y, IntPtr graphics, out bool result);
+
+ // GraphicsPathIterator
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreatePathIter (out IntPtr iterator, IntPtr path);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterGetCount (IntPtr iterator, out int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterGetSubpathCount (IntPtr iterator, out int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDeletePathIter (IntPtr iterator);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterCopyData (IntPtr iterator, out int resultCount, PointF [] points, byte [] types, int startIndex, int endIndex);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterEnumerate (IntPtr iterator, out int resultCount, PointF [] points, byte [] types, int count);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterHasCurve (IntPtr iterator, out bool curve);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterNextMarkerPath (IntPtr iterator, out int resultCount, IntPtr path);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterNextMarker (IntPtr iterator, out int resultCount, out int startIndex, out int endIndex);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterNextPathType (IntPtr iterator, out int resultCount, out byte pathType, out int startIndex, out int endIndex);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterNextSubpathPath (IntPtr iterator, out int resultCount, IntPtr path, out bool isClosed);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterNextSubpath (IntPtr iterator, out int resultCount, out int startIndex, out int endIndex, out bool isClosed);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipPathIterRewind (IntPtr iterator);
+
+ // ImageAttributes
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreateImageAttributes (out IntPtr imageattr);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetImageAttributesColorKeys (IntPtr imageattr,
+ ColorAdjustType type, bool enableFlag, int colorLow, int colorHigh);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipDisposeImageAttributes (IntPtr imageattr);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetImageAttributesColorMatrix (IntPtr imageattr,
+ ColorAdjustType type, bool enableFlag, ColorMatrix colorMatrix,
+ ColorMatrix grayMatrix, ColorMatrixFlag flags);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetImageAttributesGamma (IntPtr imageattr,
+ ColorAdjustType type, bool enableFlag,
+ float gamma);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetImageAttributesNoOp (IntPtr imageattr,
+ ColorAdjustType type, bool enableFlag);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetImageAttributesOutputChannel (IntPtr imageattr,
+ ColorAdjustType type, bool enableFlag, ColorChannelFlag channelFlags);
+
+ [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
+ internal static extern Status GdipSetImageAttributesOutputChannelColorProfile (IntPtr imageattr,
+ ColorAdjustType type, bool enableFlag, [MarshalAs (UnmanagedType.LPWStr)] string profileName);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetImageAttributesRemapTable (IntPtr imageattr,
+ ColorAdjustType type, bool enableFlag, uint mapSize, IntPtr colorMap);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetImageAttributesThreshold (IntPtr imageattr,
+ ColorAdjustType type, bool enableFlag, float thresHold);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCloneImageAttributes(IntPtr imageattr, out IntPtr cloneImageattr);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetImageAttributesAdjustedPalette(IntPtr imageattr,
+ out IntPtr colorPalette, ColorAdjustType colorAdjustType);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetImageAttributesWrapMode(IntPtr imageattr, WrapMode wrap,
+ int argb, bool clamp);
+
+
+ // Font
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateFont (IntPtr fontFamily, float emSize, FontStyle style, GraphicsUnit unit, out IntPtr font);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipDeleteFont (IntPtr font);
+ [DllImport("gdiplus.dll", CharSet=CharSet.Ansi)]
+ internal static extern Status GdipGetLogFontA(IntPtr font, IntPtr graphics, IntPtr logfontA);
+ [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)]
+ internal static extern Status GdipGetLogFontW(IntPtr font, IntPtr graphics, IntPtr logfontW);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateFontFromDC(IntPtr hdc, out IntPtr font);
+ [DllImport("gdiplus.dll", SetLastError=true)]
+ internal static extern Status GdipCreateFontFromLogfontA(IntPtr hdc, ref LOGFONTA lf, out IntPtr ptr);
+
+ // These are our private functions, they exists in our own libgdiplus library, this way we
+ // avoid relying on wine in System.Drawing
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipGetHfont (IntPtr font, out IntPtr Hfont);
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONTA lf);
+
+ // This is win32/gdi, not gdiplus, but it's easier to keep in here, also see above comment
+ [DllImport("gdi32.dll", EntryPoint="CreateFontIndirectA", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ internal static extern IntPtr CreateFontIndirectA (ref LOGFONTA logfontA);
+ [DllImport("user32.dll", EntryPoint="GetDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ internal static extern IntPtr GetDC(IntPtr hwnd);
+ [DllImport("user32.dll", EntryPoint="ReleaseDC", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ internal static extern int ReleaseDC(IntPtr hdc);
+ [DllImport("gdi32.dll", EntryPoint="SelectObject", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+ internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr obj);
+ [DllImport("user32.dll", SetLastError=true)]
+ internal static extern bool GetIconInfo (IntPtr hIcon, out IconInfo iconinfo);
+
+ [DllImport("user32.dll")]
+ internal static extern IntPtr GetDesktopWindow ();
+
+ [DllImport("gdi32.dll", SetLastError=true)]
+ public static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest,
+ int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
+
+
+ // Some special X11 stuff
+ [DllImport("libX11", EntryPoint="XOpenDisplay")]
+ internal extern static IntPtr XOpenDisplay(IntPtr display);
+
+ [DllImport("libX11", EntryPoint="XCloseDisplay")]
+ internal extern static int XCloseDisplay(IntPtr display);
+
+ [DllImport ("libX11", EntryPoint="XRootWindow")]
+ internal extern static IntPtr XRootWindow(IntPtr display, int screen);
+
+ [DllImport ("libX11", EntryPoint="XDefaultDepth")]
+ internal extern static uint XDefaultDepth(IntPtr display, int screen);
+
+ [DllImport ("libX11", EntryPoint="XGetImage")]
+ internal extern static IntPtr XGetImage(IntPtr display, IntPtr drawable, int src_x, int src_y, int width, int height, int pane, int format);
+
+ [DllImport ("libX11", EntryPoint="XGetPixel")]
+ internal extern static int XGetPixel(IntPtr image, int x, int y);
+
+ [DllImport ("libX11", EntryPoint="XDestroyImage")]
+ internal extern static int XDestroyImage(IntPtr image);
+
+ [DllImport ("libX11", EntryPoint="XDefaultVisual")]
+ internal extern static IntPtr XDefaultVisual(IntPtr display, int screen);
+
+ [DllImport ("libX11", EntryPoint="XGetVisualInfo")]
+ internal extern static IntPtr XGetVisualInfo (IntPtr display, int vinfo_mask, ref XVisualInfo vinfo_template, ref int nitems);
+
+ [DllImport ("libX11", EntryPoint="XVisualIDFromVisual")]
+ internal extern static int XVisualIDFromVisual(IntPtr visual);
+
+
+ // FontCollection
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetFontCollectionFamilyCount (IntPtr collection, out int found);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetFontCollectionFamilyList (IntPtr collection, int getCount, IntPtr dest, out int retCount);
+ //internal static extern Status GdipGetFontCollectionFamilyList( IntPtr collection, int getCount, [Out] FontFamily [] familyList, out int retCount );
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipNewInstalledFontCollection (out IntPtr collection);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipNewPrivateFontCollection (out IntPtr collection);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipDeletePrivateFontCollection (IntPtr collection);
+
+ [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
+ internal static extern Status GdipPrivateAddFontFile (IntPtr collection,
+ [MarshalAs (UnmanagedType.LPWStr)] string fileName );
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipPrivateAddMemoryFont (IntPtr collection, IntPtr mem, int length);
+
+ //FontFamily
+ [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
+ internal static extern Status GdipCreateFontFamilyFromName (
+ [MarshalAs(UnmanagedType.LPWStr)] string fName, IntPtr collection, out IntPtr fontFamily);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetFamilyName(IntPtr family, IntPtr fName, int language);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetGenericFontFamilySansSerif (out IntPtr fontFamily);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetGenericFontFamilySerif (out IntPtr fontFamily);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetGenericFontFamilyMonospace (out IntPtr fontFamily);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetCellAscent (IntPtr fontFamily, int style, out short ascent);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetCellDescent (IntPtr fontFamily, int style, out short descent);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetLineSpacing (IntPtr fontFamily, int style, out short spacing);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetEmHeight (IntPtr fontFamily, int style, out short emHeight);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipIsStyleAvailable (IntPtr fontFamily, int style, out bool styleAvailable);
+
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipDeleteFontFamily (IntPtr fontFamily);
+
+ // String Format
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCreateStringFormat(int formatAttributes, int language, out IntPtr format);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipStringFormatGetGenericDefault(out IntPtr format);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipStringFormatGetGenericTypographic(out IntPtr format);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipDeleteStringFormat(IntPtr format);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipCloneStringFormat(IntPtr srcformat, out IntPtr format);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetStringFormatFlags(IntPtr format, StringFormatFlags flags);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetStringFormatFlags(IntPtr format, out StringFormatFlags flags);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetStringFormatAlign(IntPtr format, StringAlignment align);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetStringFormatAlign(IntPtr format, out StringAlignment align);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetStringFormatLineAlign(IntPtr format, StringAlignment align);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetStringFormatLineAlign(IntPtr format, out StringAlignment align);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetStringFormatTrimming(IntPtr format, StringTrimming trimming);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetStringFormatTrimming(IntPtr format, out StringTrimming trimming);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetStringFormatHotkeyPrefix(IntPtr format, HotkeyPrefix hotkeyPrefix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetStringFormatHotkeyPrefix(IntPtr format, out HotkeyPrefix hotkeyPrefix);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetStringFormatTabStops(IntPtr format, float firstTabOffset, int count, float [] tabStops);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetStringFormatDigitSubstitution(IntPtr format, int language, out StringDigitSubstitute substitute);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipSetStringFormatDigitSubstitution(IntPtr format, int language, StringDigitSubstitute substitute);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetStringFormatTabStopCount(IntPtr format, out int count);
+ [DllImport ("gdiplus.dll")]
+ internal static extern Status GdipGetStringFormatTabStops(IntPtr format, int count, out float firstTabOffset, [In, Out] float [] tabStops);
+
+ //ImageCodecInfo functions
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetImageDecodersSize (out int decoderNums, out int arraySize);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetImageDecoders (int decoderNums, int arraySize, IntPtr decoders);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetImageEncodersSize (out int encoderNums, out int arraySize);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipGetImageEncoders (int encoderNums, int arraySize, IntPtr encoders);
+
+ //
+ // These are stuff that is unix-only
+ //
+ public delegate int StreamGetHeaderDelegate(IntPtr buf, int bufsz);
+ public delegate int StreamGetBytesDelegate (IntPtr buf, int bufsz, bool peek);
+ public delegate long StreamSeekDelegate (int offset, int whence);
+ public delegate int StreamPutBytesDelegate (IntPtr buf, int bufsz);
+ public delegate void StreamCloseDelegate ();
+ public delegate long StreamSizeDelegate ();
+
+ internal class GdiPlusStreamHelper
+ {
+ public Stream stream;
+
+ private StreamGetHeaderDelegate sghd = null;
+ private StreamGetBytesDelegate sgbd = null;
+ private StreamSeekDelegate skd = null;
+ private StreamPutBytesDelegate spbd = null;
+ private StreamCloseDelegate scd = null;
+ private StreamSizeDelegate ssd = null;
+ private byte[] start_buf;
+ private int start_buf_pos;
+ private int start_buf_len;
+
+ public GdiPlusStreamHelper (Stream s)
+ {
+ stream = s;
+ if (stream != null && stream.CanSeek) {
+ stream.Seek (0, SeekOrigin.Begin);
+ }
+ }
+
+ public int StreamGetHeaderImpl (IntPtr buf, int bufsz) {
+ int bytesRead;
+
+ start_buf = new byte[bufsz];
+
+ try {
+ bytesRead = stream.Read (start_buf, 0, bufsz);
+ } catch (IOException) {
+ return -1;
+ }
+
+ if (bytesRead > 0 && buf != IntPtr.Zero) {
+ Marshal.Copy (start_buf, 0, (IntPtr) (buf.ToInt64()), bytesRead);
+ }
+
+ start_buf_pos = 0;
+ start_buf_len = bytesRead;
+
+ return bytesRead;
+ }
+
+ public StreamGetHeaderDelegate GetHeaderDelegate {
+ get {
+ if (stream != null && stream.CanRead) {
+ if (sghd == null) {
+ sghd = new StreamGetHeaderDelegate (StreamGetHeaderImpl);
+ }
+ return sghd;
+ }
+ return null;
+ }
+ }
+
+ public int StreamGetBytesImpl (IntPtr buf, int bufsz, bool peek)
+ {
+ if (buf == IntPtr.Zero && peek) {
+ return -1;
+ }
+
+ byte[] managedBuf = new byte[bufsz];
+ int bytesRead = 0;
+ long streamPosition = 0;
+
+ if (bufsz > 0) {
+ if (stream.CanSeek) {
+ streamPosition = stream.Position;
+ }
+ if (start_buf_len > 0) {
+ if (start_buf_len > bufsz) {
+ Array.Copy(start_buf, start_buf_pos, managedBuf, 0, bufsz);
+ start_buf_pos += bufsz;
+ start_buf_len -= bufsz;
+ bytesRead = bufsz;
+ bufsz = 0;
+ } else {
+ // this is easy
+ Array.Copy(start_buf, start_buf_pos, managedBuf, 0, start_buf_len);
+ bufsz -= start_buf_len;
+ bytesRead = start_buf_len;
+ start_buf_len = 0;
+ }
+ }
+
+ if (bufsz > 0) {
+ try {
+ bytesRead += stream.Read (managedBuf, bytesRead, bufsz);
+ } catch (IOException) {
+ return -1;
+ }
+ }
+
+ if (bytesRead > 0 && buf != IntPtr.Zero) {
+ Marshal.Copy (managedBuf, 0, (IntPtr) (buf.ToInt64()), bytesRead);
+ }
+
+ if (!stream.CanSeek && (bufsz == 10) && peek) {
+ // Special 'hack' to support peeking of the type for gdi+ on non-seekable streams
+ }
+
+ if (peek) {
+ if (stream.CanSeek) {
+ // If we are peeking bytes, then go back to original position before peeking
+ stream.Seek (streamPosition, SeekOrigin.Begin);
+ } else {
+ throw new NotSupportedException();
+ }
+ }
+ }
+
+ return bytesRead;
+ }
+
+ public StreamGetBytesDelegate GetBytesDelegate {
+ get {
+ if (stream != null && stream.CanRead) {
+ if (sgbd == null) {
+ sgbd = new StreamGetBytesDelegate (StreamGetBytesImpl);
+ }
+ return sgbd;
+ }
+ return null;
+ }
+ }
+
+ public long StreamSeekImpl (int offset, int whence)
+ {
+ long retOffset;
+ if (whence == 0) {
+ retOffset = stream.Seek ((long) offset, SeekOrigin.Begin);
+ } else if (whence == 1) {
+ retOffset = stream.Seek ((long) offset, SeekOrigin.Current);
+ } else if (whence == 2) {
+ retOffset = stream.Seek ((long) offset, SeekOrigin.End);
+ } else {
+ retOffset = -1;
+ }
+
+ return retOffset;
+ }
+
+ public StreamSeekDelegate SeekDelegate {
+ get {
+ if (stream != null && stream.CanSeek) {
+ if (skd == null) {
+ skd = new StreamSeekDelegate (StreamSeekImpl);
+ }
+ return skd;
+ }
+ return null;
+ }
+ }
+
+ public int StreamPutBytesImpl (IntPtr buf, int bufsz)
+ {
+ byte[] managedBuf = new byte[bufsz];
+ Marshal.Copy (buf, managedBuf, 0, bufsz);
+ stream.Write (managedBuf, 0, bufsz);
+ return bufsz;
+ }
+
+ public StreamPutBytesDelegate PutBytesDelegate {
+ get {
+ if (stream != null && stream.CanWrite) {
+ if (spbd == null) {
+ spbd = new StreamPutBytesDelegate (StreamPutBytesImpl);
+ }
+ return spbd;
+ }
+ return null;
+ }
+ }
+
+ public void StreamCloseImpl ()
+ {
+ stream.Close ();
+ }
+
+ public StreamCloseDelegate CloseDelegate {
+ get {
+ if (stream != null) {
+ if (scd == null) {
+ scd = new StreamCloseDelegate (StreamCloseImpl);
+ }
+ return scd;
+ }
+ return null;
+ }
+ }
+
+ public long StreamSizeImpl ()
+ {
+ return stream.Length;
+ }
+
+ public StreamSizeDelegate SizeDelegate {
+ get {
+ if (stream != null) {
+ if (ssd == null) {
+ ssd = new StreamSizeDelegate (StreamSizeImpl);
+ }
+ return ssd;
+ }
+ return null;
+ }
+ }
+
+ }
+
+ /* Mac only function calls */
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateFromQuartz_macosx (IntPtr cgref, int width, int height, out IntPtr graphics);
+
+ /* Linux only function calls*/
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipSetVisibleClip_linux (IntPtr graphics, ref Rectangle rect);
+
+ [DllImport("gdiplus.dll")]
+ internal static extern Status GdipCreateFromXDrawable_linux (IntPtr drawable, IntPtr display, out IntPtr graphics);
+
+ // Stream functions for non-Win32 (libgdiplus specific(
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipLoadImageFromDelegate_linux ( StreamGetHeaderDelegate getHeader, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes,
+ StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr image);
+ [DllImport("gdiplus.dll")]
+ static internal extern Status GdipSaveImageToDelegate_linux ( IntPtr image, StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes,
+ StreamSeekDelegate doSeek, StreamCloseDelegate close, StreamSizeDelegate size, ref Guid encoderClsID, IntPtr encoderParameters );
+
+#endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs b/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs
new file mode 100644
index 00000000000..060f6e5399e
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing/gdipStructs.cs
@@ -0,0 +1,226 @@
+//
+// System.Drawing.gdipStructs.cs
+//
+// Author:
+// Alexandre Pigolkine (pigolkine@gmx.de)
+// Jordi Mas (jordi@ximian.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Drawing.Imaging;
+using System.Drawing;
+
+namespace System.Drawing
+{
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GdiplusStartupInput
+ {
+ uint GdiplusVersion;
+ IntPtr DebugEventCallback;
+ int SuppressBackgroundThread;
+ int SuppressExternalCodecs;
+
+ internal static GdiplusStartupInput MakeGdiplusStartupInput ()
+ {
+ GdiplusStartupInput result = new GdiplusStartupInput ();
+ result.GdiplusVersion = 1;
+ result.DebugEventCallback = IntPtr.Zero;
+ result.SuppressBackgroundThread = 0;
+ result.SuppressExternalCodecs = 0;
+ return result;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GdiplusStartupOutput
+ {
+ internal IntPtr NotificationHook;
+ internal IntPtr NotificationUnhook;
+
+ internal static GdiplusStartupOutput MakeGdiplusStartupOutput ()
+ {
+ GdiplusStartupOutput result = new GdiplusStartupOutput ();
+ result.NotificationHook = result.NotificationUnhook = IntPtr.Zero;
+ return result;
+ }
+ }
+
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GdiColorPalette
+ {
+ internal int Flags; // Palette flags
+ internal int Count; // Number of color entries
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GdiColorMap
+ {
+ internal int from;
+ internal int to;
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
+ internal struct LOGFONTA
+ {
+ internal int lfHeight;
+ internal uint lfWidth;
+ internal uint lfEscapement;
+ internal uint lfOrientation;
+ internal uint lfWeight;
+ internal byte lfItalic;
+ internal byte lfUnderline;
+ internal byte lfStrikeOut;
+ internal byte lfCharSet;
+ internal byte lfOutPrecision;
+ internal byte lfClipPrecision;
+ internal byte lfQuality;
+ internal byte lfPitchAndFamily;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
+ internal string lfFaceName;
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
+ internal struct LOGFONTW
+ {
+ internal int lfHeight;
+ internal uint lfWidth;
+ internal uint lfEscapement;
+ internal uint lfOrientation;
+ internal uint lfWeight;
+ internal byte lfItalic;
+ internal byte lfUnderline;
+ internal byte lfStrikeOut;
+ internal byte lfCharSet;
+ internal byte lfOutPrecision;
+ internal byte lfClipPrecision;
+ internal byte lfQuality;
+ internal byte lfPitchAndFamily;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
+ internal string lfFaceName;
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
+ internal struct GdipImageCodecInfo /*Size 76 bytes*/
+ {
+ internal Guid Clsid;
+ internal Guid FormatID;
+ internal IntPtr CodecName;
+ internal IntPtr DllName;
+ internal IntPtr FormatDescription;
+ internal IntPtr FilenameExtension;
+ internal IntPtr MimeType;
+ internal ImageCodecFlags Flags;
+ internal int Version;
+ internal int SigCount;
+ internal int SigSize;
+ IntPtr SigPattern;
+ IntPtr SigMask;
+
+ internal static void MarshalTo (GdipImageCodecInfo gdipcodec, ImageCodecInfo codec)
+ {
+ codec.CodecName = Marshal.PtrToStringUni (gdipcodec.CodecName);
+ codec.DllName = Marshal.PtrToStringUni (gdipcodec.DllName);
+ codec.FormatDescription = Marshal.PtrToStringUni (gdipcodec.FormatDescription);
+ codec.FilenameExtension = Marshal.PtrToStringUni (gdipcodec.FilenameExtension);
+ codec.MimeType = Marshal.PtrToStringUni (gdipcodec.MimeType);
+ codec.Clsid = gdipcodec.Clsid;
+ codec.FormatID = gdipcodec.FormatID;
+ codec.Flags = gdipcodec.Flags;
+ codec.Version = gdipcodec.Version;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GdipEncoderParameter {
+ internal Guid guid;
+ internal uint numberOfValues;
+ internal EncoderParameterValueType type;
+ internal IntPtr value;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct GdipPropertyItem
+ {
+ internal int id;
+ internal int len;
+ internal short type;
+ internal IntPtr value;
+
+ internal static void MarshalTo (GdipPropertyItem gdipProp, PropertyItem prop)
+ {
+ prop.Id = gdipProp.id;
+ prop.Len = gdipProp.len;
+ prop.Type = gdipProp.type;
+ prop.Value = new byte [gdipProp.len];
+ Marshal.Copy (gdipProp.value, prop.Value, 0, gdipProp.len);
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct IconInfo
+ {
+ int fIcon;
+ public int xHotspot;
+ public int yHotspot;
+ IntPtr hbmMask;
+ IntPtr hbmColor;
+
+ public bool IsIcon {
+ get {
+ return fIcon == 1;
+ }
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XColor
+ {
+ public int pixel;
+ public ushort red, green, blue;
+ public sbyte flags;
+ public sbyte pad;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct XVisualInfo
+ {
+ internal IntPtr visual;
+ internal int visualid;
+ internal int screen;
+ internal uint depth;
+ internal int klass;
+ internal uint red_mask;
+ internal uint green_mask;
+ internal uint blue_mask;
+ internal int colormap_size;
+ internal int bits_per_rgb;
+ }
+
+}
+
diff --git a/mcs/class/System.Drawing/System.Drawing_test.dll.sources b/mcs/class/System.Drawing/System.Drawing_test.dll.sources
new file mode 100644
index 00000000000..3e3807a06af
--- /dev/null
+++ b/mcs/class/System.Drawing/System.Drawing_test.dll.sources
@@ -0,0 +1,56 @@
+System.Drawing/ColorTranslator.cs
+System.Drawing/ColorConverter.cs
+System.Drawing/RegionDataTest.cs
+System.Drawing/RegionNonRectTest.cs
+System.Drawing/TestBitmap.cs
+System.Drawing/TestBrushes.cs
+System.Drawing/TestColor.cs
+System.Drawing/TestFont.cs
+System.Drawing/TestGraphics.cs
+System.Drawing/TestImage.cs
+System.Drawing/TestPens.cs
+System.Drawing/TestPoint.cs
+System.Drawing/TestPointConverter.cs
+System.Drawing/TestPointF.cs
+System.Drawing/TestRectangle.cs
+System.Drawing/TestRectangleConverter.cs
+System.Drawing/TestRectangleF.cs
+System.Drawing/TestSize.cs
+System.Drawing/TestSizeConverter.cs
+System.Drawing/TestSizeFConverter.cs
+System.Drawing/TestSizeF.cs
+System.Drawing/TestStringFormat.cs
+System.Drawing/TestSystemBrushes.cs
+System.Drawing/TestSystemPens.cs
+System.Drawing/TestImageConverter.cs
+System.Drawing/TestImageFormatConverter.cs
+System.Drawing/TestIconConverter.cs
+System.Drawing/TestIcon.cs
+System.Drawing.Drawing2D/GraphicsPathTest.cs
+System.Drawing.Drawing2D/PathDataTest.cs
+System.Drawing.Drawing2D/TestBlend.cs
+System.Drawing.Drawing2D/TestColorBlend.cs
+System.Drawing.Drawing2D/TestHatchBrush.cs
+System.Drawing.Drawing2D/TestMatrix.cs
+System.Drawing/TestRegion.cs
+System.Drawing.Imaging/TestImageCodecInfo.cs
+System.Drawing.Imaging/TestImageFormat.cs
+System.Drawing.Imaging/TestBmpCodec.cs
+System.Drawing.Imaging/TestJpegCodec.cs
+System.Drawing.Imaging/TestColorMatrix.cs
+System.Drawing.Imaging/TestImageAttributes.cs
+System.Drawing.Printing/PrinterUnitConvertTest.cs
+System.Drawing.Printing/PrintingPermissionAttributeTest.cs
+System.Drawing.Printing/PrintingPermissionTest.cs
+System.Drawing/BitmapCas.cs
+System.Drawing/GraphicsCas.cs
+System.Drawing/RegionCas.cs
+System.Drawing.Design/CategoryNameCollectionCas.cs
+System.Drawing.Design/PaintValueEventArgsCas.cs
+System.Drawing.Design/PropertyValueUIItemCas.cs
+System.Drawing.Design/TestToolboxItem.cs
+System.Drawing.Design/ToolboxComponentsCreatedEventArgsCas.cs
+System.Drawing.Design/ToolboxComponentsCreatingEventArgsCas.cs
+System.Drawing.Design/ToolboxItemCas.cs
+System.Drawing.Design/ToolboxItemCollectionCas.cs
+System.Drawing.Design/UITypeEditorCas.cs
diff --git a/mcs/class/System.Drawing/Test/ChangeLog b/mcs/class/System.Drawing/Test/ChangeLog
new file mode 100644
index 00000000000..23dd6ba37d7
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/ChangeLog
@@ -0,0 +1,28 @@
+2005-09-06 Boris Kirzner <borisk@mainsoft.com>
+
+ * Test.dotnet.csproj, Test.vmwcsproj: Added GraphicsPathIterator.cs.
+
+2005-08-16 Andrew Skiba <andrews@mainsoft.com>
+
+ * Test.dotnet.csproj, Test.vmwcsproj: Embed Bitmap1.png, add Bitmap1.bmp
+
+2005-08-10 Boris Kirzner <borisk@mainsoft.com>
+ * Test.dotnet.csproj, Test.vmwcsproj: Added GraphicsPath.cs.
+
+2005-08-09 Andrew Skiba <andrews@mainsoft.com>
+
+ * Test.dotnet.csproj, Test.vmcsproj: add ColorConverter.cs and ColorTranslator.cs
+
+2005-08-08 Andrew Skiba <andrews@mainsoft.com>
+ * Test.dotnet.csproj, Test.vmcsproj: move these projects from DrawingTest/Test and include Mono tests in addition to Mainsoft tests.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * System.Drawing.Drawing2D: Created repository for tests of
+ this namespace.
+ * System.Drawing.Imaging: Created repository for tests of
+ this namespace.
+ * System.Drawing.Printing: Created repository for tests of
+ this namespace.
+ * System.Drawing.Text: Created repository for tests of this
+ namespace.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/ChangeLog b/mcs/class/System.Drawing/Test/DrawingTest/ChangeLog
new file mode 100644
index 00000000000..786c4d865ac
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/ChangeLog
@@ -0,0 +1,20 @@
+2005-08-08 Andrew Skiba <andrews@mainsoft.com>
+
+ * System.Drawing.Test.dotnet.sln, System.Drawing.Test.sln: move projects to the parent dir
+ so it's easy to include Mono tests
+
+2005-08-04 Andrew Skiba <andrews@mainsoft.com>
+
+ * Test/Test.dotnet.csproj, System.Drawing.Test.dotnet.sln,
+ DrawingTestHelper/DrawingTestHelper.csproj: Project builds on dotnet
+
+2005-08-04 Andrew Skiba <andrews@mainsoft.com>
+
+ * Test/Test.vmwcsproj, Test/Test.dotnet.csproj, System.Drawing.Test.dotnet.sln,
+ Exocortex.DSP/src/Exocortex.DSP.v1.J2EE.vmwcsproj, System.Drawing.Test.sln,
+ DrawingTestHelper/DrawingTestHelper_java.vmwcsproj,
+ DrawingTestHelper/DrawingTestHelper.csproj: Projects builds on GH
+
+2005-08-04 Andrew Skiba <andrews@mainsoft.com>
+
+ Initial commit
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/AssemblyInfo.cs b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/AssemblyInfo.cs
new file mode 100644
index 00000000000..177a4f0e70a
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/AssemblyInfo.cs
@@ -0,0 +1,58 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: AssemblyVersion("1.0.*")]
+
+//
+// In order to sign your assembly you must specify a key to use. Refer to the
+// Microsoft .NET Framework documentation for more information on assembly signing.
+//
+// Use the attributes below to control which key is used for signing.
+//
+// Notes:
+// (*) If no key is specified, the assembly is not signed.
+// (*) KeyName refers to a key that has been installed in the Crypto Service
+// Provider (CSP) on your machine. KeyFile refers to a file which contains
+// a key.
+// (*) If the KeyFile and the KeyName values are both specified, the
+// following processing occurs:
+// (1) If the KeyName can be found in the CSP, that key is used.
+// (2) If the KeyName does not exist and the KeyFile does exist, the key
+// in the KeyFile is installed into the CSP and used.
+// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
+// When specifying the KeyFile, the location of the KeyFile should be
+// relative to the project output directory which is
+// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
+// located in the project directory, you would specify the AssemblyKeyFile
+// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
+// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
+// documentation for more information on this.
+//
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("")]
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/ChangeLog b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/ChangeLog
new file mode 100644
index 00000000000..f162ebb2e61
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/ChangeLog
@@ -0,0 +1,29 @@
+2005-09-20 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * DrawingTest.cs: Added Pixel Distance comparer PDCompare()
+ * Added PDComparer.cs
+
+2005-09-06 Boris Kirzner <borisk@mainsoft.com>
+
+ * DrawingTest.cs: bug fix.
+
+2005-08-16 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * DrawingTest.cs: Added special tolerance feature
+ fixed compare()
+ fixed constructor
+
+2005-08-16 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * DrawingTest.cs: fixed JavaDrawingTest.CalculateSHA1()
+
+2005-08-08 Andrew Skiba <andrews@mainsoft.com>
+
+ * DrawingTestHelper.cs: fix ambiguity between System.Math and java.lang.Math
+
+2005-08-07 Andrew Skiba <andrews@mainsoft.com>
+
+ * DrawingTest.cs: add nunit assert to Compare functions
+ * DrawingTestHelper_java.vmwcsproj, DrawingTestHelper.csproj: add nunit.framework
+ reference
+
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTest.cs b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTest.cs
new file mode 100644
index 00000000000..f5504625c92
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTest.cs
@@ -0,0 +1,652 @@
+using System;
+using System.Drawing;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using Exocortex.DSP;
+using System.Reflection;
+using System.Xml.Serialization;
+using System.Collections;
+using System.Security.Cryptography;
+
+#if TARGET_JVM
+using awt = java.awt;
+using javax.imageio;
+using java.lang;
+using java.security;
+using java.awt.image;
+#else
+using System.Windows.Forms;
+using System.Drawing.Imaging;
+using System.Runtime.InteropServices;
+#endif
+
+using NUnit.Framework;
+
+namespace DrawingTestHelper
+{
+ #region Results serialization classes
+ public sealed class ExpectedResult {
+ public ExpectedResult(){}
+ public ExpectedResult(string testName, double norm) {
+ TestName = testName;
+ Norm = norm;
+ }
+ public string TestName;
+ public double Norm;
+ }
+
+ public sealed class ExpectedResults {
+ [XmlArrayItem(typeof(ExpectedResult))]
+ public ArrayList Tests = new ArrayList();
+ }
+
+ public sealed class ExpectedResultsHash {
+ Hashtable _hash;
+ ExpectedResults _suite;
+
+ public ExpectedResultsHash () {
+ try {
+ using (StreamReader s = new StreamReader (FileName)) {
+ _suite = (ExpectedResults)TestSuiteSerializer.Deserialize(s);
+ }
+ }
+ catch {
+ _suite = new ExpectedResults ();
+ }
+ _hash = new Hashtable(_suite.Tests.Count);
+ foreach (ExpectedResult res in _suite.Tests)
+ _hash[res.TestName] = res.Norm;
+ }
+
+ public const string FileName = "ExpectedResults.xml";
+ public readonly static XmlSerializer TestSuiteSerializer = new XmlSerializer(typeof(ExpectedResults));
+
+ public double GetNorm(string testName) {
+ object res = _hash[testName];
+ if (res != null)
+ return (double)res;
+ return double.NaN;
+ }
+
+ public void WriteNorm (string testName, double myNorm) {
+ if (_hash.Contains (testName)) {
+ for (int i = 0; i < _suite.Tests.Count; i++) {
+ ExpectedResult cur = (ExpectedResult) _suite.Tests[i];
+ if (cur.TestName == testName) {
+ cur.Norm = myNorm;
+ break;
+ }
+ }
+ }
+ else
+ _suite.Tests.Add(new ExpectedResult(testName, myNorm));
+
+ _hash[testName] = myNorm;
+ using(StreamWriter w = new StreamWriter(FileName))
+ TestSuiteSerializer.Serialize(w, _suite);
+ }
+ }
+
+ public sealed class CachedResult {
+ public CachedResult (){}
+ public CachedResult (string testName, string sha1, double norm) {
+ TestName = testName;
+ SHA1 = sha1;
+ Norm = norm;
+ DateTime = DateTime.Now;
+ }
+
+ public string TestName;
+ public string SHA1;
+ public double Norm;
+ public DateTime DateTime;
+ }
+
+ public sealed class CachedResults {
+ [XmlArrayItem(typeof(CachedResult))]
+ public ArrayList Tests = new ArrayList();
+ }
+
+ public class Cache {
+ Hashtable _hash;
+ CachedResults _results;
+
+#if TARGET_JVM
+ public const string FileName = "CachedResults.xml";
+ public const string NewFileName = "NewCachedResults.xml";
+#else
+ public const string FileName = "dotnet.CachedResults.xml";
+ public const string NewFileName = "dotnet.NewCachedResults.xml";
+#endif
+ public readonly static XmlSerializer TestSuiteSerializer =
+ new XmlSerializer(typeof(CachedResults));
+
+ public Cache () {
+ try {
+ using (StreamReader r = new StreamReader(FileName))
+ _results = (CachedResults)TestSuiteSerializer.Deserialize(r);
+ }
+ catch {
+ _results = new CachedResults ();
+ }
+
+ _hash = new Hashtable(_results.Tests.Count);
+ foreach (CachedResult res in _results.Tests)
+ _hash[res.SHA1] = res.Norm;
+ }
+
+ public double GetNorm (string sha1) {
+ if (_hash.ContainsKey (sha1))
+ return (double)_hash[sha1];
+ else
+ return double.NaN;
+ }
+
+ public void Add (string testName, string sha1, double norm) {
+ if (_hash.ContainsKey (sha1))
+ throw new ArgumentException ("This SHA1 is already in the cache", "sha1");
+
+ _results.Tests.Add (new CachedResult(testName, sha1, norm));
+ _hash.Add (sha1, norm);
+
+ using(StreamWriter w = new StreamWriter(NewFileName))
+ TestSuiteSerializer.Serialize(w, _results);
+ }
+ }
+ #endregion
+
+ /// <summary>
+ /// Summary description for DrawingTest.
+ /// </summary>
+ public abstract class DrawingTest {
+
+ public const float DEFAULT_FLOAT_TOLERANCE = 1e-5f;
+ public const int DEFAULT_IMAGE_TOLERANCE = 2;
+
+ Graphics _graphics;
+ protected Bitmap _bitmap;
+ static string _callingFunction;
+ //static int _counter;
+ static Hashtable _mpFuncCount = new Hashtable();
+ static bool _showForms = false;
+ static bool _createResults = true;
+ protected string _ownerClass = "";
+ protected Hashtable _specialTolerance = null;
+
+ protected readonly static ExpectedResultsHash ExpectedResults = new ExpectedResultsHash ();
+ protected readonly static Cache cache = new Cache ();
+
+ public Graphics Graphics {get {return _graphics;}}
+ public Bitmap Bitmap {get { return _bitmap; }}
+
+ public Hashtable SpecialTolerance
+ {
+ get {return _specialTolerance;}
+ set {_specialTolerance = value;}
+ }
+
+ public string OwnerClass
+ {
+ get {return _ownerClass;}
+ set {_ownerClass = value;}
+ }
+
+ public static bool ShowForms
+ {
+ get {return _showForms;}
+ set {_showForms = value;}
+ }
+
+ public static bool CreateResults {
+ get {return _createResults;}
+ set {_createResults = value;}
+ }
+
+ protected DrawingTest() {}
+
+ private void Init (int width, int height) {
+ Init (new Bitmap (width, height));
+ }
+
+ private void Init (Bitmap bitmap) {
+ _bitmap = bitmap;
+ _graphics = Graphics.FromImage (_bitmap);
+ }
+
+ protected abstract string DetermineCallingFunction ();
+
+ protected interface IMyForm {
+ void Show ();
+ }
+
+ protected abstract IMyForm CreateForm (string title);
+
+ public void Show () {
+ CheckCounter ();
+ if (!ShowForms)
+ return;
+ IMyForm form = CreateForm(_callingFunction + _mpFuncCount[_callingFunction]);
+ form.Show ();
+ }
+
+ static protected string TestName {
+ get {
+ return _callingFunction + ":" + _mpFuncCount[_callingFunction]/* + ".dat"*/;
+ }
+ }
+
+ #region GetImageFFTArray
+ private static ComplexF[] GetImageFFTArray(Bitmap bitmap) {
+ float scale = 1F / (float) System.Math.Sqrt(bitmap.Width * bitmap.Height);
+ ComplexF[] data = new ComplexF [bitmap.Width * bitmap.Height * 4];
+
+ int offset = 0;
+ for( int y = 0; y < bitmap.Height; y ++ )
+ for( int x = 0; x < bitmap.Width; x ++ ) {
+ Color c = bitmap.GetPixel (x, y);
+ float s = 1F;
+ if( (( x + y ) & 0x1 ) != 0 ) {
+ s = -1F;
+ }
+
+ data [offset++] = new ComplexF( c.A * s / 256F, 0);
+ data [offset++] = new ComplexF( c.R * s / -256F, 0);
+ data [offset++] = new ComplexF( c.G * s / 256F, 0);
+ data [offset++] = new ComplexF( c.B * s / -256F, 0);
+ }
+
+
+ Fourier.FFT3( data, 4, bitmap.Width, bitmap.Height, FourierDirection.Forward );
+
+ for( int i = 0; i < data.Length; i ++ ) {
+ data[i] *= scale;
+ }
+
+ return data;
+ }
+ #endregion
+
+ abstract public string CalculateSHA1 ();
+
+ public static double CalculateNorm (Bitmap bitmap) {
+ ComplexF[] matrix = GetImageFFTArray(bitmap);
+
+ double norm = 0;
+ int size_x = 4; //ARGB values
+ int size_y = bitmap.Width;
+ int size_z = bitmap.Height;
+ for (int x=1; x<=size_x; x++) {
+ double norm_y = 0;
+ for (int y=1; y<=size_y; y++) {
+ double norm_z = 0;
+ for (int z=1; z<=size_z; z++) {
+ ComplexF cur = matrix[(size_x-x)+size_x*(size_y-y)+size_x*size_y*(size_z-z)];
+ norm_z += cur.GetModulusSquared ();// * z;
+ }
+ norm_y += norm_z;// * y;
+ }
+ norm += norm_y;// * x;
+ }
+ return norm;
+ }
+
+ public double GetNorm () {
+ string sha1 = CalculateSHA1 ();
+
+ double norm = cache.GetNorm (sha1);
+ if (double.IsNaN (norm)) {
+ norm = CalculateNorm (_bitmap);
+ cache.Add (TestName, sha1, norm);
+ //_bitmap.Save(TestName.Replace(":", "_"));
+ }
+ return norm;
+ }
+
+ protected abstract double GetExpectedNorm (double myNorm);
+
+ private void CheckCounter () {
+ string callFunc = DetermineCallingFunction ();
+ _callingFunction = callFunc;
+ if (!_mpFuncCount.Contains(_callingFunction)) {
+
+ _mpFuncCount[_callingFunction] = 1;
+ }
+ else {
+ int counter = (int)_mpFuncCount[_callingFunction];
+ counter ++;
+ _mpFuncCount[_callingFunction] = counter;
+ }
+ }
+
+ public static void AssertAlmostEqual (float expected, float actual)
+ {
+ AssertAlmostEqual (expected, actual, DEFAULT_FLOAT_TOLERANCE);
+ }
+
+ public static void AssertAlmostEqual (float expected, float actual, float tolerance)
+ {
+ string msg = String.Format("\nExpected : {0} \nActual : {1}",expected.ToString(),actual.ToString());
+ AssertAlmostEqual (expected, actual, tolerance, msg);
+ }
+
+ private static void AssertAlmostEqual (float expected, float actual, float tolerance, string message)
+ {
+ float error = System.Math.Abs ((expected - actual) / (expected + actual + float.Epsilon));
+ Assert.IsTrue (error < tolerance, message);
+ }
+
+ public static void AssertAlmostEqual (PointF expected, PointF actual)
+ {
+ string msg = String.Format("\nExpected : {0} \n Actual : {1}",expected.ToString(),actual.ToString());
+ AssertAlmostEqual (expected.X, actual.X, DEFAULT_FLOAT_TOLERANCE, msg);
+ AssertAlmostEqual (expected.Y, actual.Y, DEFAULT_FLOAT_TOLERANCE, msg);
+ }
+
+ /// <summary>
+ /// Checks that the given bitmap norm is similar to expected
+ /// </summary>
+ /// <param name="tolerance">tolerance in percents (0..100)</param>
+ /// <returns></returns>
+ ///
+ public bool Compare (double tolerance) {
+ CheckCounter ();
+
+ double error = CompareToExpectedInternal()*100;
+
+ if (SpecialTolerance != null)
+ return error <= GetSpecialTolerance(TestName);
+
+ return error <= tolerance;
+ }
+
+ public bool PDCompare (double tolerance) {
+ Bitmap ri = GetReferenceImage(TestName);
+ if (ri == null)
+ return true;
+
+ double error = PDComparer.Compare(ri, _bitmap);
+ return error <= tolerance;
+ }
+
+ public bool Compare () {
+ CheckCounter ();
+
+ double error = CompareToExpectedInternal()*100;
+
+ if (SpecialTolerance != null)
+ return error <= GetSpecialTolerance(TestName);
+
+ return error <= DEFAULT_IMAGE_TOLERANCE;
+ }
+
+ public bool PDCompare () {
+ Bitmap ri = GetReferenceImage(TestName);
+ if (ri == null)
+ return true;
+
+ double error = PDComparer.Compare(ri, _bitmap);
+ return error <= DEFAULT_IMAGE_TOLERANCE;
+ }
+
+ protected abstract Bitmap GetReferenceImage(string testName);
+
+ protected double GetSpecialTolerance(string testName) {
+ try {
+ string shortTestName = testName.Substring( testName.LastIndexOf(".") + 1 );
+ object o = SpecialTolerance[shortTestName];
+ if (o == null)
+ return DEFAULT_IMAGE_TOLERANCE;
+
+ return Convert.ToDouble(o);
+ }
+ catch (System.Exception) {
+ return DEFAULT_IMAGE_TOLERANCE;
+ }
+ }
+
+ public void AssertCompare () {
+ CheckCounter ();
+ Assert.IsTrue ((CompareToExpectedInternal () * 100) < DEFAULT_IMAGE_TOLERANCE);
+ }
+
+ public void AssertCompare (double tolerance) {
+ CheckCounter ();
+ Assert.IsTrue ((CompareToExpectedInternal () * 100) < tolerance);
+ }
+
+ public double CompareToExpected () {
+ CheckCounter ();
+ return CompareToExpectedInternal ();
+ }
+
+ double CompareToExpectedInternal () {
+ if (ShowForms)
+ return 0;
+
+ double norm = GetNorm ();
+ double expNorm = GetExpectedNorm (norm);
+ return System.Math.Abs (norm-expNorm)/(norm+expNorm+double.Epsilon);
+ }
+
+ public static DrawingTest Create (int width, int height) {
+ return Create(width, height, "GraphicsFixture");
+ }
+ public static DrawingTest Create (int width, int height, string ownerClass) {
+ DrawingTest test;
+#if TARGET_JVM
+ test = new JavaDrawingTest ();
+#else
+ test = new NetDrawingTest ();
+#endif
+ test.Init (width, height);
+ test.OwnerClass = ownerClass;
+ return test;
+ }
+ }
+
+#if TARGET_JVM
+ internal class JavaDrawingTest:DrawingTest {
+ java.awt.image.BufferedImage _image;
+ java.awt.image.BufferedImage Image {
+ get {
+ if (_image != null)
+ return _image;
+ Type imageType = typeof (Bitmap);
+ PropertyInfo [] props = imageType.GetProperties (
+ BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
+
+ PropertyInfo prop = null;
+ foreach (PropertyInfo p in props) {
+ if (p.Name == "NativeObject")
+ if (p.PropertyType == typeof(java.awt.image.BufferedImage))
+ prop = p;
+ }
+
+ MethodInfo method = prop.GetGetMethod (true);
+ _image = (java.awt.image.BufferedImage) method.Invoke (_bitmap, new object [0]);
+ return _image;
+ }
+ }
+
+ public JavaDrawingTest () {}
+
+ protected override double GetExpectedNorm (double myNorm) {
+ return ExpectedResults.GetNorm(TestName);
+ }
+
+ protected override Bitmap GetReferenceImage(string testName) {
+ try{
+ string dotNetResultsFolder = @"..\Debug\";
+ string fileName = dotNetResultsFolder + testName.Replace(":", "_") + ".png";
+ return new Bitmap(fileName);
+ }
+ catch(System.Exception e) {
+ throw new System.Exception("Error creating .Net reference image");
+ }
+ }
+
+ private class JavaForm:java.awt.Dialog,IMyForm {
+ class EventListener : java.awt.@event.WindowListener {
+ #region WindowListener Members
+
+ public void windowOpened(java.awt.@event.WindowEvent arg_0) {
+ // TODO: Add ttt.windowOpened implementation
+ }
+
+ public void windowActivated(java.awt.@event.WindowEvent arg_0) {
+ // TODO: Add ttt.windowActivated implementation
+ }
+
+ public void windowClosed(java.awt.@event.WindowEvent arg_0) {
+ // TODO: Add ttt.windowClosed implementation
+ }
+
+ public void windowDeiconified(java.awt.@event.WindowEvent arg_0) {
+ // TODO: Add ttt.windowDeiconified implementation
+ }
+
+ public void windowIconified(java.awt.@event.WindowEvent arg_0) {
+ // TODO: Add ttt.windowIconified implementation
+ }
+
+ public void windowClosing(java.awt.@event.WindowEvent arg_0) {
+ // TODO: Add ttt.windowClosing implementation
+ java.awt.Window w = arg_0.getWindow();
+ java.awt.Window par = w.getOwner ();
+ w.dispose();
+ par.dispose ();
+ }
+
+ public void windowDeactivated(java.awt.@event.WindowEvent arg_0) {
+ // TODO: Add ttt.windowDeactivated implementation
+ }
+
+ #endregion
+ }
+
+ java.awt.Image _image;
+ Size _s;
+
+ public JavaForm (string title, java.awt.Image anImage, Size s)
+ : base(new java.awt.Frame(), title, true) {
+ _image = anImage;
+ _s = s;
+
+ addWindowListener(new EventListener());
+ }
+ public override void paint (java.awt.Graphics g) {
+ base.paint (g);
+ awt.Insets insets = this.getInsets ();
+ g.drawImage (_image, insets.left, insets.top, null);
+ }
+ void IMyForm.Show () {
+ awt.Insets insets = this.getInsets ();
+ base.setSize (_s.Width + insets.left + insets.right,
+ _s.Width + insets.top + insets.bottom);
+ this.show ();
+ //save the image
+ //ImageIO.write((java.awt.image.RenderedImage)_image, "png", new java.io.File("test.java.png"));
+ }
+ }
+
+ protected override IMyForm CreateForm(string title) {
+ return new JavaForm (title, Image, _bitmap.Size);
+ }
+
+ protected override string DetermineCallingFunction() {
+ System.Exception e = new System.Exception ();
+ java.lang.Class c = vmw.common.TypeUtils.ToClass (e);
+ java.lang.reflect.Method m = c.getMethod ("getStackTrace",
+ new java.lang.Class [0]);
+ java.lang.StackTraceElement [] els = (java.lang.StackTraceElement [])
+ m.invoke (e, new object [0]);
+ java.lang.StackTraceElement el = els [4];
+ return el.getClassName () + "." + _ownerClass + "." + el.getMethodName ();
+ }
+
+ public override string CalculateSHA1() {
+ MessageDigest md = MessageDigest.getInstance ("SHA");
+ DataBufferInt dbi = (DataBufferInt) Image.getRaster ().getDataBuffer ();
+ for (int i=0; i<dbi.getNumBanks (); i++) {
+ int [] curBank = dbi.getData (i);
+ for (int j=0; j<curBank.Length; j++) {
+ int x = curBank[j];
+ md.update ((sbyte) (x & 0xFF));
+ md.update ((sbyte) ((x>>8) & 0xFF));
+ md.update ((sbyte) ((x>>16) & 0xFF));
+ md.update ((sbyte) ((x>>24) & 0xFF));
+ }
+ }
+ byte [] resdata = (byte[])vmw.common.TypeUtils.ToByteArray(md.digest());
+ return Convert.ToBase64String (resdata);
+ }
+ }
+#else
+ internal class NetDrawingTest:DrawingTest {
+ public NetDrawingTest () {}
+
+ protected override double GetExpectedNorm (double myNorm) {
+ if (CreateResults)
+ ExpectedResults.WriteNorm (TestName, myNorm);
+
+ return myNorm;
+ }
+
+ protected override Bitmap GetReferenceImage(string testName) {
+ try{
+ string fileName = testName.Replace(":", "_") + ".png";
+ _bitmap.Save( fileName );
+ return null;
+ }
+ catch(System.Exception e) {
+ throw new System.Exception("Error creating .Net reference image");
+ }
+ }
+
+ private class NetForm:Form,IMyForm {
+ Image image;
+ public NetForm(string title, Image anImage):base() {
+ base.Text = title;
+ image = anImage;
+ }
+ protected override void OnPaint(PaintEventArgs e) {
+ e.Graphics.DrawImageUnscaled (image, 0, 0);
+ }
+ void IMyForm.Show () {
+ this.Size = image.Size;
+ this.ShowDialog ();
+ this.image.Save("test.net.png");
+ }
+ }
+ protected override IMyForm CreateForm(string title) {
+ return new NetForm (title, _bitmap);
+ }
+
+ protected override string DetermineCallingFunction() {
+ StackFrame sf = new StackFrame (3, true);
+ MethodBase mb = sf.GetMethod ();
+
+ string name = mb.DeclaringType.FullName + "." + _ownerClass + "." + mb.Name;
+ return name;
+ }
+
+ public override string CalculateSHA1() {
+ Rectangle r = new Rectangle(0, 0, _bitmap.Width, _bitmap.Height);
+
+ BitmapData data = _bitmap.LockBits (r, ImageLockMode.ReadOnly,
+ _bitmap.PixelFormat);
+ int dataSize = data.Stride * data.Height;
+ byte [] bdata = new byte [dataSize];
+ Marshal.Copy (data.Scan0, bdata, 0, dataSize);
+ _bitmap.UnlockBits (data);
+
+ SHA1 sha1 = new SHA1CryptoServiceProvider ();
+ byte [] resdata = sha1.ComputeHash (bdata);
+ return Convert.ToBase64String (resdata);
+ }
+
+ }
+#endif
+
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper.csproj b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper.csproj
new file mode 100644
index 00000000000..ad091ca114e
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper.csproj
@@ -0,0 +1,117 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "DrawingTest"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "DrawingTest"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = "1595"
+ Optimize = "false"
+ OutputPath = "..\bin\Debug_Java\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = "1595"
+ Optimize = "true"
+ OutputPath = "..\bin\Release_Java\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
+ />
+ <Reference
+ Name = "System.Drawing"
+ AssemblyName = "System.Drawing"
+ HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"
+ Private = "False"
+ />
+ <Reference
+ Name = "System.Windows.Forms"
+ AssemblyName = "System.Windows.Forms"
+ HintPath = "..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll"
+ />
+ <Reference
+ Name = "Exocortex.DSP.v1"
+ Project = "{1904A41B-D1B8-40E5-ADBB-728DDCF7C816}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.XML"
+ HintPath = "..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
+ />
+ <Reference
+ Name = "nunit.framework"
+ AssemblyName = "nunit.framework"
+ HintPath = "..\..\..\..\..\..\..\..\Program Files\NUnit 2.2\bin\nunit.framework.dll"
+ AssemblyFolderKey = "hklm\dn\nunit.framework"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "AssemblyInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper_java.vmwcsproj b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper_java.vmwcsproj
new file mode 100644
index 00000000000..2bce100e959
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/DrawingTestHelper_java.vmwcsproj
@@ -0,0 +1,29 @@
+<VisualStudioProject>
+ <CSHARP ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}">
+ <Build>
+ <Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="DrawingTest" AssemblyOriginatorKeyFile="" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" PreBuildEvent="" PostBuildEvent="" RootNamespace="DrawingTest" RunPostBuildEvent="OnBuildSuccess" StartupObject="">
+ <Config Name="Debug_Java" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE;TARGET_JVM" DocumentationFile="" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="1595" Optimize="false" OutputPath="..\bin\Debug_Java\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ <Config Name="Release_Java" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="TRACE;JAVA" DocumentationFile="" DebugSymbols="false" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="1595" Optimize="true" OutputPath="..\bin\Release_Java\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ <Config Name="Debug" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE" DocumentationFile="" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="1595" Optimize="false" OutputPath="..\bin\Debug\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ </Settings>
+ <References>
+ <Reference Name="System" AssemblyName="System" HintPath="..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"/>
+ <Reference Name="rt" AssemblyName="rt" HintPath="..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\j2sdk1.4\rt.dll" Private="False"/>
+ <Reference Name="System.Drawing" AssemblyName="System.Drawing" HintPath="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll" Private="False"/>
+ <Reference Name="System.Windows.Forms" AssemblyName="System.Windows.Forms" HintPath="..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll"/>
+ <Reference Name="vmwutils" AssemblyName="vmwutils" HintPath="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\vmwutils.dll" Private="False"/>
+ <Reference Name="J2SE.Helpers" AssemblyName="J2SE.Helpers" HintPath="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\J2SE.Helpers.dll" Private="False"/>
+ <Reference Name="System.Xml" AssemblyName="System.Xml" HintPath="..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Xml.dll" Private="False"/>
+ <Reference Name="Exocortex.DSP.v1.J2EE" Project="{8D602CEF-DC13-48F1-AF0C-F6201A634FD2}" Package="{83B010C7-76FC-4FAD-A26C-00D7EFE60256}"/>
+ <Reference Name="nunit.framework" AssemblyName="nunit.framework" HintPath="..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\nunit.framework.dll" Private="False"/>
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File RelPath="AssemblyInfo.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="DrawingTest.cs" SubType="Code" BuildAction="Compile"/>
+ </Include>
+ </Files>
+ <UserProperties jarserver="ipa" REFS.JarPath.system.xml="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Xml.jar" REFS.JarPath.system.drawing="C:\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Drawing.jar" project.JDKType="1.4.2_05" REFS.JarPath.rt="..\..\Program Files\Mainsoft\Visual MainWin for J2EE\j2sdk1.4\lib\rt.jar" REFS.JarPath.system="..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.jar" REFS.JarPath.vmwutils="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\vmwutils.jar" REFS.JarPath.j2se.helpers="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\J2SE.Helpers.jar"/>
+ </CSHARP>
+ <VisualMainWin><Project Prop2023="1.4.2_05" Prop2024="" Prop2026="" Prop2015="" Version="1.6.0" ProjectType="1"/><References/><Configs><Config Prop2000="1" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="0" Prop2006="" Prop2007="" Prop2008="" Prop2009="" Prop2010="" Prop2011="-1" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="-1" Name="Debug"/><Config Prop2000="0" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="0" Prop2006="" Prop2007="" Prop2008="" Prop2009="" Prop2010="" Prop2011="0" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="-1" Name="Release_Java"/><Config Prop2000="0" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="0" Prop2006="" Prop2007="" Prop2008="" Prop2009="" Prop2010="" Prop2011="-1" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="-1" Name="Debug_Java"/></Configs></VisualMainWin></VisualStudioProject>
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/Makefile b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/Makefile
new file mode 100644
index 00000000000..dd4551c6398
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/Makefile
@@ -0,0 +1,10 @@
+MCS=mcs
+sources=AssemblyInfo.cs DrawingTest.cs
+EXOCORTEX=Exocortex.DSP.dll
+
+DrawingTestHelper.dll: $(sources) $(EXOCORTEX)
+ $(MCS) -t:library $(sources) -r:System.Windows.Forms -r:System.Drawing -r:$(EXOCORTEX) -r:nunit.framework -out:DrawingTestHelper.dll
+
+$(EXOCORTEX):
+ cd ../Exocortex.DSP/ && make
+ cp ../Exocortex.DSP/*.dll .
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/PDComparer.cs b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/PDComparer.cs
new file mode 100644
index 00000000000..689a1298f49
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/DrawingTestHelper/PDComparer.cs
@@ -0,0 +1,109 @@
+using System;
+using System.Drawing;
+using System.Collections;
+
+namespace DrawingTestHelper
+{
+ /// <summary>
+ /// Summary description for PDComparer.
+ /// </summary>
+ public class PDComparer
+ {
+ static int SearchRectSize = 10;
+ static double [,] ltDistances = new double[SearchRectSize,SearchRectSize];
+
+
+ static PDComparer()
+ {
+ for (int x = 0; x < SearchRectSize; x++)
+ for (int y = 0; y < SearchRectSize; y++)
+ {
+ ltDistances[x,y] = Math.Sqrt(x*x + y*y);
+ }
+ }
+
+ public PDComparer()
+ {
+ }
+
+ public static double Compare(Bitmap b1, Bitmap b2)
+ {
+ Point [] shapePoints = GetPointFromImage(b1);
+ double [] pointsDistance = new double[ shapePoints.Length ];
+
+ for (int i = 0; i < shapePoints.Length; i++)
+ {
+ pointsDistance[i] = DistanceToClosestPoint( shapePoints[i], b2 );
+ }
+
+ return Max( pointsDistance );
+ }
+
+ private static double DistanceToClosestPoint(Point p, Bitmap b)
+ {
+ if (IsPixelExist( b.GetPixel(p.X, p.Y) ))
+ return 0;
+
+ Rectangle r = new Rectangle(
+ p.X - SearchRectSize / 2,
+ p.Y - SearchRectSize / 2,
+ SearchRectSize,
+ SearchRectSize);
+
+ double min_distance = SearchRectSize;
+
+ for (int x = r.X; x < r.X + SearchRectSize; x++)
+ for (int y = r.Y; y < r.Y + SearchRectSize; y++)
+ if ((x < b.Width) && (y < b.Height) && (x >= 0) && (y >= 0))
+ {
+ if ( IsPixelExist( b.GetPixel(x, y) ) )
+ {
+ double d = CalculateDistance(p.X, p.Y, x, y);
+ if (d < min_distance)
+ min_distance = d;
+ }
+ }
+
+ return min_distance;
+ }
+
+ private static double CalculateDistance(Point a, Point b)
+ {
+ return CalculateDistance(a.X, a.Y, b.X, b.Y);
+ }
+
+ private static double CalculateDistance(int x1, int y1, int x2, int y2)
+ {
+ int delta_x = Math.Abs(x2 - x1);
+ int delta_y = Math.Abs(y2 - y1);
+ return ltDistances[delta_x, delta_y];
+ }
+
+ private static double Max(double [] a)
+ {
+ double max = 0;
+
+ for (int i = 0; i < a.Length; i++)
+ if (a[i] > max)
+ max = a[i];
+ return max;
+ }
+
+ private static Point [] GetPointFromImage(Bitmap b)
+ {
+ ArrayList points = new ArrayList();
+
+ for(int x = 0; x < b.Width; x++)
+ for(int y = 0; y < b.Height; y++)
+ if (IsPixelExist ( b.GetPixel(x, y) ))
+ points.Add( new Point(x, y) );
+
+ return (Point [])points.ToArray( typeof(Point) );
+ }
+
+ private static bool IsPixelExist(Color c)
+ {
+ return c.A > 0;
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/Makefile b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/Makefile
new file mode 100644
index 00000000000..d2a62000721
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/Makefile
@@ -0,0 +1,10 @@
+MCS=mcs
+sources=src/AssemblyInfo.cs src/Complex.cs src/ComplexArray.cs src/ComplexF.cs src/ComplexMath.cs src/ComplexStats.cs src/Fourier.cs src/FourierDirection.cs
+
+.SUFFIXES: .cs .exe .dll
+
+all: Exocortex.DSP.dll
+
+Exocortex.DSP.dll: $(sources)
+ $(MCS) -t:library $(sources) -out:Exocortex.DSP.dll
+
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/doc/Exocortex.DSP.xml b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/doc/Exocortex.DSP.xml
new file mode 100644
index 00000000000..71e0cf22a6c
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/doc/Exocortex.DSP.xml
@@ -0,0 +1,1124 @@
+<?xml version="1.0"?>
+<doc>
+ <assembly>
+ <name>Exocortex.DSP.v1</name>
+ </assembly>
+ <members>
+ <member name="T:Exocortex.DSP.Complex">
+ <summary>
+ <p>A double-precision complex number representation.</p>
+ </summary>
+ </member>
+ <member name="F:Exocortex.DSP.Complex.Re">
+ <summary>
+ The real component of the complex number
+ </summary>
+ </member>
+ <member name="F:Exocortex.DSP.Complex.Im">
+ <summary>
+ The imaginary component of the complex number
+ </summary>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.#ctor(System.Double,System.Double)">
+ <summary>
+ Create a complex number from a real and an imaginary component
+ </summary>
+ <param name="real"></param>
+ <param name="imaginary"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.#ctor(Exocortex.DSP.Complex)">
+ <summary>
+ Create a complex number based on an existing complex number
+ </summary>
+ <param name="c"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.FromRealImaginary(System.Double,System.Double)">
+ <summary>
+ Create a complex number from a real and an imaginary component
+ </summary>
+ <param name="real"></param>
+ <param name="imaginary"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.FromModulusArgument(System.Double,System.Double)">
+ <summary>
+ Create a complex number from a modulus (length) and an argument (radian)
+ </summary>
+ <param name="modulus"></param>
+ <param name="argument"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.Clone">
+ <summary>
+ Clone the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.GetModulus">
+ <summary>
+ The modulus (length) of the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.GetModulusSquared">
+ <summary>
+ The squared modulus (length^2) of the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.GetArgument">
+ <summary>
+ The argument (radians) of the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.GetConjugate">
+ <summary>
+ Get the conjugate of the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.Normalize">
+ <summary>
+ Scale the complex number to 1.
+ </summary>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Explicit(Exocortex.DSP.ComplexF)~Exocortex.DSP.Complex">
+ <summary>
+ Convert to a from double precision complex number to a single precison complex number
+ </summary>
+ <param name="cF"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Explicit(System.Double)~Exocortex.DSP.Complex">
+ <summary>
+ Convert from a single precision real number to a complex number
+ </summary>
+ <param name="d"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Explicit(Exocortex.DSP.Complex)~System.Double">
+ <summary>
+ Convert from a single precision complex to a real number
+ </summary>
+ <param name="c"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Equality(Exocortex.DSP.Complex,Exocortex.DSP.Complex)">
+ <summary>
+ Are these two complex numbers equivalent?
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Inequality(Exocortex.DSP.Complex,Exocortex.DSP.Complex)">
+ <summary>
+ Are these two complex numbers different?
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.GetHashCode">
+ <summary>
+ Get the hash code of the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.Equals(System.Object)">
+ <summary>
+ Is this complex number equivalent to another object?
+ </summary>
+ <param name="o"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.CompareTo(System.Object)">
+ <summary>
+ Compare to other complex numbers or real numbers
+ </summary>
+ <param name="o"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_UnaryPlus(Exocortex.DSP.Complex)">
+ <summary>
+ This operator doesn't do much. :-)
+ </summary>
+ <param name="a"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_UnaryNegation(Exocortex.DSP.Complex)">
+ <summary>
+ Negate the complex number
+ </summary>
+ <param name="a"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Addition(Exocortex.DSP.Complex,System.Double)">
+ <summary>
+ Add a complex number to a real
+ </summary>
+ <param name="a"></param>
+ <param name="f"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Addition(System.Double,Exocortex.DSP.Complex)">
+ <summary>
+ Add a real to a complex number
+ </summary>
+ <param name="f"></param>
+ <param name="a"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Addition(Exocortex.DSP.Complex,Exocortex.DSP.Complex)">
+ <summary>
+ Add to complex numbers
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Subtraction(Exocortex.DSP.Complex,System.Double)">
+ <summary>
+ Subtract a real from a complex number
+ </summary>
+ <param name="a"></param>
+ <param name="f"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Subtraction(System.Double,Exocortex.DSP.Complex)">
+ <summary>
+ Subtract a complex number from a real
+ </summary>
+ <param name="f"></param>
+ <param name="a"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Subtraction(Exocortex.DSP.Complex,Exocortex.DSP.Complex)">
+ <summary>
+ Subtract two complex numbers
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Multiply(Exocortex.DSP.Complex,System.Double)">
+ <summary>
+ Multiply a complex number by a real
+ </summary>
+ <param name="a"></param>
+ <param name="f"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Multiply(System.Double,Exocortex.DSP.Complex)">
+ <summary>
+ Multiply a real by a complex number
+ </summary>
+ <param name="f"></param>
+ <param name="a"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Multiply(Exocortex.DSP.Complex,Exocortex.DSP.Complex)">
+ <summary>
+ Multiply two complex numbers together
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Division(Exocortex.DSP.Complex,System.Double)">
+ <summary>
+ Divide a complex number by a real number
+ </summary>
+ <param name="a"></param>
+ <param name="f"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.op_Division(Exocortex.DSP.Complex,Exocortex.DSP.Complex)">
+ <summary>
+ Divide a complex number by a complex number
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.Parse(System.String)">
+ <summary>
+ Parse a complex representation in this fashion: "( %f, %f )"
+ </summary>
+ <param name="s"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.ToString">
+ <summary>
+ Get the string representation
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.Complex.IsEqual(Exocortex.DSP.Complex,Exocortex.DSP.Complex,System.Double)">
+ <summary>
+ Determine whether two complex numbers are almost (i.e. within the tolerance) equivalent.
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <param name="tolerance"></param>
+ <returns></returns>
+ </member>
+ <member name="P:Exocortex.DSP.Complex.Zero">
+ <summary>
+ Represents zero
+ </summary>
+ </member>
+ <member name="P:Exocortex.DSP.Complex.I">
+ <summary>
+ Represents the result of sqrt( -1 )
+ </summary>
+ </member>
+ <member name="P:Exocortex.DSP.Complex.MaxValue">
+ <summary>
+ Represents the largest possible value of Complex.
+ </summary>
+ </member>
+ <member name="P:Exocortex.DSP.Complex.MinValue">
+ <summary>
+ Represents the smallest possible value of Complex.
+ </summary>
+ </member>
+ <member name="T:Exocortex.DSP.ComplexArray">
+ <summary>
+ <p>A set of array utilities for complex number arrays</p>
+ </summary>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.ClampLength(Exocortex.DSP.Complex[],System.Double,System.Double)">
+ <summary>
+ Clamp length (modulus) of the elements in the complex array
+ </summary>
+ <param name="array"></param>
+ <param name="fMinimum"></param>
+ <param name="fMaximum"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Clamp(Exocortex.DSP.Complex[],Exocortex.DSP.Complex,Exocortex.DSP.Complex)">
+ <summary>
+ Clamp elements in the complex array to range [minimum,maximum]
+ </summary>
+ <param name="array"></param>
+ <param name="minimum"></param>
+ <param name="maximum"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.ClampToRealUnit(Exocortex.DSP.Complex[])">
+ <summary>
+ Clamp elements in the complex array to real unit range (i.e. [0,1])
+ </summary>
+ <param name="array"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Shift(Exocortex.DSP.Complex[],System.Int32)">
+ <summary>
+ Shift (offset) the elements in the array
+ </summary>
+ <param name="array"></param>
+ <param name="offset"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Shift(Exocortex.DSP.ComplexF[],System.Int32)">
+ <summary>
+ Shift (offset) the elements in the array
+ </summary>
+ <param name="array"></param>
+ <param name="offset"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.GetLengthRange(Exocortex.DSP.Complex[],System.Double@,System.Double@)">
+ <summary>
+ Get the range of element lengths
+ </summary>
+ <param name="array"></param>
+ <param name="minimum"></param>
+ <param name="maximum"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.GetLengthRange(Exocortex.DSP.ComplexF[],System.Single@,System.Single@)">
+ <summary>
+ Get the range of element lengths
+ </summary>
+ <param name="array"></param>
+ <param name="minimum"></param>
+ <param name="maximum"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.IsEqual(Exocortex.DSP.Complex[],Exocortex.DSP.Complex[],System.Double)">
+ <summary>
+ Determine whether the elements in the two arrays are the same
+ </summary>
+ <param name="array1"></param>
+ <param name="array2"></param>
+ <param name="tolerance"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.IsEqual(Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF[],System.Single)">
+ <summary>
+ Determine whether the elements in the two arrays are the same
+ </summary>
+ <param name="array1"></param>
+ <param name="array2"></param>
+ <param name="tolerance"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Offset(Exocortex.DSP.Complex[],System.Double)">
+ <summary>
+ Add a specific value to each element in the array
+ </summary>
+ <param name="array"></param>
+ <param name="offset"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Offset(Exocortex.DSP.Complex[],Exocortex.DSP.Complex)">
+ <summary>
+ Add a specific value to each element in the array
+ </summary>
+ <param name="array"></param>
+ <param name="offset"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Offset(Exocortex.DSP.ComplexF[],System.Single)">
+ <summary>
+ Add a specific value to each element in the array
+ </summary>
+ <param name="array"></param>
+ <param name="offset"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Offset(Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF)">
+ <summary>
+ Add a specific value to each element in the array
+ </summary>
+ <param name="array"></param>
+ <param name="offset"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Scale(Exocortex.DSP.Complex[],System.Double)">
+ <summary>
+ Multiply each element in the array by a specific value
+ </summary>
+ <param name="array"></param>
+ <param name="scale"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Scale(Exocortex.DSP.Complex[],System.Double,System.Int32,System.Int32)">
+ <summary>
+ Multiply each element in the array by a specific value
+ </summary>
+ <param name="array"></param>
+ <param name="scale"></param>
+ <param name="start"></param>
+ <param name="length"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Scale(Exocortex.DSP.Complex[],Exocortex.DSP.Complex)">
+ <summary>
+ Multiply each element in the array by a specific value
+ </summary>
+ <param name="array"></param>
+ <param name="scale"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Scale(Exocortex.DSP.Complex[],Exocortex.DSP.Complex,System.Int32,System.Int32)">
+ <summary>
+ Multiply each element in the array by a specific value
+ </summary>
+ <param name="array"></param>
+ <param name="scale"></param>
+ <param name="start"></param>
+ <param name="length"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Scale(Exocortex.DSP.ComplexF[],System.Single)">
+ <summary>
+ Multiply each element in the array by a specific value
+ </summary>
+ <param name="array"></param>
+ <param name="scale"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Scale(Exocortex.DSP.ComplexF[],System.Single,System.Int32,System.Int32)">
+ <summary>
+ Multiply each element in the array by a specific value
+ </summary>
+ <param name="array"></param>
+ <param name="scale"></param>
+ <param name="start"></param>
+ <param name="length"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Scale(Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF)">
+ <summary>
+ Multiply each element in the array by a specific value
+ </summary>
+ <param name="array"></param>
+ <param name="scale"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Scale(Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF,System.Int32,System.Int32)">
+ <summary>
+ Multiply each element in the array by a specific value
+ </summary>
+ <param name="array"></param>
+ <param name="scale"></param>
+ <param name="start"></param>
+ <param name="length"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Multiply(Exocortex.DSP.Complex[],Exocortex.DSP.Complex[])">
+ <summary>
+ Multiply each element in target array with corresponding element in rhs array
+ </summary>
+ <param name="target"></param>
+ <param name="rhs"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Multiply(Exocortex.DSP.Complex[],Exocortex.DSP.Complex[],Exocortex.DSP.Complex[])">
+ <summary>
+ Multiply each element in lhs array with corresponding element in rhs array and
+ put product in result array
+ </summary>
+ <param name="lhs"></param>
+ <param name="rhs"></param>
+ <param name="result"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Multiply(Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF[])">
+ <summary>
+ Multiply each element in target array with corresponding element in rhs array
+ </summary>
+ <param name="target"></param>
+ <param name="rhs"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Multiply(Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF[])">
+ <summary>
+ Multiply each element in lhs array with corresponding element in rhs array and
+ put product in result array
+ </summary>
+ <param name="lhs"></param>
+ <param name="rhs"></param>
+ <param name="result"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Divide(Exocortex.DSP.Complex[],Exocortex.DSP.Complex[])">
+ <summary>
+ Divide each element in target array with corresponding element in rhs array
+ </summary>
+ <param name="target"></param>
+ <param name="rhs"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Divide(Exocortex.DSP.Complex[],Exocortex.DSP.Complex[],Exocortex.DSP.Complex[])">
+ <summary>
+ Divide each element in lhs array with corresponding element in rhs array and
+ put product in result array
+ </summary>
+ <param name="lhs"></param>
+ <param name="rhs"></param>
+ <param name="result"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Divide(Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF[])">
+ <summary>
+ Divide each element in target array with corresponding element in rhs array
+ </summary>
+ <param name="target"></param>
+ <param name="rhs"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Divide(Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF[])">
+ <summary>
+ Divide each element in lhs array with corresponding element in rhs array and
+ put product in result array
+ </summary>
+ <param name="lhs"></param>
+ <param name="rhs"></param>
+ <param name="result"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Copy(Exocortex.DSP.Complex[],Exocortex.DSP.Complex[])">
+ <summary>
+ Copy an array
+ </summary>
+ <param name="dest"></param>
+ <param name="source"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Copy(Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF[])">
+ <summary>
+ Copy an array
+ </summary>
+ <param name="dest"></param>
+ <param name="source"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Reverse(Exocortex.DSP.Complex[])">
+ <summary>
+ Reverse the elements in the array
+ </summary>
+ <param name="array"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Normalize(Exocortex.DSP.Complex[])">
+ <summary>
+ Scale and offset the elements in the array so that the
+ overall range is [0, 1]
+ </summary>
+ <param name="array"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Normalize(Exocortex.DSP.ComplexF[])">
+ <summary>
+ Scale and offset the elements in the array so that the
+ overall range is [0, 1]
+ </summary>
+ <param name="array"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Invert(Exocortex.DSP.Complex[])">
+ <summary>
+ Invert each element in the array
+ </summary>
+ <param name="array"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexArray.Invert(Exocortex.DSP.ComplexF[])">
+ <summary>
+ Invert each element in the array
+ </summary>
+ <param name="array"></param>
+ </member>
+ <member name="T:Exocortex.DSP.ComplexF">
+ <summary>
+ <p>A single-precision complex number representation.</p>
+ </summary>
+ </member>
+ <member name="F:Exocortex.DSP.ComplexF.Re">
+ <summary>
+ The real component of the complex number
+ </summary>
+ </member>
+ <member name="F:Exocortex.DSP.ComplexF.Im">
+ <summary>
+ The imaginary component of the complex number
+ </summary>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.#ctor(System.Single,System.Single)">
+ <summary>
+ Create a complex number from a real and an imaginary component
+ </summary>
+ <param name="real"></param>
+ <param name="imaginary"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.#ctor(Exocortex.DSP.ComplexF)">
+ <summary>
+ Create a complex number based on an existing complex number
+ </summary>
+ <param name="c"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.FromRealImaginary(System.Single,System.Single)">
+ <summary>
+ Create a complex number from a real and an imaginary component
+ </summary>
+ <param name="real"></param>
+ <param name="imaginary"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.FromModulusArgument(System.Single,System.Single)">
+ <summary>
+ Create a complex number from a modulus (length) and an argument (radian)
+ </summary>
+ <param name="modulus"></param>
+ <param name="argument"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.Clone">
+ <summary>
+ Clone the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.GetModulus">
+ <summary>
+ The modulus (length) of the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.GetModulusSquared">
+ <summary>
+ The squared modulus (length^2) of the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.GetArgument">
+ <summary>
+ The argument (radians) of the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.GetConjugate">
+ <summary>
+ Get the conjugate of the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.Normalize">
+ <summary>
+ Scale the complex number to 1.
+ </summary>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Explicit(Exocortex.DSP.Complex)~Exocortex.DSP.ComplexF">
+ <summary>
+ Convert to a from double precision complex number to a single precison complex number
+ </summary>
+ <param name="c"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Explicit(System.Single)~Exocortex.DSP.ComplexF">
+ <summary>
+ Convert from a single precision real number to a complex number
+ </summary>
+ <param name="f"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Explicit(Exocortex.DSP.ComplexF)~System.Single">
+ <summary>
+ Convert from a single precision complex to a real number
+ </summary>
+ <param name="c"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Equality(Exocortex.DSP.ComplexF,Exocortex.DSP.ComplexF)">
+ <summary>
+ Are these two complex numbers equivalent?
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Inequality(Exocortex.DSP.ComplexF,Exocortex.DSP.ComplexF)">
+ <summary>
+ Are these two complex numbers different?
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.GetHashCode">
+ <summary>
+ Get the hash code of the complex number
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.Equals(System.Object)">
+ <summary>
+ Is this complex number equivalent to another object?
+ </summary>
+ <param name="o"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.CompareTo(System.Object)">
+ <summary>
+ Compare to other complex numbers or real numbers
+ </summary>
+ <param name="o"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_UnaryPlus(Exocortex.DSP.ComplexF)">
+ <summary>
+ This operator doesn't do much. :-)
+ </summary>
+ <param name="a"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_UnaryNegation(Exocortex.DSP.ComplexF)">
+ <summary>
+ Negate the complex number
+ </summary>
+ <param name="a"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Addition(Exocortex.DSP.ComplexF,System.Single)">
+ <summary>
+ Add a complex number to a real
+ </summary>
+ <param name="a"></param>
+ <param name="f"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Addition(System.Single,Exocortex.DSP.ComplexF)">
+ <summary>
+ Add a real to a complex number
+ </summary>
+ <param name="f"></param>
+ <param name="a"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Addition(Exocortex.DSP.ComplexF,Exocortex.DSP.ComplexF)">
+ <summary>
+ Add to complex numbers
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Subtraction(Exocortex.DSP.ComplexF,System.Single)">
+ <summary>
+ Subtract a real from a complex number
+ </summary>
+ <param name="a"></param>
+ <param name="f"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Subtraction(System.Single,Exocortex.DSP.ComplexF)">
+ <summary>
+ Subtract a complex number from a real
+ </summary>
+ <param name="f"></param>
+ <param name="a"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Subtraction(Exocortex.DSP.ComplexF,Exocortex.DSP.ComplexF)">
+ <summary>
+ Subtract two complex numbers
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Multiply(Exocortex.DSP.ComplexF,System.Single)">
+ <summary>
+ Multiply a complex number by a real
+ </summary>
+ <param name="a"></param>
+ <param name="f"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Multiply(System.Single,Exocortex.DSP.ComplexF)">
+ <summary>
+ Multiply a real by a complex number
+ </summary>
+ <param name="f"></param>
+ <param name="a"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Multiply(Exocortex.DSP.ComplexF,Exocortex.DSP.ComplexF)">
+ <summary>
+ Multiply two complex numbers together
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Division(Exocortex.DSP.ComplexF,System.Single)">
+ <summary>
+ Divide a complex number by a real number
+ </summary>
+ <param name="a"></param>
+ <param name="f"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.op_Division(Exocortex.DSP.ComplexF,Exocortex.DSP.ComplexF)">
+ <summary>
+ Divide a complex number by a complex number
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.Parse(System.String)">
+ <summary>
+ Parse a complex representation in this fashion: "( %f, %f )"
+ </summary>
+ <param name="s"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.ToString">
+ <summary>
+ Get the string representation
+ </summary>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexF.IsEqual(Exocortex.DSP.ComplexF,Exocortex.DSP.ComplexF,System.Single)">
+ <summary>
+ Determine whether two complex numbers are almost (i.e. within the tolerance) equivalent.
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ <param name="tolerance"></param>
+ <returns></returns>
+ </member>
+ <member name="P:Exocortex.DSP.ComplexF.Zero">
+ <summary>
+ Represents zero
+ </summary>
+ </member>
+ <member name="P:Exocortex.DSP.ComplexF.I">
+ <summary>
+ Represents the result of sqrt( -1 )
+ </summary>
+ </member>
+ <member name="P:Exocortex.DSP.ComplexF.MaxValue">
+ <summary>
+ Represents the largest possible value of ComplexF.
+ </summary>
+ </member>
+ <member name="P:Exocortex.DSP.ComplexF.MinValue">
+ <summary>
+ Represents the smallest possible value of ComplexF.
+ </summary>
+ </member>
+ <member name="T:Exocortex.DSP.ComplexMath">
+ <summary>
+ <p>Various mathematical functions for complex numbers.</p>
+ </summary>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexMath.Swap(Exocortex.DSP.Complex@,Exocortex.DSP.Complex@)">
+ <summary>
+ Swap two complex numbers
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexMath.Swap(Exocortex.DSP.ComplexF@,Exocortex.DSP.ComplexF@)">
+ <summary>
+ Swap two complex numbers
+ </summary>
+ <param name="a"></param>
+ <param name="b"></param>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexMath.Sqrt(Exocortex.DSP.ComplexF)">
+ <summary>
+ Calculate the square root of a complex number
+ </summary>
+ <param name="c"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexMath.Sqrt(Exocortex.DSP.Complex)">
+ <summary>
+ Calculate the square root of a complex number
+ </summary>
+ <param name="c"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexMath.Pow(Exocortex.DSP.ComplexF,System.Double)">
+ <summary>
+ Calculate the power of a complex number
+ </summary>
+ <param name="c"></param>
+ <param name="exponent"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexMath.Pow(Exocortex.DSP.Complex,System.Double)">
+ <summary>
+ Calculate the power of a complex number
+ </summary>
+ <param name="c"></param>
+ <param name="exponent"></param>
+ <returns></returns>
+ </member>
+ <member name="T:Exocortex.DSP.ComplexStats">
+ <summary>
+ <p>A set of statistical utilities for complex number arrays</p>
+ </summary>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.Sum(Exocortex.DSP.ComplexF[])">
+ <summary>
+ Calculate the sum
+ </summary>
+ <param name="data"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.Sum(Exocortex.DSP.Complex[])">
+ <summary>
+ Calculate the sum
+ </summary>
+ <param name="data"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.SumOfSquares(Exocortex.DSP.ComplexF[])">
+ <summary>
+ Calculate the sum of squares
+ </summary>
+ <param name="data"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.SumOfSquares(Exocortex.DSP.Complex[])">
+ <summary>
+ Calculate the sum of squares
+ </summary>
+ <param name="data"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.Mean(Exocortex.DSP.ComplexF[])">
+ <summary>
+ Calculate the mean (average)
+ </summary>
+ <param name="data"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.Mean(Exocortex.DSP.Complex[])">
+ <summary>
+ Calculate the mean (average)
+ </summary>
+ <param name="data"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.Variance(Exocortex.DSP.ComplexF[])">
+ <summary>
+ Calculate the variance
+ </summary>
+ <param name="data"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.Variance(Exocortex.DSP.Complex[])">
+ <summary>
+ Calculate the variance
+ </summary>
+ <param name="data"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.StdDev(Exocortex.DSP.ComplexF[])">
+ <summary>
+ Calculate the standard deviation
+ </summary>
+ <param name="data"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.StdDev(Exocortex.DSP.Complex[])">
+ <summary>
+ Calculate the standard deviation
+ </summary>
+ <param name="data"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.RMSError(Exocortex.DSP.ComplexF[],Exocortex.DSP.ComplexF[])">
+ <summary>
+ Calculate the root mean squared (RMS) error between two sets of data.
+ </summary>
+ <param name="alpha"></param>
+ <param name="beta"></param>
+ <returns></returns>
+ </member>
+ <member name="M:Exocortex.DSP.ComplexStats.RMSError(Exocortex.DSP.Complex[],Exocortex.DSP.Complex[])">
+ <summary>
+ Calculate the root mean squared (RMS) error between two sets of data.
+ </summary>
+ <param name="alpha"></param>
+ <param name="beta"></param>
+ <returns></returns>
+ </member>
+ <member name="T:Exocortex.DSP.Fourier">
+ <summary>
+ <p>Static functions for doing various Fourier Operations.</p>
+ </summary>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT(System.Single[],System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 1D fast Fourier transform of a dataset of complex numbers (as pairs of float's).
+ </summary>
+ <param name="data"></param>
+ <param name="length"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT_Quick(System.Single[],System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 1D fast Fourier transform of a dataset of complex numbers (as pairs of float's).
+ </summary>
+ <param name="data"></param>
+ <param name="length"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT(Exocortex.DSP.ComplexF[],System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 1D fast Fourier transform of a dataset of complex numbers.
+ </summary>
+ <param name="data"></param>
+ <param name="length"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT_Quick(Exocortex.DSP.ComplexF[],System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 1D fast Fourier transform of a dataset of complex numbers.
+ </summary>
+ <param name="data"></param>
+ <param name="length"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT(Exocortex.DSP.ComplexF[],Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 1D fast Fourier transform of a dataset of complex numbers.
+ </summary>
+ <param name="data"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT(Exocortex.DSP.Complex[],System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 1D fast Fourier transform of a dataset of complex numbers.
+ </summary>
+ <param name="data"></param>
+ <param name="length"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT_Quick(Exocortex.DSP.Complex[],System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 1D fast Fourier transform of a dataset of complex numbers.
+ </summary>
+ <param name="data"></param>
+ <param name="length"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.RFFT(System.Single[],Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 1D real-symmetric fast fourier transform.
+ </summary>
+ <param name="data"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.RFFT(System.Single[],System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 1D real-symmetric fast fourier transform.
+ </summary>
+ <param name="data"></param>
+ <param name="length"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT2(System.Single[],System.Int32,System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 2D fast fourier transform on a data set of complex numbers (represented as pairs of floats)
+ </summary>
+ <param name="data"></param>
+ <param name="xLength"></param>
+ <param name="yLength"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT2(Exocortex.DSP.ComplexF[],System.Int32,System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 2D fast fourier transform on a data set of complex numbers
+ </summary>
+ <param name="data"></param>
+ <param name="xLength"></param>
+ <param name="yLength"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT2(Exocortex.DSP.Complex[],System.Int32,System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 2D fast fourier transform on a data set of complex numbers
+ </summary>
+ <param name="data"></param>
+ <param name="xLength"></param>
+ <param name="yLength"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT3(Exocortex.DSP.ComplexF[],System.Int32,System.Int32,System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 3D fast fourier transform on a data set of complex numbers
+ </summary>
+ <param name="data"></param>
+ <param name="xLength"></param>
+ <param name="yLength"></param>
+ <param name="zLength"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="M:Exocortex.DSP.Fourier.FFT3(Exocortex.DSP.Complex[],System.Int32,System.Int32,System.Int32,Exocortex.DSP.FourierDirection)">
+ <summary>
+ Compute a 3D fast fourier transform on a data set of complex numbers
+ </summary>
+ <param name="data"></param>
+ <param name="xLength"></param>
+ <param name="yLength"></param>
+ <param name="zLength"></param>
+ <param name="direction"></param>
+ </member>
+ <member name="T:Exocortex.DSP.FourierDirection">
+ <summary>
+ <p>The direction of the fourier transform.</p>
+ </summary>
+ </member>
+ <member name="F:Exocortex.DSP.FourierDirection.Forward">
+ <summary>
+ Forward direction. Usually in reference to moving from temporal
+ representation to frequency representation
+ </summary>
+ </member>
+ <member name="F:Exocortex.DSP.FourierDirection.Backward">
+ <summary>
+ Backward direction. Usually in reference to moving from frequency
+ representation to temporal representation
+ </summary>
+ </member>
+ </members>
+</doc>
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/AssemblyInfo.cs b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/AssemblyInfo.cs
new file mode 100644
index 00000000000..177a4f0e70a
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/AssemblyInfo.cs
@@ -0,0 +1,58 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: AssemblyVersion("1.0.*")]
+
+//
+// In order to sign your assembly you must specify a key to use. Refer to the
+// Microsoft .NET Framework documentation for more information on assembly signing.
+//
+// Use the attributes below to control which key is used for signing.
+//
+// Notes:
+// (*) If no key is specified, the assembly is not signed.
+// (*) KeyName refers to a key that has been installed in the Crypto Service
+// Provider (CSP) on your machine. KeyFile refers to a file which contains
+// a key.
+// (*) If the KeyFile and the KeyName values are both specified, the
+// following processing occurs:
+// (1) If the KeyName can be found in the CSP, that key is used.
+// (2) If the KeyName does not exist and the KeyFile does exist, the key
+// in the KeyFile is installed into the CSP and used.
+// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
+// When specifying the KeyFile, the location of the KeyFile should be
+// relative to the project output directory which is
+// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
+// located in the project directory, you would specify the AssemblyKeyFile
+// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
+// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
+// documentation for more information on this.
+//
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("")]
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Complex.cs b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Complex.cs
new file mode 100644
index 00000000000..349d2108dc2
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Complex.cs
@@ -0,0 +1,527 @@
+/*
+ * BSD Licence:
+ * Copyright (c) 2001, 2002 Ben Houston [ ben@exocortex.org ]
+ * Exocortex Technologies [ www.exocortex.org ]
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+using System;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+
+namespace Exocortex.DSP {
+
+ // Comments? Questions? Bugs? Tell Ben Houston at ben@exocortex.org
+ // Version: May 4, 2002
+
+ /// <summary>
+ /// <p>A double-precision complex number representation.</p>
+ /// </summary>
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Complex : IComparable, ICloneable {
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// The real component of the complex number
+ /// </summary>
+ public double Re;
+
+ /// <summary>
+ /// The imaginary component of the complex number
+ /// </summary>
+ public double Im;
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Create a complex number from a real and an imaginary component
+ /// </summary>
+ /// <param name="real"></param>
+ /// <param name="imaginary"></param>
+ public Complex( double real, double imaginary ) {
+ this.Re = (double) real;
+ this.Im = (double) imaginary;
+ }
+
+ /// <summary>
+ /// Create a complex number based on an existing complex number
+ /// </summary>
+ /// <param name="c"></param>
+ public Complex( Complex c ) {
+ this.Re = c.Re;
+ this.Im = c.Im;
+ }
+
+ /// <summary>
+ /// Create a complex number from a real and an imaginary component
+ /// </summary>
+ /// <param name="real"></param>
+ /// <param name="imaginary"></param>
+ /// <returns></returns>
+ static public Complex FromRealImaginary( double real, double imaginary ) {
+ Complex c;
+ c.Re = (double) real;
+ c.Im = (double) imaginary;
+ return c;
+ }
+
+ /// <summary>
+ /// Create a complex number from a modulus (length) and an argument (radian)
+ /// </summary>
+ /// <param name="modulus"></param>
+ /// <param name="argument"></param>
+ /// <returns></returns>
+ static public Complex FromModulusArgument( double modulus, double argument ) {
+ Complex c;
+ c.Re = (double)( modulus * System.Math.Cos( argument ) );
+ c.Im = (double)( modulus * System.Math.Sin( argument ) );
+ return c;
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ object ICloneable.Clone() {
+ return new Complex( this );
+ }
+ /// <summary>
+ /// Clone the complex number
+ /// </summary>
+ /// <returns></returns>
+ public Complex Clone() {
+ return new Complex( this );
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// The modulus (length) of the complex number
+ /// </summary>
+ /// <returns></returns>
+ public double GetModulus() {
+ double x = this.Re;
+ double y = this.Im;
+ return (double) Math.Sqrt( x*x + y*y );
+ }
+
+ /// <summary>
+ /// The squared modulus (length^2) of the complex number
+ /// </summary>
+ /// <returns></returns>
+ public double GetModulusSquared() {
+ double x = this.Re;
+ double y = this.Im;
+ return (double) x*x + y*y;
+ }
+
+ /// <summary>
+ /// The argument (radians) of the complex number
+ /// </summary>
+ /// <returns></returns>
+ public double GetArgument() {
+ return (double) Math.Atan2( this.Im, this.Re );
+ }
+
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Get the conjugate of the complex number
+ /// </summary>
+ /// <returns></returns>
+ public Complex GetConjugate() {
+ return FromRealImaginary( this.Re, -this.Im );
+ }
+
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Scale the complex number to 1.
+ /// </summary>
+ public void Normalize() {
+ double modulus = this.GetModulus();
+ if( modulus == 0 ) {
+ throw new DivideByZeroException( "Can not normalize a complex number that is zero." );
+ }
+ this.Re = (double)( this.Re / modulus );
+ this.Im = (double)( this.Im / modulus );
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Convert to a from double precision complex number to a single precison complex number
+ /// </summary>
+ /// <param name="cF"></param>
+ /// <returns></returns>
+ public static explicit operator Complex ( ComplexF cF ) {
+ Complex c;
+ c.Re = (double) cF.Re;
+ c.Im = (double) cF.Im;
+ return c;
+ }
+
+ /// <summary>
+ /// Convert from a single precision real number to a complex number
+ /// </summary>
+ /// <param name="d"></param>
+ /// <returns></returns>
+ public static explicit operator Complex ( double d ) {
+ Complex c;
+ c.Re = (double) d;
+ c.Im = (double) 0;
+ return c;
+ }
+
+ /// <summary>
+ /// Convert from a single precision complex to a real number
+ /// </summary>
+ /// <param name="c"></param>
+ /// <returns></returns>
+ public static explicit operator double ( Complex c ) {
+ return (double) c.Re;
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Are these two complex numbers equivalent?
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static bool operator==( Complex a, Complex b ) {
+ return ( a.Re == b.Re ) && ( a.Im == b.Im );
+ }
+
+ /// <summary>
+ /// Are these two complex numbers different?
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static bool operator!=( Complex a, Complex b ) {
+ return ( a.Re != b.Re ) || ( a.Im != b.Im );
+ }
+
+ /// <summary>
+ /// Get the hash code of the complex number
+ /// </summary>
+ /// <returns></returns>
+ public override int GetHashCode() {
+ return ( this.Re.GetHashCode() ^ this.Im.GetHashCode() );
+ }
+
+ /// <summary>
+ /// Is this complex number equivalent to another object?
+ /// </summary>
+ /// <param name="o"></param>
+ /// <returns></returns>
+ public override bool Equals( object o ) {
+ if( o is Complex ) {
+ Complex c = (Complex) o;
+ return ( this == c );
+ }
+ return false;
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Compare to other complex numbers or real numbers
+ /// </summary>
+ /// <param name="o"></param>
+ /// <returns></returns>
+ public int CompareTo( object o ) {
+ if( o == null ) {
+ return 1; // null sorts before current
+ }
+ if( o is Complex ) {
+ return this.GetModulus().CompareTo( ((Complex)o).GetModulus() );
+ }
+ if( o is double ) {
+ return this.GetModulus().CompareTo( (double)o );
+ }
+ if( o is ComplexF ) {
+ return this.GetModulus().CompareTo( ((ComplexF)o).GetModulus() );
+ }
+ if( o is float ) {
+ return this.GetModulus().CompareTo( (float)o );
+ }
+ throw new ArgumentException();
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// This operator doesn't do much. :-)
+ /// </summary>
+ /// <param name="a"></param>
+ /// <returns></returns>
+ public static Complex operator+( Complex a ) {
+ return a;
+ }
+
+ /// <summary>
+ /// Negate the complex number
+ /// </summary>
+ /// <param name="a"></param>
+ /// <returns></returns>
+ public static Complex operator-( Complex a ) {
+ a.Re = -a.Re;
+ a.Im = -a.Im;
+ return a;
+ }
+
+ /// <summary>
+ /// Add a complex number to a real
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="f"></param>
+ /// <returns></returns>
+ public static Complex operator+( Complex a, double f ) {
+ a.Re = (double)( a.Re + f );
+ return a;
+ }
+
+ /// <summary>
+ /// Add a real to a complex number
+ /// </summary>
+ /// <param name="f"></param>
+ /// <param name="a"></param>
+ /// <returns></returns>
+ public static Complex operator+( double f, Complex a ) {
+ a.Re = (double)( a.Re + f );
+ return a;
+ }
+
+ /// <summary>
+ /// Add to complex numbers
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static Complex operator+( Complex a, Complex b ) {
+ a.Re = a.Re + b.Re;
+ a.Im = a.Im + b.Im;
+ return a;
+ }
+
+ /// <summary>
+ /// Subtract a real from a complex number
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="f"></param>
+ /// <returns></returns>
+ public static Complex operator-( Complex a, double f ) {
+ a.Re = (double)( a.Re - f );
+ return a;
+ }
+
+ /// <summary>
+ /// Subtract a complex number from a real
+ /// </summary>
+ /// <param name="f"></param>
+ /// <param name="a"></param>
+ /// <returns></returns>
+ public static Complex operator-( double f, Complex a ) {
+ a.Re = (float)( f - a.Re );
+ a.Im = (float)( 0 - a.Im );
+ return a;
+ }
+
+ /// <summary>
+ /// Subtract two complex numbers
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static Complex operator-( Complex a, Complex b ) {
+ a.Re = a.Re - b.Re;
+ a.Im = a.Im - b.Im;
+ return a;
+ }
+
+ /// <summary>
+ /// Multiply a complex number by a real
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="f"></param>
+ /// <returns></returns>
+ public static Complex operator*( Complex a, double f ) {
+ a.Re = (double)( a.Re * f );
+ a.Im = (double)( a.Im * f );
+ return a;
+ }
+
+ /// <summary>
+ /// Multiply a real by a complex number
+ /// </summary>
+ /// <param name="f"></param>
+ /// <param name="a"></param>
+ /// <returns></returns>
+ public static Complex operator*( double f, Complex a ) {
+ a.Re = (double)( a.Re * f );
+ a.Im = (double)( a.Im * f );
+
+ return a;
+ }
+
+ /// <summary>
+ /// Multiply two complex numbers together
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static Complex operator*( Complex a, Complex b ) {
+ // (x + yi)(u + vi) = (xu – yv) + (xv + yu)i.
+ double x = a.Re, y = a.Im;
+ double u = b.Re, v = b.Im;
+
+ a.Re = (double)( x*u - y*v );
+ a.Im = (double)( x*v + y*u );
+
+ return a;
+ }
+
+ /// <summary>
+ /// Divide a complex number by a real number
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="f"></param>
+ /// <returns></returns>
+ public static Complex operator/( Complex a, double f ) {
+ if( f == 0 ) {
+ throw new DivideByZeroException();
+ }
+
+ a.Re = (double)( a.Re / f );
+ a.Im = (double)( a.Im / f );
+
+ return a;
+ }
+
+ /// <summary>
+ /// Divide a complex number by a complex number
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static Complex operator/( Complex a, Complex b ) {
+ double x = a.Re, y = a.Im;
+ double u = b.Re, v = b.Im;
+ double denom = u*u + v*v;
+
+ if( denom == 0 ) {
+ throw new DivideByZeroException();
+ }
+
+ a.Re = (double)( ( x*u + y*v ) / denom );
+ a.Im = (double)( ( y*u - x*v ) / denom );
+
+ return a;
+ }
+
+ /// <summary>
+ /// Parse a complex representation in this fashion: "( %f, %f )"
+ /// </summary>
+ /// <param name="s"></param>
+ /// <returns></returns>
+ static public Complex Parse( string s ) {
+ throw new NotImplementedException( "Complex Complex.Parse( string s ) is not implemented." );
+ }
+
+ /// <summary>
+ /// Get the string representation
+ /// </summary>
+ /// <returns></returns>
+ public override string ToString() {
+ return String.Format( "( {0}, {1}i )", this.Re, this.Im );
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Determine whether two complex numbers are almost (i.e. within the tolerance) equivalent.
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <param name="tolerance"></param>
+ /// <returns></returns>
+ static public bool IsEqual( Complex a, Complex b, double tolerance ) {
+ return
+ ( Math.Abs( a.Re - b.Re ) < tolerance ) &&
+ ( Math.Abs( a.Im - b.Im ) < tolerance );
+
+ }
+
+ //----------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Represents zero
+ /// </summary>
+ static public Complex Zero {
+ get { return new Complex( 0, 0 ); }
+ }
+
+ /// <summary>
+ /// Represents the result of sqrt( -1 )
+ /// </summary>
+ static public Complex I {
+ get { return new Complex( 0, 1 ); }
+ }
+
+ /// <summary>
+ /// Represents the largest possible value of Complex.
+ /// </summary>
+ static public Complex MaxValue {
+ get { return new Complex( double.MaxValue, double.MaxValue ); }
+ }
+
+ /// <summary>
+ /// Represents the smallest possible value of Complex.
+ /// </summary>
+ static public Complex MinValue {
+ get { return new Complex( double.MinValue, double.MinValue ); }
+ }
+
+
+ //----------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------
+ }
+
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexArray.cs b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexArray.cs
new file mode 100644
index 00000000000..4c2dcfa8bc8
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexArray.cs
@@ -0,0 +1,682 @@
+/*
+ * BSD Licence:
+ * Copyright (c) 2001, 2002 Ben Houston [ ben@exocortex.org ]
+ * Exocortex Technologies [ www.exocortex.org ]
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+
+using System;
+using System.Diagnostics;
+using Exocortex.DSP;
+
+namespace Exocortex.DSP {
+
+ // Comments? Questions? Bugs? Tell Ben Houston at ben@exocortex.org
+ // Version: May 4, 2002
+
+ /// <summary>
+ /// <p>A set of array utilities for complex number arrays</p>
+ /// </summary>
+ public class ComplexArray {
+
+ //---------------------------------------------------------------------------------------------
+
+ private ComplexArray() {
+ }
+
+ //---------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Clamp length (modulus) of the elements in the complex array
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="fMinimum"></param>
+ /// <param name="fMaximum"></param>
+ static public void ClampLength( Complex[] array, double fMinimum, double fMaximum ) {
+ for( int i = 0; i < array.Length; i ++ ) {
+ array[i] = Complex.FromModulusArgument( Math.Max( fMinimum, Math.Min( fMaximum, array[i].GetModulus() ) ), array[i].GetArgument() );
+ }
+ }
+
+ /// <summary>
+ /// Clamp elements in the complex array to range [minimum,maximum]
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="minimum"></param>
+ /// <param name="maximum"></param>
+ static public void Clamp( Complex[] array, Complex minimum, Complex maximum ) {
+ for( int i = 0; i < array.Length; i ++ ) {
+ array[i].Re = Math.Min( Math.Max( array[ i ].Re, minimum.Re ), maximum.Re );
+ array[i].Im = Math.Min( Math.Max( array[ i ].Re, minimum.Im ), maximum.Im );
+ }
+ }
+
+ /// <summary>
+ /// Clamp elements in the complex array to real unit range (i.e. [0,1])
+ /// </summary>
+ /// <param name="array"></param>
+ static public void ClampToRealUnit( Complex[] array ) {
+ for( int i = 0; i < array.Length; i ++ ) {
+ array[i].Re = Math.Min( Math.Max( array[i].Re, 0 ), 1 );
+ array[i].Im = 0;
+ }
+ }
+
+ //---------------------------------------------------------------------------------------------
+
+ static private bool _workspaceFLocked = false;
+ static private ComplexF[] _workspaceF = new ComplexF[ 0 ];
+
+ static private void LockWorkspaceF( int length, ref ComplexF[] workspace ) {
+ Debug.Assert( _workspaceFLocked == false );
+ _workspaceFLocked = true;
+ if( length >= _workspaceF.Length ) {
+ _workspaceF = new ComplexF[ length ];
+ }
+ workspace = _workspaceF;
+ }
+ static private void UnlockWorkspaceF( ref ComplexF[] workspace ) {
+ Debug.Assert( _workspaceF == workspace );
+ Debug.Assert( _workspaceFLocked == true );
+ _workspaceFLocked = false;
+ workspace = null;
+ }
+
+ //---------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Shift (offset) the elements in the array
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="offset"></param>
+ static public void Shift( Complex[] array, int offset ) {
+ Debug.Assert( array != null );
+ Debug.Assert( offset >= 0 );
+ Debug.Assert( offset < array.Length );
+
+ if( offset == 0 ) {
+ return;
+ }
+
+ int length = array.Length;
+ Complex[] temp = new Complex[ length ];
+
+ for( int i = 0; i < length; i ++ ) {
+ temp[ ( i + offset ) % length ] = array[ i ];
+ }
+ for( int i = 0; i < length; i ++ ) {
+ array[ i ] = temp[ i ];
+ }
+ }
+
+ /// <summary>
+ /// Shift (offset) the elements in the array
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="offset"></param>
+ static public void Shift( ComplexF[] array, int offset ) {
+ Debug.Assert( array != null );
+ Debug.Assert( offset >= 0 );
+ Debug.Assert( offset < array.Length );
+
+ if( offset == 0 ) {
+ return;
+ }
+
+ int length = array.Length;
+ ComplexF[] workspace = null;
+ ComplexArray.LockWorkspaceF( length, ref workspace );
+
+ for( int i = 0; i < length; i ++ ) {
+ workspace[ ( i + offset ) % length ] = array[ i ];
+ }
+ for( int i = 0; i < length; i ++ ) {
+ array[ i ] = workspace[ i ];
+ }
+
+ ComplexArray.UnlockWorkspaceF( ref workspace );
+ }
+
+ //---------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Get the range of element lengths
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="minimum"></param>
+ /// <param name="maximum"></param>
+ static public void GetLengthRange( Complex[] array, ref double minimum, ref double maximum ) {
+ minimum = +double.MaxValue;
+ maximum = -double.MaxValue;
+ for( int i = 0; i < array.Length; i ++ ) {
+ double temp = array[i].GetModulus();
+ minimum = Math.Min( temp, minimum );
+ maximum = Math.Max( temp, maximum );
+ }
+ }
+ /// <summary>
+ /// Get the range of element lengths
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="minimum"></param>
+ /// <param name="maximum"></param>
+ static public void GetLengthRange( ComplexF[] array, ref float minimum, ref float maximum ) {
+ minimum = +float.MaxValue;
+ maximum = -float.MaxValue;
+ for( int i = 0; i < array.Length; i ++ ) {
+ float temp = array[i].GetModulus();
+ minimum = Math.Min( temp, minimum );
+ maximum = Math.Max( temp, maximum );
+ }
+ }
+
+ // // <summary>
+ // // Conver the complex array to a double array
+ // // </summary>
+ // // <param name="array"></param>
+ // // <param name="style"></param>
+ // // <returns></returns>
+ /* static public double[] ConvertToDoubleArray( Complex[] array, ConversionStyle style ) {
+ double[] newArray = new double[ array.Length ];
+ switch( style ) {
+ case ConversionStyle.Length:
+ for( int i = 0; i < array.Length; i ++ ) {
+ newArray[i] = (double) array[i].GetModulus();
+ }
+ break;
+ case ConversionStyle.Real:
+ for( int i = 0; i < array.Length; i ++ ) {
+ newArray[i] = (double) array[i].Re;
+ }
+ break;
+ case ConversionStyle.Imaginary:
+ for( int i = 0; i < array.Length; i ++ ) {
+ newArray[i] = (double) array[i].Im;
+ }
+ break;
+ default:
+ Debug.Assert( false );
+ break;
+ }
+ return newArray;
+ } */
+
+ //---------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Determine whether the elements in the two arrays are the same
+ /// </summary>
+ /// <param name="array1"></param>
+ /// <param name="array2"></param>
+ /// <param name="tolerance"></param>
+ /// <returns></returns>
+ static public bool IsEqual( Complex[] array1, Complex[] array2, double tolerance ) {
+ if ( array1.Length != array2.Length ) {
+ return false;
+ }
+ for( int i = 0; i < array1.Length; i ++ ) {
+ if( Complex.IsEqual( array1[i], array2[i], tolerance ) == false ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Determine whether the elements in the two arrays are the same
+ /// </summary>
+ /// <param name="array1"></param>
+ /// <param name="array2"></param>
+ /// <param name="tolerance"></param>
+ /// <returns></returns>
+ static public bool IsEqual( ComplexF[] array1, ComplexF[] array2, float tolerance ) {
+ if ( array1.Length != array2.Length ) {
+ return false;
+ }
+ for( int i = 0; i < array1.Length; i ++ ) {
+ if( ComplexF.IsEqual( array1[i], array2[i], tolerance ) == false ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ //---------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Add a specific value to each element in the array
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="offset"></param>
+ static public void Offset( Complex[] array, double offset ) {
+ int length = array.Length;
+ for( int i = 0; i < length; i ++ ) {
+ array[i].Re += offset;
+ }
+ }
+
+ /// <summary>
+ /// Add a specific value to each element in the array
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="offset"></param>
+ static public void Offset( Complex[] array, Complex offset ) {
+ int length = array.Length;
+ for( int i = 0; i < length; i ++ ) {
+ array[i] += offset;
+ }
+ }
+
+ /// <summary>
+ /// Add a specific value to each element in the array
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="offset"></param>
+ static public void Offset( ComplexF[] array, float offset ) {
+ int length = array.Length;
+ for( int i = 0; i < length; i ++ ) {
+ array[i].Re += offset;
+ }
+ }
+
+ /// <summary>
+ /// Add a specific value to each element in the array
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="offset"></param>
+ static public void Offset( ComplexF[] array, ComplexF offset ) {
+ int length = array.Length;
+ for( int i = 0; i < length; i ++ ) {
+ array[i] += offset;
+ }
+ }
+
+ //---------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Multiply each element in the array by a specific value
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="scale"></param>
+ static public void Scale( Complex[] array, double scale ) {
+ Debug.Assert( array != null );
+
+ int length = array.Length;
+ for( int i = 0; i < length; i ++ ) {
+ array[i] *= scale;
+ }
+ }
+ /// <summary>
+ /// Multiply each element in the array by a specific value
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="scale"></param>
+ /// <param name="start"></param>
+ /// <param name="length"></param>
+ static public void Scale( Complex[] array, double scale, int start, int length ) {
+ Debug.Assert( array != null );
+ Debug.Assert( start >= 0 );
+ Debug.Assert( length >= 0 );
+ Debug.Assert( ( start + length ) < array.Length );
+
+ for( int i = 0; i < length; i ++ ) {
+ array[i + start] *= scale;
+ }
+ }
+
+ /// <summary>
+ /// Multiply each element in the array by a specific value
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="scale"></param>
+ static public void Scale( Complex[] array, Complex scale ) {
+ Debug.Assert( array != null );
+
+ int length = array.Length;
+ for( int i = 0; i < length; i ++ ) {
+ array[i] *= scale;
+ }
+ }
+ /// <summary>
+ /// Multiply each element in the array by a specific value
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="scale"></param>
+ /// <param name="start"></param>
+ /// <param name="length"></param>
+ static public void Scale( Complex[] array, Complex scale, int start, int length ) {
+ Debug.Assert( array != null );
+ Debug.Assert( start >= 0 );
+ Debug.Assert( length >= 0 );
+ Debug.Assert( ( start + length ) < array.Length );
+
+ for( int i = 0; i < length; i ++ ) {
+ array[i + start] *= scale;
+ }
+ }
+
+ /// <summary>
+ /// Multiply each element in the array by a specific value
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="scale"></param>
+ static public void Scale( ComplexF[] array, float scale ) {
+ Debug.Assert( array != null );
+
+ int length = array.Length;
+ for( int i = 0; i < length; i ++ ) {
+ array[i] *= scale;
+ }
+ }
+ /// <summary>
+ /// Multiply each element in the array by a specific value
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="scale"></param>
+ /// <param name="start"></param>
+ /// <param name="length"></param>
+ static public void Scale( ComplexF[] array, float scale, int start, int length ) {
+ Debug.Assert( array != null );
+ Debug.Assert( start >= 0 );
+ Debug.Assert( length >= 0 );
+ Debug.Assert( ( start + length ) < array.Length );
+
+ for( int i = 0; i < length; i ++ ) {
+ array[i + start] *= scale;
+ }
+ }
+
+ /// <summary>
+ /// Multiply each element in the array by a specific value
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="scale"></param>
+ static public void Scale( ComplexF[] array, ComplexF scale ) {
+ Debug.Assert( array != null );
+
+ int length = array.Length;
+ for( int i = 0; i < length; i ++ ) {
+ array[i] *= scale;
+ }
+ }
+ /// <summary>
+ /// Multiply each element in the array by a specific value
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="scale"></param>
+ /// <param name="start"></param>
+ /// <param name="length"></param>
+ static public void Scale( ComplexF[] array, ComplexF scale, int start, int length ) {
+ Debug.Assert( array != null );
+ Debug.Assert( start >= 0 );
+ Debug.Assert( length >= 0 );
+ Debug.Assert( ( start + length ) < array.Length );
+
+ for( int i = 0; i < length; i ++ ) {
+ array[i + start] *= scale;
+ }
+ }
+
+ //---------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Multiply each element in target array with corresponding element in rhs array
+ /// </summary>
+ /// <param name="target"></param>
+ /// <param name="rhs"></param>
+ static public void Multiply( Complex[] target, Complex[] rhs ) {
+ ComplexArray.Multiply( target, rhs, target );
+ }
+ /// <summary>
+ /// Multiply each element in lhs array with corresponding element in rhs array and
+ /// put product in result array
+ /// </summary>
+ /// <param name="lhs"></param>
+ /// <param name="rhs"></param>
+ /// <param name="result"></param>
+ static public void Multiply( Complex[] lhs, Complex[] rhs, Complex[] result ) {
+ Debug.Assert( lhs != null );
+ Debug.Assert( rhs != null );
+ Debug.Assert( result != null );
+ Debug.Assert( lhs.Length == rhs.Length );
+ Debug.Assert( lhs.Length == result.Length );
+
+ int length = lhs.Length;
+ for( int i = 0; i < length; i ++ ) {
+ result[i] = lhs[i] * rhs[i];
+ }
+ }
+
+ /// <summary>
+ /// Multiply each element in target array with corresponding element in rhs array
+ /// </summary>
+ /// <param name="target"></param>
+ /// <param name="rhs"></param>
+ static public void Multiply( ComplexF[] target, ComplexF[] rhs ) {
+ ComplexArray.Multiply( target, rhs, target );
+ }
+ /// <summary>
+ /// Multiply each element in lhs array with corresponding element in rhs array and
+ /// put product in result array
+ /// </summary>
+ /// <param name="lhs"></param>
+ /// <param name="rhs"></param>
+ /// <param name="result"></param>
+ static public void Multiply( ComplexF[] lhs, ComplexF[] rhs, ComplexF[] result ) {
+ Debug.Assert( lhs != null );
+ Debug.Assert( rhs != null );
+ Debug.Assert( result != null );
+ Debug.Assert( lhs.Length == rhs.Length );
+ Debug.Assert( lhs.Length == result.Length );
+
+ int length = lhs.Length;
+ for( int i = 0; i < length; i ++ ) {
+ result[i] = lhs[i] * rhs[i];
+ }
+ }
+
+ //---------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Divide each element in target array with corresponding element in rhs array
+ /// </summary>
+ /// <param name="target"></param>
+ /// <param name="rhs"></param>
+ static public void Divide( Complex[] target, Complex[] rhs ) {
+ ComplexArray.Divide( target, rhs, target );
+ }
+ /// <summary>
+ /// Divide each element in lhs array with corresponding element in rhs array and
+ /// put product in result array
+ /// </summary>
+ /// <param name="lhs"></param>
+ /// <param name="rhs"></param>
+ /// <param name="result"></param>
+ static public void Divide( Complex[] lhs, Complex[] rhs, Complex[] result ) {
+ Debug.Assert( lhs != null );
+ Debug.Assert( rhs != null );
+ Debug.Assert( result != null );
+ Debug.Assert( lhs.Length == rhs.Length );
+ Debug.Assert( lhs.Length == result.Length );
+
+ int length = lhs.Length;
+ for( int i = 0; i < length; i ++ ) {
+ result[i] = lhs[i] / rhs[i];
+ }
+ }
+
+ /// <summary>
+ /// Divide each element in target array with corresponding element in rhs array
+ /// </summary>
+ /// <param name="target"></param>
+ /// <param name="rhs"></param>
+ static public void Divide( ComplexF[] target, ComplexF[] rhs ) {
+ ComplexArray.Divide( target, rhs, target );
+ }
+ /// <summary>
+ /// Divide each element in lhs array with corresponding element in rhs array and
+ /// put product in result array
+ /// </summary>
+ /// <param name="lhs"></param>
+ /// <param name="rhs"></param>
+ /// <param name="result"></param>
+ static public void Divide( ComplexF[] lhs, ComplexF[] rhs, ComplexF[] result ) {
+ Debug.Assert( lhs != null );
+ Debug.Assert( rhs != null );
+ Debug.Assert( result != null );
+ Debug.Assert( lhs.Length == rhs.Length );
+ Debug.Assert( lhs.Length == result.Length );
+
+ ComplexF zero = ComplexF.Zero;
+ int length = lhs.Length;
+ for( int i = 0; i < length; i ++ ) {
+ if( rhs[i] != zero ) {
+ result[i] = lhs[i] / rhs[i];
+ }
+ else {
+ result[i] = zero;
+ }
+ }
+ }
+
+ //---------------------------------------------------------------------------------------------
+
+ /*static public void Flip( ComplexF[] array, Size3 size ) {
+ Debug.Assert( array != null );
+
+ ComplexF[] workspace = null;
+ ComplexArray.LockWorkspaceF( size.GetTotalLength(), ref workspace );
+
+ for( int z = 0; z < size.Depth; z ++ ) {
+ for( int y = 0; y < size.Height; y ++ ) {
+ int xyzOffset = 0 + y * size.Width + z * size.Width * size.Height;
+ int abcOffset = size.Width - 1 + ( size.Height - y - 1 ) * size.Width + ( size.Depth - z - 1 ) * size.Width * size.Height;
+ for( int x = 0; x < size.Width; x ++ ) {
+ workspace[ xyzOffset ++ ] = array[ abcOffset -- ];
+ }
+ }
+ }
+
+ for( int i = 0; i < size.GetTotalLength(); i ++ ) {
+ array[ i ] = workspace[ i ];
+ }
+
+ ComplexArray.UnlockWorkspaceF( ref workspace );
+ } */
+
+
+ /// <summary>
+ /// Copy an array
+ /// </summary>
+ /// <param name="dest"></param>
+ /// <param name="source"></param>
+ static public void Copy( Complex[] dest, Complex[] source ) {
+ Debug.Assert( dest != null );
+ Debug.Assert( source != null );
+ Debug.Assert( dest.Length == source.Length );
+ for( int i = 0; i < dest.Length; i ++ ) {
+ dest[i] = source[i];
+ }
+ }
+
+ /// <summary>
+ /// Copy an array
+ /// </summary>
+ /// <param name="dest"></param>
+ /// <param name="source"></param>
+ static public void Copy( ComplexF[] dest, ComplexF[] source ) {
+ Debug.Assert( dest != null );
+ Debug.Assert( source != null );
+ Debug.Assert( dest.Length == source.Length );
+ for( int i = 0; i < dest.Length; i ++ ) {
+ dest[i] = source[i];
+ }
+ }
+
+ /// <summary>
+ /// Reverse the elements in the array
+ /// </summary>
+ /// <param name="array"></param>
+ static public void Reverse( Complex[] array ) {
+ Complex temp;
+ int length = array.Length;
+ for( int i = 0; i < length/2; i ++ ) {
+ temp = array[i];
+ array[i] = array[length-1-i];
+ array[length-1-i] = temp;
+ }
+ }
+
+ /// <summary>
+ /// Scale and offset the elements in the array so that the
+ /// overall range is [0, 1]
+ /// </summary>
+ /// <param name="array"></param>
+ static public void Normalize( Complex[] array ) {
+ double min = 0, max = 0;
+ GetLengthRange( array, ref min, ref max );
+ Scale( array, ( 1 / ( max - min ) ) );
+ Offset( array, ( - min / ( max - min ) ) );
+ }
+
+ /// <summary>
+ /// Scale and offset the elements in the array so that the
+ /// overall range is [0, 1]
+ /// </summary>
+ /// <param name="array"></param>
+ static public void Normalize( ComplexF[] array ) {
+ float min = 0, max = 0;
+ GetLengthRange( array, ref min, ref max );
+ Scale( array, ( 1 / ( max - min ) ) );
+ Offset( array, ( - min / ( max - min ) ) );
+ }
+
+ /// <summary>
+ /// Invert each element in the array
+ /// </summary>
+ /// <param name="array"></param>
+ static public void Invert( Complex[] array ) {
+ for( int i = 0; i < array.Length; i ++ ) {
+ array[i] = ((Complex) 1 ) / array[i];
+ }
+ }
+
+ /// <summary>
+ /// Invert each element in the array
+ /// </summary>
+ /// <param name="array"></param>
+ static public void Invert( ComplexF[] array ) {
+ for( int i = 0; i < array.Length; i ++ ) {
+ array[i] = ((ComplexF) 1 ) / array[i];
+ }
+ }
+
+ //----------------------------------------------------------------------------------------
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexF.cs b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexF.cs
new file mode 100644
index 00000000000..b2d399645f3
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexF.cs
@@ -0,0 +1,520 @@
+/*
+ * BSD Licence:
+ * Copyright (c) 2001, 2002 Ben Houston [ ben@exocortex.org ]
+ * Exocortex Technologies [ www.exocortex.org ]
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+using System;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+
+namespace Exocortex.DSP {
+
+ // Comments? Questions? Bugs? Tell Ben Houston at ben@exocortex.org
+ // Version: May 4, 2002
+
+ /// <summary>
+ /// <p>A single-precision complex number representation.</p>
+ /// </summary>
+ [StructLayout(LayoutKind.Sequential)]
+ public struct ComplexF : IComparable, ICloneable {
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// The real component of the complex number
+ /// </summary>
+ public float Re;
+
+ /// <summary>
+ /// The imaginary component of the complex number
+ /// </summary>
+ public float Im;
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Create a complex number from a real and an imaginary component
+ /// </summary>
+ /// <param name="real"></param>
+ /// <param name="imaginary"></param>
+ public ComplexF( float real, float imaginary ) {
+ this.Re = (float) real;
+ this.Im = (float) imaginary;
+ }
+
+ /// <summary>
+ /// Create a complex number based on an existing complex number
+ /// </summary>
+ /// <param name="c"></param>
+ public ComplexF( ComplexF c ) {
+ this.Re = c.Re;
+ this.Im = c.Im;
+ }
+
+ /// <summary>
+ /// Create a complex number from a real and an imaginary component
+ /// </summary>
+ /// <param name="real"></param>
+ /// <param name="imaginary"></param>
+ /// <returns></returns>
+ static public ComplexF FromRealImaginary( float real, float imaginary ) {
+ ComplexF c;
+ c.Re = (float) real;
+ c.Im = (float) imaginary;
+ return c;
+ }
+
+ /// <summary>
+ /// Create a complex number from a modulus (length) and an argument (radian)
+ /// </summary>
+ /// <param name="modulus"></param>
+ /// <param name="argument"></param>
+ /// <returns></returns>
+ static public ComplexF FromModulusArgument( float modulus, float argument ) {
+ ComplexF c;
+ c.Re = (float)( modulus * System.Math.Cos( argument ) );
+ c.Im = (float)( modulus * System.Math.Sin( argument ) );
+ return c;
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ object ICloneable.Clone() {
+ return new ComplexF( this );
+ }
+ /// <summary>
+ /// Clone the complex number
+ /// </summary>
+ /// <returns></returns>
+ public ComplexF Clone() {
+ return new ComplexF( this );
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// The modulus (length) of the complex number
+ /// </summary>
+ /// <returns></returns>
+ public float GetModulus() {
+ float x = this.Re;
+ float y = this.Im;
+ return (float) Math.Sqrt( x*x + y*y );
+ }
+
+ /// <summary>
+ /// The squared modulus (length^2) of the complex number
+ /// </summary>
+ /// <returns></returns>
+ public float GetModulusSquared() {
+ float x = this.Re;
+ float y = this.Im;
+ return (float) x*x + y*y;
+ }
+
+ /// <summary>
+ /// The argument (radians) of the complex number
+ /// </summary>
+ /// <returns></returns>
+ public float GetArgument() {
+ return (float) Math.Atan2( this.Im, this.Re );
+ }
+
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Get the conjugate of the complex number
+ /// </summary>
+ /// <returns></returns>
+ public ComplexF GetConjugate() {
+ return FromRealImaginary( this.Re, -this.Im );
+ }
+
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Scale the complex number to 1.
+ /// </summary>
+ public void Normalize() {
+ double modulus = this.GetModulus();
+ if( modulus == 0 ) {
+ throw new DivideByZeroException( "Can not normalize a complex number that is zero." );
+ }
+ this.Re = (float)( this.Re / modulus );
+ this.Im = (float)( this.Im / modulus );
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Convert to a from double precision complex number to a single precison complex number
+ /// </summary>
+ /// <param name="c"></param>
+ /// <returns></returns>
+ public static explicit operator ComplexF ( Complex c ) {
+ ComplexF cF;
+ cF.Re = (float) c.Re;
+ cF.Im = (float) c.Im;
+ return cF;
+ }
+
+ /// <summary>
+ /// Convert from a single precision real number to a complex number
+ /// </summary>
+ /// <param name="f"></param>
+ /// <returns></returns>
+ public static explicit operator ComplexF ( float f ) {
+ ComplexF c;
+ c.Re = (float) f;
+ c.Im = (float) 0;
+ return c;
+ }
+
+ /// <summary>
+ /// Convert from a single precision complex to a real number
+ /// </summary>
+ /// <param name="c"></param>
+ /// <returns></returns>
+ public static explicit operator float ( ComplexF c ) {
+ return (float) c.Re;
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Are these two complex numbers equivalent?
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static bool operator==( ComplexF a, ComplexF b ) {
+ return ( a.Re == b.Re ) && ( a.Im == b.Im );
+ }
+
+ /// <summary>
+ /// Are these two complex numbers different?
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static bool operator!=( ComplexF a, ComplexF b ) {
+ return ( a.Re != b.Re ) || ( a.Im != b.Im );
+ }
+
+ /// <summary>
+ /// Get the hash code of the complex number
+ /// </summary>
+ /// <returns></returns>
+ public override int GetHashCode() {
+ return ( this.Re.GetHashCode() ^ this.Im.GetHashCode() );
+ }
+
+ /// <summary>
+ /// Is this complex number equivalent to another object?
+ /// </summary>
+ /// <param name="o"></param>
+ /// <returns></returns>
+ public override bool Equals( object o ) {
+ if( o is ComplexF ) {
+ ComplexF c = (ComplexF) o;
+ return ( this == c );
+ }
+ return false;
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Compare to other complex numbers or real numbers
+ /// </summary>
+ /// <param name="o"></param>
+ /// <returns></returns>
+ public int CompareTo( object o ) {
+ if( o == null ) {
+ return 1; // null sorts before current
+ }
+ if( o is ComplexF ) {
+ return this.GetModulus().CompareTo( ((ComplexF)o).GetModulus() );
+ }
+ if( o is float ) {
+ return this.GetModulus().CompareTo( (float)o );
+ }
+ if( o is Complex ) {
+ return this.GetModulus().CompareTo( ((Complex)o).GetModulus() );
+ }
+ if( o is double ) {
+ return this.GetModulus().CompareTo( (double)o );
+ }
+ throw new ArgumentException();
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// This operator doesn't do much. :-)
+ /// </summary>
+ /// <param name="a"></param>
+ /// <returns></returns>
+ public static ComplexF operator+( ComplexF a ) {
+ return a;
+ }
+
+ /// <summary>
+ /// Negate the complex number
+ /// </summary>
+ /// <param name="a"></param>
+ /// <returns></returns>
+ public static ComplexF operator-( ComplexF a ) {
+ a.Re = -a.Re;
+ a.Im = -a.Im;
+ return a;
+ }
+
+ /// <summary>
+ /// Add a complex number to a real
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="f"></param>
+ /// <returns></returns>
+ public static ComplexF operator+( ComplexF a, float f ) {
+ a.Re = (float)( a.Re + f );
+ return a;
+ }
+
+ /// <summary>
+ /// Add a real to a complex number
+ /// </summary>
+ /// <param name="f"></param>
+ /// <param name="a"></param>
+ /// <returns></returns>
+ public static ComplexF operator+( float f, ComplexF a ) {
+ a.Re = (float)( a.Re + f );
+ return a;
+ }
+
+ /// <summary>
+ /// Add to complex numbers
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static ComplexF operator+( ComplexF a, ComplexF b ) {
+ a.Re = a.Re + b.Re;
+ a.Im = a.Im + b.Im;
+ return a;
+ }
+
+ /// <summary>
+ /// Subtract a real from a complex number
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="f"></param>
+ /// <returns></returns>
+ public static ComplexF operator-( ComplexF a, float f ) {
+ a.Re = (float)( a.Re - f );
+ return a;
+ }
+
+ /// <summary>
+ /// Subtract a complex number from a real
+ /// </summary>
+ /// <param name="f"></param>
+ /// <param name="a"></param>
+ /// <returns></returns>
+ public static ComplexF operator-( float f, ComplexF a ) {
+ a.Re = (float)( f - a.Re );
+ a.Im = (float)( 0 - a.Im );
+ return a;
+ }
+
+ /// <summary>
+ /// Subtract two complex numbers
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static ComplexF operator-( ComplexF a, ComplexF b ) {
+ a.Re = a.Re - b.Re;
+ a.Im = a.Im - b.Im;
+ return a;
+ }
+
+ /// <summary>
+ /// Multiply a complex number by a real
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="f"></param>
+ /// <returns></returns>
+ public static ComplexF operator*( ComplexF a, float f ) {
+ a.Re = (float)( a.Re * f );
+ a.Im = (float)( a.Im * f );
+ return a;
+ }
+
+ /// <summary>
+ /// Multiply a real by a complex number
+ /// </summary>
+ /// <param name="f"></param>
+ /// <param name="a"></param>
+ /// <returns></returns>
+ public static ComplexF operator*( float f, ComplexF a ) {
+ a.Re = (float)( a.Re * f );
+ a.Im = (float)( a.Im * f );
+ return a;
+ }
+
+ /// <summary>
+ /// Multiply two complex numbers together
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static ComplexF operator*( ComplexF a, ComplexF b ) {
+ // (x + yi)(u + vi) = (xu – yv) + (xv + yu)i.
+ double x = a.Re, y = a.Im;
+ double u = b.Re, v = b.Im;
+ a.Re = (float)( x*u - y*v );
+ a.Im = (float)( x*v + y*u );
+ return a;
+ }
+
+ /// <summary>
+ /// Divide a complex number by a real number
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="f"></param>
+ /// <returns></returns>
+ public static ComplexF operator/( ComplexF a, float f ) {
+ if( f == 0 ) {
+ throw new DivideByZeroException();
+ }
+ a.Re = (float)( a.Re / f );
+ a.Im = (float)( a.Im / f );
+ return a;
+ }
+
+ /// <summary>
+ /// Divide a complex number by a complex number
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <returns></returns>
+ public static ComplexF operator/( ComplexF a, ComplexF b ) {
+ double x = a.Re, y = a.Im;
+ double u = b.Re, v = b.Im;
+ double denom = u*u + v*v;
+
+ if( denom == 0 ) {
+ throw new DivideByZeroException();
+ }
+ a.Re = (float)( ( x*u + y*v ) / denom );
+ a.Im = (float)( ( y*u - x*v ) / denom );
+ return a;
+ }
+
+ /// <summary>
+ /// Parse a complex representation in this fashion: "( %f, %f )"
+ /// </summary>
+ /// <param name="s"></param>
+ /// <returns></returns>
+ static public ComplexF Parse( string s ) {
+ throw new NotImplementedException( "ComplexF ComplexF.Parse( string s ) is not implemented." );
+ }
+
+ /// <summary>
+ /// Get the string representation
+ /// </summary>
+ /// <returns></returns>
+ public override string ToString() {
+ return String.Format( "( {0}, {1}i )", this.Re, this.Im );
+ }
+
+ //-----------------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Determine whether two complex numbers are almost (i.e. within the tolerance) equivalent.
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ /// <param name="tolerance"></param>
+ /// <returns></returns>
+ static public bool IsEqual( ComplexF a, ComplexF b, float tolerance ) {
+ return
+ ( Math.Abs( a.Re - b.Re ) < tolerance ) &&
+ ( Math.Abs( a.Im - b.Im ) < tolerance );
+
+ }
+
+ //----------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Represents zero
+ /// </summary>
+ static public ComplexF Zero {
+ get { return new ComplexF( 0, 0 ); }
+ }
+
+ /// <summary>
+ /// Represents the result of sqrt( -1 )
+ /// </summary>
+ static public ComplexF I {
+ get { return new ComplexF( 0, 1 ); }
+ }
+
+ /// <summary>
+ /// Represents the largest possible value of ComplexF.
+ /// </summary>
+ static public ComplexF MaxValue {
+ get { return new ComplexF( float.MaxValue, float.MaxValue ); }
+ }
+
+ /// <summary>
+ /// Represents the smallest possible value of ComplexF.
+ /// </summary>
+ static public ComplexF MinValue {
+ get { return new ComplexF( float.MinValue, float.MinValue ); }
+ }
+
+
+ //----------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------------
+ }
+
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexMath.cs b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexMath.cs
new file mode 100644
index 00000000000..3ce28dd147c
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexMath.cs
@@ -0,0 +1,158 @@
+/*
+ * BSD Licence:
+ * Copyright (c) 2001, 2002 Ben Houston [ ben@exocortex.org ]
+ * Exocortex Technologies [ www.exocortex.org ]
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+using System;
+using System.Diagnostics;
+
+
+namespace Exocortex.DSP {
+
+ // Comments? Questions? Bugs? Tell Ben Houston at ben@exocortex.org
+ // Version: May 4, 2002
+
+ /// <summary>
+ /// <p>Various mathematical functions for complex numbers.</p>
+ /// </summary>
+ public class ComplexMath {
+
+ //---------------------------------------------------------------------------------------------------
+
+ private ComplexMath() {
+ }
+
+ //---------------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Swap two complex numbers
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ static public void Swap( ref Complex a, ref Complex b ) {
+ Complex temp = a;
+ a = b;
+ b = temp;
+ }
+
+ /// <summary>
+ /// Swap two complex numbers
+ /// </summary>
+ /// <param name="a"></param>
+ /// <param name="b"></param>
+ static public void Swap( ref ComplexF a, ref ComplexF b ) {
+ ComplexF temp = a;
+ a = b;
+ b = temp;
+ }
+
+ //---------------------------------------------------------------------------------------------------
+
+ static private double _halfOfRoot2 = 0.5 * Math.Sqrt( 2 );
+
+ /// <summary>
+ /// Calculate the square root of a complex number
+ /// </summary>
+ /// <param name="c"></param>
+ /// <returns></returns>
+ static public ComplexF Sqrt( ComplexF c ) {
+ double x = c.Re;
+ double y = c.Im;
+
+ double modulus = Math.Sqrt( x*x + y*y );
+ int sign = ( y < 0 ) ? -1 : 1;
+
+ c.Re = (float)( _halfOfRoot2 * Math.Sqrt( modulus + x ) );
+ c.Im = (float)( _halfOfRoot2 * sign * Math.Sqrt( modulus - x ) );
+
+ return c;
+ }
+
+ /// <summary>
+ /// Calculate the square root of a complex number
+ /// </summary>
+ /// <param name="c"></param>
+ /// <returns></returns>
+ static public Complex Sqrt( Complex c ) {
+ double x = c.Re;
+ double y = c.Im;
+
+ double modulus = Math.Sqrt( x*x + y*y );
+ int sign = ( y < 0 ) ? -1 : 1;
+
+ c.Re = (double)( _halfOfRoot2 * Math.Sqrt( modulus + x ) );
+ c.Im = (double)( _halfOfRoot2 * sign * Math.Sqrt( modulus - x ) );
+
+ return c;
+ }
+
+ //---------------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Calculate the power of a complex number
+ /// </summary>
+ /// <param name="c"></param>
+ /// <param name="exponent"></param>
+ /// <returns></returns>
+ static public ComplexF Pow( ComplexF c, double exponent ) {
+ double x = c.Re;
+ double y = c.Im;
+
+ double modulus = Math.Pow( x*x + y*y, exponent * 0.5 );
+ double argument = Math.Atan2( y, x ) * exponent;
+
+ c.Re = (float)( modulus * System.Math.Cos( argument ) );
+ c.Im = (float)( modulus * System.Math.Sin( argument ) );
+
+ return c;
+ }
+
+ /// <summary>
+ /// Calculate the power of a complex number
+ /// </summary>
+ /// <param name="c"></param>
+ /// <param name="exponent"></param>
+ /// <returns></returns>
+ static public Complex Pow( Complex c, double exponent ) {
+ double x = c.Re;
+ double y = c.Im;
+
+ double modulus = Math.Pow( x*x + y*y, exponent * 0.5 );
+ double argument = Math.Atan2( y, x ) * exponent;
+
+ c.Re = (double)( modulus * System.Math.Cos( argument ) );
+ c.Im = (double)( modulus * System.Math.Sin( argument ) );
+
+ return c;
+ }
+
+ //---------------------------------------------------------------------------------------------------
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexStats.cs b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexStats.cs
new file mode 100644
index 00000000000..1de21c419d2
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/ComplexStats.cs
@@ -0,0 +1,306 @@
+/*
+ * BSD Licence:
+ * Copyright (c) 2001, 2002 Ben Houston [ ben@exocortex.org ]
+ * Exocortex Technologies [ www.exocortex.org ]
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+using System;
+using System.Diagnostics;
+
+namespace Exocortex.DSP
+{
+ // Comments? Questions? Bugs? Tell Ben Houston at ben@exocortex.org
+ // Version: May 4, 2002
+
+ /// <summary>
+ /// <p>A set of statistical utilities for complex number arrays</p>
+ /// </summary>
+ public class ComplexStats
+ {
+ //---------------------------------------------------------------------------------------------
+
+ private ComplexStats() {
+ }
+
+ //---------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Calculate the sum
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ static public ComplexF Sum( ComplexF[] data ) {
+ Debug.Assert( data != null );
+ return SumRecursion( data, 0, data.Length );
+ }
+ static private ComplexF SumRecursion( ComplexF[] data, int start, int end ) {
+ Debug.Assert( 0 <= start, "start = " + start );
+ Debug.Assert( start < end, "start = " + start + " and end = " + end );
+ Debug.Assert( end <= data.Length, "end = " + end + " and data.Length = " + data.Length );
+ if( ( end - start ) <= 1000 ) {
+ ComplexF sum = ComplexF.Zero;
+ for( int i = start; i < end; i ++ ) {
+ sum += data[ i ];
+
+ }
+ return sum;
+ }
+ else {
+ int middle = ( start + end ) >> 1;
+ return SumRecursion( data, start, middle ) + SumRecursion( data, middle, end );
+ }
+ }
+
+ /// <summary>
+ /// Calculate the sum
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ static public Complex Sum( Complex[] data ) {
+ Debug.Assert( data != null );
+ return SumRecursion( data, 0, data.Length );
+ }
+ static private Complex SumRecursion( Complex[] data, int start, int end ) {
+ Debug.Assert( 0 <= start, "start = " + start );
+ Debug.Assert( start < end, "start = " + start + " and end = " + end );
+ Debug.Assert( end <= data.Length, "end = " + end + " and data.Length = " + data.Length );
+ if( ( end - start ) <= 1000 ) {
+ Complex sum = Complex.Zero;
+ for( int i = start; i < end; i ++ ) {
+ sum += data[ i ];
+
+ }
+ return sum;
+ }
+ else {
+ int middle = ( start + end ) >> 1;
+ return SumRecursion( data, start, middle ) + SumRecursion( data, middle, end );
+ }
+ }
+
+ //--------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Calculate the sum of squares
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ static public ComplexF SumOfSquares( ComplexF[] data ) {
+ Debug.Assert( data != null );
+ return SumOfSquaresRecursion( data, 0, data.Length );
+ }
+ static private ComplexF SumOfSquaresRecursion( ComplexF[] data, int start, int end ) {
+ Debug.Assert( 0 <= start, "start = " + start );
+ Debug.Assert( start < end, "start = " + start + " and end = " + end );
+ Debug.Assert( end <= data.Length, "end = " + end + " and data.Length = " + data.Length );
+ if( ( end - start ) <= 1000 ) {
+ ComplexF sumOfSquares = ComplexF.Zero;
+ for( int i = start; i < end; i ++ ) {
+ sumOfSquares += data[ i ] * data[ i ];
+
+ }
+ return sumOfSquares;
+ }
+ else {
+ int middle = ( start + end ) >> 1;
+ return SumOfSquaresRecursion( data, start, middle ) + SumOfSquaresRecursion( data, middle, end );
+ }
+ }
+
+ /// <summary>
+ /// Calculate the sum of squares
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ static public Complex SumOfSquares( Complex[] data ) {
+ Debug.Assert( data != null );
+ return SumOfSquaresRecursion( data, 0, data.Length );
+ }
+ static private Complex SumOfSquaresRecursion( Complex[] data, int start, int end ) {
+ Debug.Assert( 0 <= start, "start = " + start );
+ Debug.Assert( start < end, "start = " + start + " and end = " + end );
+ Debug.Assert( end <= data.Length, "end = " + end + " and data.Length = " + data.Length );
+ if( ( end - start ) <= 1000 ) {
+ Complex sumOfSquares = Complex.Zero;
+ for( int i = start; i < end; i ++ ) {
+ sumOfSquares += data[ i ] * data[ i ];
+
+ }
+ return sumOfSquares;
+ }
+ else {
+ int middle = ( start + end ) >> 1;
+ return SumOfSquaresRecursion( data, start, middle ) + SumOfSquaresRecursion( data, middle, end );
+ }
+ }
+
+ //--------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Calculate the mean (average)
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ static public ComplexF Mean( ComplexF[] data ) {
+ return ComplexStats.Sum( data ) / data.Length;
+ }
+
+ /// <summary>
+ /// Calculate the mean (average)
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ static public Complex Mean( Complex[] data ) {
+ return ComplexStats.Sum( data ) / data.Length;
+ }
+
+ /// <summary>
+ /// Calculate the variance
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ static public ComplexF Variance( ComplexF[] data ) {
+ Debug.Assert( data != null );
+ if( data.Length == 0 ) {
+ throw new DivideByZeroException( "length of data is zero" );
+ }
+ return ComplexStats.SumOfSquares( data ) / data.Length - ComplexStats.Sum( data );
+ }
+ /// <summary>
+ /// Calculate the variance
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ static public Complex Variance( Complex[] data ) {
+ Debug.Assert( data != null );
+ if( data.Length == 0 ) {
+ throw new DivideByZeroException( "length of data is zero" );
+ }
+ return ComplexStats.SumOfSquares( data ) / data.Length - ComplexStats.Sum( data );
+ }
+
+ /// <summary>
+ /// Calculate the standard deviation
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ static public ComplexF StdDev( ComplexF[] data ) {
+ Debug.Assert( data != null );
+ if( data.Length == 0 ) {
+ throw new DivideByZeroException( "length of data is zero" );
+ }
+ return ComplexMath.Sqrt( ComplexStats.Variance( data ) );
+ }
+ /// <summary>
+ /// Calculate the standard deviation
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ static public Complex StdDev( Complex[] data ) {
+ Debug.Assert( data != null );
+ if( data.Length == 0 ) {
+ throw new DivideByZeroException( "length of data is zero" );
+ }
+ return ComplexMath.Sqrt( ComplexStats.Variance( data ) );
+ }
+
+ //--------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------------------------
+
+ /// <summary>
+ /// Calculate the root mean squared (RMS) error between two sets of data.
+ /// </summary>
+ /// <param name="alpha"></param>
+ /// <param name="beta"></param>
+ /// <returns></returns>
+ static public float RMSError( ComplexF[] alpha, ComplexF[] beta ) {
+ Debug.Assert( alpha != null );
+ Debug.Assert( beta != null );
+ Debug.Assert( beta.Length == alpha.Length );
+
+ return (float) Math.Sqrt( SumOfSquaredErrorRecursion( alpha, beta, 0, alpha.Length ) );
+ }
+ static private float SumOfSquaredErrorRecursion( ComplexF[] alpha, ComplexF[] beta, int start, int end ) {
+ Debug.Assert( 0 <= start, "start = " + start );
+ Debug.Assert( start < end, "start = " + start + " and end = " + end );
+ Debug.Assert( end <= alpha.Length, "end = " + end + " and alpha.Length = " + alpha.Length );
+ Debug.Assert( beta.Length == alpha.Length );
+ if( ( end - start ) <= 1000 ) {
+ float sumOfSquaredError = 0;
+ for( int i = start; i < end; i ++ ) {
+ ComplexF delta = beta[ i ] - alpha[ i ];
+ sumOfSquaredError += ( delta.Re * delta.Re ) + ( delta.Im * delta.Im );
+
+ }
+ return sumOfSquaredError;
+ }
+ else {
+ int middle = ( start + end ) >> 1;
+ return SumOfSquaredErrorRecursion( alpha, beta, start, middle ) + SumOfSquaredErrorRecursion( alpha, beta, middle, end );
+ }
+ }
+
+ /// <summary>
+ /// Calculate the root mean squared (RMS) error between two sets of data.
+ /// </summary>
+ /// <param name="alpha"></param>
+ /// <param name="beta"></param>
+ /// <returns></returns>
+ static public double RMSError( Complex[] alpha, Complex[] beta ) {
+ Debug.Assert( alpha != null );
+ Debug.Assert( beta != null );
+ Debug.Assert( beta.Length == alpha.Length );
+
+ return Math.Sqrt( SumOfSquaredErrorRecursion( alpha, beta, 0, alpha.Length ) );
+ }
+ static private double SumOfSquaredErrorRecursion( Complex[] alpha, Complex[] beta, int start, int end ) {
+ Debug.Assert( 0 <= start, "start = " + start );
+ Debug.Assert( start < end, "start = " + start + " and end = " + end );
+ Debug.Assert( end <= alpha.Length, "end = " + end + " and alpha.Length = " + alpha.Length );
+ Debug.Assert( beta.Length == alpha.Length );
+ if( ( end - start ) <= 1000 ) {
+ double sumOfSquaredError = 0;
+ for( int i = start; i < end; i ++ ) {
+ Complex delta = beta[ i ] - alpha[ i ];
+ sumOfSquaredError += ( delta.Re * delta.Re ) + ( delta.Im * delta.Im );
+
+ }
+ return sumOfSquaredError;
+ }
+ else {
+ int middle = ( start + end ) >> 1;
+ return SumOfSquaredErrorRecursion( alpha, beta, start, middle ) + SumOfSquaredErrorRecursion( alpha, beta, middle, end );
+ }
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Exocortex.DSP.v1.J2EE.vmwcsproj b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Exocortex.DSP.v1.J2EE.vmwcsproj
new file mode 100644
index 00000000000..4854e55ec81
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Exocortex.DSP.v1.J2EE.vmwcsproj
@@ -0,0 +1,31 @@
+<VisualStudioProject>
+ <CSHARP ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{8D602CEF-DC13-48F1-AF0C-F6201A634FD2}">
+ <Build>
+ <Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="Exocortex.DSP.v1" AssemblyOriginatorKeyFile="" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" PreBuildEvent="" PostBuildEvent="" RootNamespace="Exocortex.DSP" RunPostBuildEvent="OnBuildSuccess" StartupObject="">
+ <Config Name="Debug_Java" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="true" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE;TARGET_JVM" DocumentationFile="doc\Exocortex.DSP.xml" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="" Optimize="true" OutputPath="bin\Debug_Java\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ <Config Name="Release_Java" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="true" ConfigurationOverrideFile="" DefineConstants="TRACE;JAVA" DocumentationFile="doc\Exocortex.DSP.xml" DebugSymbols="false" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="" Optimize="true" OutputPath="bin\Release_Java\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ <Config Name="Debug" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="true" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE" DocumentationFile="doc\Exocortex.DSP.xml" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="" Optimize="true" OutputPath="bin\Debug_Java\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ </Settings>
+ <References>
+ <Reference Name="System" AssemblyName="System" HintPath="..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"/>
+ <Reference Name="System.Data" AssemblyName="System.Data" HintPath="..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"/>
+ <Reference Name="System.Xml" AssemblyName="System.Xml" HintPath="..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Xml.dll"/>
+ <Reference Name="System.Drawing" AssemblyName="System.Drawing" HintPath="..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"/>
+ <Reference Name="rt" AssemblyName="rt" HintPath="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\j2sdk1.4\rt.dll" Private="False"/>
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File RelPath="AssemblyInfo.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="Complex.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="ComplexArray.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="ComplexF.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="ComplexMath.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="ComplexStats.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="Fourier.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="FourierDirection.cs" SubType="Code" BuildAction="Compile"/>
+ </Include>
+ </Files>
+ <UserProperties jarserver="ipa" project.JDKType="1.4.2_05" REFS.JarPath.rt="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\j2sdk1.4\lib\rt.jar" REFS.JarPath.system="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.jar" REFS.JarPath.system.data="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Data.jar" REFS.JarPath.system.xml="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Xml.jar" REFS.JarPath.system.drawing="..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Drawing.jar"/>
+ </CSHARP>
+ <VisualMainWin><Project Prop2023="1.4.2_05" Prop2024="" Prop2026="" Prop2015="" Version="1.6.0" ProjectType="1"/><References/><Configs><Config Prop2000="0" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="0" Prop2006="" Prop2007="" Prop2008="" Prop2009="" Prop2010="" Prop2011="0" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="0" Name="Debug_Java"/><Config Prop2000="1" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="0" Prop2006="" Prop2007="" Prop2008="" Prop2009="" Prop2010="" Prop2011="0" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="0" Name="Debug"/><Config Prop2000="0" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="0" Prop2006="" Prop2007="" Prop2008="" Prop2009="" Prop2010="" Prop2011="0" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="0" Name="Release_Java"/></Configs></VisualMainWin></VisualStudioProject>
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Exocortex.DSP.v1.csproj b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Exocortex.DSP.v1.csproj
new file mode 100644
index 00000000000..7c10afb2b67
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Exocortex.DSP.v1.csproj
@@ -0,0 +1,135 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{1904A41B-D1B8-40E5-ADBB-728DDCF7C816}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "Exocortex.DSP.v1"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "Exocortex.DSP"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "true"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = "doc\Exocortex.DSP.xml"
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "true"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "true"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = "doc\Exocortex.DSP.xml"
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.dll"
+ />
+ <Reference
+ Name = "System.Data"
+ AssemblyName = "System.Data"
+ HintPath = "..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.Xml"
+ HintPath = "..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
+ />
+ <Reference
+ Name = "System.Drawing"
+ AssemblyName = "System.Drawing"
+ HintPath = "..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Drawing.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "AssemblyInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Complex.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ComplexArray.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ComplexF.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ComplexMath.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ComplexStats.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Fourier.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "FourierDirection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Fourier.cs b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Fourier.cs
new file mode 100644
index 00000000000..87bbd971ec7
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/Fourier.cs
@@ -0,0 +1,1346 @@
+/*
+ * BSD Licence:
+ * Copyright (c) 2001, 2002 Ben Houston [ ben@exocortex.org ]
+ * Exocortex Technologies [ www.exocortex.org ]
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+
+//using Exocortex.Imaging;
+
+namespace Exocortex.DSP {
+
+ // Comments? Questions? Bugs? Tell Ben Houston at ben@exocortex.org
+ // Version: May 4, 2002
+
+ /// <summary>
+ /// <p>Static functions for doing various Fourier Operations.</p>
+ /// </summary>
+ public class Fourier {
+
+ //======================================================================================
+
+ private Fourier() {
+ }
+
+ //======================================================================================
+
+ static private void Swap( ref float a, ref float b ) {
+ float temp = a;
+ a = b;
+ b = temp;
+ }
+ static private void Swap( ref double a, ref double b ) {
+ double temp = a;
+ a = b;
+ b = temp;
+ }
+ static private void Swap( ref ComplexF a, ref ComplexF b ) {
+ ComplexF temp = a;
+ a = b;
+ b = temp;
+ }
+ static private void Swap( ref Complex a, ref Complex b ) {
+ Complex temp = a;
+ a = b;
+ b = temp;
+ }
+
+ //-------------------------------------------------------------------------------------
+
+ private const int cMaxLength = 4096;
+ private const int cMinLength = 1;
+
+ private const int cMaxBits = 12;
+ private const int cMinBits = 0;
+
+
+ static private bool IsPowerOf2( int x ) {
+ return (x & (x - 1)) == 0;
+ //return ( x == Pow2( Log2( x ) ) );
+ }
+ static private int Pow2( int exponent ) {
+ if( exponent >= 0 && exponent < 31 ) {
+ return 1 << exponent;
+ }
+ return 0;
+ }
+ static private int Log2( int x ) {
+ if( x <= 65536 ) {
+ if( x <= 256 ) {
+ if( x <= 16 ) {
+ if( x <= 4 ) {
+ if( x <= 2 ) {
+ if( x <= 1 ) {
+ return 0;
+ }
+ return 1;
+ }
+ return 2;
+ }
+ if( x <= 8 )
+ return 3;
+ return 4;
+ }
+ if( x <= 64 ) {
+ if( x <= 32 )
+ return 5;
+ return 6;
+ }
+ if( x <= 128 )
+ return 7;
+ return 8;
+ }
+ if( x <= 4096 ) {
+ if( x <= 1024 ) {
+ if( x <= 512 )
+ return 9;
+ return 10;
+ }
+ if( x <= 2048 )
+ return 11;
+ return 12;
+ }
+ if( x <= 16384 ) {
+ if( x <= 8192 )
+ return 13;
+ return 14;
+ }
+ if( x <= 32768 )
+ return 15;
+ return 16;
+ }
+ if( x <= 16777216 ) {
+ if( x <= 1048576 ) {
+ if( x <= 262144 ) {
+ if( x <= 131072 )
+ return 17;
+ return 18;
+ }
+ if( x <= 524288 )
+ return 19;
+ return 20;
+ }
+ if( x <= 4194304 ) {
+ if( x <= 2097152 )
+ return 21;
+ return 22;
+ }
+ if( x <= 8388608 )
+ return 23;
+ return 24;
+ }
+ if( x <= 268435456 ) {
+ if( x <= 67108864 ) {
+ if( x <= 33554432 )
+ return 25;
+ return 26;
+ }
+ if( x <= 134217728 )
+ return 27;
+ return 28;
+ }
+ if( x <= 1073741824 ) {
+ if( x <= 536870912 )
+ return 29;
+ return 30;
+ }
+ // since int is unsigned it can never be higher than 2,147,483,647
+ // if( x <= 2147483648 )
+ // return 31;
+ // return 32;
+ return 31;
+ }
+
+ //-------------------------------------------------------------------------------------
+ //-------------------------------------------------------------------------------------
+
+ static private int ReverseBits( int index, int numberOfBits ) {
+ Debug.Assert( numberOfBits >= cMinBits );
+ Debug.Assert( numberOfBits <= cMaxBits );
+
+ int reversedIndex = 0;
+ for( int i = 0; i < numberOfBits; i ++ ) {
+ reversedIndex = ( reversedIndex << 1 ) | ( index & 1 );
+ index = ( index >> 1 );
+ }
+ return reversedIndex;
+ }
+
+ //-------------------------------------------------------------------------------------
+
+ static private int[][] _reversedBits = new int[ cMaxBits ][];
+ static private int[] GetReversedBits( int numberOfBits ) {
+ Debug.Assert( numberOfBits >= cMinBits );
+ Debug.Assert( numberOfBits <= cMaxBits );
+ if( _reversedBits[ numberOfBits - 1 ] == null ) {
+ int maxBits = Fourier.Pow2( numberOfBits );
+ int[] reversedBits = new int[ maxBits ];
+ for( int i = 0; i < maxBits; i ++ ) {
+ int oldBits = i;
+ int newBits = 0;
+ for( int j = 0; j < numberOfBits; j ++ ) {
+ newBits = ( newBits << 1 ) | ( oldBits & 1 );
+ oldBits = ( oldBits >> 1 );
+ }
+ reversedBits[ i ] = newBits;
+ }
+ _reversedBits[ numberOfBits - 1 ] = reversedBits;
+ }
+ return _reversedBits[ numberOfBits - 1 ];
+ }
+
+ //-------------------------------------------------------------------------------------
+
+ static private void ReorderArray( float[] data ) {
+ Debug.Assert( data != null );
+
+ int length = data.Length / 2;
+
+ Debug.Assert( Fourier.IsPowerOf2( length ) == true );
+ Debug.Assert( length >= cMinLength );
+ Debug.Assert( length <= cMaxLength );
+
+ int[] reversedBits = Fourier.GetReversedBits( Fourier.Log2( length ) );
+ for( int i = 0; i < length; i ++ ) {
+ int swap = reversedBits[ i ];
+ if( swap > i ) {
+ Fourier.Swap( ref data[ (i<<1) ], ref data[ (swap<<1) ] );
+ Fourier.Swap( ref data[ (i<<1) + 1 ], ref data[ (swap<<1) + 1 ] );
+ }
+ }
+ }
+
+ static private void ReorderArray( double[] data ) {
+ Debug.Assert( data != null );
+
+ int length = data.Length / 2;
+
+ Debug.Assert( Fourier.IsPowerOf2( length ) == true );
+ Debug.Assert( length >= cMinLength );
+ Debug.Assert( length <= cMaxLength );
+
+ int[] reversedBits = Fourier.GetReversedBits( Fourier.Log2( length ) );
+ for( int i = 0; i < length; i ++ ) {
+ int swap = reversedBits[ i ];
+ if( swap > i ) {
+ Fourier.Swap( ref data[ i<<1 ], ref data[ swap<<1 ] );
+ Fourier.Swap( ref data[ i<<1 + 1 ], ref data[ swap<<1 + 1 ] );
+ }
+ }
+ }
+
+ static private void ReorderArray( Complex[] data ) {
+ Debug.Assert( data != null );
+
+ int length = data.Length;
+
+ Debug.Assert( Fourier.IsPowerOf2( length ) == true );
+ Debug.Assert( length >= cMinLength );
+ Debug.Assert( length <= cMaxLength );
+
+ int[] reversedBits = Fourier.GetReversedBits( Fourier.Log2( length ) );
+ for( int i = 0; i < length; i ++ ) {
+ int swap = reversedBits[ i ];
+ if( swap > i ) {
+ Complex temp = data[ i ];
+ data[ i ] = data[ swap ];
+ data[ swap ] = temp;
+ }
+ }
+ }
+
+ static private void ReorderArray( ComplexF[] data ) {
+ Debug.Assert( data != null );
+
+ int length = data.Length;
+
+ Debug.Assert( Fourier.IsPowerOf2( length ) == true );
+ Debug.Assert( length >= cMinLength );
+ Debug.Assert( length <= cMaxLength );
+
+ int[] reversedBits = Fourier.GetReversedBits( Fourier.Log2( length ) );
+ for( int i = 0; i < length; i ++ ) {
+ int swap = reversedBits[ i ];
+ if( swap > i ) {
+ ComplexF temp = data[ i ];
+ data[ i ] = data[ swap ];
+ data[ swap ] = temp;
+ }
+ }
+ }
+
+ //======================================================================================
+
+ private static int[][] _reverseBits = null;
+
+ private static int _ReverseBits( int bits, int n ) {
+ int bitsReversed = 0;
+ for( int i = 0; i < n; i ++ ) {
+ bitsReversed = ( bitsReversed << 1 ) | ( bits & 1 );
+ bits = ( bits >> 1 );
+ }
+ return bitsReversed;
+ }
+
+ private static void InitializeReverseBits( int levels ) {
+ _reverseBits = new int[levels + 1][];
+ for( int j = 0; j < ( levels + 1 ); j ++ ) {
+ int count = (int) Math.Pow( 2, j );
+ _reverseBits[j] = new int[ count ];
+ for( int i = 0; i < count; i ++ ) {
+ _reverseBits[j][i] = _ReverseBits( i, j );
+ }
+ }
+ }
+
+ private static int _lookupTabletLength = -1;
+ private static double[,][] _uRLookup = null;
+ private static double[,][] _uILookup = null;
+ private static float[,][] _uRLookupF = null;
+ private static float[,][] _uILookupF = null;
+
+ private static void SyncLookupTableLength( int length ) {
+ Debug.Assert( length < 1024*10 );
+ Debug.Assert( length >= 0 );
+ if( length > _lookupTabletLength ) {
+ int level = (int) Math.Ceiling( Math.Log( length, 2 ) );
+ Fourier.InitializeReverseBits( level );
+ Fourier.InitializeComplexRotations( level );
+ //_cFFTData = new Complex[ Math2.CeilingBase( length, 2 ) ];
+ //_cFFTDataF = new ComplexF[ Math2.CeilingBase( length, 2 ) ];
+ _lookupTabletLength = length;
+ }
+ }
+
+ private static int GetLookupTableLength() {
+ return _lookupTabletLength;
+ }
+
+ private static void ClearLookupTables() {
+ _uRLookup = null;
+ _uILookup = null;
+ _uRLookupF = null;
+ _uILookupF = null;
+ _lookupTabletLength = -1;
+ }
+
+ private static void InitializeComplexRotations( int levels ) {
+ int ln = levels;
+ //_wRLookup = new float[ levels + 1, 2 ];
+ //_wILookup = new float[ levels + 1, 2 ];
+
+ _uRLookup = new double[ levels + 1, 2 ][];
+ _uILookup = new double[ levels + 1, 2 ][];
+
+ _uRLookupF = new float[ levels + 1, 2 ][];
+ _uILookupF = new float[ levels + 1, 2 ][];
+
+ int N = 1;
+ for( int level = 1; level <= ln; level ++ ) {
+ int M = N;
+ N <<= 1;
+
+ //float scale = (float)( 1 / Math.Sqrt( 1 << ln ) );
+
+ // positive sign ( i.e. [M,0] )
+ {
+ double uR = 1;
+ double uI = 0;
+ double angle = (double) Math.PI / M * 1;
+ double wR = (double) Math.Cos( angle );
+ double wI = (double) Math.Sin( angle );
+
+ _uRLookup[level,0] = new double[ M ];
+ _uILookup[level,0] = new double[ M ];
+ _uRLookupF[level,0] = new float[ M ];
+ _uILookupF[level,0] = new float[ M ];
+
+ for( int j = 0; j < M; j ++ ) {
+ _uRLookupF[level,0][j] = (float)( _uRLookup[level,0][j] = uR );
+ _uILookupF[level,0][j] = (float)( _uILookup[level,0][j] = uI );
+ double uwI = uR*wI + uI*wR;
+ uR = uR*wR - uI*wI;
+ uI = uwI;
+ }
+ }
+ {
+
+
+ // negative sign ( i.e. [M,1] )
+ double uR = 1;
+ double uI = 0;
+ double angle = (double) Math.PI / M * -1;
+ double wR = (double) Math.Cos( angle );
+ double wI = (double) Math.Sin( angle );
+
+ _uRLookup[level,1] = new double[ M ];
+ _uILookup[level,1] = new double[ M ];
+ _uRLookupF[level,1] = new float[ M ];
+ _uILookupF[level,1] = new float[ M ];
+
+ for( int j = 0; j < M; j ++ ) {
+ _uRLookupF[level,1][j] = (float)( _uRLookup[level,1][j] = uR );
+ _uILookupF[level,1][j] = (float)( _uILookup[level,1][j] = uI );
+ double uwI = uR*wI + uI*wR;
+ uR = uR*wR - uI*wI;
+ uI = uwI;
+ }
+ }
+
+ }
+ }
+
+ //======================================================================================
+ //======================================================================================
+
+ static private bool _bufferFLocked = false;
+ static private float[] _bufferF = new float[ 0 ];
+
+ static private void LockBufferF( int length, ref float[] buffer ) {
+ Debug.Assert( _bufferFLocked == false );
+ _bufferFLocked = true;
+ if( length >= _bufferF.Length ) {
+ _bufferF = new float[ length ];
+ }
+ buffer = _bufferF;
+ }
+ static private void UnlockBufferF( ref float[] buffer ) {
+ Debug.Assert( _bufferF == buffer );
+ Debug.Assert( _bufferFLocked == true );
+ _bufferFLocked = false;
+ buffer = null;
+ }
+
+ private static void LinearFFT( float[] data, int start, int inc, int length, FourierDirection direction ) {
+ Debug.Assert( data != null );
+ Debug.Assert( start >= 0 );
+ Debug.Assert( inc >= 1 );
+ Debug.Assert( length >= 1 );
+ Debug.Assert( ( start + inc * ( length - 1 ) ) * 2 < data.Length );
+
+ // copy to buffer
+ float[] buffer = null;
+ LockBufferF( length * 2, ref buffer );
+ int j = start;
+ for( int i = 0; i < length * 2; i ++ ) {
+ buffer[ i ] = data[ j ];
+ j += inc;
+ }
+
+ FFT( buffer, length, direction );
+
+ // copy from buffer
+ j = start;
+ for( int i = 0; i < length; i ++ ) {
+ data[ j ] = buffer[ i ];
+ j += inc;
+ }
+ UnlockBufferF( ref buffer );
+ }
+
+ private static void LinearFFT_Quick( float[] data, int start, int inc, int length, FourierDirection direction ) {
+ /*Debug.Assert( data != null );
+ Debug.Assert( start >= 0 );
+ Debug.Assert( inc >= 1 );
+ Debug.Assert( length >= 1 );
+ Debug.Assert( ( start + inc * ( length - 1 ) ) * 2 < data.Length );*/
+
+ // copy to buffer
+ float[] buffer = null;
+ LockBufferF( length * 2, ref buffer );
+ int j = start;
+ for( int i = 0; i < length * 2; i ++ ) {
+ buffer[ i ] = data[ j ];
+ j += inc;
+ }
+
+ FFT_Quick( buffer, length, direction );
+
+ // copy from buffer
+ j = start;
+ for( int i = 0; i < length; i ++ ) {
+ data[ j ] = buffer[ i ];
+ j += inc;
+ }
+ UnlockBufferF( ref buffer );
+ }
+
+ //======================================================================================
+ //======================================================================================
+
+ static private bool _bufferCFLocked = false;
+ static private ComplexF[] _bufferCF = new ComplexF[ 0 ];
+
+ static private void LockBufferCF( int length, ref ComplexF[] buffer ) {
+ Debug.Assert( length >= 0 );
+ Debug.Assert( _bufferCFLocked == false );
+
+ _bufferCFLocked = true;
+ if( length != _bufferCF.Length ) {
+ _bufferCF = new ComplexF[ length ];
+ }
+ buffer = _bufferCF;
+ }
+ static private void UnlockBufferCF( ref ComplexF[] buffer ) {
+ Debug.Assert( _bufferCF == buffer );
+ Debug.Assert( _bufferCFLocked == true );
+
+ _bufferCFLocked = false;
+ buffer = null;
+ }
+
+ private static void LinearFFT( ComplexF[] data, int start, int inc, int length, FourierDirection direction ) {
+ Debug.Assert( data != null );
+ Debug.Assert( start >= 0 );
+ Debug.Assert( inc >= 1 );
+ Debug.Assert( length >= 1 );
+ Debug.Assert( ( start + inc * ( length - 1 ) ) < data.Length );
+
+ // copy to buffer
+ ComplexF[] buffer = null;
+ LockBufferCF( length, ref buffer );
+ int j = start;
+ for( int i = 0; i < length; i ++ ) {
+ buffer[ i ] = data[ j ];
+ j += inc;
+ }
+
+ FFT( buffer, length, direction );
+
+ // copy from buffer
+ j = start;
+ for( int i = 0; i < length; i ++ ) {
+ data[ j ] = buffer[ i ];
+ j += inc;
+ }
+ UnlockBufferCF( ref buffer );
+ }
+
+ private static void LinearFFT_Quick( ComplexF[] data, int start, int inc, int length, FourierDirection direction ) {
+ /*Debug.Assert( data != null );
+ Debug.Assert( start >= 0 );
+ Debug.Assert( inc >= 1 );
+ Debug.Assert( length >= 1 );
+ Debug.Assert( ( start + inc * ( length - 1 ) ) < data.Length ); */
+
+ // copy to buffer
+ ComplexF[] buffer = null;
+ LockBufferCF( length, ref buffer );
+ int j = start;
+ for( int i = 0; i < length; i ++ ) {
+ buffer[ i ] = data[ j ];
+ j += inc;
+ }
+
+ FFT( buffer, length, direction );
+
+ // copy from buffer
+ j = start;
+ for( int i = 0; i < length; i ++ ) {
+ data[ j ] = buffer[ i ];
+ j += inc;
+ }
+ UnlockBufferCF( ref buffer );
+ }
+
+ //======================================================================================
+ //======================================================================================
+
+ static private bool _bufferCLocked = false;
+ static private Complex[] _bufferC = new Complex[ 0 ];
+
+ static private void LockBufferC( int length, ref Complex[] buffer ) {
+ Debug.Assert( length >= 0 );
+ Debug.Assert( _bufferCLocked == false );
+
+ _bufferCLocked = true;
+ if( length >= _bufferC.Length ) {
+ _bufferC = new Complex[ length ];
+ }
+ buffer = _bufferC;
+ }
+ static private void UnlockBufferC( ref Complex[] buffer ) {
+ Debug.Assert( _bufferC == buffer );
+ Debug.Assert( _bufferCLocked == true );
+
+ _bufferCLocked = false;
+ buffer = null;
+ }
+
+ private static void LinearFFT( Complex[] data, int start, int inc, int length, FourierDirection direction ) {
+ Debug.Assert( data != null );
+ Debug.Assert( start >= 0 );
+ Debug.Assert( inc >= 1 );
+ Debug.Assert( length >= 1 );
+ Debug.Assert( ( start + inc * ( length - 1 ) ) < data.Length );
+
+ // copy to buffer
+ Complex[] buffer = null;
+ LockBufferC( length, ref buffer );
+ int j = start;
+ for( int i = 0; i < length; i ++ ) {
+ buffer[ i ] = data[ j ];
+ j += inc;
+ }
+
+ FFT( buffer, length, direction );
+
+ // copy from buffer
+ j = start;
+ for( int i = 0; i < length; i ++ ) {
+ data[ j ] = buffer[ i ];
+ j += inc;
+ }
+ UnlockBufferC( ref buffer );
+ }
+
+ private static void LinearFFT_Quick( Complex[] data, int start, int inc, int length, FourierDirection direction ) {
+ /*Debug.Assert( data != null );
+ Debug.Assert( start >= 0 );
+ Debug.Assert( inc >= 1 );
+ Debug.Assert( length >= 1 );
+ Debug.Assert( ( start + inc * ( length - 1 ) ) < data.Length );*/
+
+ // copy to buffer
+ Complex[] buffer = null;
+ LockBufferC( length, ref buffer );
+ int j = start;
+ for( int i = 0; i < length; i ++ ) {
+ buffer[ i ] = data[ j ];
+ j += inc;
+ }
+
+ FFT_Quick( buffer, length, direction );
+
+ // copy from buffer
+ j = start;
+ for( int i = 0; i < length; i ++ ) {
+ data[ j ] = buffer[ i ];
+ j += inc;
+ }
+ UnlockBufferC( ref buffer );
+ }
+
+ //======================================================================================
+ //======================================================================================
+
+ /// <summary>
+ /// Compute a 1D fast Fourier transform of a dataset of complex numbers (as pairs of float's).
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="length"></param>
+ /// <param name="direction"></param>
+ public static void FFT( float[] data, int length, FourierDirection direction ) {
+ Debug.Assert( data != null );
+ Debug.Assert( data.Length >= length*2 );
+ Debug.Assert( Fourier.IsPowerOf2( length ) == true );
+
+ Fourier.SyncLookupTableLength( length );
+
+ int ln = Fourier.Log2( length );
+
+ // reorder array
+ Fourier.ReorderArray( data );
+
+ // successive doubling
+ int N = 1;
+ int signIndex = ( direction == FourierDirection.Forward ) ? 0 : 1;
+ for( int level = 1; level <= ln; level ++ ) {
+ int M = N;
+ N <<= 1;
+
+ float[] uRLookup = _uRLookupF[ level, signIndex ];
+ float[] uILookup = _uILookupF[ level, signIndex ];
+
+ for( int j = 0; j < M; j ++ ) {
+ float uR = uRLookup[j];
+ float uI = uILookup[j];
+
+ for( int evenT = j; evenT < length; evenT += N ) {
+ int even = evenT << 1;
+ int odd = ( evenT + M ) << 1;
+
+ float r = data[ odd ];
+ float i = data[ odd+1 ];
+
+ float odduR = r * uR - i * uI;
+ float odduI = r * uI + i * uR;
+
+ r = data[ even ];
+ i = data[ even+1 ];
+
+ data[ even ] = r + odduR;
+ data[ even+1 ] = i + odduI;
+
+ data[ odd ] = r - odduR;
+ data[ odd+1 ] = i - odduI;
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Compute a 1D fast Fourier transform of a dataset of complex numbers (as pairs of float's).
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="length"></param>
+ /// <param name="direction"></param>
+ public static void FFT_Quick( float[] data, int length, FourierDirection direction ) {
+ /*Debug.Assert( data != null );
+ Debug.Assert( data.Length >= length*2 );
+ Debug.Assert( Fourier.IsPowerOf2( length ) == true );
+
+ Fourier.SyncLookupTableLength( length );*/
+
+ int ln = Fourier.Log2( length );
+
+ // reorder array
+ Fourier.ReorderArray( data );
+
+ // successive doubling
+ int N = 1;
+ int signIndex = ( direction == FourierDirection.Forward ) ? 0 : 1;
+ for( int level = 1; level <= ln; level ++ ) {
+ int M = N;
+ N <<= 1;
+
+ float[] uRLookup = _uRLookupF[ level, signIndex ];
+ float[] uILookup = _uILookupF[ level, signIndex ];
+
+ for( int j = 0; j < M; j ++ ) {
+ float uR = uRLookup[j];
+ float uI = uILookup[j];
+
+ for( int evenT = j; evenT < length; evenT += N ) {
+ int even = evenT << 1;
+ int odd = ( evenT + M ) << 1;
+
+ float r = data[ odd ];
+ float i = data[ odd+1 ];
+
+ float odduR = r * uR - i * uI;
+ float odduI = r * uI + i * uR;
+
+ r = data[ even ];
+ i = data[ even+1 ];
+
+ data[ even ] = r + odduR;
+ data[ even+1 ] = i + odduI;
+
+ data[ odd ] = r - odduR;
+ data[ odd+1 ] = i - odduI;
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Compute a 1D fast Fourier transform of a dataset of complex numbers.
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="length"></param>
+ /// <param name="direction"></param>
+ public static void FFT( ComplexF[] data, int length, FourierDirection direction ) {
+ if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ if( data.Length < length ) {
+ throw new ArgumentOutOfRangeException( "length", length, "must be at least as large as 'data.Length' parameter" );
+ }
+ if( Fourier.IsPowerOf2( length ) == false ) {
+ throw new ArgumentOutOfRangeException( "length", length, "must be a power of 2" );
+ }
+
+ Fourier.SyncLookupTableLength( length );
+
+ int ln = Fourier.Log2( length );
+
+ // reorder array
+ Fourier.ReorderArray( data );
+
+ // successive doubling
+ int N = 1;
+ int signIndex = ( direction == FourierDirection.Forward ) ? 0 : 1;
+
+ for( int level = 1; level <= ln; level ++ ) {
+ int M = N;
+ N <<= 1;
+
+ float[] uRLookup = _uRLookupF[ level, signIndex ];
+ float[] uILookup = _uILookupF[ level, signIndex ];
+
+ for( int j = 0; j < M; j ++ ) {
+ float uR = uRLookup[j];
+ float uI = uILookup[j];
+
+ for( int even = j; even < length; even += N ) {
+ int odd = even + M;
+
+ float r = data[ odd ].Re;
+ float i = data[ odd ].Im;
+
+ float odduR = r * uR - i * uI;
+ float odduI = r * uI + i * uR;
+
+ r = data[ even ].Re;
+ i = data[ even ].Im;
+
+ data[ even ].Re = r + odduR;
+ data[ even ].Im = i + odduI;
+
+ data[ odd ].Re = r - odduR;
+ data[ odd ].Im = i - odduI;
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Compute a 1D fast Fourier transform of a dataset of complex numbers.
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="length"></param>
+ /// <param name="direction"></param>
+ public static void FFT_Quick( ComplexF[] data, int length, FourierDirection direction ) {
+ /*if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ if( data.Length < length ) {
+ throw new ArgumentOutOfRangeException( "length", length, "must be at least as large as 'data.Length' parameter" );
+ }
+ if( Fourier.IsPowerOf2( length ) == false ) {
+ throw new ArgumentOutOfRangeException( "length", length, "must be a power of 2" );
+ }
+
+ Fourier.SyncLookupTableLength( length );*/
+
+ int ln = Fourier.Log2( length );
+
+ // reorder array
+ Fourier.ReorderArray( data );
+
+ // successive doubling
+ int N = 1;
+ int signIndex = ( direction == FourierDirection.Forward ) ? 0 : 1;
+
+ for( int level = 1; level <= ln; level ++ ) {
+ int M = N;
+ N <<= 1;
+
+ float[] uRLookup = _uRLookupF[ level, signIndex ];
+ float[] uILookup = _uILookupF[ level, signIndex ];
+
+ for( int j = 0; j < M; j ++ ) {
+ float uR = uRLookup[j];
+ float uI = uILookup[j];
+
+ for( int even = j; even < length; even += N ) {
+ int odd = even + M;
+
+ float r = data[ odd ].Re;
+ float i = data[ odd ].Im;
+
+ float odduR = r * uR - i * uI;
+ float odduI = r * uI + i * uR;
+
+ r = data[ even ].Re;
+ i = data[ even ].Im;
+
+ data[ even ].Re = r + odduR;
+ data[ even ].Im = i + odduI;
+
+ data[ odd ].Re = r - odduR;
+ data[ odd ].Im = i - odduI;
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Compute a 1D fast Fourier transform of a dataset of complex numbers.
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="direction"></param>
+ public static void FFT( ComplexF[] data, FourierDirection direction ) {
+ if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ Fourier.FFT( data, data.Length, direction );
+ }
+
+ /// <summary>
+ /// Compute a 1D fast Fourier transform of a dataset of complex numbers.
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="length"></param>
+ /// <param name="direction"></param>
+ public static void FFT( Complex[] data, int length, FourierDirection direction ) {
+ if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ if( data.Length < length ) {
+ throw new ArgumentOutOfRangeException( "length", length, "must be at least as large as 'data.Length' parameter" );
+ }
+ if( Fourier.IsPowerOf2( length ) == false ) {
+ throw new ArgumentOutOfRangeException( "length", length, "must be a power of 2" );
+ }
+
+ Fourier.SyncLookupTableLength( length );
+
+ int ln = Fourier.Log2( length );
+
+ // reorder array
+ Fourier.ReorderArray( data );
+
+ // successive doubling
+ int N = 1;
+ int signIndex = ( direction == FourierDirection.Forward ) ? 0 : 1;
+
+ for( int level = 1; level <= ln; level ++ ) {
+ int M = N;
+ N <<= 1;
+
+ double[] uRLookup = _uRLookup[ level, signIndex ];
+ double[] uILookup = _uILookup[ level, signIndex ];
+
+ for( int j = 0; j < M; j ++ ) {
+ double uR = uRLookup[j];
+ double uI = uILookup[j];
+
+ for( int even = j; even < length; even += N ) {
+ int odd = even + M;
+
+ double r = data[ odd ].Re;
+ double i = data[ odd ].Im;
+
+ double odduR = r * uR - i * uI;
+ double odduI = r * uI + i * uR;
+
+ r = data[ even ].Re;
+ i = data[ even ].Im;
+
+ data[ even ].Re = r + odduR;
+ data[ even ].Im = i + odduI;
+
+ data[ odd ].Re = r - odduR;
+ data[ odd ].Im = i - odduI;
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Compute a 1D fast Fourier transform of a dataset of complex numbers.
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="length"></param>
+ /// <param name="direction"></param>
+ public static void FFT_Quick( Complex[] data, int length, FourierDirection direction ) {
+ /*if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ if( data.Length < length ) {
+ throw new ArgumentOutOfRangeException( "length", length, "must be at least as large as 'data.Length' parameter" );
+ }
+ if( Fourier.IsPowerOf2( length ) == false ) {
+ throw new ArgumentOutOfRangeException( "length", length, "must be a power of 2" );
+ }
+
+ Fourier.SyncLookupTableLength( length ); */
+
+ int ln = Fourier.Log2( length );
+
+ // reorder array
+ Fourier.ReorderArray( data );
+
+ // successive doubling
+ int N = 1;
+ int signIndex = ( direction == FourierDirection.Forward ) ? 0 : 1;
+
+ for( int level = 1; level <= ln; level ++ ) {
+ int M = N;
+ N <<= 1;
+
+ double[] uRLookup = _uRLookup[ level, signIndex ];
+ double[] uILookup = _uILookup[ level, signIndex ];
+
+ for( int j = 0; j < M; j ++ ) {
+ double uR = uRLookup[j];
+ double uI = uILookup[j];
+
+ for( int even = j; even < length; even += N ) {
+ int odd = even + M;
+
+ double r = data[ odd ].Re;
+ double i = data[ odd ].Im;
+
+ double odduR = r * uR - i * uI;
+ double odduI = r * uI + i * uR;
+
+ r = data[ even ].Re;
+ i = data[ even ].Im;
+
+ data[ even ].Re = r + odduR;
+ data[ even ].Im = i + odduI;
+
+ data[ odd ].Re = r - odduR;
+ data[ odd ].Im = i - odduI;
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Compute a 1D real-symmetric fast fourier transform.
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="direction"></param>
+ public static void RFFT( float[] data, FourierDirection direction ) {
+ if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ Fourier.RFFT( data, data.Length, direction );
+ }
+
+ /// <summary>
+ /// Compute a 1D real-symmetric fast fourier transform.
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="length"></param>
+ /// <param name="direction"></param>
+ public static void RFFT( float[] data, int length, FourierDirection direction ) {
+ if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ if( data.Length < length ) {
+ throw new ArgumentOutOfRangeException( "length", length, "must be at least as large as 'data.Length' parameter" );
+ }
+ if( Fourier.IsPowerOf2( length ) == false ) {
+ throw new ArgumentOutOfRangeException( "length", length, "must be a power of 2" );
+ }
+
+ float c1 = 0.5f, c2;
+ float theta = (float) Math.PI / (length/2);
+
+ if( direction == FourierDirection.Forward ) {
+ c2 = -0.5f;
+ FFT( data, length/2, direction );
+ }
+ else {
+ c2 = 0.5f;
+ theta = - theta;
+ }
+
+ float wtemp = (float) Math.Sin( 0.5*theta );
+ float wpr = -2 * wtemp*wtemp;
+ float wpi =(float) Math.Sin( theta );
+ float wr = 1 + wpr;
+ float wi = wpi;
+
+ // do / undo packing
+ for( int i = 1; i < length/4; i ++ ) {
+ int a = 2*i;
+ int b = length - 2*i;
+ float h1r = c1 * ( data[ a ] + data[ b ] );
+ float h1i = c1 * ( data[ a+1 ] - data[ b+1 ] );
+ float h2r = -c2 * ( data[ a+1 ] + data[ b+1 ] );
+ float h2i = c2 * ( data[ a ] - data[ b ] );
+ data[ a ] = h1r + wr*h2r - wi*h2i;
+ data[ a+1 ] = h1i + wr*h2i + wi*h2r;
+ data[ b ] = h1r - wr*h2r + wi*h2i;
+ data[ b+1 ] = -h1i + wr*h2i + wi*h2r;
+ wr = (wtemp = wr) * wpr - wi * wpi + wr;
+ wi = wi * wpr + wtemp * wpi + wi;
+ }
+
+ if( direction == FourierDirection.Forward ) {
+ float hir = data[0];
+ data[0] = hir + data[1];
+ data[1] = hir - data[1];
+ }
+ else {
+ float hir = data[0];
+ data[0] = c1 * ( hir + data[1] );
+ data[1] = c1 * ( hir - data[1] );
+ Fourier.FFT( data, length/2, direction );
+ }
+ }
+
+ /// <summary>
+ /// Compute a 2D fast fourier transform on a data set of complex numbers (represented as pairs of floats)
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="xLength"></param>
+ /// <param name="yLength"></param>
+ /// <param name="direction"></param>
+ public static void FFT2( float[] data, int xLength, int yLength, FourierDirection direction ) {
+ if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ if( data.Length < xLength*yLength*2 ) {
+ throw new ArgumentOutOfRangeException( "data.Length", data.Length, "must be at least as large as 'xLength * yLength * 2' parameter" );
+ }
+ if( Fourier.IsPowerOf2( xLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "xLength", xLength, "must be a power of 2" );
+ }
+ if( Fourier.IsPowerOf2( yLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "yLength", yLength, "must be a power of 2" );
+ }
+
+ int xInc = 1;
+ int yInc = xLength;
+
+ if( xLength > 1 ) {
+ Fourier.SyncLookupTableLength( xLength );
+ for( int y = 0; y < yLength; y ++ ) {
+ int xStart = y * yInc;
+ Fourier.LinearFFT_Quick( data, xStart, xInc, xLength, direction );
+ }
+ }
+
+ if( yLength > 1 ) {
+ Fourier.SyncLookupTableLength( yLength );
+ for( int x = 0; x < xLength; x ++ ) {
+ int yStart = x * xInc;
+ Fourier.LinearFFT_Quick( data, yStart, yInc, yLength, direction );
+ }
+ }
+ }
+
+ /// <summary>
+ /// Compute a 2D fast fourier transform on a data set of complex numbers
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="xLength"></param>
+ /// <param name="yLength"></param>
+ /// <param name="direction"></param>
+ public static void FFT2( ComplexF[] data, int xLength, int yLength, FourierDirection direction ) {
+ if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ if( data.Length < xLength*yLength ) {
+ throw new ArgumentOutOfRangeException( "data.Length", data.Length, "must be at least as large as 'xLength * yLength' parameter" );
+ }
+ if( Fourier.IsPowerOf2( xLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "xLength", xLength, "must be a power of 2" );
+ }
+ if( Fourier.IsPowerOf2( yLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "yLength", yLength, "must be a power of 2" );
+ }
+
+ int xInc = 1;
+ int yInc = xLength;
+
+ if( xLength > 1 ) {
+ Fourier.SyncLookupTableLength( xLength );
+ for( int y = 0; y < yLength; y ++ ) {
+ int xStart = y * yInc;
+ Fourier.LinearFFT_Quick( data, xStart, xInc, xLength, direction );
+ }
+ }
+
+ if( yLength > 1 ) {
+ Fourier.SyncLookupTableLength( yLength );
+ for( int x = 0; x < xLength; x ++ ) {
+ int yStart = x * xInc;
+ Fourier.LinearFFT_Quick( data, yStart, yInc, yLength, direction );
+ }
+ }
+ }
+
+ /// <summary>
+ /// Compute a 2D fast fourier transform on a data set of complex numbers
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="xLength"></param>
+ /// <param name="yLength"></param>
+ /// <param name="direction"></param>
+ public static void FFT2( Complex[] data, int xLength, int yLength, FourierDirection direction ) {
+ if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ if( data.Length < xLength*yLength ) {
+ throw new ArgumentOutOfRangeException( "data.Length", data.Length, "must be at least as large as 'xLength * yLength' parameter" );
+ }
+ if( Fourier.IsPowerOf2( xLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "xLength", xLength, "must be a power of 2" );
+ }
+ if( Fourier.IsPowerOf2( yLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "yLength", yLength, "must be a power of 2" );
+ }
+
+ int xInc = 1;
+ int yInc = xLength;
+
+ if( xLength > 1 ) {
+ Fourier.SyncLookupTableLength( xLength );
+ for( int y = 0; y < yLength; y ++ ) {
+ int xStart = y * yInc;
+ Fourier.LinearFFT_Quick( data, xStart, xInc, xLength, direction );
+ }
+ }
+
+ if( yLength > 1 ) {
+ Fourier.SyncLookupTableLength( yLength );
+ for( int x = 0; x < xLength; x ++ ) {
+ int yStart = x * xInc;
+ Fourier.LinearFFT_Quick( data, yStart, yInc, yLength, direction );
+ }
+ }
+ }
+
+ /// <summary>
+ /// Compute a 3D fast fourier transform on a data set of complex numbers
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="xLength"></param>
+ /// <param name="yLength"></param>
+ /// <param name="zLength"></param>
+ /// <param name="direction"></param>
+ public static void FFT3( ComplexF[] data, int xLength, int yLength, int zLength, FourierDirection direction ) {
+ if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ if( data.Length < xLength*yLength*zLength ) {
+ throw new ArgumentOutOfRangeException( "data.Length", data.Length, "must be at least as large as 'xLength * yLength * zLength' parameter" );
+ }
+ if( Fourier.IsPowerOf2( xLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "xLength", xLength, "must be a power of 2" );
+ }
+ if( Fourier.IsPowerOf2( yLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "yLength", yLength, "must be a power of 2" );
+ }
+ if( Fourier.IsPowerOf2( zLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "zLength", zLength, "must be a power of 2" );
+ }
+
+ int xInc = 1;
+ int yInc = xLength;
+ int zInc = xLength * yLength;
+
+ if( xLength > 1 ) {
+ Fourier.SyncLookupTableLength( xLength );
+ for( int z = 0; z < zLength; z ++ ) {
+ for( int y = 0; y < yLength; y ++ ) {
+ int xStart = y * yInc + z * zInc;
+ Fourier.LinearFFT_Quick( data, xStart, xInc, xLength, direction );
+ }
+ }
+ }
+
+ if( yLength > 1 ) {
+ Fourier.SyncLookupTableLength( yLength );
+ for( int z = 0; z < zLength; z ++ ) {
+ for( int x = 0; x < xLength; x ++ ) {
+ int yStart = z * zInc + x * xInc;
+ Fourier.LinearFFT_Quick( data, yStart, yInc, yLength, direction );
+ }
+ }
+ }
+
+ if( zLength > 1 ) {
+ Fourier.SyncLookupTableLength( zLength );
+ for( int y = 0; y < yLength; y ++ ) {
+ for( int x = 0; x < xLength; x ++ ) {
+ int zStart = y * yInc + x * xInc;
+ Fourier.LinearFFT_Quick( data, zStart, zInc, zLength, direction );
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Compute a 3D fast fourier transform on a data set of complex numbers
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="xLength"></param>
+ /// <param name="yLength"></param>
+ /// <param name="zLength"></param>
+ /// <param name="direction"></param>
+ public static void FFT3( Complex[] data, int xLength, int yLength, int zLength, FourierDirection direction ) {
+ if( data == null ) {
+ throw new ArgumentNullException( "data" );
+ }
+ if( data.Length < xLength*yLength*zLength ) {
+ throw new ArgumentOutOfRangeException( "data.Length", data.Length, "must be at least as large as 'xLength * yLength * zLength' parameter" );
+ }
+ if( Fourier.IsPowerOf2( xLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "xLength", xLength, "must be a power of 2" );
+ }
+ if( Fourier.IsPowerOf2( yLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "yLength", yLength, "must be a power of 2" );
+ }
+ if( Fourier.IsPowerOf2( zLength ) == false ) {
+ throw new ArgumentOutOfRangeException( "zLength", zLength, "must be a power of 2" );
+ }
+
+ int xInc = 1;
+ int yInc = xLength;
+ int zInc = xLength * yLength;
+
+ if( xLength > 1 ) {
+ Fourier.SyncLookupTableLength( xLength );
+ for( int z = 0; z < zLength; z ++ ) {
+ for( int y = 0; y < yLength; y ++ ) {
+ int xStart = y * yInc + z * zInc;
+ Fourier.LinearFFT_Quick( data, xStart, xInc, xLength, direction );
+ }
+ }
+ }
+
+ if( yLength > 1 ) {
+ Fourier.SyncLookupTableLength( yLength );
+ for( int z = 0; z < zLength; z ++ ) {
+ for( int x = 0; x < xLength; x ++ ) {
+ int yStart = z * zInc + x * xInc;
+ Fourier.LinearFFT_Quick( data, yStart, yInc, yLength, direction );
+ }
+ }
+ }
+
+ if( zLength > 1 ) {
+ Fourier.SyncLookupTableLength( zLength );
+ for( int y = 0; y < yLength; y ++ ) {
+ for( int x = 0; x < xLength; x ++ ) {
+ int zStart = y * yInc + x * xInc;
+ Fourier.LinearFFT_Quick( data, zStart, zInc, zLength, direction );
+ }
+ }
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/FourierDirection.cs b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/FourierDirection.cs
new file mode 100644
index 00000000000..275ad743c18
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Exocortex.DSP/src/FourierDirection.cs
@@ -0,0 +1,55 @@
+/*
+ * BSD Licence:
+ * Copyright (c) 2001, 2002 Ben Houston [ ben@exocortex.org ]
+ * Exocortex Technologies [ www.exocortex.org ]
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+
+using System;
+
+namespace Exocortex.DSP
+{
+ // Comments? Questions? Bugs? Tell Ben Houston at ben@exocortex.org
+ // Version: May 4, 2002
+
+ /// <summary>
+ /// <p>The direction of the fourier transform.</p>
+ /// </summary>
+ public enum FourierDirection : int {
+ /// <summary>
+ /// Forward direction. Usually in reference to moving from temporal
+ /// representation to frequency representation
+ /// </summary>
+ Forward = 1,
+ /// <summary>
+ /// Backward direction. Usually in reference to moving from frequency
+ /// representation to temporal representation
+ /// </summary>
+ Backward = -1,
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.dotnet.sln b/mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.dotnet.sln
new file mode 100644
index 00000000000..c786bb02b1b
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.dotnet.sln
@@ -0,0 +1,51 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.dotnet", "..\Test.dotnet.csproj", "{DFE29E81-D6A8-45D4-A627-161F462BE767}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exocortex.DSP.v1", "Exocortex.DSP\src\Exocortex.DSP.v1.csproj", "{1904A41B-D1B8-40E5-ADBB-728DDCF7C816}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrawingTestHelper", "DrawingTestHelper\DrawingTestHelper.csproj", "{8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Debug_Java = Debug_Java
+ Release = Release
+ Release_Java = Release_Java
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {DFE29E81-D6A8-45D4-A627-161F462BE767}.Debug.ActiveCfg = Debug|.NET
+ {DFE29E81-D6A8-45D4-A627-161F462BE767}.Debug.Build.0 = Debug|.NET
+ {DFE29E81-D6A8-45D4-A627-161F462BE767}.Debug_Java.ActiveCfg = Debug|.NET
+ {DFE29E81-D6A8-45D4-A627-161F462BE767}.Debug_Java.Build.0 = Debug|.NET
+ {DFE29E81-D6A8-45D4-A627-161F462BE767}.Release.ActiveCfg = Release|.NET
+ {DFE29E81-D6A8-45D4-A627-161F462BE767}.Release.Build.0 = Release|.NET
+ {DFE29E81-D6A8-45D4-A627-161F462BE767}.Release_Java.ActiveCfg = Release|.NET
+ {DFE29E81-D6A8-45D4-A627-161F462BE767}.Release_Java.Build.0 = Release|.NET
+ {1904A41B-D1B8-40E5-ADBB-728DDCF7C816}.Debug.ActiveCfg = Debug|.NET
+ {1904A41B-D1B8-40E5-ADBB-728DDCF7C816}.Debug.Build.0 = Debug|.NET
+ {1904A41B-D1B8-40E5-ADBB-728DDCF7C816}.Debug_Java.ActiveCfg = Debug|.NET
+ {1904A41B-D1B8-40E5-ADBB-728DDCF7C816}.Debug_Java.Build.0 = Debug|.NET
+ {1904A41B-D1B8-40E5-ADBB-728DDCF7C816}.Release.ActiveCfg = Release|.NET
+ {1904A41B-D1B8-40E5-ADBB-728DDCF7C816}.Release.Build.0 = Release|.NET
+ {1904A41B-D1B8-40E5-ADBB-728DDCF7C816}.Release_Java.ActiveCfg = Release|.NET
+ {1904A41B-D1B8-40E5-ADBB-728DDCF7C816}.Release_Java.Build.0 = Release|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Debug.ActiveCfg = Debug|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Debug.Build.0 = Debug|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Debug_Java.ActiveCfg = Debug|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Debug_Java.Build.0 = Debug|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Release.ActiveCfg = Release|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Release.Build.0 = Release|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Release_Java.ActiveCfg = Release|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Release_Java.Build.0 = Release|.NET
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.sln b/mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.sln
new file mode 100644
index 00000000000..dea52ef1fb5
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/System.Drawing.Test.sln
@@ -0,0 +1,44 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{83B010C7-76FC-4FAD-A26C-00D7EFE60256}") = "Exocortex.DSP.v1.J2EE", "Exocortex.DSP\src\Exocortex.DSP.v1.J2EE.vmwcsproj", "{8D602CEF-DC13-48F1-AF0C-F6201A634FD2}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{83B010C7-76FC-4FAD-A26C-00D7EFE60256}") = "DrawingTestHelper_java", "DrawingTestHelper\DrawingTestHelper_java.vmwcsproj", "{8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{83B010C7-76FC-4FAD-A26C-00D7EFE60256}") = "Test", "..\Test.vmwcsproj", "{D92997D0-B8BD-49A8-A7D0-8B6043930A07}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Debug_Java = Debug_Java
+ Release_Java = Release_Java
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {8D602CEF-DC13-48F1-AF0C-F6201A634FD2}.Debug.ActiveCfg = Debug|.NET
+ {8D602CEF-DC13-48F1-AF0C-F6201A634FD2}.Debug.Build.0 = Debug|.NET
+ {8D602CEF-DC13-48F1-AF0C-F6201A634FD2}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {8D602CEF-DC13-48F1-AF0C-F6201A634FD2}.Debug_Java.Build.0 = Debug_Java|.NET
+ {8D602CEF-DC13-48F1-AF0C-F6201A634FD2}.Release_Java.ActiveCfg = Release_Java|.NET
+ {8D602CEF-DC13-48F1-AF0C-F6201A634FD2}.Release_Java.Build.0 = Release_Java|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Debug.ActiveCfg = Debug|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Debug.Build.0 = Debug|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Debug_Java.Build.0 = Debug_Java|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Release_Java.ActiveCfg = Release_Java|.NET
+ {8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}.Release_Java.Build.0 = Release_Java|.NET
+ {D92997D0-B8BD-49A8-A7D0-8B6043930A07}.Debug.ActiveCfg = Debug|.NET
+ {D92997D0-B8BD-49A8-A7D0-8B6043930A07}.Debug.Build.0 = Debug|.NET
+ {D92997D0-B8BD-49A8-A7D0-8B6043930A07}.Debug_Java.ActiveCfg = Debug_Java|.NET
+ {D92997D0-B8BD-49A8-A7D0-8B6043930A07}.Debug_Java.Build.0 = Debug_Java|.NET
+ {D92997D0-B8BD-49A8-A7D0-8B6043930A07}.Release_Java.ActiveCfg = Release_Java|.NET
+ {D92997D0-B8BD-49A8-A7D0-8B6043930A07}.Release_Java.Build.0 = Release_Java|.NET
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/AssemblyInfo.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/AssemblyInfo.cs
new file mode 100644
index 00000000000..177a4f0e70a
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/AssemblyInfo.cs
@@ -0,0 +1,58 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: AssemblyVersion("1.0.*")]
+
+//
+// In order to sign your assembly you must specify a key to use. Refer to the
+// Microsoft .NET Framework documentation for more information on assembly signing.
+//
+// Use the attributes below to control which key is used for signing.
+//
+// Notes:
+// (*) If no key is specified, the assembly is not signed.
+// (*) KeyName refers to a key that has been installed in the Crypto Service
+// Provider (CSP) on your machine. KeyFile refers to a file which contains
+// a key.
+// (*) If the KeyFile and the KeyName values are both specified, the
+// following processing occurs:
+// (1) If the KeyName can be found in the CSP, that key is used.
+// (2) If the KeyName does not exist and the KeyFile does exist, the key
+// in the KeyFile is installed into the CSP and used.
+// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
+// When specifying the KeyFile, the location of the KeyFile should be
+// relative to the project output directory which is
+// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
+// located in the project directory, you would specify the AssemblyKeyFile
+// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
+// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
+// documentation for more information on this.
+//
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("")]
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap.cs
new file mode 100644
index 00000000000..483e1cefaba
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using NUnit.Framework;
+using DrawingTestHelper;
+
+namespace Test.Sys.Drawing
+{
+ /// <summary>
+ /// Summary description for Bitmap.
+ /// </summary>
+ [TestFixture]
+ public class BitmapFixture {
+ DrawingTest t;
+
+ [SetUp]
+ public void SetUp () {
+ t = DrawingTest.Create (64, 64);
+ Bitmap b = new Bitmap (@"..\..\..\Test\Bitmap1.png");
+ t.Graphics.DrawImageUnscaled (b, 0, 0);
+ DrawingTest.ShowForms = false;
+ }
+ [Test]
+ public void CloneTest () {
+ Bitmap b1 = (Bitmap) t.Bitmap.Clone ();
+ Assert.IsFalse (Object.ReferenceEquals (t.Bitmap, b1));
+ Assert.AreEqual (DrawingTest.CalculateNorm (t.Bitmap),
+ DrawingTest.CalculateNorm (b1));
+ t.Graphics.FillRectangle (Brushes.Black, 0, 0, 64, 64);
+ Assert.IsFalse (DrawingTest.CalculateNorm (t.Bitmap) ==
+ DrawingTest.CalculateNorm (b1));
+ }
+ [Test]
+ public void GetPixel () {
+ Assert.AreEqual (Color.FromArgb (255, Color.White),
+ t.Bitmap.GetPixel (0, 0));
+ t.Graphics.FillRectangle (Brushes.Black, 30, 30, 30, 30);
+ Assert.AreEqual (Color.FromArgb (255, Color.Black),
+ t.Bitmap.GetPixel (31, 31));
+ }
+ [Test]
+ [Category ("GHNotWorking")] //FIXME: MakeTransparent method does not working as expected. Fix it.
+ public void MakeTransparent () {
+ t.Show ();
+ Bitmap b = (Bitmap) t.Bitmap.Clone ();
+ b.MakeTransparent (Color.White);
+ t.Graphics.FillRectangle (Brushes.Black, 0, 0, 64, 64);
+ t.Graphics.DrawImageUnscaled (b, 0, 0);
+ t.Show ();
+ Assert.IsTrue (t.Compare (10));
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap1.bmp b/mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap1.bmp
new file mode 100644
index 00000000000..4c21def1a0f
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap1.bmp
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap1.png b/mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap1.png
new file mode 100644
index 00000000000..3d378deb233
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Bitmap1.png
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Brush.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/Brush.cs
new file mode 100644
index 00000000000..e97215f7b50
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Brush.cs
@@ -0,0 +1,139 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using NUnit.Framework;
+using DrawingTestHelper;
+
+namespace Test.Sys.Drawing
+{
+ /// <summary>
+ /// Summary description for Brush.
+ /// </summary>
+
+ #region BrushFixture
+
+ [TestFixture]
+ public class BrushFixture
+ {
+ [Test]
+ public void ColorTest()
+ {
+ SolidBrush b = new SolidBrush (Color.Azure);
+ Assert.AreEqual (Color.Azure, b.Color);
+ DrawingTest t = DrawingTest.Create (64, 64);
+ t.Graphics.FillRectangle (b, 0, 0, 30, 30);
+ t.Show ();
+ b.Color = Color.FromArgb (100, 240, 30);
+ t.Graphics.FillRectangle (b, 30, 5, 30, 50);
+ t.Show ();
+ b.Color = Color.FromArgb (70, Color.FromName ("red"));
+ t.Graphics.FillRectangle (b, 15, 15, 40, 40);
+ t.Show ();
+ }
+ }
+
+ #endregion
+
+ #region TextureBrushFixture
+ [TestFixture]
+ public class GraphicsFixtureFillModes {
+ protected DrawingTest t;
+ protected int TOLERANCE = 3;
+ Image bmp;
+ Image bmp2;
+
+ [SetUp]
+ public virtual void SetUp() {
+ SetUp("TextureBrushFixture");
+ }
+ public virtual void SetUp(string ownerClass) {
+ t = DrawingTest.Create(512, 512, ownerClass);
+ bmp = Bitmap.FromFile(@"..\..\bitmap50.png");
+ bmp2 = Bitmap.FromFile(@"..\..\bitmap25.png");
+ }
+ [TearDown]
+ public void TearDown() {
+ }
+
+ [Test]
+ public void WrapMode_1() {
+ TextureBrush b = new TextureBrush( bmp );
+ Assert.AreEqual(WrapMode.Tile, b.WrapMode);
+ }
+ [Test]
+ public void TextureBush_1() {
+ TextureBrush b = new TextureBrush( bmp );
+ t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void TextureBush_2() {
+ TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipX );
+ t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void TextureBush_3() {
+ TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipY );
+ t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void TextureBush_4() {
+ TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipXY );
+ t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void TextureBush_5() {
+ TextureBrush b = new TextureBrush( bmp2, new Rectangle(100, 100, 50, 50) );
+ t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void TextureBush_6() {
+ TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipX, new Rectangle(100, 100, 50, 50) );
+ t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void TextureBush_7() {
+ TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipY, new Rectangle(100, 100, 50, 50) );
+ t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void TextureBush_8() {
+ TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipXY, new Rectangle(100, 100, 50, 50) );
+ t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void TextureBush_9() {
+ TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipXY, new Rectangle(100, 100, 50, 50) );
+ t.Graphics.RotateTransform(30);
+ t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void TextureBush_10() {
+ TextureBrush b = new TextureBrush( bmp, WrapMode.TileFlipXY, new Rectangle(100, 100, 50, 50) );
+ t.Graphics.RotateTransform(30);
+ b.RotateTransform(30);
+ t.Graphics.FillRectangle( b, 100, 100, 300, 300 );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ }
+ #endregion
+
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Brushes.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/Brushes.cs
new file mode 100644
index 00000000000..6c495440c48
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Brushes.cs
@@ -0,0 +1,367 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using NUnit.Framework;
+using DrawingTestHelper;
+using System.Reflection;
+
+namespace Test.Sys.Drawing
+{
+ /// <summary>
+ /// Summary description for Pens.
+ /// </summary>
+
+ [TestFixture]
+ public class BrushesFixture
+ {
+
+ [SetUp]
+ public void SetUp ()
+ {
+ }
+
+ #region Names Array
+ string [] ar_brushes = {
+ "Transparent",
+ "AliceBlue",
+ "AntiqueWhite",
+ "Aqua",
+ "Aquamarine",
+ "Azure",
+ "Beige",
+ "Bisque",
+ "Black",
+ "BlanchedAlmond",
+ "Blue",
+ "BlueViolet",
+ "Brown",
+ "BurlyWood",
+ "CadetBlue",
+ "Chartreuse",
+ "Chocolate",
+ "Coral",
+ "CornflowerBlue",
+ "Cornsilk",
+ "Crimson",
+ "Cyan",
+ "DarkBlue",
+ "DarkCyan",
+ "DarkGoldenrod",
+ "DarkGray",
+ "DarkGreen",
+ "DarkKhaki",
+ "DarkMagenta",
+ "DarkOliveGreen",
+ "DarkOrange",
+ "DarkOrchid",
+ "DarkRed",
+ "DarkSalmon",
+ "DarkSeaGreen",
+ "DarkSlateBlue",
+ "DarkSlateGray",
+ "DarkTurquoise",
+ "DarkViolet",
+ "DeepPink",
+ "DeepSkyBlue",
+ "DimGray",
+ "DodgerBlue",
+ "Firebrick",
+ "FloralWhite",
+ "ForestGreen",
+ "Fuchsia",
+ "Gainsboro",
+ "GhostWhite",
+ "Gold",
+ "Goldenrod",
+ "Gray",
+ "Green",
+ "GreenYellow",
+ "Honeydew",
+ "HotPink",
+ "IndianRed",
+ "Indigo",
+ "Ivory",
+ "Khaki",
+ "Lavender",
+ "LavenderBlush",
+ "LawnGreen",
+ "LemonChiffon",
+ "LightBlue",
+ "LightCoral",
+ "LightCyan",
+ "LightGoldenrodYellow",
+ "LightGreen",
+ "LightGray",
+ "LightPink",
+ "LightSalmon",
+ "LightSeaGreen",
+ "LightSkyBlue",
+ "LightSlateGray",
+ "LightSteelBlue",
+ "LightYellow",
+ "Lime",
+ "LimeGreen",
+ "Linen",
+ "Magenta",
+ "Maroon",
+ "MediumAquamarine",
+ "MediumBlue",
+ "MediumOrchid",
+ "MediumPurple",
+ "MediumSeaGreen",
+ "MediumSlateBlue",
+ "MediumSpringGreen",
+ "MediumTurquoise",
+ "MediumVioletRed",
+ "MidnightBlue",
+ "MintCream",
+ "MistyRose",
+ "Moccasin",
+ "NavajoWhite",
+ "Navy",
+ "OldLace",
+ "Olive",
+ "OliveDrab",
+ "Orange",
+ "OrangeRed",
+ "Orchid",
+ "PaleGoldenrod",
+ "PaleGreen",
+ "PaleTurquoise",
+ "PaleVioletRed",
+ "PapayaWhip",
+ "PeachPuff",
+ "Peru",
+ "Pink",
+ "Plum",
+ "PowderBlue",
+ "Purple",
+ "Red",
+ "RosyBrown",
+ "RoyalBlue",
+ "SaddleBrown",
+ "Salmon",
+ "SandyBrown",
+ "SeaGreen",
+ "SeaShell",
+ "Sienna",
+ "Silver",
+ "SkyBlue",
+ "SlateBlue",
+ "SlateGray",
+ "Snow",
+ "SpringGreen",
+ "SteelBlue",
+ "Tan",
+ "Teal",
+ "Thistle",
+ "Tomato",
+ "Turquoise",
+ "Violet",
+ "Wheat",
+ "White",
+ "WhiteSmoke",
+ "Yellow",
+ "YellowGreen"};
+
+ string [] ar_system_brushes = {
+ "ActiveBorder",
+ "ActiveCaption",
+ "ActiveCaptionText",
+ "AppWorkspace",
+ "Desktop",
+ "Control",
+ "ControlLightLight",
+ "ControlLight",
+ "ControlDark",
+ "ControlDarkDark",
+ "ControlText",
+ "Highlight",
+ "HighlightText",
+ "HotTrack",
+ "InactiveCaption",
+ "InactiveBorder",
+ "Info",
+ "Menu",
+ "ScrollBar",
+ "Window",
+ "WindowText"};
+
+
+ #endregion
+
+ [Test]
+ public void BrushesPropertyCount()
+ {
+ Type t = typeof(Brushes);
+ PropertyInfo [] pi = t.GetProperties(BindingFlags.Static | BindingFlags.Public);
+
+ int i = 0;
+ foreach (PropertyInfo p in pi)
+ {
+ if (p.PropertyType == typeof(Brush))
+ {
+ i++;
+ }
+ }
+ Assert.AreEqual(ar_brushes.Length, i, "Number of brushes");
+ }
+
+ [Test]
+ public void BrushesProperties ()
+ {
+ Type t = typeof(Brushes);
+ foreach (string s in ar_brushes)
+ {
+ MemberInfo [] mi = t.GetMember(s);
+
+ if (mi.Length == 1)
+ {
+ if (mi[0].MemberType == MemberTypes.Property)
+ {
+ PropertyInfo p = (PropertyInfo)mi[0];
+ SolidBrush brush = (SolidBrush)p.GetValue(null, null);
+ Assert.AreEqual("Color [" + s + "]", brush.Color.ToString());
+ }
+ else
+ {
+ Assert.Fail(s + " is not property of Brushes class");
+ }
+ }
+ else
+ {
+ Assert.Fail("Property " + s + " not found in Brushes class");
+ }
+ }
+ }
+
+ [Test]
+ public void BrushesAssignValue ()
+ {
+ Type t = typeof(Brushes);
+ foreach (string s in ar_brushes)
+ {
+ MemberInfo [] mi = t.GetMember(s);
+
+ if (mi.Length == 1)
+ {
+ if (mi[0].MemberType == MemberTypes.Property)
+ {
+ PropertyInfo p = (PropertyInfo)mi[0];
+ SolidBrush brush = (SolidBrush)p.GetValue(null, null);
+
+ try
+ {
+ Color c = brush.Color;
+ brush.Color = Color.AliceBlue;
+ brush.Color = c;
+
+ //BUG: Bug in .NET
+ //Assert.Fail("SolidBrush.Color must throw exception");
+ Assert.IsTrue(true);
+ }
+ catch(ArgumentException)
+ {
+ Assert.IsTrue(true);
+ }
+ }
+ else
+ {
+ Assert.Fail(s + " is not property of Brushes class");
+ }
+ }
+ else
+ {
+ Assert.Fail("Property " + s + " not found in Brushes class");
+ }
+ }
+ }
+
+ [Test]
+ public void SystemBrushesPropertyCount()
+ {
+ Type t = typeof(SystemBrushes);
+ PropertyInfo [] pi = t.GetProperties(BindingFlags.Static | BindingFlags.Public);
+
+ int i = 0;
+ foreach (PropertyInfo p in pi)
+ {
+ if (p.PropertyType == typeof(Brush))
+ {
+ i++;
+ }
+ }
+ Assert.AreEqual(ar_system_brushes.Length, i, "Number of brushes");
+ }
+
+ [Test]
+ public void SystemBrushesProperties ()
+ {
+ Type t = typeof(SystemBrushes);
+ foreach (string s in ar_system_brushes)
+ {
+ MemberInfo [] mi = t.GetMember(s);
+
+ if (mi.Length == 1)
+ {
+ if (mi[0].MemberType == MemberTypes.Property)
+ {
+ PropertyInfo p = (PropertyInfo)mi[0];
+ SolidBrush brush = (SolidBrush)p.GetValue(null, null);
+ Assert.AreEqual("Color [" + s + "]", brush.Color.ToString());
+ }
+ else
+ {
+ Assert.Fail(s + " is not property of SystemBrushes class");
+ }
+ }
+ else
+ {
+ Assert.Fail("Property " + s + " not found in SystemBrushes class");
+ }
+ }
+ }
+
+ [Test]
+ public void SystemBrushesAssignValue ()
+ {
+ Type t = typeof(SystemBrushes);
+ foreach (string s in ar_system_brushes)
+ {
+ MemberInfo [] mi = t.GetMember(s);
+
+ if (mi.Length == 1)
+ {
+ if (mi[0].MemberType == MemberTypes.Property)
+ {
+ PropertyInfo p = (PropertyInfo)mi[0];
+ SolidBrush brush = (SolidBrush)p.GetValue(null, null);
+
+ try
+ {
+ Color c = brush.Color;
+ brush.Color = Color.AliceBlue;
+ brush.Color = c;
+
+ //BUG: Bug in .NET
+ //Assert.Fail("SolidBrush.Color must throw exception");
+ Assert.IsTrue(true);
+ }
+ catch(ArgumentException)
+ {
+ Assert.IsTrue(true);
+ }
+ }
+ else
+ {
+ Assert.Fail(s + " is not property of SystemBrushes class");
+ }
+ }
+ else
+ {
+ Assert.Fail("Property " + s + " not found in SystemBrushes class");
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/ChangeLog b/mcs/class/System.Drawing/Test/DrawingTest/Test/ChangeLog
new file mode 100644
index 00000000000..124280203d7
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/ChangeLog
@@ -0,0 +1,76 @@
+2005-10-27 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Brush.cs: added texture brush with transform tests
+ * Graphics.cs: added DrawImage, BeginContainer tests
+
+2005-10-17 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.cs: Added FillMode tests
+ * Brush.cs: Added TextureBrush tests
+
+2005-09-21 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.cs: Added tests for DrawImage
+ * Image.cs: Added tests for clone, GetFrameCount
+
+2005-09-20 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.cs: Added tests for DrawImage, fixed use pixel distance comparer
+
+2005-09-10 Konstnatin Triger <kostat@mainsoft.com>
+
+ * Graphics.cs: Added test for Clipping
+
+2005-09-07 Boris Kirzner <borisk@mainsoft.com>
+ * GraphicsPath.cs: Added another PathData test..
+
+2005-09-06 Boris Kirzner <borisk@mainsoft.com>
+ * GraphicsPathIterator.cs: added.
+ * GraphicsPath.cs: Changed tests. Added NotWorking for the tests that
+ should fail in TARGET_JVM.
+
+2005-08-25 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Graphics.cs: Added tests for Graphics.Begin/EndContaioner,
+ Graphics.Save/Restore, Transforms
+
+2005-08-25 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Pen.cs: Refactoring
+ * Image.cs: Refactoring
+ * Bitmap.cs: Refactoring
+ * Graphics.cs: Refactoring
+ * Region.cs: Refactoring
+
+2005-08-16 Andrew Skiba <andrews@mainsoft.com>
+
+ * Test.dotnet.csproj, Test.vmwcsproj: make Bitmap1.png embedded resource,
+ add Bitmap1.bmp
+ * Bitmap1.bmp: added to make tests on java without jai
+ * Bitmap.cs: open bitmap from resources, to get rid of dir dependency
+ * Color.cs: remove unnecessary using DrawingTestHelper
+ * Graphics.cs: naive StringAlignment tests, must be improved later
+ * Image.cs: same as Bitmap.cs + use test.bmp instead of test.png (works
+ immediately on java w/o jai)
+
+2005-08-10 Boris Kirzner <borisk@mainsoft.com>
+ * GraphicsPath.cs: Added new class. Test fixture for GraphicsPath.
+
+2005-08-08 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Pen.cs: Added LineCaps and LineJoin tests
+ * Image.cs: Added png interop test
+ * Added test images bitmap_gh.png, bitmap_net.png
+
+2005-08-08 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * Added Brushes.cs: Brushes and SystemBrushes tests
+ * Added Colors.cs: Colors, SystemColors tests
+ * Added Enums.cs: Various enums tests
+ * Added Pens.cs: Pens, SystemPent tests
+
+Andrew Skiba <andrews@mainsoft.com>
+
+ * Test.dotnet.csproj, Test.vmwcsproj: move project to sys.drawing/Test so
+ it's easy to include Mono tests
+
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Colors.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/Colors.cs
new file mode 100644
index 00000000000..5217c80da61
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Colors.cs
@@ -0,0 +1,361 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using NUnit.Framework;
+using System.Reflection;
+
+namespace Test.Sys.Drawing
+{
+ /// <summary>
+ /// Summary description for Pens.
+ /// </summary>
+
+ [TestFixture]
+ public class ColorsFixture
+ {
+
+ [SetUp]
+ public void SetUp ()
+ {
+ }
+
+ #region names array
+ private string [] ar_colors = {
+ "Transparent,0,255,255,255,1,0,0",
+ "AliceBlue,255,240,248,255,0.9705882,208,1",
+ "AntiqueWhite,255,250,235,215,0.9117647,34.28571,0.7777778",
+ "Aqua,255,0,255,255,0.5,180,1",
+ "Aquamarine,255,127,255,212,0.7490196,159.8438,1",
+ "Azure,255,240,255,255,0.9705882,180,1",
+ "Beige,255,245,245,220,0.9117647,60,0.5555556",
+ "Bisque,255,255,228,196,0.8843137,32.54237,1",
+ "Black,255,0,0,0,0,0,0",
+ "BlanchedAlmond,255,255,235,205,0.9019608,36,1",
+ "Blue,255,0,0,255,0.5,240,1",
+ "BlueViolet,255,138,43,226,0.527451,271.1476,0.7593361",
+ "Brown,255,165,42,42,0.4058824,0,0.5942029",
+ "BurlyWood,255,222,184,135,0.7,33.7931,0.5686275",
+ "CadetBlue,255,95,158,160,0.5,181.8462,0.254902",
+ "Chartreuse,255,127,255,0,0.5,90.11765,1",
+ "Chocolate,255,210,105,30,0.4705882,25,0.75",
+ "Coral,255,255,127,80,0.6568627,16.11428,1",
+ "CornflowerBlue,255,100,149,237,0.6607843,218.5401,0.7919075",
+ "Cornsilk,255,255,248,220,0.9313725,48,1",
+ "Crimson,255,220,20,60,0.4705882,348,0.8333333",
+ "Cyan,255,0,255,255,0.5,180,1",
+ "DarkBlue,255,0,0,139,0.272549,240,1",
+ "DarkCyan,255,0,139,139,0.272549,180,1",
+ "DarkGoldenrod,255,184,134,11,0.3823529,42.65896,0.8871795",
+ "DarkGray,255,169,169,169,0.6627451,0,0",
+ "DarkGreen,255,0,100,0,0.1960784,120,1",
+ "DarkKhaki,255,189,183,107,0.5803922,55.60976,0.3831776",
+ "DarkMagenta,255,139,0,139,0.272549,300,1",
+ "DarkOliveGreen,255,85,107,47,0.3019608,82,0.3896104",
+ "DarkOrange,255,255,140,0,0.5,32.94118,1",
+ "DarkOrchid,255,153,50,204,0.4980392,280.1299,0.6062992",
+ "DarkRed,255,139,0,0,0.272549,0,1",
+ "DarkSalmon,255,233,150,122,0.6960784,15.13514,0.7161291",
+ "DarkSeaGreen,255,143,188,139,0.6411765,115.102,0.2677596",
+ "DarkSlateBlue,255,72,61,139,0.3921569,248.4615,0.39",
+ "DarkSlateGray,255,47,79,79,0.2470588,180,0.2539683",
+ "DarkTurquoise,255,0,206,209,0.4098039,180.8612,1",
+ "DarkViolet,255,148,0,211,0.4137255,282.0853,1",
+ "DeepPink,255,255,20,147,0.5392157,327.5745,1",
+ "DeepSkyBlue,255,0,191,255,0.5,195.0588,1",
+ "DimGray,255,105,105,105,0.4117647,0,0",
+ "DodgerBlue,255,30,144,255,0.5588235,209.6,1",
+ "Firebrick,255,178,34,34,0.4156863,0,0.6792453",
+ "FloralWhite,255,255,250,240,0.9705882,40,1",
+ "ForestGreen,255,34,139,34,0.3392157,120,0.6069364",
+ "Fuchsia,255,255,0,255,0.5,300,1",
+ "Gainsboro,255,220,220,220,0.8627451,0,0",
+ "GhostWhite,255,248,248,255,0.9862745,240,1",
+ "Gold,255,255,215,0,0.5,50.58823,1",
+ "Goldenrod,255,218,165,32,0.4901961,42.90322,0.744",
+ "Gray,255,128,128,128,0.5019608,0,0",
+ "Green,255,0,128,0,0.2509804,120,1",
+ "GreenYellow,255,173,255,47,0.5921569,83.65385,1",
+ "Honeydew,255,240,255,240,0.9705882,120,1",
+ "HotPink,255,255,105,180,0.7058824,330,1",
+ "IndianRed,255,205,92,92,0.5823529,0,0.5305164",
+ "Indigo,255,75,0,130,0.254902,274.6154,1",
+ "Ivory,255,255,255,240,0.9705882,60,1",
+ "Khaki,255,240,230,140,0.7450981,54,0.7692308",
+ "Lavender,255,230,230,250,0.9411765,240,0.6666667",
+ "LavenderBlush,255,255,240,245,0.9705882,340,1",
+ "LawnGreen,255,124,252,0,0.4941176,90.47619,1",
+ "LemonChiffon,255,255,250,205,0.9019608,54,1",
+ "LightBlue,255,173,216,230,0.7901961,194.7368,0.5327103",
+ "LightCoral,255,240,128,128,0.7215686,0,0.7887324",
+ "LightCyan,255,224,255,255,0.9392157,180,1",
+ "LightGoldenrodYellow,255,250,250,210,0.9019608,60,0.8",
+ "LightGreen,255,144,238,144,0.7490196,120,0.734375",
+ "LightGray,255,211,211,211,0.827451,0,0",
+ "LightPink,255,255,182,193,0.8568628,350.9589,1",
+ "LightSalmon,255,255,160,122,0.7392157,17.14286,1",
+ "LightSeaGreen,255,32,178,170,0.4117647,176.7123,0.6952381",
+ "LightSkyBlue,255,135,206,250,0.754902,202.9565,0.92",
+ "LightSlateGray,255,119,136,153,0.5333334,210,0.1428572",
+ "LightSteelBlue,255,176,196,222,0.7803922,213.913,0.4107143",
+ "LightYellow,255,255,255,224,0.9392157,60,1",
+ "Lime,255,0,255,0,0.5,120,1",
+ "LimeGreen,255,50,205,50,0.5,120,0.6078432",
+ "Linen,255,250,240,230,0.9411765,30,0.6666667",
+ "Magenta,255,255,0,255,0.5,300,1",
+ "Maroon,255,128,0,0,0.2509804,0,1",
+ "MediumAquamarine,255,102,205,170,0.6019608,159.6116,0.5073892",
+ "MediumBlue,255,0,0,205,0.4019608,240,1",
+ "MediumOrchid,255,186,85,211,0.5803922,288.0952,0.5887851",
+ "MediumPurple,255,147,112,219,0.6490196,259.6262,0.5977654",
+ "MediumSeaGreen,255,60,179,113,0.4686275,146.7227,0.497908",
+ "MediumSlateBlue,255,123,104,238,0.6705883,248.5075,0.797619",
+ "MediumSpringGreen,255,0,250,154,0.4901961,156.96,1",
+ "MediumTurquoise,255,72,209,204,0.5509804,177.8102,0.5982533",
+ "MediumVioletRed,255,199,21,133,0.4313726,322.2472,0.8090909",
+ "MidnightBlue,255,25,25,112,0.2686275,240,0.6350365",
+ "MintCream,255,245,255,250,0.9803922,150,1",
+ "MistyRose,255,255,228,225,0.9411765,6,1",
+ "Moccasin,255,255,228,181,0.854902,38.10811,1",
+ "NavajoWhite,255,255,222,173,0.8392157,35.85366,1",
+ "Navy,255,0,0,128,0.2509804,240,1",
+ "OldLace,255,253,245,230,0.9470588,39.13044,0.8518519",
+ "Olive,255,128,128,0,0.2509804,60,1",
+ "OliveDrab,255,107,142,35,0.3470588,79.62617,0.6045198",
+ "Orange,255,255,165,0,0.5,38.82353,1",
+ "OrangeRed,255,255,69,0,0.5,16.23529,1",
+ "Orchid,255,218,112,214,0.6470588,302.2642,0.5888889",
+ "PaleGoldenrod,255,238,232,170,0.8,54.70588,0.6666667",
+ "PaleGreen,255,152,251,152,0.7901961,120,0.9252337",
+ "PaleTurquoise,255,175,238,238,0.809804,180,0.6494845",
+ "PaleVioletRed,255,219,112,147,0.6490196,340.3738,0.5977654",
+ "PapayaWhip,255,255,239,213,0.9176471,37.14286,1",
+ "PeachPuff,255,255,218,185,0.8627451,28.28572,1",
+ "Peru,255,205,133,63,0.5254902,29.57747,0.5867769",
+ "Pink,255,255,192,203,0.8764706,349.5238,1",
+ "Plum,255,221,160,221,0.7470589,300,0.4728682",
+ "PowderBlue,255,176,224,230,0.7960784,186.6667,0.5192308",
+ "Purple,255,128,0,128,0.2509804,300,1",
+ "Red,255,255,0,0,0.5,0,1",
+ "RosyBrown,255,188,143,143,0.6490196,0,0.2513967",
+ "RoyalBlue,255,65,105,225,0.5686275,225,0.7272727",
+ "SaddleBrown,255,139,69,19,0.3098039,25,0.7594936",
+ "Salmon,255,250,128,114,0.7137255,6.176474,0.9315069",
+ "SandyBrown,255,244,164,96,0.6666667,27.56757,0.8705882",
+ "SeaGreen,255,46,139,87,0.3627451,146.4516,0.5027027",
+ "SeaShell,255,255,245,238,0.9666667,24.70588,1",
+ "Sienna,255,160,82,45,0.4019608,19.30435,0.5609756",
+ "Silver,255,192,192,192,0.7529412,0,0",
+ "SkyBlue,255,135,206,235,0.7254902,197.4,0.7142857",
+ "SlateBlue,255,106,90,205,0.5784314,248.3478,0.5348837",
+ "SlateGray,255,112,128,144,0.5019608,210,0.1259843",
+ "Snow,255,255,250,250,0.9901961,0,1",
+ "SpringGreen,255,0,255,127,0.5,149.8824,1",
+ "SteelBlue,255,70,130,180,0.4901961,207.2727,0.44",
+ "Tan,255,210,180,140,0.6862745,34.28571,0.4375",
+ "Teal,255,0,128,128,0.2509804,180,1",
+ "Thistle,255,216,191,216,0.7980392,300,0.2427184",
+ "Tomato,255,255,99,71,0.6392157,9.130435,1",
+ "Turquoise,255,64,224,208,0.5647059,174,0.7207207",
+ "Violet,255,238,130,238,0.7215686,300,0.7605634",
+ "Wheat,255,245,222,179,0.8313726,39.09091,0.7674419",
+ "White,255,255,255,255,1,0,0",
+ "WhiteSmoke,255,245,245,245,0.9607843,0,0",
+ "Yellow,255,255,255,0,0.5,60,1",
+ "YellowGreen,255,154,205,50,0.5,79.74194,0.6078432"};
+
+ string [] ar_system_colors = {
+ "ActiveBorder,255,212,208,200,0.8078431,40,0.122449",
+ "ActiveCaption,255,10,36,106,0.227451,223.75,0.8275862",
+ "ActiveCaptionText,255,255,255,255,1,0,0",
+ "AppWorkspace,255,128,128,128,0.5019608,0,0",
+ "Control,255,212,208,200,0.8078431,40,0.122449",
+ "ControlDark,255,128,128,128,0.5019608,0,0",
+ "ControlDarkDark,255,64,64,64,0.2509804,0,0",
+ "ControlLight,255,212,208,200,0.8078431,40,0.122449",
+ "ControlLightLight,255,255,255,255,1,0,0",
+ "ControlText,255,0,0,0,0,0,0",
+ "Desktop,255,58,110,165,0.4372549,210.8411,0.4798206",
+ "GrayText,255,128,128,128,0.5019608,0,0",
+ "Highlight,255,10,36,106,0.227451,223.75,0.8275862",
+ "HighlightText,255,255,255,255,1,0,0",
+ "HotTrack,255,0,0,128,0.2509804,240,1",
+ "InactiveBorder,255,212,208,200,0.8078431,40,0.122449",
+ "InactiveCaption,255,128,128,128,0.5019608,0,0",
+ "InactiveCaptionText,255,212,208,200,0.8078431,40,0.122449",
+ "Info,255,255,255,225,0.9411765,60,1",
+ "InfoText,255,0,0,0,0,0,0",
+ "Menu,255,212,208,200,0.8078431,40,0.122449",
+ "MenuText,255,0,0,0,0,0,0",
+ "ScrollBar,255,212,208,200,0.8078431,40,0.122449",
+ "Window,255,255,255,255,1,0,0",
+ "WindowFrame,255,0,0,0,0,0,0",
+ "WindowText,255,0,0,0,0,0,0"};
+
+ string [] ar_system_color_conversions = {
+ "ActiveBorder,activeborder",
+ "ActiveCaption,activecaption",
+ "ActiveCaptionText,captiontext",
+ "AppWorkspace,appworkspace",
+ "Control,buttonface",
+ "ControlDark,buttonshadow",
+ "ControlDarkDark,threeddarkshadow",
+ "ControlLight,buttonface",
+ "ControlLightLight,buttonhighlight",
+ "ControlText,buttontext",
+ "Desktop,background",
+ "GrayText,graytext",
+ "Highlight,highlight",
+ "HighlightText,highlighttext",
+ "HotTrack,highlight",
+ "InactiveBorder,inactiveborder",
+ "InactiveCaption,inactivecaption",
+ "InactiveCaptionText,inactivecaptiontext",
+ "Info,infobackground",
+ "InfoText,infotext",
+ "Menu,menu",
+ "MenuText,menutext",
+ "ScrollBar,scrollbar",
+ "Window,window",
+ "WindowFrame,windowframe",
+ "WindowText,windowtext"};
+ #endregion
+
+
+ [Test]
+ public void ColorPropertyCount()
+ {
+ Type t = typeof(Color);
+ PropertyInfo [] pi = t.GetProperties(BindingFlags.Static | BindingFlags.Public);
+
+ int i = 0;
+ foreach (PropertyInfo p in pi)
+ {
+ if (p.PropertyType == typeof(Color))
+ {
+ i++;
+ }
+ }
+ Assert.AreEqual(ar_colors.Length, i, "Number of Colors");
+ }
+
+ [Test]
+ public void ColorProperties ()
+ {
+ Type t = typeof(Color);
+ foreach (string s in ar_colors)
+ {
+ string [] col = s.Split(',');
+ MemberInfo [] mi = t.GetMember(col[0]);
+
+ if (mi.Length == 1)
+ {
+ if (mi[0].MemberType == MemberTypes.Property)
+ {
+ PropertyInfo p = (PropertyInfo)mi[0];
+ Color color = (Color)p.GetValue(null, null);
+ Assert.AreEqual(col[0], color.Name, col[0] + " Color Name is wrong");
+ Assert.AreEqual(Convert.ToByte( col[1] ), color.A, col[0] + " Color A is wrong");
+ Assert.AreEqual(Convert.ToByte( col[2] ), color.R, col[0] + " Color R is wrong");
+ Assert.AreEqual(Convert.ToByte( col[3] ), color.G, col[0] + " Color G is wrong");
+ Assert.AreEqual(Convert.ToByte( col[4] ), color.B, col[0] + " Color B is wrong");
+
+ Assert.AreEqual(float.Parse(col[5]), color.GetBrightness(), 0.001F, col[0] + " Color.GetBrightness() is wrong");
+ Assert.AreEqual(float.Parse(col[6]), color.GetHue(), 0.001F, col[0] + " Color.GetHue() is wrong");
+ Assert.AreEqual(float.Parse(col[7]), color.GetSaturation(), 0.001F, col[0] + " Color.GetSaturation() is wrong");
+
+ Assert.AreEqual(true, color.IsNamedColor, col[0] + " IsNamedColor is wrong");
+ Assert.AreEqual(false, color.IsSystemColor, col[0] + " IsSystemColor is wrong");
+ Assert.AreEqual(true, color.IsKnownColor, col[0] + " IsKnownColor is wrong");
+ }
+ else
+ {
+ Assert.Fail(s + " is not property of Color class");
+ }
+ }
+ else
+ {
+ Assert.Fail("Property " + s + " not found in Color class");
+ }
+ }
+ }
+
+ [Test]
+ public void SystemColorPropertyCount()
+ {
+ Type t = typeof(SystemColors);
+ PropertyInfo [] pi = t.GetProperties(BindingFlags.Static | BindingFlags.Public);
+
+ int i = 0;
+ foreach (PropertyInfo p in pi)
+ {
+ if (p.PropertyType == typeof(Color))
+ {
+ i++;
+ }
+ }
+ Assert.AreEqual(ar_system_colors.Length, i, "Number of SystemColors");
+ }
+
+ [Test]
+ public void SystemColorProperties ()
+ {
+ Type t = typeof(SystemColors);
+ foreach (string s in ar_system_colors)
+ {
+ string [] col = s.Split(',');
+ MemberInfo [] mi = t.GetMember(col[0]);
+
+ if (mi.Length == 1)
+ {
+ if (mi[0].MemberType == MemberTypes.Property)
+ {
+ PropertyInfo p = (PropertyInfo)mi[0];
+ Color color = (Color)p.GetValue(null, null);
+ Assert.AreEqual(col[0], color.Name, col[0] + " Color Name is wrong");
+ Assert.AreEqual(Convert.ToByte( col[1] ), color.A, col[0] + " Color A is wrong");
+ Assert.AreEqual(Convert.ToByte( col[2] ), color.R, col[0] + " Color R is wrong");
+ Assert.AreEqual(Convert.ToByte( col[3] ), color.G, col[0] + " Color G is wrong");
+ Assert.AreEqual(Convert.ToByte( col[4] ), color.B, col[0] + " Color B is wrong");
+
+ Assert.AreEqual(float.Parse(col[5]), color.GetBrightness(), 0.001F, col[0] + " Color.GetBrightness() is wrong");
+ Assert.AreEqual(float.Parse(col[6]), color.GetHue(), 0.001F, col[0] + " Color.GetHue() is wrong");
+ Assert.AreEqual(float.Parse(col[7]), color.GetSaturation(), 0.001F, col[0] + " Color.GetSaturation() is wrong");
+
+ Assert.AreEqual(true, color.IsNamedColor, col[0] + " IsNamedColor is wrong");
+ Assert.AreEqual(true, color.IsSystemColor, col[0] + " IsSystemColor is wrong");
+ Assert.AreEqual(true, color.IsKnownColor, col[0] + " IsKnownColor is wrong");
+ }
+ else
+ {
+ Assert.Fail(s + " is not property of SystemColors class");
+ }
+ }
+ else
+ {
+ Assert.Fail("Property " + s + " not found in SystemColors class");
+ }
+ }
+ }
+ [Test]
+ public void SystemColorTranslator()
+ {
+ Type t = typeof(SystemColors);
+
+ foreach (string s in ar_system_color_conversions)
+ {
+ string [] col = s.Split(',');
+ try
+ {
+ PropertyInfo pi = t.GetProperty(col[0]);
+ Color c = (Color)pi.GetValue(null, null);
+
+ Assert.AreEqual(col[1], ColorTranslator.ToHtml(c), col[0] + " is worng");
+ }
+ catch (Exception)
+ {
+ Assert.Fail(col[0] + " failed");
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Enums.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/Enums.cs
new file mode 100644
index 00000000000..4f777d5bf8d
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Enums.cs
@@ -0,0 +1,454 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using NUnit.Framework;
+using DrawingTestHelper;
+using System.Reflection;
+
+namespace Test.Sys.Drawing
+{
+ /// <summary>
+ /// Summary description for Enums.
+ /// </summary>
+
+ [TestFixture]
+ public class Enums
+ {
+ #region Names Arrays
+ string [] ar_known_color = {
+ "ActiveBorder",
+ "ActiveCaption",
+ "ActiveCaptionText",
+ "AppWorkspace",
+ "Control",
+ "ControlDark",
+ "ControlDarkDark",
+ "ControlLight",
+ "ControlLightLight",
+ "ControlText",
+ "Desktop",
+ "GrayText",
+ "Highlight",
+ "HighlightText",
+ "HotTrack",
+ "InactiveBorder",
+ "InactiveCaption",
+ "InactiveCaptionText",
+ "Info",
+ "InfoText",
+ "Menu",
+ "MenuText",
+ "ScrollBar",
+ "Window",
+ "WindowFrame",
+ "WindowText",
+ "Transparent",
+ "AliceBlue",
+ "AntiqueWhite",
+ "Aqua",
+ "Aquamarine",
+ "Azure",
+ "Beige",
+ "Bisque",
+ "Black",
+ "BlanchedAlmond",
+ "Blue",
+ "BlueViolet",
+ "Brown",
+ "BurlyWood",
+ "CadetBlue",
+ "Chartreuse",
+ "Chocolate",
+ "Coral",
+ "CornflowerBlue",
+ "Cornsilk",
+ "Crimson",
+ "Cyan",
+ "DarkBlue",
+ "DarkCyan",
+ "DarkGoldenrod",
+ "DarkGray",
+ "DarkGreen",
+ "DarkKhaki",
+ "DarkMagenta",
+ "DarkOliveGreen",
+ "DarkOrange",
+ "DarkOrchid",
+ "DarkRed",
+ "DarkSalmon",
+ "DarkSeaGreen",
+ "DarkSlateBlue",
+ "DarkSlateGray",
+ "DarkTurquoise",
+ "DarkViolet",
+ "DeepPink",
+ "DeepSkyBlue",
+ "DimGray",
+ "DodgerBlue",
+ "Firebrick",
+ "FloralWhite",
+ "ForestGreen",
+ "Fuchsia",
+ "Gainsboro",
+ "GhostWhite",
+ "Gold",
+ "Goldenrod",
+ "Gray",
+ "Green",
+ "GreenYellow",
+ "Honeydew",
+ "HotPink",
+ "IndianRed",
+ "Indigo",
+ "Ivory",
+ "Khaki",
+ "Lavender",
+ "LavenderBlush",
+ "LawnGreen",
+ "LemonChiffon",
+ "LightBlue",
+ "LightCoral",
+ "LightCyan",
+ "LightGoldenrodYellow",
+ "LightGray",
+ "LightGreen",
+ "LightPink",
+ "LightSalmon",
+ "LightSeaGreen",
+ "LightSkyBlue",
+ "LightSlateGray",
+ "LightSteelBlue",
+ "LightYellow",
+ "Lime",
+ "LimeGreen",
+ "Linen",
+ "Magenta",
+ "Maroon",
+ "MediumAquamarine",
+ "MediumBlue",
+ "MediumOrchid",
+ "MediumPurple",
+ "MediumSeaGreen",
+ "MediumSlateBlue",
+ "MediumSpringGreen",
+ "MediumTurquoise",
+ "MediumVioletRed",
+ "MidnightBlue",
+ "MintCream",
+ "MistyRose",
+ "Moccasin",
+ "NavajoWhite",
+ "Navy",
+ "OldLace",
+ "Olive",
+ "OliveDrab",
+ "Orange",
+ "OrangeRed",
+ "Orchid",
+ "PaleGoldenrod",
+ "PaleGreen",
+ "PaleTurquoise",
+ "PaleVioletRed",
+ "PapayaWhip",
+ "PeachPuff",
+ "Peru",
+ "Pink",
+ "Plum",
+ "PowderBlue",
+ "Purple",
+ "Red",
+ "RosyBrown",
+ "RoyalBlue",
+ "SaddleBrown",
+ "Salmon",
+ "SandyBrown",
+ "SeaGreen",
+ "SeaShell",
+ "Sienna",
+ "Silver",
+ "SkyBlue",
+ "SlateBlue",
+ "SlateGray",
+ "Snow",
+ "SpringGreen",
+ "SteelBlue",
+ "Tan",
+ "Teal",
+ "Thistle",
+ "Tomato",
+ "Turquoise",
+ "Violet",
+ "Wheat",
+ "White",
+ "WhiteSmoke",
+ "Yellow",
+ "YellowGreen"};
+
+ string [] ar_font_style = {
+ "Regular",
+ "Bold",
+ "Italic",
+ "Underline",
+ "Strikeout"};
+
+
+ string [] ar_content_alignment = {
+ "TopLeft",
+ "TopCenter",
+ "TopRight",
+ "MiddleLeft",
+ "MiddleCenter",
+ "MiddleRight",
+ "BottomLeft",
+ "BottomCenter",
+ "BottomRight"};
+
+ string [] ar_string_alignment = {
+ "Near",
+ "Center",
+ "Far"};
+
+
+ string [] ar_string_digit_substitute = {
+ "User",
+ "None",
+ "National",
+ "Traditional"};
+
+ string [] ar_string_unit = {
+ "World",
+ "Display",
+ "Pixel",
+ "Point",
+ "Inch",
+ "Document",
+ "Millimeter",
+ "Em"};
+
+ string [] ar_string_trimming = {
+ "None",
+ "Character",
+ "Word",
+ "EllipsisCharacter",
+ "EllipsisWord",
+ "EllipsisPath"};
+
+ #endregion
+
+ [SetUp]
+ public void SetUp ()
+ {
+ }
+
+ #region KnownColor
+ [Test]
+ public void KnownColors()
+ {
+ Type t = typeof(KnownColor);
+
+ foreach (string s in ar_known_color)
+ {
+ try
+ {
+ FieldInfo fi = t.GetField(s);
+ Assert.AreEqual(s, fi.Name);
+ }
+ catch (Exception)
+ {
+ Assert.Fail("Color " + s + " is not found");
+ }
+ }
+ }
+
+ [Test]
+ public void KnownColorsCount()
+ {
+ Type t = typeof(KnownColor);
+
+ MemberInfo [] mi = t.GetFields(BindingFlags.Static | BindingFlags.Public);
+ Assert.AreEqual(ar_known_color.Length, mi.Length);
+ }
+ #endregion
+
+ #region FontStyle
+ [Test]
+ public void FontStyles()
+ {
+ Type t = typeof(FontStyle);
+
+ foreach (string s in ar_font_style)
+ {
+ try
+ {
+ FieldInfo fi = t.GetField(s);
+ Assert.AreEqual(s, fi.Name);
+ }
+ catch (Exception)
+ {
+ Assert.Fail("Font Style " + s + " is not found");
+ }
+ }
+ }
+
+ [Test]
+ public void FontStylesCount()
+ {
+ Type t = typeof(FontStyle);
+
+ MemberInfo [] mi = t.GetFields(BindingFlags.Static | BindingFlags.Public);
+ Assert.AreEqual(ar_font_style.Length, mi.Length);
+ }
+ #endregion
+
+ #region ContentAligment
+ [Test]
+ public void ContentAlignments()
+ {
+ Type t = typeof(ContentAlignment);
+
+ foreach (string s in ar_content_alignment)
+ {
+ try
+ {
+ FieldInfo fi = t.GetField(s);
+ Assert.AreEqual(s, fi.Name);
+ }
+ catch (Exception)
+ {
+ Assert.Fail("ContentAligment " + s + " is not found");
+ }
+ }
+ }
+
+ [Test]
+ public void ContentAlignmentsCount()
+ {
+ Type t = typeof(ContentAlignment);
+
+ MemberInfo [] mi = t.GetFields(BindingFlags.Static | BindingFlags.Public);
+ Assert.AreEqual(ar_content_alignment.Length, mi.Length);
+ }
+ #endregion
+
+ #region StringAligment
+ [Test]
+ public void StringAlignments()
+ {
+ Type t = typeof(StringAlignment);
+
+ foreach (string s in ar_string_alignment)
+ {
+ try
+ {
+ FieldInfo fi = t.GetField(s);
+ Assert.AreEqual(s, fi.Name);
+ }
+ catch (Exception)
+ {
+ Assert.Fail("Font Style " + s + " is not found");
+ }
+ }
+ }
+
+ [Test]
+ public void StringAlignmentsCount()
+ {
+ Type t = typeof(StringAlignment);
+
+ MemberInfo [] mi = t.GetFields(BindingFlags.Static | BindingFlags.Public);
+ Assert.AreEqual(ar_string_alignment.Length, mi.Length);
+ }
+ #endregion
+
+ #region StringDigitSubstitute
+ [Test]
+ public void StringDigitSubstitutes()
+ {
+ Type t = typeof(StringDigitSubstitute);
+
+ foreach (string s in ar_string_digit_substitute)
+ {
+ try
+ {
+ FieldInfo fi = t.GetField(s);
+ Assert.AreEqual(s, fi.Name);
+ }
+ catch (Exception)
+ {
+ Assert.Fail("Font Style " + s + " is not found");
+ }
+ }
+ }
+
+ [Test]
+ public void StringDigitSubstitutesCount()
+ {
+ Type t = typeof(StringDigitSubstitute);
+
+ MemberInfo [] mi = t.GetFields(BindingFlags.Static | BindingFlags.Public);
+ Assert.AreEqual(ar_string_digit_substitute.Length, mi.Length);
+ }
+ #endregion
+
+ #region StringUnit
+ [Test]
+ public void StringUnits()
+ {
+ Type t = typeof(StringUnit);
+
+ foreach (string s in ar_string_unit)
+ {
+ try
+ {
+ FieldInfo fi = t.GetField(s);
+ Assert.AreEqual(s, fi.Name);
+ }
+ catch (Exception)
+ {
+ Assert.Fail("Font Style " + s + " is not found");
+ }
+ }
+ }
+
+ [Test]
+ public void StringUnitsCount()
+ {
+ Type t = typeof(StringUnit);
+
+ MemberInfo [] mi = t.GetFields(BindingFlags.Static | BindingFlags.Public);
+ Assert.AreEqual(ar_string_unit.Length, mi.Length);
+ }
+ #endregion
+
+ #region StringTrimming
+ [Test]
+ public void StringTrimmings()
+ {
+ Type t = typeof(StringTrimming);
+
+ foreach (string s in ar_string_trimming)
+ {
+ try
+ {
+ FieldInfo fi = t.GetField(s);
+ Assert.AreEqual(s, fi.Name);
+ }
+ catch (Exception)
+ {
+ Assert.Fail("Font Style " + s + " is not found");
+ }
+ }
+ }
+
+ [Test]
+ public void StringTrimmingsCount()
+ {
+ Type t = typeof(StringTrimming);
+
+ MemberInfo [] mi = t.GetFields(BindingFlags.Static | BindingFlags.Public);
+ Assert.AreEqual(ar_string_trimming.Length, mi.Length);
+ }
+ #endregion
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Graphics.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/Graphics.cs
new file mode 100644
index 00000000000..10c4a206e7c
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Graphics.cs
@@ -0,0 +1,2740 @@
+//
+// Test.System.Drawing.Graphics.cs
+//
+// Author:
+// Konstantin Triger <kostat@mainsoft.com>
+//
+
+//
+// Copyright (C) 2005 Mainsoft, Corp (http://www.mainsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Diagnostics;
+using NUnit.Framework;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+using System.Drawing.Imaging;
+using DrawingTestHelper;
+using System.IO;
+
+namespace Test.Sys.Drawing.GraphicsFixtures {
+ #region GraphicsFixtureProps
+
+ [TestFixture]
+ public class GraphicsFixtureProps {
+
+ protected DrawingTest t;
+ const int TOLERANCE = 3; //in %
+
+ [SetUp]
+ public void SetUp() {
+ t = DrawingTest.Create(512, 512);
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Newly created region area is not the same.
+#endif
+ public void ClipTest_1() {
+ Region r = new Region();
+ Assert.IsTrue(r.Equals(t.Graphics.Clip, t.Graphics));
+ }
+
+ [Test]
+ public void ClipTest_2() {
+ Region r = new Region(new Rectangle(10, 10, 60, 60));
+ t.Graphics.Clip = r;
+ Assert.IsTrue(r.Equals(t.Graphics.Clip, t.Graphics));
+
+ Pen redPen = new Pen(Color.Red, 3);
+ Pen greenPen = new Pen(Color.Green, 3);
+ // Create points that define curve.
+ Point point1 = new Point( 50, 50);
+ Point point2 = new Point(100, 25);
+ Point point3 = new Point(200, 5);
+ Point point4 = new Point(250, 50);
+ Point point5 = new Point(300, 100);
+ Point point6 = new Point(350, 200);
+ Point point7 = new Point(250, 250);
+ Point[] curvePoints = {
+ point1,
+ point2,
+ point3,
+ point4,
+ point5,
+ point6,
+ point7
+ };
+ // Draw lines between original points to screen.
+ t.Graphics.DrawLines(redPen, curvePoints);
+ t.Show ();
+ Assert.IsTrue(t.PDCompare(TOLERANCE));
+ }
+
+ [Test]
+ public void ClipTest_3() {
+ t.Graphics.TranslateTransform(3, 3);
+ t.Graphics.SetClip(new Rectangle(23, 24, 30, 40));
+
+ RectangleF cb = t.Graphics.VisibleClipBounds;
+ DrawingTest.AssertAlmostEqual(23, cb.X);
+ DrawingTest.AssertAlmostEqual(24, cb.Y);
+ DrawingTest.AssertAlmostEqual(30, cb.Width);
+ DrawingTest.AssertAlmostEqual(40, cb.Height);
+
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+
+ t.Graphics.RotateTransform(128);
+
+ t.Graphics.TranslateTransform(14, 14);
+ t.Graphics.ExcludeClip(new Rectangle(0, 0, 4, 60));
+
+
+ t.Graphics.RotateTransform(128);
+
+ t.Graphics.PageUnit = GraphicsUnit.Pixel;
+
+ t.Graphics.TranslateClip(5.2f, 3.1f);
+
+ t.Graphics.ResetTransform();
+ t.Graphics.PageUnit = GraphicsUnit.Pixel;
+
+ cb = t.Graphics.VisibleClipBounds;
+ DrawingTest.AssertAlmostEqual(28, cb.X);
+ DrawingTest.AssertAlmostEqual(22, cb.Y);
+ DrawingTest.AssertAlmostEqual(30, cb.Width);
+ DrawingTest.AssertAlmostEqual(40, cb.Height);
+
+ t.Graphics.ScaleTransform(5, 7);
+ t.Graphics.IntersectClip(new Rectangle(7, 4, 20, 20));
+
+ cb = t.Graphics.VisibleClipBounds;
+ DrawingTest.AssertAlmostEqual(7, cb.X);
+ DrawingTest.AssertAlmostEqual(4f, cb.Y);
+ DrawingTest.AssertAlmostEqual(4.6f, cb.Width);
+ DrawingTest.AssertAlmostEqual(4.85714245f, cb.Height);
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Newly created region area is not the same.
+#endif
+ public void ClipBoundsTest() {
+ Region r = new Region();
+ Assert.IsTrue(t.Graphics.ClipBounds.Equals(r.GetBounds(t.Graphics)));
+
+ RectangleF rf = new RectangleF(10, 10, 60, 60);
+ r = new Region(rf);
+ t.Graphics.Clip = r;
+ Assert.IsTrue(rf.Equals(t.Graphics.ClipBounds));
+ }
+
+ [Test]
+ public void CompositingModeTest() {
+ //TODO: seems to draw equal images
+ Assert.AreEqual(CompositingMode.SourceOver, t.Graphics.CompositingMode);
+
+ Bitmap b = new Bitmap(100, 100);
+ Graphics g = Graphics.FromImage(b);
+
+ Color c = Color.FromArgb(100, Color.Red);
+
+ Brush redBrush = new SolidBrush(c);
+ g.FillEllipse(redBrush, 5, 6, 100, 200);
+ //t.Graphics.FillEllipse(redBrush, 5, 6, 100, 200);
+ t.Graphics.DrawImage(b, 10, 10);
+
+ t.Show ();
+
+ t.Graphics.CompositingMode = CompositingMode.SourceCopy;
+
+ t.Graphics.DrawImage(b, 300, 300);
+
+ t.Show ();
+ Assert.IsTrue(t.PDCompare(TOLERANCE));
+ }
+
+ [Test] //TBD
+ public void CompositingQualityTest() {
+ }
+
+ [Test]
+ public void DpiXTest() {
+ Assert.IsTrue(t.Graphics.DpiX == 96f);
+ }
+
+ [Test]
+ public void DpiYTest() {
+ Assert.IsTrue(t.Graphics.DpiY == 96f);
+ }
+
+ [Test] //TBD
+ public void InterpolationModeTest() {
+ Assert.AreEqual(InterpolationMode.Bilinear, t.Graphics.InterpolationMode);
+ }
+
+ [Test]
+ public void IsClipEmtpyTest() {
+ Assert.IsFalse(t.Graphics.IsClipEmpty);
+
+ try {
+ t.Graphics.Clip = null;
+ Assert.Fail("The ArgumentNullException was not thrown");
+ }
+ catch(Exception e) {
+ Assert.AreEqual(e.GetType(), typeof(ArgumentNullException));
+ }
+
+ Region r = new Region(new Rectangle(10, 10, 0, 0));
+ t.Graphics.Clip = r;
+
+ Assert.IsTrue( t.Graphics.IsClipEmpty);
+ }
+
+ [Test]
+ public void IsVisibleClipEmtpyTest() {
+ Assert.IsFalse(t.Graphics.IsVisibleClipEmpty, "default t.Graphics.IsVisibleClipEmpty");
+
+ Region r = new Region(new Rectangle(512, 512, 100, 100));
+ t.Graphics.Clip = r;
+ Assert.IsFalse(t.Graphics.IsClipEmpty);
+ Assert.IsTrue(t.Graphics.IsVisibleClipEmpty);
+ }
+
+ [Test]
+ public void PageScaleTest() {
+ Assert.AreEqual(1f, t.Graphics.PageScale);
+ }
+
+ [Test]
+ public void PageUnitTest() {
+ Assert.AreEqual(GraphicsUnit.Display, t.Graphics.PageUnit);
+ }
+
+ [Test]
+ public void PixelOffsetModeTest() {
+ Assert.AreEqual(PixelOffsetMode.Default, t.Graphics.PixelOffsetMode);
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: RenderingOrigin is not implemented
+#endif
+ public void RenderingOriginTest() {
+ Assert.AreEqual(new Point(0,0), t.Graphics.RenderingOrigin);
+ }
+
+ [Test]
+ public void SmoothingModeTest() {
+ Assert.AreEqual(SmoothingMode.None, t.Graphics.SmoothingMode);
+ }
+
+ [Test]
+ public void TextContrastTest() {
+ Assert.AreEqual(4, t.Graphics.TextContrast);
+ }
+
+ [Test]
+ public void TextRenderingHintTest() {
+ Assert.AreEqual(TextRenderingHint.SystemDefault, t.Graphics.TextRenderingHint);
+ }
+
+ [Test]
+ public void TransformTest() {
+ Assert.AreEqual(new Matrix(), t.Graphics.Transform);
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Graphics.ClipBounds retun null if no clip region was set.
+#endif
+ public void VisibleClipBoundsTest() {
+ Assert.AreEqual(new RectangleF(0, 0, 512, 512), t.Graphics.VisibleClipBounds);
+ }
+ }
+
+ #endregion
+
+ #region DrawImage
+ [TestFixture]
+ public class DrawImage {
+ protected DrawingTest t;
+ protected int TOLERANCE = 10; //in %;
+ protected Hashtable st = new Hashtable();
+
+ Rectangle src = new Rectangle(0, 0, 50, 50);
+ RectangleF srcF = new Rectangle(0, 0, 50, 50);
+ Rectangle dst = new Rectangle(170, 170, 100, 100);
+ RectangleF dstF = new Rectangle(270, 270, 100, 100);
+
+ Image bmp;
+ Image bmp2;
+
+ [SetUp]
+ public virtual void SetUp() {
+ SetUp("DrawImage");
+ DrawingTest.ShowForms = false;
+ try {
+ bmp = Bitmap.FromFile(@"..\..\bitmap50.png");
+ bmp2 = Bitmap.FromFile(@"..\..\bitmap25.png");
+ }
+ catch(Exception e) {
+ Console.WriteLine(e.Message);
+ }
+ }
+ public virtual void SetUp(string ownerClass) {
+ t = DrawingTest.Create(512, 512, ownerClass);
+ t.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
+
+ // hashtable of differents tolerance values for specified tests.
+ }
+ [TearDown]
+ public void TearDown() {
+ }
+
+ [Test]
+ public void DrawImage1() {
+ t.Graphics.DrawImage(bmp, new Point[]{new Point(170,10), new Point(250,0), new Point(100,100)}, src, GraphicsUnit.Pixel );
+ t.Graphics.DrawImage(bmp, new PointF[]{new PointF(70,10), new PointF(150,0), new PointF(10,100)}, srcF, GraphicsUnit.Pixel );
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImage2() {
+ t.Graphics.DrawImage(bmp, dst, src, GraphicsUnit.Pixel);
+ t.Graphics.DrawImage(bmp, dstF, srcF, GraphicsUnit.Pixel);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImage3() {
+ t.Graphics.DrawImage(bmp, 10.0F, 10.0F, srcF, GraphicsUnit.Pixel);
+ t.Graphics.DrawImage(bmp, 70.0F, 150.0F, 250.0F, 150.0F);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImage4() {
+ t.Graphics.DrawImage(bmp, dst);
+ t.Graphics.DrawImage(bmp, dstF);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImage5() {
+ t.Graphics.SetClip( new Rectangle(70, 0, 20, 200));
+ t.Graphics.DrawImage(bmp, new Point[]{new Point(50,50), new Point(250,30), new Point(100,150)}, src, GraphicsUnit.Pixel );
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImage6() {
+ t.Graphics.ScaleTransform(2, 2);
+ t.Graphics.SetClip( new Rectangle(70, 0, 20, 200));
+ t.Graphics.DrawImage(bmp, new Point[]{new Point(50,50), new Point(250,30), new Point(100,150)}, src, GraphicsUnit.Pixel );
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImage7() {
+ t.Graphics.DrawImage(bmp, 170, 70, src, GraphicsUnit.Pixel);
+ t.Graphics.DrawImage(bmp, 70, 350, 350, 150);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImage8() {
+ t.Graphics.DrawImage(bmp, new Point[]{new Point(170,10), new Point(250,10), new Point(100,100)} );
+ t.Graphics.DrawImage(bmp, new PointF[]{new PointF(170,100), new PointF(250,100), new PointF(100,190)} );
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImage9() {
+ t.Graphics.DrawImage(bmp, 0, 0);
+ t.Graphics.DrawImage(bmp, 200, 200);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImagePageUnit() {
+ t.Graphics.PageUnit = GraphicsUnit.Document;
+ Point [] p = new Point[]{
+ new Point(100, 100),
+ new Point(200, 100),
+ new Point(50, 200)
+ };
+
+ t.Graphics.DrawImage(bmp2, p, new Rectangle(100, 100, 100, 100), GraphicsUnit.Pixel);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImagePageUnit_2() {
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+ t.Graphics.ScaleTransform(0.3f, 0.3f);
+ Point [] p = new Point[]{
+ new Point(100, 100),
+ new Point(200, 100),
+ new Point(50, 200)
+ };
+
+ t.Graphics.DrawImage(bmp2, p, new Rectangle(100, 100, 100, 100), GraphicsUnit.Pixel);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImagePageUnit_3() {
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+ t.Graphics.ScaleTransform(0.3f, 0.3f);
+ t.Graphics.DrawImage(bmp2, new Rectangle(100, 100, 100, 100));
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImagePageUnit_4() {
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+ t.Graphics.ScaleTransform(0.5f, 0.5f);
+ t.Graphics.DrawImage(bmp, 50, 50);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImagePageUnitClip() {
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+ t.Graphics.ScaleTransform(0.3f, 0.3f);
+ Point [] p = new Point[]{
+ new Point(100, 100),
+ new Point(200, 100),
+ new Point(50, 200)
+ };
+
+ t.Graphics.SetClip( new Rectangle(120, 120, 50, 100) );
+ t.Graphics.DrawImage(bmp2, p, new Rectangle(100, 100, 100, 100), GraphicsUnit.Pixel);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImageWithResolution() {
+ t.Graphics.DrawImage(bmp2, 0, 0);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImageInContainer1() {
+ t.Graphics.BeginContainer(new Rectangle(10, 10, 50, 50), new Rectangle(70, 70, 100, 100), GraphicsUnit.Pixel);
+ t.Graphics.DrawImage(bmp, 0, 0);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImageInContainer2() {
+ t.Graphics.BeginContainer(new Rectangle(10, 10, 50, 50), new Rectangle(70, 70, 100, 100), GraphicsUnit.Pixel);
+ t.Graphics.DrawImage(bmp2, 0, 0);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImageInContainer3() {
+ t.Graphics.BeginContainer(new Rectangle(10, 10, 50, 50), new Rectangle(70, 70, 100, 100), GraphicsUnit.Pixel);
+ t.Graphics.SetClip( new Rectangle(0, 0, 15, 15) );
+ t.Graphics.ScaleTransform(0.5f, 0.5f);
+ t.Graphics.DrawImage(bmp2, 0, 0);
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ [Test]
+ public void DrawImageInContainer4() {
+ Point [] p = new Point[]{
+ new Point(100, 100),
+ new Point(200, 100),
+ new Point(50, 200)
+ };
+
+ t.Graphics.SetClip( new Rectangle(70, 70, 70, 70) );
+ GraphicsContainer c = t.Graphics.BeginContainer( new Rectangle(20, 20, 10, 10), new Rectangle(77, 77, 7, 7), GraphicsUnit.Pixel);
+ t.Graphics.DrawImage(bmp2, p, new Rectangle(100, 100, 100, 100), GraphicsUnit.Pixel);
+ t.Graphics.EndContainer( c );
+ t.Show();
+ Assert.IsTrue(t.Compare());
+ }
+ }
+ #endregion
+
+ #region GraphicsFixtureFillModes
+ [TestFixture]
+ public class GraphicsFixtureFillModes {
+ protected DrawingTest t;
+ protected int TOLERANCE = 3; //in %;
+
+ [SetUp]
+ public virtual void SetUp() {
+ SetUp("GraphicsFixtureFillModes");
+ }
+ public virtual void SetUp(string ownerClass) {
+ t = DrawingTest.Create(512, 512, ownerClass);
+ }
+ [TearDown]
+ public void TearDown() {
+ }
+
+ [Test]
+ public void FillModeAlternate() {
+ GraphicsPath p = new GraphicsPath();
+ Assert.AreEqual(FillMode.Alternate, p.FillMode);
+ }
+ [Test]
+ public void FillModeAlternate_1() {
+ Point [] p = new Point[] {
+ new Point(50, 100),
+ new Point(70, 10),
+ new Point(90, 100),
+ new Point(140, 10),
+ new Point(150, 100),
+ new Point(170, 10),
+ new Point(50, 100)
+ };
+
+ GraphicsPath path = new GraphicsPath();
+ path.AddLines( p );
+ path.FillMode = FillMode.Alternate;
+ t.Graphics.FillPath( Brushes.Blue, path );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void FillModeAlternate_2() {
+
+ Rectangle r1 = new Rectangle(100, 100, 100, 100);
+ Rectangle r2 = new Rectangle(125, 125, 50, 50);
+ GraphicsPath path = new GraphicsPath();
+ path.AddRectangle( r1 );
+ path.AddRectangle( r2 );
+ path.FillMode = FillMode.Alternate;
+ t.Graphics.FillPath( Brushes.Blue, path );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void FillModeAlternate_3() {
+ Point [] p = new Point[] {
+ new Point(50, 100),
+ new Point(150, 50),
+ new Point(250, 100),
+ new Point(50, 75),
+ new Point(250, 50),
+ new Point(50, 100)
+ };
+
+ GraphicsPath path = new GraphicsPath();
+ path.AddLines( p );
+ path.FillMode = FillMode.Alternate;
+ t.Graphics.FillPath( Brushes.Blue, path );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void FillModeWinding_1() {
+ Point [] p = new Point[] {
+ new Point(50, 100),
+ new Point(70, 10),
+ new Point(90, 100),
+ new Point(140, 10),
+ new Point(150, 100),
+ new Point(170, 10),
+ new Point(50, 100)
+ };
+
+ GraphicsPath path = new GraphicsPath();
+ path.AddLines( p );
+ path.FillMode = FillMode.Winding;
+ t.Graphics.FillPath( Brushes.Blue, path );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void FillModeWinding_2() {
+
+ Rectangle r1 = new Rectangle(100, 100, 100, 100);
+ Rectangle r2 = new Rectangle(125, 125, 50, 50);
+ GraphicsPath path = new GraphicsPath();
+ path.AddRectangle( r1 );
+ path.AddRectangle( r2 );
+ path.FillMode = FillMode.Winding;
+ t.Graphics.FillPath( Brushes.Blue, path );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void FillModeWinding_3() {
+ Point [] p = new Point[] {
+ new Point(50, 100),
+ new Point(150, 50),
+ new Point(250, 100),
+ new Point(50, 75),
+ new Point(250, 50),
+ new Point(50, 100)
+ };
+
+ GraphicsPath path = new GraphicsPath();
+ path.AddLines( p );
+ path.FillMode = FillMode.Winding;
+ t.Graphics.FillPath( Brushes.Blue, path );
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ }
+ #endregion
+
+
+ #region GraphicsFixture
+ /// <summary>
+ /// Summary description for Graphics.
+ /// </summary>
+ [TestFixture]
+ public class GraphicsFixture {
+ protected DrawingTest t;
+ protected int TOLERANCE = 3; //in %;
+ protected Hashtable st = new Hashtable();
+
+ [SetUp]
+ public virtual void SetUp() {
+ SetUp("GraphicsFixture");
+ }
+ public virtual void SetUp(string ownerClass) {
+ t = DrawingTest.Create(512, 512, ownerClass);
+
+ // hashtable of differents tolerance values for specified tests. (for fft comparer)
+ st["DrawArcTest:6"] = TOLERANCE * 2.5f;
+ st["DrawCurveTestF:4"] = TOLERANCE * 2f;
+ st["DrawPolygonPoint:2"] = TOLERANCE * 2f;
+ st["DrawPolygonPointF:2"] = TOLERANCE * 2f;
+ st["DrawStringFloatFormat:2"] = TOLERANCE * 2f; // in .net the font is shmoothed
+ st["DrawStringFloatFormat:4"] = TOLERANCE * 2.5f; // in .net the font is shmoothed
+ st["DrawStringFloatFormat:6"] = TOLERANCE * 2.5f; // in .net the font is shmoothed
+ st["RotateTransformAngleMatrixOrder1:2"] = TOLERANCE * 2f; // Line width problem
+ st["ScaleTransformFloatMatrixOrder:2"] = TOLERANCE * 2f; // Line width problem
+ st["TranslateTransformAngleMatrixOrder:2"] = TOLERANCE * 2f; // Line width problem
+ t.SpecialTolerance = st;
+ }
+
+ [TearDown]
+ public void TearDown() {
+ }
+
+ [Test]
+ [Category ("hehe")]
+ public void BeginContainerTest() {
+ // Define transformation for container.
+ RectangleF srcRect = new RectangleF(0.0F, 0.0F, 200.0F, 200.0F);
+ RectangleF destRect = new RectangleF(100.0F, 100.0F, 150.0F, 150.0F);
+ // Begin graphics container.
+ GraphicsContainer containerState = t.Graphics.BeginContainer(
+ destRect, srcRect,
+ GraphicsUnit.Pixel);
+ // Fill red rectangle in container.
+ t.Graphics.FillRectangle(new SolidBrush(Color.Red), 0.0F, 0.0F, 200.0F, 200.0F);
+ t.Show ();
+ // End graphics container.
+ t.Graphics.EndContainer(containerState);
+ // Fill untransformed rectangle with green.
+ t.Graphics.FillRectangle(new SolidBrush(Color.Green), 0.0F, 0.0F, 200.0F, 200.0F);
+ t.Show ();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ [Category ("hehe")]
+ public void BeginContainerTest_2() {
+ t.Graphics.DrawRectangle( Pens.Black, new Rectangle(70, 70, 50, 100) );
+ t.Graphics.DrawRectangle( Pens.Black, new Rectangle(50, 100, 150, 50) );
+ t.Graphics.DrawRectangle( Pens.Black, new Rectangle(80, 120, 10, 10) );
+
+ t.Graphics.SetClip( new Rectangle(70, 70, 50, 100) );
+ t.Graphics.Clear( Color.Blue );
+
+ GraphicsContainer c1 = t.Graphics.BeginContainer();
+ t.Graphics.SetClip( new Rectangle(50, 100, 150, 50) );
+ t.Graphics.Clear( Color.Green );
+
+ GraphicsContainer c2 = t.Graphics.BeginContainer();
+ t.Graphics.SetClip( new Rectangle(80, 120, 10, 10) );
+ t.Graphics.Clear( Color.Red );
+
+ t.Graphics.EndContainer( c2 );
+ t.Graphics.FillRectangle( Brushes.Yellow, new Rectangle(100, 120, 10, 10) );
+ t.Graphics.FillRectangle( Brushes.Yellow, new Rectangle(150, 120, 10, 10) );
+
+ t.Graphics.EndContainer( c1 );
+ t.Graphics.FillRectangle( Brushes.Yellow, new Rectangle(100, 80, 10, 10) );
+ t.Graphics.FillRectangle( Brushes.Yellow, new Rectangle(150, 80, 10, 10) );
+
+ t.Show ();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void ClearTest() {
+ // Clear screen with teal background.
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ t.Graphics.Clear(Color.Teal);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawArcTest() {
+ // Create pen.
+ Pen blackPen= new Pen(Color.Black, 1);
+ // Create coordinates of rectangle to bound ellipse.
+ float x = 10.0F;
+ float y = 10.0F;
+ float width = 400.0F;
+ float height = 100.0F;
+ // Create start and sweep angles on ellipse.
+ float startAngle = 370.0F;
+ float sweepAngle = 70.0F;
+ // Draw arc to screen.
+ t.Graphics.DrawArc(blackPen, (int)x, (int)y, (int)width, (int)height, (int)startAngle, (int)sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+ startAngle = 10.0F;
+ sweepAngle = 120.0F;
+ t.Graphics.DrawArc(blackPen, new Rectangle((int)x, (int)y, (int)width, (int)height), startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+ startAngle = 10.0F;
+ sweepAngle = 190.0F;
+ t.Graphics.DrawArc(blackPen, x, y, width, height, startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+ startAngle = 10.0F;
+ sweepAngle = 300.0F;
+ t.Graphics.DrawArc(blackPen, new RectangleF(x, y, width, height), startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+ startAngle = -179.9F;
+ sweepAngle = -359.9F;
+ t.Graphics.DrawArc(blackPen, new RectangleF(x, y, width, height), startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+ startAngle = -10.0F;
+ sweepAngle = -300.0F;
+ t.Graphics.DrawArc(blackPen, new RectangleF(x, y, width, height), startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawBezierTest() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create coordinates of points for curve.
+ float startX = 100.0F;
+ float startY = 100.0F;
+ float controlX1 = 200.0F;
+ float controlY1 = 10.0F;
+ float controlX2 = 350.0F;
+ float controlY2 = 50.0F;
+ float endX = 500.0F;
+ float endY = 100.0F;
+ // Draw arc to screen.
+ t.Graphics.DrawBezier(blackPen, startX, startY,
+ controlX1, controlY1,
+ controlX2, controlY2,
+ endX, endY);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+ t.Graphics.DrawBezier(blackPen, new PointF( startX, startY),
+ new PointF(controlX1, controlY1),
+ new PointF(controlX2, controlY2),
+ new PointF(endX, endY));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+ t.Graphics.DrawBezier(blackPen, new Point((int)startX, (int)startY),
+ new Point((int)controlX1, (int)controlY1),
+ new Point((int)controlX2, (int)controlY2),
+ new Point((int)endX, (int)endY));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawBeziersTest() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create points for curve.
+ Point start = new Point(100, 100);
+ Point control1 = new Point(200, 10);
+ Point control2 = new Point(350, 50);
+ Point end1 = new Point(500, 100);
+ Point control3 = new Point(600, 150);
+ Point control4 = new Point(650, 250);
+ Point end2 = new Point(500, 300);
+ Point[] bezierPoints = {
+ start, control1, control2, end1,
+ control3, control4, end2
+ };
+ // Draw arc to screen.
+ t.Graphics.DrawBeziers(blackPen, bezierPoints);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ PointF startF = new PointF(100.0F, 100.0F);
+ PointF control1F = new PointF(200.0F, 10.0F);
+ PointF control2F = new PointF(350.0F, 50.0F);
+ PointF end1F = new PointF(500.0F, 100.0F);
+ PointF control3F = new PointF(600.0F, 150.0F);
+ PointF control4F = new PointF(650.0F, 250.0F);
+ PointF end2F = new PointF(500.0F, 300.0F);
+ PointF[] bezierPointsF = {
+ startF, control1F, control2F, end1F,
+ control3F, control4F, end2F
+ };
+ // Draw arc to screen.
+ t.Graphics.DrawBeziers(blackPen, bezierPointsF);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawClosedCurveTest() {
+ // Create pens.
+ Pen redPen = new Pen(Color.Red, 3);
+ Pen greenPen = new Pen(Color.Green, 3);
+ // Create points that define curve.
+ PointF point1 = new PointF( 50.0F, 50.0F);
+ PointF point2 = new PointF(100.0F, 25.0F);
+ PointF point3 = new PointF(200.0F, 5.0F);
+ PointF point4 = new PointF(250.0F, 50.0F);
+ PointF point5 = new PointF(300.0F, 100.0F);
+ PointF point6 = new PointF(350.0F, 200.0F);
+ PointF point7 = new PointF(250.0F, 250.0F);
+ PointF[] curvePoints = {
+ point1,
+ point2,
+ point3,
+ point4,
+ point5,
+ point6,
+ point7
+ };
+ // Draw lines between original points to screen.
+ t.Graphics.DrawLines(redPen, curvePoints);
+ // Create tension and fill mode.
+ float tension = 0.7F;
+ FillMode aFillMode = FillMode.Alternate;
+ // Draw closed curve to screen.
+ t.Graphics.DrawClosedCurve(greenPen, curvePoints, tension, aFillMode);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ aFillMode = FillMode.Winding;
+ // Draw closed curve to screen.
+ t.Graphics.DrawClosedCurve(greenPen, curvePoints, tension, aFillMode);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawCurveTest() {
+ // Create pens.
+ Pen redPen = new Pen(Color.Red, 3);
+ Pen greenPen = new Pen(Color.Green, 3);
+ // Create points that define curve.
+ Point point1 = new Point( 50, 50);
+ Point point2 = new Point(100, 25);
+ Point point3 = new Point(200, 5);
+ Point point4 = new Point(250, 50);
+ Point point5 = new Point(300, 100);
+ Point point6 = new Point(350, 200);
+ Point point7 = new Point(250, 250);
+ Point[] curvePoints = {
+ point1,
+ point2,
+ point3,
+ point4,
+ point5,
+ point6,
+ point7
+ };
+ // Draw lines between original points to screen.
+ t.Graphics.DrawLines(redPen, curvePoints);
+ // Create offset, number of segments, and tension.
+ int offset = 2;
+ int numSegments = 4;
+ float tension = 0.7F;
+ // Draw curve to screen.
+ t.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments, tension);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawCurve(greenPen, curvePoints, tension);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawCurve(greenPen, curvePoints);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawCurveTestF() {
+ // Create pens.
+ Pen redPen = new Pen(Color.Red, 3);
+ Pen greenPen = new Pen(Color.Green, 3);
+ // Create points that define curve.
+ PointF point1 = new PointF( 50.0F, 50.0F);
+ PointF point2 = new PointF(100.0F, 25.0F);
+ PointF point3 = new PointF(200.0F, 5.0F);
+ PointF point4 = new PointF(250.0F, 50.0F);
+ PointF point5 = new PointF(300.0F, 100.0F);
+ PointF point6 = new PointF(350.0F, 200.0F);
+ PointF point7 = new PointF(250.0F, 250.0F);
+ PointF[] curvePoints = {
+ point1,
+ point2,
+ point3,
+ point4,
+ point5,
+ point6,
+ point7
+ };
+ // Draw lines between original points to screen.
+ t.Graphics.DrawLines(redPen, curvePoints);
+ // Create offset, number of segments, and tension.
+ int offset = 2;
+ int numSegments = 4;
+ float tension = 0.7F;
+ // Draw curve to screen.
+ t.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments, tension);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawCurve(greenPen, curvePoints, offset, numSegments);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawCurve(greenPen, curvePoints, tension);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawCurve(greenPen, curvePoints);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawEllipseTest() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create location and size of ellipse.
+ int x = 0;
+ int y = 0;
+ int width = 200;
+ int height = 100;
+ // Draw ellipse to screen.
+ t.Graphics.DrawEllipse(blackPen, x, y, width, height);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawEllipse(blackPen, new Rectangle(x, y, width, height));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawEllipseTestF() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create location and size of ellipse.
+ float x = 0.0F;
+ float y = 0.0F;
+ float width = 200.0F;
+ float height = 100.0F;
+ // Draw ellipse to screen.
+ t.Graphics.DrawEllipse(blackPen, x, y, width, height);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawEllipse(blackPen, new RectangleF(x, y, width, height));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ static string getInFile (string file) {
+ string sRslt;
+
+ sRslt = Path.GetFullPath (file);
+
+ if (! File.Exists (file))
+ sRslt = Path.Combine (
+ Path.Combine ("..", ".."),
+ file);
+
+ return sRslt;
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: ImageFormat.Icon is not supported yet.
+ // java external library should be installed.
+#endif
+ public void DrawIconTest() {
+ // Create icon.
+ Icon newIcon = new Icon(getInFile ("SampIcon.ico"));
+ // Create coordinates for upper-left corner of icon.
+ int x = 100;
+ int y = 100;
+ // Draw icon to screen.
+ t.Graphics.DrawIcon(newIcon, x, y);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+
+ t.Graphics.DrawIcon(newIcon, new Rectangle(200, 300, 125, 345));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: ImageFormat.Icon is not supported yet.
+ // java external library should be installed.
+#endif
+ public void DrawIconUnstretchedTest() {
+ // Create icon.
+ Icon newIcon = new Icon(getInFile ("SampIcon.ico"));
+ // Create rectangle for icon.
+ Rectangle rect = new Rectangle( 100, 100, 200, 200);
+ // Draw icon to screen.
+ t.Graphics.DrawIconUnstretched(newIcon, rect);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+#if INTPTR_SUPPORTED
+ // Define DrawImageAbort callback method.
+ private bool DrawImageCallback(IntPtr callBackData) {
+ // Test for call that passes callBackData parameter.
+ if(callBackData==IntPtr.Zero) {
+ // If no callBackData passed, abort DrawImage method.
+ return true;
+ }
+ else {
+ // If callBackData passed, continue DrawImage method.
+ return false;
+ }
+ }
+
+ [Test] //TBD: add more overrides
+ public void DrawImageTest() {
+ // Create callback method.
+ Graphics.DrawImageAbort imageCallback
+ = new Graphics.DrawImageAbort(DrawImageCallback);
+ IntPtr imageCallbackData = new IntPtr(1);
+ // Create image.
+ Image newImage = Image.FromFile("SampIcon.ico");
+ // Create rectangle for displaying original image.
+ Rectangle destRect1 = new Rectangle( 100, 25, 450, 150);
+ // Create coordinates of rectangle for source image.
+ float x = 50.0F;
+ float y = 50.0F;
+ float width = 150.0F;
+ float height = 150.0F;
+ GraphicsUnit units = GraphicsUnit.Pixel;
+ // Draw original image to screen.
+ t.Graphics.DrawImage(newImage, destRect1, x, y, width, height, units);
+ t.Show();
+ // Create rectangle for adjusted image.
+ Rectangle destRect2 = new Rectangle(100, 175, 450, 150);
+ // Create image attributes and set large gamma.
+ ImageAttributes imageAttr = new ImageAttributes();
+ imageAttr.SetGamma(4.0F);
+ // Draw adjusted image to screen.
+
+ t.Graphics.DrawImage(
+ newImage,
+ destRect2,
+ x, y,
+ width, height,
+ units,
+ imageAttr,
+ imageCallback,
+ imageCallbackData);
+
+ t.Show();
+ }
+#endif
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // GH NUnit unable to read machine.config or any other app.config files
+#endif
+ public void DrawImageUnscaledTest() {
+ // Create image.
+ Image newImage = Bitmap.FromFile(getInFile ("bitmap_gh.png"));
+ // Create coordinates for upper-left corner of image.
+ int x = 100;
+ int y = 100;
+ // Draw image to screen.
+ t.Graphics.DrawImageUnscaled(newImage, x, y, 100, 125);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawImageUnscaled(newImage, new Rectangle(x, y, 34, 235));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawImageUnscaled(newImage, x, y);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawImageUnscaled(newImage, new Point(x, y));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawLineTest() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create coordinates of points that define line.
+ int x1 = 100;
+ int y1 = 100;
+ int x2 = 500;
+ int y2 = 100;
+ // Draw line to screen.
+ t.Graphics.DrawLine(blackPen, x1, y1, x2, y2);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawLine(blackPen, new Point( x1, y1), new Point( x2, y2));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawLineTestF() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create coordinates of points that define line.
+ float x1 = 100.0F;
+ float y1 = 100.0F;
+ float x2 = 500.0F;
+ float y2 = 100.0F;
+ // Draw line to screen.
+ t.Graphics.DrawLine(blackPen, x1, y1, x2, y2);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawLine(blackPen, new PointF( x1, y1), new PointF( x2, y2));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawLinesTest() {
+ // Create pen.
+ Pen pen = new Pen(Color.Black, 3);
+ // Create array of points that define lines to draw.
+ Point[] points = {
+ new Point( 10, 10),
+ new Point( 10, 100),
+ new Point(200, 50),
+ new Point(250, 300)
+ };
+ //Draw lines to screen.
+ t.Graphics.DrawLines(pen, points);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawLinesTestF() {
+ // Create pen.
+ Pen pen = new Pen(Color.Black, 3);
+ // Create array of points that define lines to draw.
+ PointF[] points = {
+ new PointF( 10.0F, 10.0F),
+ new PointF( 10.0F, 100.0F),
+ new PointF(200.0F, 50.0F),
+ new PointF(250.0F, 300.0F)
+ };
+ //Draw lines to screen.
+ t.Graphics.DrawLines(pen, points);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawPathTest() {
+ // Create graphics path object and add ellipse.
+ GraphicsPath graphPath = new GraphicsPath();
+ graphPath.AddEllipse(0, 0, 200, 100);
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Draw graphics path to screen.
+ t.Graphics.DrawPath(blackPen, graphPath);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawPieTestF() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create location and size of ellipse.
+ float x = 0.0F;
+ float y = 0.0F;
+ float width = 200.0F;
+ float height = 100.0F;
+ // Create start and sweep angles.
+ float startAngle = 0.0F;
+ float sweepAngle = 45.0F;
+ // Draw pie to screen.
+ t.Graphics.DrawPie(blackPen, x, y, width, height, startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawPie(blackPen, new RectangleF( x, y, width, height), startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawPieTest() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create location and size of ellipse.
+ int x = 0;
+ int y = 0;
+ int width = 200;
+ int height = 100;
+ // Create start and sweep angles.
+ int startAngle = 0;
+ int sweepAngle = 45;
+ // Draw pie to screen.
+ t.Graphics.DrawPie(blackPen, x, y, width, height, startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawPie(blackPen, new Rectangle( x, y, width, height), startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawPolygonPoint() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create points that define polygon.
+ Point point1 = new Point( 50, 50);
+ Point point2 = new Point(100, 25);
+ Point point3 = new Point(200, 5);
+ Point point4 = new Point(250, 50);
+ Point point5 = new Point(300, 100);
+ Point point6 = new Point(350, 200);
+ Point point7 = new Point(250, 250);
+ Point[] curvePoints = {
+ point1,
+ point2,
+ point3,
+ point4,
+ point5,
+ point6,
+ point7
+ };
+ // Draw polygon to screen.
+ t.Graphics.DrawPolygon(blackPen, curvePoints);
+ t.Show();
+ Assert.IsTrue(t.PDCompare()); // .NET's lines of polygon is more wide
+ }
+
+ [Test]
+ public void DrawPolygonPointF() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create points that define polygon.
+ PointF point1 = new PointF( 50, 50);
+ PointF point2 = new PointF(100, 25);
+ PointF point3 = new PointF(200, 5);
+ PointF point4 = new PointF(250, 50);
+ PointF point5 = new PointF(300, 100);
+ PointF point6 = new PointF(350, 200);
+ PointF point7 = new PointF(250, 250);
+ PointF[] curvePoints = {
+ point1,
+ point2,
+ point3,
+ point4,
+ point5,
+ point6,
+ point7
+ };
+ // Draw polygon to screen.
+ t.Graphics.DrawPolygon(blackPen, curvePoints);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawRectangleFloat() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create location and size of rectangle.
+ float x = 7.0F;
+ float y = 7.0F;
+ float width = 200.0F;
+ float height = 200.0F;
+ // Draw rectangle to screen.
+ t.Graphics.DrawRectangle(blackPen, x, y, width, height);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawRectangle(blackPen, (int)x, (int)y, (int)width, (int)height);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.DrawRectangle(blackPen, new Rectangle( (int)x, (int)y, (int)width, (int)height));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawRectanglesRectangleF() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create array of rectangles.
+ RectangleF[] rects = {
+ new RectangleF( 20.0F, 20.0F, 100.0F, 200.0F),
+ new RectangleF(100.0F, 200.0F, 250.0F, 50.0F),
+ new RectangleF(300.0F, 20.0F, 50.0F, 100.0F)
+ };
+ // Draw rectangles to screen.
+ t.Graphics.DrawRectangles(blackPen, rects);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void DrawRectanglesRectangle() {
+ // Create pen.
+ Pen blackPen = new Pen(Color.Black, 3);
+ // Create array of rectangles.
+ Rectangle[] rects = {
+ new Rectangle( 20, 20, 100, 200),
+ new Rectangle(100, 200, 250, 50),
+ new Rectangle(300, 20, 50, 100)
+ };
+ // Draw rectangles to screen.
+ t.Graphics.DrawRectangles(blackPen, rects);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test] //TBD: add more combinations
+ public void DrawStringFloatFormat() {
+ // Create string to draw.
+ String drawString = "Sample Text";
+ // Create font and brush.
+ Font drawFont = new Font("Arial", 34, FontStyle.Italic);
+ SolidBrush drawBrush = new SolidBrush(Color.Black);
+ // Create point for upper-left corner of drawing.
+ float x = 150.0F;
+ float y = 50.0F;
+ // Set format of string.
+ StringFormat drawFormat = new StringFormat();
+ drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
+ // Draw string to screen.
+ t.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
+ t.Show();
+ Assert.IsTrue(t.PDCompare()); // in .net the font is shmoothed
+ SetUp();
+
+ drawFormat.FormatFlags = StringFormatFlags.NoClip;
+ // Draw string to screen.
+ t.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ drawFormat.FormatFlags = StringFormatFlags.FitBlackBox;
+ // Draw string to screen.
+ t.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void EndContainerState() {
+ // Begin graphics container.
+ GraphicsContainer containerState = t.Graphics.BeginContainer();
+ // Translate world transformation.
+ t.Graphics.TranslateTransform(100.0F, 100.0F);
+ // Fill translated rectangle in container with red.
+ t.Graphics.FillRectangle(new SolidBrush(Color.Red), 0, 0, 200, 200);
+ t.Show();
+ // End graphics container.
+ t.Graphics.EndContainer(containerState);
+ // Fill untransformed rectangle with green.
+ t.Graphics.FillRectangle(new SolidBrush(Color.Green), 0, 0, 200, 200);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test] //TBD
+ public void EnumerateMetafile() {
+ }
+
+ [Test]
+ public void ExcludeClipRegion() {
+ // Create rectangle for exclusion.
+ Rectangle excludeRect = new Rectangle(100, 100, 200, 200);
+ // Set clipping region to exclude rectangle.
+ t.Graphics.ExcludeClip(excludeRect);
+ // Fill large rectangle to show clipping region.
+ t.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 300, 300);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillClosedCurvePointFillModeTension() {
+ // Create solid brush.
+ SolidBrush redBrush = new SolidBrush(Color.Red);
+ // Create array of points for curve.
+ Point point1 = new Point(100, 100);
+ Point point2 = new Point(200, 50);
+ Point point3 = new Point(250, 200);
+ Point point4 = new Point( 50, 150);
+ Point[] points = {point1, point2, point3, point4};
+ // Set fill mode.
+ FillMode newFillMode = FillMode.Winding;
+ // Set tension.
+ float tension = 0.68F;
+ // Fill curve on screen.
+ t.Graphics.FillClosedCurve(redBrush, points);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+
+ SetUp();
+ t.Graphics.FillClosedCurve(redBrush, points, newFillMode);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+
+ SetUp();
+ newFillMode = FillMode.Alternate;
+ t.Graphics.FillClosedCurve(redBrush, points, newFillMode, tension);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillClosedCurvePointFFillModeTension() {
+ // Create solid brush.
+ SolidBrush redBrush = new SolidBrush(Color.Red);
+ // Create array of points for curve.
+ PointF point1 = new PointF(100.0F, 100.0F);
+ PointF point2 = new PointF(200.0F, 50.0F);
+ PointF point3 = new PointF(250.0F, 200.0F);
+ PointF point4 = new PointF( 50.0F, 150.0F);
+ PointF[] points = {point1, point2, point3, point4};
+ // Set fill mode.
+ FillMode newFillMode = FillMode.Winding;
+ // Set tension.
+ float tension = 0.68F;
+ // Fill curve on screen.
+ t.Graphics.FillClosedCurve(redBrush, points);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillClosedCurve(redBrush, points, newFillMode);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ newFillMode = FillMode.Alternate;
+ t.Graphics.FillClosedCurve(redBrush, points, newFillMode, tension);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillEllipse() {
+ // Create solid brush.
+ SolidBrush redBrush = new SolidBrush(Color.Red);
+ // Create location and size of ellipse.
+ int x = 0;
+ int y = 0;
+ int width = 200;
+ int height = 100;
+ // Fill ellipse on screen.
+ t.Graphics.FillEllipse(redBrush, x, y, width, height);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillEllipse(redBrush, new Rectangle( x, y, width, height));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillEllipseFloat() {
+ // Create solid brush.
+ SolidBrush redBrush = new SolidBrush(Color.Red);
+ // Create location and size of ellipse.
+ float x = 0.0F;
+ float y = 0.0F;
+ float width = 200.0F;
+ float height = 100.0F;
+ // Fill ellipse on screen.
+ t.Graphics.FillEllipse(redBrush, x, y, width, height);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillEllipse(redBrush, new RectangleF( x, y, width, height));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillPathEllipse() {
+ // Create solid brush.
+ SolidBrush redBrush = new SolidBrush(Color.Red);
+ // Create graphics path object and add ellipse.
+ GraphicsPath graphPath = new GraphicsPath();
+ graphPath.AddEllipse(0, 0, 200, 100);
+ // Fill graphics path to screen.
+ t.Graphics.FillPath(redBrush, graphPath);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillPieFloat() {
+ // Create solid brush.
+ SolidBrush redBrush = new SolidBrush(Color.Red);
+ // Create location and size of ellipse.
+ int x = 0;
+ int y = 0;
+ int width = 200;
+ int height = 100;
+ // Create start and sweep angles.
+ float startAngle = 0.0F;
+ float sweepAngle = 45.0F;
+ // Fill pie to screen.
+ t.Graphics.FillPie(redBrush, new Rectangle(x, y, width, height), startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillPie(redBrush, x, y, width, height, (int)startAngle, (int)sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillPie(redBrush, (float)x, (float)y, (float)width, (float)height, startAngle, sweepAngle);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillPolygonPointFillMode() {
+ // Create solid brush.
+ SolidBrush blueBrush = new SolidBrush(Color.Blue);
+ // Create points that define polygon.
+ Point point1 = new Point( 50, 50);
+ Point point2 = new Point(100, 25);
+ Point point3 = new Point(200, 5);
+ Point point4 = new Point(250, 50);
+ Point point5 = new Point(300, 100);
+ Point point6 = new Point(350, 200);
+ Point point7 = new Point(250, 250);
+ Point[] curvePoints = {
+ point1,
+ point2,
+ point3,
+ point4,
+ point5,
+ point6,
+ point7
+ };
+
+ // Fill polygon to screen.
+ t.Graphics.FillPolygon(blueBrush, curvePoints, FillMode.Winding);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillPolygon(blueBrush, curvePoints, FillMode.Alternate);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillPolygon(blueBrush, curvePoints);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillPolygonPointFFillMode() {
+ // Create solid brush.
+ SolidBrush blueBrush = new SolidBrush(Color.Blue);
+ // Create points that define polygon.
+ PointF point1 = new PointF( 50.0F, 50.0F);
+ PointF point2 = new PointF(100.0F, 25.0F);
+ PointF point3 = new PointF(200.0F, 5.0F);
+ PointF point4 = new PointF(250.0F, 50.0F);
+ PointF point5 = new PointF(300.0F, 100.0F);
+ PointF point6 = new PointF(350.0F, 200.0F);
+ PointF point7 = new PointF(250.0F, 250.0F);
+ PointF[] curvePoints = {
+ point1,
+ point2,
+ point3,
+ point4,
+ point5,
+ point6,
+ point7
+ };
+
+ // Fill polygon to screen.
+ t.Graphics.FillPolygon(blueBrush, curvePoints, FillMode.Winding);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillPolygon(blueBrush, curvePoints, FillMode.Alternate);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillPolygon(blueBrush, curvePoints);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillRectangle() {
+ // Create solid brush.
+ SolidBrush blueBrush = new SolidBrush(Color.Blue);
+ // Create location and size of rectangle.
+ int x = 0;
+ int y = 0;
+ int width = 300;
+ int height = 200;
+ // Fill rectangle to screen.
+ t.Graphics.FillRectangle(blueBrush, x, y, width, height);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillRectangle(blueBrush, new Rectangle( x, y, width, height));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillRectangleFloat() {
+ // Create solid brush.
+ SolidBrush blueBrush = new SolidBrush(Color.Blue);
+ // Create location and size of rectangle.
+ float x = 0.0F;
+ float y = 0.0F;
+ float width = 300.0F;
+ float height = 200.0F;
+ // Fill rectangle to screen.
+ t.Graphics.FillRectangle(blueBrush, x, y, width, height);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ SetUp();
+
+ t.Graphics.FillRectangle(blueBrush, new RectangleF( x, y, width, height));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillRectanglesRectangle() {
+ // Create solid brush.
+ SolidBrush blueBrush = new SolidBrush(Color.Blue);
+ // Create array of rectangles.
+ Rectangle[] rects = {
+ new Rectangle( 0, 0, 100, 200),
+ new Rectangle(100, 200, 250, 50),
+ new Rectangle(300, 0, 50, 100)
+ };
+ // Fill rectangles to screen.
+ t.Graphics.FillRectangles(blueBrush, rects);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillRectanglesRectangleF() {
+ // Create solid brush.
+ SolidBrush blueBrush = new SolidBrush(Color.Blue);
+ // Create array of rectangles.
+ RectangleF[] rects = {
+ new RectangleF( 0.0F, 0.0F, 100.0F, 200.0F),
+ new RectangleF(100.0F, 200.0F, 250.0F, 50.0F),
+ new RectangleF(300.0F, 0.0F, 50.0F, 100.0F)
+ };
+ // Fill rectangles to screen.
+ t.Graphics.FillRectangles(blueBrush, rects);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FillRegionRectangle() {
+ // Create solid brush.
+ SolidBrush blueBrush = new SolidBrush(Color.Blue);
+ // Create rectangle for region.
+ Rectangle fillRect = new Rectangle(100, 150, 200, 250);
+ // Create region for fill.
+ Region fillRegion = new Region(fillRect);
+ // Fill region to screen.
+ t.Graphics.FillRegion(blueBrush, fillRegion);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void FlushTest() {
+ t.Graphics.Flush();
+ t.Graphics.Flush(FlushIntention.Flush);
+ }
+
+ [Test]
+ public void IntersectClipRegion() {
+ // Set clipping region.
+ Rectangle clipRect = new Rectangle(0, 0, 200, 300);
+ Region clipRegion = new Region(clipRect);
+ t.Graphics.SetClip(clipRegion, CombineMode.Replace);
+ // Update clipping region to intersection of
+ // existing region with specified rectangle.
+ Rectangle intersectRect = new Rectangle(100, 100, 200, 300);
+ Region intersectRegion = new Region(intersectRect);
+ t.Graphics.IntersectClip(intersectRegion);
+ // Fill rectangle to demonstrate effective clipping region.
+ t.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 500, 600);
+ t.Show();
+ // Reset clipping region to infinite.
+ t.Graphics.ResetClip();
+ // Draw clipRect and intersectRect to screen.
+ t.Graphics.DrawRectangle(new Pen(Color.Black), clipRect);
+ t.Show();
+ t.Graphics.DrawRectangle(new Pen(Color.Red), intersectRect);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void IsVisible4Float() {
+ // Set clip region.
+ Region clipRegion = new Region(new Rectangle(50, 50, 100, 100));
+ t.Graphics.SetClip(clipRegion, CombineMode.Replace);
+ // Set up coordinates of rectangles.
+ float x1 = 100.0F;
+ float y1 = 100.0F;
+ float width1 = 20.0F;
+ float height1 = 20.0F;
+ float x2 = 200.0F;
+ float y2 = 200.0F;
+ float width2 = 20.0F;
+ float height2 = 20.0F;
+ // If rectangle is visible, fill it.
+ if (t.Graphics.IsVisible(x1, y1, width1, height1)) {
+ t.Graphics.FillRectangle(new SolidBrush(Color.Red), x1, y1, width1, height1);
+ t.Show();
+ }
+ if (t.Graphics.IsVisible(x2, y2, width2, height2)) {
+ t.Graphics.FillRectangle(new SolidBrush(Color.Blue), x2, y2, width2, height2);
+ t.Show();
+ }
+
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Graphics.MeasureCharacterRanges is not implemented
+#endif
+ public void MeasureCharacterRangesRegions() {
+ // Set up string.
+ string measureString = "First and Second ranges";
+ Font stringFont = new Font("Times New Roman", 16.0F);
+ // Set character ranges to "First" and "Second".
+ CharacterRange[] characterRanges = {
+ new CharacterRange(0, 5),
+ new CharacterRange(10, 6)
+ };
+ // Create rectangle for layout.
+ float x = 50.0F;
+ float y = 50.0F;
+ float width = 35.0F;
+ float height = 200.0F;
+ RectangleF layoutRect = new RectangleF(x, y, width, height);
+ // Set string format.
+ StringFormat stringFormat = new StringFormat();
+ stringFormat.FormatFlags = StringFormatFlags.DirectionVertical;
+ stringFormat.SetMeasurableCharacterRanges(characterRanges);
+ // Draw string to screen.
+ t.Graphics.DrawString(
+ measureString,
+ stringFont,
+ Brushes.Black,
+ x, y,
+ stringFormat);
+ // Measure two ranges in string.
+ Region[] stringRegions = new Region[2];
+ stringRegions = t.Graphics.MeasureCharacterRanges(
+ measureString,
+ stringFont,
+ layoutRect,
+ stringFormat);
+ // Draw rectangle for first measured range.
+ RectangleF measureRect1 = stringRegions[0].GetBounds(t.Graphics);
+ t.Graphics.DrawRectangle(
+ new Pen(Color.Red, 1),
+ Rectangle.Round(measureRect1));
+ t.Show();
+ // Draw rectangle for second measured range.
+ RectangleF measureRect2 = stringRegions[1].GetBounds(t.Graphics);
+ t.Graphics.DrawRectangle(
+ new Pen(Color.Blue, 1),
+ Rectangle.Round(measureRect2));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test] //TBD: add more overloads
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Graphics.MeasureString(string,Font,SizeF,StringFormat,out int,out int)
+ // is not implemented
+#endif
+ public void MeasureStringSizeFFormatInts() {
+ // Set up string.
+ string measureString = "Measure String";
+ Font stringFont = new Font("Arial", 16);
+ // Set maximum layout size.
+ SizeF layoutSize = new SizeF(100.0F, 200.0F);
+ // Set string format.
+ StringFormat newStringFormat = new StringFormat();
+ newStringFormat.FormatFlags = StringFormatFlags.DirectionVertical;
+ // Measure string.
+ int charactersFitted;
+ int linesFilled;
+ SizeF stringSize = new SizeF();
+ stringSize = t.Graphics.MeasureString(
+ measureString,
+ stringFont,
+ layoutSize,
+ newStringFormat,
+ out charactersFitted,
+ out linesFilled);
+ // Draw rectangle representing size of string.
+ t.Graphics.DrawRectangle(
+ new Pen(Color.Red, 1),
+ 0.0F, 0.0F, stringSize.Width, stringSize.Height);
+ t.Show();
+ // Draw string to screen.
+ t.Graphics.DrawString(
+ measureString,
+ stringFont,
+ Brushes.Black,
+ new PointF(0, 0),
+ newStringFormat);
+ t.Show();
+ // Draw output parameters to screen.
+ string outString = "chars " + charactersFitted + ", lines " + linesFilled;
+ t.Graphics.DrawString(
+ outString,
+ stringFont,
+ Brushes.Black,
+ new PointF(100, 0));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void MultiplyTransform() {
+ // Create transform matrix.
+ Matrix transformMatrix = new Matrix();
+ // Translate matrix, prepending translation vector.
+ transformMatrix.Translate(200.0F, 100.0F);
+ // Rotate transformation matrix of graphics object,
+ // prepending rotation matrix.
+ t.Graphics.RotateTransform(30.0F);
+ // Multiply (append to) transformation matrix of
+ // graphics object to translate graphics transformation.
+ t.Graphics.MultiplyTransform(transformMatrix);
+ // Draw rotated, translated ellipse.
+ t.Graphics.DrawEllipse(new Pen(Color.Blue, 3), -80, -40, 160, 80);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void MultiplyTransformMatrixOrder() {
+ // Create transform matrix.
+ Matrix transformMatrix = new Matrix();
+ // Translate matrix, prepending translation vector.
+ transformMatrix.Translate(200.0F, 100.0F);
+ // Rotate transformation matrix of graphics object,
+ // prepending rotation matrix.
+ t.Graphics.RotateTransform(30.0F);
+ // Multiply (append to) transformation matrix of
+ // graphics object to translate graphics transformation.
+ t.Graphics.MultiplyTransform(transformMatrix, MatrixOrder.Append);
+ // Draw rotated, translated ellipse.
+ t.Graphics.DrawEllipse(new Pen(Color.Blue, 3), -80, -40, 160, 80);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void MultiplyTransformMatrixOrder1() {
+ // Create transform matrix.
+ Matrix transformMatrix = new Matrix();
+ // Translate matrix, prepending translation vector.
+ transformMatrix.Translate(200.0F, 100.0F);
+ // Rotate transformation matrix of graphics object,
+ // prepending rotation matrix.
+ t.Graphics.RotateTransform(30.0F);
+ // Multiply (append to) transformation matrix of
+ // graphics object to translate graphics transformation.
+ t.Graphics.MultiplyTransform(transformMatrix, MatrixOrder.Prepend);
+ // Draw rotated, translated ellipse.
+ t.Graphics.DrawEllipse(new Pen(Color.Blue, 3), -80, -40, 160, 80);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void ResetClipIntersectClipRectangleF() {
+ // Set clipping region.
+ Rectangle clipRect = new Rectangle(0, 0, 200, 200);
+ t.Graphics.SetClip(clipRect);
+ // Update clipping region to intersection of existing region with new rectangle.
+ RectangleF intersectRectF = new RectangleF(100.0F, 100.0F, 200.0F, 200.0F);
+ t.Graphics.IntersectClip(intersectRectF);
+ // Fill rectangle to demonstrate effective clipping region.
+ t.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 500, 500);
+ // Reset clipping region to infinite.
+ t.Graphics.ResetClip();
+ // Draw clipRect and intersectRect to screen.
+ t.Graphics.DrawRectangle(new Pen(Color.Black), clipRect);
+ t.Graphics.DrawRectangle(new Pen(Color.Red), Rectangle.Round(intersectRectF));
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void SaveRestoreTranslate() {
+ // Translate transformation matrix.
+ t.Graphics.TranslateTransform(100, 0);
+ // Save translated graphics state.
+ GraphicsState transState = t.Graphics.Save();
+ // Reset transformation matrix to identity and fill rectangle.
+ t.Graphics.ResetTransform();
+ t.Graphics.FillRectangle(new SolidBrush(Color.Red), 0, 0, 100, 100);
+ t.Show();
+ // Restore graphics state to translated state and fill second rectangle.
+ t.Graphics.Restore(transState);
+ t.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 100, 100);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void RotateTransformAngleMatrixOrder() {
+ // Set world transform of graphics object to translate.
+ t.Graphics.TranslateTransform(100.0F, 0.0F);
+ // Then to rotate, appending rotation matrix.
+ t.Graphics.RotateTransform(30.0F, MatrixOrder.Append);
+ // Draw translated, rotated ellipse to screen.
+ t.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void RotateTransformAngleMatrixOrder1() {
+ // Set world transform of graphics object to translate.
+ t.Graphics.TranslateTransform(100.0F, 0.0F);
+ // Then to rotate, appending rotation matrix.
+ t.Graphics.RotateTransform(30.0F, MatrixOrder.Prepend);
+ // Draw translated, rotated ellipse to screen.
+ t.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
+ t.Show();
+ Assert.IsTrue(t.PDCompare()); // Line width problem
+ }
+
+ [Test]
+ public void ScaleTransformFloatMatrixOrder() {
+ // Set world transform of graphics object to rotate.
+ t.Graphics.RotateTransform(30.0F);
+ // Then to scale, appending to world transform.
+ t.Graphics.ScaleTransform(3.0F, 1.0F, MatrixOrder.Append);
+ // Draw rotated, scaled rectangle to screen.
+ t.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40);
+ t.Show();
+ Assert.IsTrue(t.PDCompare()); // Line width problem
+ }
+
+ [Test]
+ public void ScaleTransformFloatMatrixOrder1() {
+ // Set world transform of graphics object to rotate.
+ t.Graphics.RotateTransform(30.0F);
+ // Then to scale, appending to world transform.
+ t.Graphics.ScaleTransform(3.0F, 1.0F, MatrixOrder.Prepend);
+ // Draw rotated, scaled rectangle to screen.
+ t.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test] //TBD: add more combination
+ public void SetClipRegionCombine() {
+ // Create region for clipping.
+ Region clipRegion = new Region(new Rectangle(0, 0, 200, 100));
+ // Set clipping region of graphics to region.
+ t.Graphics.SetClip(clipRegion, CombineMode.Replace);
+ // Fill rectangle to demonstrate clip region.
+ t.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void TransformPointsPointF() {
+ // Create array of two points.
+ PointF[] points = {new PointF(0.0F, 0.0F),
+ new PointF(100.0F, 50.0F)};
+ // Draw line connecting two untransformed points.
+ t.Graphics.DrawLine(new Pen(Color.Blue, 3),
+ points[0],
+ points[1]);
+ // Set world transformation of Graphics object to translate.
+ t.Graphics.TranslateTransform(40.0F, 30.0F);
+ // Transform points in array from world to page coordinates.
+ t.Graphics.TransformPoints(CoordinateSpace.Page,
+ CoordinateSpace.World,
+ points);
+ // Reset world transformation.
+ t.Graphics.ResetTransform();
+ // Draw line that connects transformed points.
+ t.Graphics.DrawLine(new Pen(Color.Red, 3),
+ points[0],
+ points[1]);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void TranslateClipFloat() {
+ // Create rectangle for clipping region.
+ RectangleF clipRect = new RectangleF(0.0F, 0.0F, 100.0F, 100.0F);
+ // Set clipping region of graphics to rectangle.
+ t.Graphics.SetClip(clipRect);
+ // Translate clipping region.
+ float dx = 50.0F;
+ float dy = 50.0F;
+ t.Graphics.TranslateClip(dx, dy);
+ // Fill rectangle to demonstrate translated clip region.
+ t.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void TranslateTransformAngleMatrixOrder() {
+ // Set world transform of graphics object to rotate.
+ t.Graphics.RotateTransform(30.0F);
+ // Then to translate, appending to world transform.
+ t.Graphics.TranslateTransform(100.0F, 0.0F, MatrixOrder.Append);
+ // Draw rotated, translated ellipse to screen.
+ t.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
+ t.Show();
+ Assert.IsTrue(t.PDCompare()); // Line width problem
+ }
+
+ [Test]
+ public void TranslateTransformAngleMatrixOrder1() {
+ // Set world transform of graphics object to rotate.
+ t.Graphics.RotateTransform(30.0F);
+ // Then to translate, appending to world transform.
+ t.Graphics.TranslateTransform(100.0F, 0.0F, MatrixOrder.Prepend);
+ // Draw rotated, translated ellipse to screen.
+ t.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void TransfromPageScaleUnits() {
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+ t.Graphics.PageScale = 1.0F;
+ t.Graphics.DrawLine(Pens.Red, 10, 70, 70, 10);
+
+ t.Graphics.PageUnit = GraphicsUnit.Document;
+ t.Graphics.PageScale = 10.0F;
+ t.Graphics.DrawLine(Pens.Blue, 10, 70, 70, 10);
+
+ t.Graphics.PageUnit = GraphicsUnit.Inch;
+ t.Graphics.PageScale = 0.055F;
+ t.Graphics.DrawLine(Pens.Green, 10, 70, 70, 10);
+
+ Matrix mx=new Matrix(0.5f,0,0,0.5f,0,0);
+ t.Graphics.Transform = mx;
+
+ t.Graphics.PageUnit = GraphicsUnit.Inch;
+ t.Graphics.DrawLine(Pens.Black, 10, 70, 70, 10);
+
+ t.Graphics.PageUnit = GraphicsUnit.Point;
+ t.Graphics.PageScale = 2.7F;
+ t.Graphics.DrawLine(Pens.Yellow, 10, 70, 70, 10);
+
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void TransfromPageScaleUnits_2() {
+ t.Graphics.RotateTransform(45);
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+ t.Graphics.PageScale = 1.0F;
+ t.Graphics.DrawLine(Pens.Red, 10, 70, 70, 10);
+
+ t.Graphics.TranslateTransform(100, 0);
+ t.Graphics.PageUnit = GraphicsUnit.Pixel;
+ t.Graphics.PageScale = 2.0F;
+ t.Graphics.DrawLine(Pens.Blue, 10, 70, 70, 10);
+
+ t.Graphics.ResetTransform();
+ t.Graphics.DrawLine(Pens.Green, 10, 70, 70, 10);
+
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ [Test]
+ public void TransfromPageScaleUnits_3() {
+ t.Graphics.TranslateTransform(20, 20);
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+ t.Graphics.PageScale = 1.0F;
+ t.Graphics.DrawLine(Pens.Red, 10, 70, 70, 10);
+
+ t.Graphics.TranslateTransform(10, 10);
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+ t.Graphics.PageScale = 1.0F;
+ t.Graphics.DrawLine(Pens.Red, 10, 70, 70, 10);
+
+ t.Graphics.RotateTransform(15);
+
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+ t.Graphics.PageScale = 0.5F;
+ t.Graphics.DrawLine(Pens.Red, 10, 70, 70, 10);
+
+ t.Graphics.PageUnit = GraphicsUnit.Pixel;
+ t.Graphics.PageScale = 0.5F;
+ t.Graphics.DrawLine(Pens.Red, 10, 70, 70, 10);
+
+ t.Graphics.PageUnit = GraphicsUnit.Pixel;
+ t.Graphics.TranslateTransform(0, 0);
+ t.Graphics.PageScale = 1.5F;
+ t.Graphics.DrawLine(Pens.Red, 10, 70, 70, 10);
+
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+ }
+
+
+ #endregion
+
+ #region GraphicsFixturePropClip
+
+ [TestFixture]
+ public class GraphicsFixturePropClip : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropClip");
+ t.Graphics.Clip = new Region(new Rectangle(10, 10, 100, 100));
+
+ st["DrawArcTest:6"] = TOLERANCE * 5.0f;
+ st["DrawArcTest:8"] = TOLERANCE * 3.7f;
+ st["DrawLinesTest:2"] = TOLERANCE * 3.0f;
+ st["DrawLinesTestF:2"] = TOLERANCE * 3.0f;
+ st["DrawPieTestF:2"] = TOLERANCE * 2.0f;
+ st["DrawPieTestF:4"] = TOLERANCE * 2.0f;
+ st["DrawPieTest:2"] = TOLERANCE * 2.0f;
+ st["DrawPieTest:4"] = TOLERANCE * 2.0f;
+ st["FillClosedCurvePointFillModeTension:2"] = TOLERANCE * 1.5f;
+ st["FillClosedCurvePointFFillModeTension:2"] = TOLERANCE * 1.5f;
+ st["FillClosedCurvePointFillModeTension:4"] = TOLERANCE * 1.5f;
+ st["FillClosedCurvePointFFillModeTension:4"] = TOLERANCE * 1.5f;
+ st["FillClosedCurvePointFillModeTension:5"] = TOLERANCE * 1.5f;
+ st["FillClosedCurvePointFFillModeTension:6"] = TOLERANCE * 1.5f;
+ st["ScaleTransformFloatMatrixOrder1:2"] = TOLERANCE * 3.5f;
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropCompositingMode
+
+ [TestFixture]
+ public class GraphicsFixturePropCompositingMode1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropCompositingMode1");
+ t.Graphics.CompositingMode = CompositingMode.SourceCopy;
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropCompositingMode2 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropCompositingMode2");
+ t.Graphics.CompositingMode = CompositingMode.SourceOver;
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropInterpolationMode
+
+ [TestFixture]
+ public class GraphicsFixturePropInterpolationMode1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropInterpolationMode1");
+ t.Graphics.InterpolationMode = InterpolationMode.Bilinear;
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropInterpolationMode2 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropInterpolationMode2");
+ t.Graphics.InterpolationMode = InterpolationMode.Bicubic;
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropPageScale
+
+ [TestFixture]
+ public class GraphicsFixturePropPageScale : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPageScale");
+
+ t.Graphics.PageScale = 4.34f;
+ t.Graphics.PageUnit = GraphicsUnit.Pixel;
+
+ st["IntersectClipRegion:4"] = TOLERANCE * 1.5f;
+ st["ResetClipIntersectClipRectangleF:2"] = TOLERANCE * 1.5f;
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropPageUnit
+
+ [TestFixture]
+ public class GraphicsFixturePropPageUnit1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPageUnit1");
+ t.Graphics.PageUnit = GraphicsUnit.Display;
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPageUnit2 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPageUnit2");
+ t.Graphics.PageUnit = GraphicsUnit.Document;
+
+ // FIXME: scaling down loss some pixels.
+ st["DrawBezierTest:2"] = TOLERANCE * 2.5f;
+ st["DrawBezierTest:4"] = TOLERANCE * 2.5f;
+ st["DrawBezierTest:6"] = TOLERANCE * 2.5f;
+ st["DrawBeziersTest:2"] = TOLERANCE * 2.0f;
+ st["DrawBeziersTest:4"] = TOLERANCE * 2.0f;
+ st["DrawClosedCurveTest:2"] = TOLERANCE * 3.0f;
+ st["DrawClosedCurveTest:4"] = TOLERANCE * 3.7f;
+ st["DrawCurveTest:2"] = TOLERANCE * 2.5f;
+ st["DrawCurveTest:4"] = TOLERANCE * 2.0f;
+ st["DrawCurveTest:6"] = TOLERANCE * 4.0f;
+ st["DrawCurveTestF:2"] = TOLERANCE * 2.5f;
+ st["DrawCurveTestF:4"] = TOLERANCE * 6.0f;
+ st["DrawCurveTestF:6"] = TOLERANCE * 6.0f;
+ st["DrawCurveTestF:8"] = TOLERANCE * 6.0f;
+ st["DrawEllipseTest:2"] = TOLERANCE * 2.0f;
+ st["DrawEllipseTest:4"] = TOLERANCE * 2.0f;
+ st["DrawEllipseTestF:2"] = TOLERANCE * 2.0f;
+ st["DrawEllipseTestF:4"] = TOLERANCE * 2.0f;
+ st["DrawLinesTest:2"] = TOLERANCE * 2.0f;
+ st["DrawLinesTestF:2"] = TOLERANCE * 2.0f;
+ st["DrawPathTest:2"] = TOLERANCE * 2.0f;
+ st["DrawPolygonPoint:2"] = TOLERANCE * 7.0f;
+ st["DrawPolygonPointF:2"] = TOLERANCE * 7.0f;
+ st["FillPieFloat:2"] = TOLERANCE * 1.5f;
+ st["FillPieFloat:4"] = TOLERANCE * 1.5f;
+ st["FillPieFloat:6"] = TOLERANCE * 1.5f;
+ st["IntersectClipRegion:4"] = TOLERANCE * 3.0f;
+ st["MultiplyTransform:2"] = TOLERANCE * 2.5f;
+ st["MultiplyTransformMatrixOrder1:2"] = TOLERANCE * 2.5f;
+ st["TranslateTransformAngleMatrixOrder1:2"] = TOLERANCE * 4.0f;
+ st["ScaleTransformFloatMatrixOrder:2"] = TOLERANCE * 4.0f;
+ st["ScaleTransformFloatMatrixOrder1:2"] = TOLERANCE * 5.5f;
+ st["RotateTransformAngleMatrixOrder:2"] = TOLERANCE * 3.5f;
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPageUnit3 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPageUnit3");
+ t.Graphics.PageUnit = GraphicsUnit.Inch;
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPageUnit4 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPageUnit4");
+ t.Graphics.PageUnit = GraphicsUnit.Millimeter;
+
+ st["DrawArcTest:8"] = TOLERANCE * 1.5f;
+ st["DrawRectangleFloat:2"] = TOLERANCE * 1.5f; // line width problem
+ st["DrawRectangleFloat:4"] = TOLERANCE * 1.5f;
+ st["DrawRectangleFloat:6"] = TOLERANCE * 1.5f;
+ st["DrawRectanglesRectangle:2"] = TOLERANCE * 1.5f;
+ st["DrawRectanglesRectangleF:2"] = TOLERANCE * 1.5f;
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPageUnit5 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPageUnit5");
+
+ t.Graphics.PageUnit = GraphicsUnit.Pixel;
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPageUnit6 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPageUnit6");
+ t.Graphics.PageUnit = GraphicsUnit.Point;
+
+ st["DrawArcTest:2"] = TOLERANCE * 2.5f;
+ st["DrawArcTest:4"] = TOLERANCE * 8.0f; // big difference in width of line
+ st["DrawArcTest:6"] = TOLERANCE * 8.0f; // big difference in width of line
+ st["DrawArcTest:8"] = TOLERANCE * 6.0f; // big difference in width of line
+ st["IsVisible4Float:2"] = TOLERANCE * 1.5f;
+ st["TransformPointsPointF:2"] = TOLERANCE * 2.0f;
+ }
+ }
+
+ // [TestFixture]
+ // public class GraphicsFixturePropPageUnit7 : GraphicsFixture {
+ // public override void SetUp() {
+ // base.SetUp ();
+ //
+ // t.Graphics.PageUnit = GraphicsUnit.World;
+ // }
+ // }
+
+ #endregion
+
+ #region GraphicsFixturePropPixelOffsetMode
+
+ [TestFixture]
+ public class GraphicsFixturePropPixelOffsetMode : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPixelOffsetMode");
+ t.Graphics.PixelOffsetMode = PixelOffsetMode.Half;
+
+ st["TransformPointsPointF:2"] = TOLERANCE * 3.0f;
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPixelOffsetMode1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPixelOffsetMode1");
+ t.Graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropPixelOffsetMode2 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropPixelOffsetMode2");
+ t.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
+
+ st["TransformPointsPointF:2"] = TOLERANCE * 3.0f;
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropRenderingOrigin
+
+ [TestFixture]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Graphics.RenderingOrigin is not implemented
+#endif
+ public class GraphicsFixturePropRenderingOrigin : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropRenderingOrigin");
+ t.Graphics.RenderingOrigin = new Point(12, 23);
+ }
+ }
+
+ #endregion
+
+ /// <summary>
+ /// TBD: add more variants
+ /// </summary>
+ #region GraphicsFixturePropSmoothingMode
+
+ [TestFixture]
+ public class GraphicsFixturePropSmoothingMode : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropSmoothingMode");
+ t.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
+
+ st["DrawArcTest:4"] = TOLERANCE * 3.0f;
+ st["DrawLineTest:2"] = TOLERANCE * 3.0f;
+ st["DrawLineTest:4"] = TOLERANCE * 3.0f; // difference in line width even in horizontal lines
+ st["DrawLineTestF:2"] = TOLERANCE * 3.0f;
+ st["DrawLineTestF:4"] = TOLERANCE * 3.0f;
+ st["DrawPieTest:2"] = TOLERANCE * 1.5f;
+ st["DrawPieTestF:2"] = TOLERANCE * 1.5f;
+ st["DrawPieTest:4"] = TOLERANCE * 1.5f;
+ st["DrawPieTestF:4"] = TOLERANCE * 1.5f;
+ st["DrawRectangleFloat:2"] = TOLERANCE * 3.0f; // big difference in line width
+ st["DrawRectangleFloat:4"] = TOLERANCE * 3.0f; // big difference in line width
+ st["DrawRectangleFloat:6"] = TOLERANCE * 3.0f;
+ st["DrawRectanglesRectangle:2"] = TOLERANCE * 3.0f;
+ st["DrawRectanglesRectangleF:2"] = TOLERANCE * 3.0f;
+ }
+ }
+
+ [TestFixture]
+ public class GraphicsFixturePropSmoothingMode1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropSmoothingMode1");
+ t.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropTextContrast
+
+ [TestFixture]
+ public class GraphicsFixturePropTextContrast : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextContrast");
+ t.Graphics.TextContrast = 9;
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixtureGraphicsState
+
+ [TestFixture]
+ public class GraphicsFixtureGraphicsState {
+ protected DrawingTest t;
+ protected int TOLERANCE = 3; //in %;
+
+ [SetUp]
+ public virtual void SetUp() {
+ t = DrawingTest.Create(512, 512, "GraphicsFixtureGraphicsState");
+ }
+
+ [TearDown]
+ public void TearDown() {
+ }
+
+ [Test]
+ public void BeginEndContainer() {
+ t.Graphics.FillRectangle( Brushes.Blue, 0, 0, 100, 100 );
+
+ GraphicsContainer c1 = t.Graphics.BeginContainer(
+ new Rectangle(100, 100, 100, 100),
+ new Rectangle(0, 0, 100, 100),
+ GraphicsUnit.Pixel);
+
+ t.Graphics.FillRectangle( Brushes.Green, 0, 0, 100, 100 );
+
+ GraphicsContainer c2 = t.Graphics.BeginContainer(
+ new Rectangle(100, 100, 100, 100),
+ new Rectangle(0, 0, 100, 100),
+ GraphicsUnit.Pixel);
+
+ t.Graphics.FillRectangle( Brushes.Red, 0, 0, 100, 100 );
+
+ GraphicsState s1 = t.Graphics.Save();
+ t.Graphics.PageUnit = GraphicsUnit.Pixel;
+
+ t.Graphics.PageScale = 0.7f;
+ t.Graphics.FillRectangle( Brushes.SeaGreen, 0, 0, 100, 100 );
+
+ t.Graphics.EndContainer(c2);
+ t.Graphics.PageScale = 0.7f;
+ t.Graphics.FillRectangle( Brushes.SeaGreen, 0, 0, 100, 100 );
+
+ t.Graphics.EndContainer(c1);
+ t.Graphics.PageScale = 0.7f;
+ t.Graphics.FillRectangle( Brushes.SeaGreen, 0, 0, 100, 100 );
+
+ t.Show();
+ Assert.IsTrue(t.PDCompare());
+ }
+
+ [Test]
+ public void SaveRestoreGraphicsProps() {
+ t.Graphics.CompositingQuality = CompositingQuality.GammaCorrected;
+ t.Graphics.CompositingMode = CompositingMode.SourceCopy;
+ t.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
+ t.Graphics.PageScale = 7;
+ t.Graphics.PageUnit = GraphicsUnit.Inch;
+ t.Graphics.PixelOffsetMode = PixelOffsetMode.Half;
+ t.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
+ t.Graphics.Transform = new Matrix(1, 2, 3, 4, 5, 6);
+ t.Graphics.TextContrast = 10;
+ t.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
+
+ GraphicsContainer c1 = t.Graphics.BeginContainer();
+
+ Assert.AreEqual(CompositingQuality.Default, t.Graphics.CompositingQuality);
+ Assert.AreEqual(CompositingMode.SourceOver, t.Graphics.CompositingMode);
+ Assert.AreEqual(InterpolationMode.Bilinear, t.Graphics.InterpolationMode);
+ Assert.AreEqual(1.0F, t.Graphics.PageScale);
+ Assert.AreEqual(GraphicsUnit.Display, t.Graphics.PageUnit);
+ Assert.AreEqual(PixelOffsetMode.Default, t.Graphics.PixelOffsetMode);
+ Assert.AreEqual(SmoothingMode.None, t.Graphics.SmoothingMode);
+ Assert.AreEqual(true, t.Graphics.Transform.IsIdentity);
+ Assert.AreEqual(4.0f, t.Graphics.TextContrast);
+ Assert.AreEqual(TextRenderingHint.SystemDefault, t.Graphics.TextRenderingHint);
+
+ t.Graphics.EndContainer(c1);
+ }
+ [Test]
+ public void SaveRestoreGraphicsProps_2() {
+ GraphicsState s = t.Graphics.Save();
+
+ t.Graphics.CompositingQuality = CompositingQuality.GammaCorrected;
+ t.Graphics.CompositingMode = CompositingMode.SourceCopy;
+ t.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
+ t.Graphics.PageScale = 7;
+ t.Graphics.PageUnit = GraphicsUnit.Inch;
+ t.Graphics.PixelOffsetMode = PixelOffsetMode.Half;
+ t.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
+ t.Graphics.Transform = new Matrix(1, 2, 3, 4, 5, 6);
+ t.Graphics.TextContrast = 10;
+ t.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
+
+ t.Graphics.Restore(s);
+
+ Assert.AreEqual(CompositingQuality.Default, t.Graphics.CompositingQuality);
+ Assert.AreEqual(CompositingMode.SourceOver, t.Graphics.CompositingMode);
+ Assert.AreEqual(InterpolationMode.Bilinear, t.Graphics.InterpolationMode);
+ Assert.AreEqual(1.0F, t.Graphics.PageScale);
+ Assert.AreEqual(GraphicsUnit.Display, t.Graphics.PageUnit);
+ Assert.AreEqual(PixelOffsetMode.Default, t.Graphics.PixelOffsetMode);
+ Assert.AreEqual(SmoothingMode.None, t.Graphics.SmoothingMode);
+ Assert.AreEqual(true, t.Graphics.Transform.IsIdentity);
+ Assert.AreEqual(4.0f, t.Graphics.TextContrast);
+ Assert.AreEqual(TextRenderingHint.SystemDefault, t.Graphics.TextRenderingHint);
+ }
+
+ [Test]
+ public void SaveRestoreGraphicsProps_3() {
+ t.Graphics.PageScale = 2;
+ GraphicsContainer c1 = t.Graphics.BeginContainer();
+
+ t.Graphics.PageScale = 3;
+ GraphicsContainer c2 = t.Graphics.BeginContainer();
+
+ t.Graphics.PageScale = 4;
+ GraphicsContainer c3 = t.Graphics.BeginContainer();
+
+ t.Graphics.EndContainer(c2);
+ Assert.AreEqual(3, t.Graphics.PageScale);
+
+ t.Graphics.PageScale = 5;
+ GraphicsState c5 = t.Graphics.Save();
+
+ t.Graphics.EndContainer(c3);
+ Assert.AreEqual(5, t.Graphics.PageScale);
+
+ t.Graphics.Restore(c5);
+ Assert.AreEqual(5, t.Graphics.PageScale);
+
+ t.Graphics.EndContainer(c1);
+ Assert.AreEqual(2, t.Graphics.PageScale);
+ }
+ [Test]
+ public void SaveRestoreGraphicsProps_4() {
+ t.Graphics.PageScale = 2;
+ GraphicsContainer c1 = t.Graphics.BeginContainer();
+
+ t.Graphics.PageScale = 3;
+ GraphicsState c2 = t.Graphics.Save();
+
+ t.Graphics.EndContainer(c1);
+ Assert.AreEqual(2, t.Graphics.PageScale);
+
+ t.Graphics.Restore(c2);
+ Assert.AreEqual(2, t.Graphics.PageScale);
+ }
+ }
+ #endregion
+
+ #region GraphicsFixturePropTextRenderingHint
+
+ [TestFixture]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Graphics.TextRenderingHint is not implemented
+#endif
+ public class GraphicsFixturePropTextRenderingHint : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint");
+ t.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
+ }
+ }
+
+ [TestFixture]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Graphics.TextRenderingHint is not implemented
+#endif
+ public class GraphicsFixturePropTextRenderingHint1 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint1");
+ t.Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
+ }
+ }
+
+ [TestFixture]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Graphics.TextRenderingHint is not implemented
+#endif
+ public class GraphicsFixturePropTextRenderingHint2 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint2");
+ t.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
+ }
+ }
+
+ [TestFixture]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Graphics.TextRenderingHint is not implemented
+#endif
+ public class GraphicsFixturePropTextRenderingHint3 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint3");
+ t.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
+ }
+ }
+
+ [TestFixture]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Graphics.TextRenderingHint is not implemented
+#endif
+ public class GraphicsFixturePropTextRenderingHint4 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint4");
+ t.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
+ }
+ }
+
+ [TestFixture]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Graphics.TextRenderingHint is not implemented
+#endif
+ public class GraphicsFixturePropTextRenderingHint5 : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTextRenderingHint5");
+ t.Graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
+ }
+ }
+
+ #endregion
+
+ #region GraphicsFixturePropTransform
+
+ [TestFixture]
+ public class GraphicsFixturePropTransform : GraphicsFixture {
+ public override void SetUp() {
+ base.SetUp ("GraphicsFixturePropTransform");
+ t.Graphics.Transform = new Matrix(0, 1, 2, 0, 0, 0);
+
+ st["DrawArcTest:2"] = TOLERANCE * 11.0f; // FIXME: Transfrom is ok, but very big difference in width
+ st["DrawArcTest:4"] = TOLERANCE * 12.0f; // FIXME: Transfrom is ok, but very big difference in width
+ st["DrawArcTest:6"] = TOLERANCE * 12.0f; // FIXME: Transfrom is ok, but very big difference in width
+ st["DrawArcTest:8"] = TOLERANCE * 10.0f; // FIXME: Transfrom is ok, but very big difference in width
+ st["DrawClosedCurveTest:4"] = TOLERANCE * 2.0f;
+ st["RotateTransformAngleMatrixOrder:2"] = TOLERANCE * 1.5f;
+ st["TransformPointsPointF:2"] = TOLERANCE * 3.5f;
+ }
+ }
+
+ #endregion
+
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPath.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPath.cs
new file mode 100644
index 00000000000..3663bebea55
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPath.cs
@@ -0,0 +1,5729 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using NUnit.Framework;
+using DrawingTestHelper;
+
+namespace Test.Sys.Drawing
+{
+ [TestFixture]
+ public class GraphicsPathFixture
+ {
+ DrawingTest t;
+ GraphicsPath path;
+ Pen p;
+
+ [SetUp]
+ public void SetUp () {
+ DrawingTest.ShowForms = false;
+ t = DrawingTest.Create (512, 512);
+ p = new Pen (Color.Blue);
+ p.Width = 2;
+ }
+
+ [Test]
+ public void ctor_void()
+ {
+ path = new GraphicsPath ();
+ Assert.AreEqual (FillMode.Alternate, path.FillMode);
+ Assert.AreEqual (0, path.PathData.Points.Length);
+ Assert.AreEqual (0, path.PointCount);
+ }
+
+ [Test]
+ public void ctor_FillMode()
+ {
+ path = new GraphicsPath (FillMode.Alternate);
+ Assert.AreEqual (FillMode.Alternate, path.FillMode);
+ Assert.AreEqual (0, path.PathData.Points.Length);
+ Assert.AreEqual (0, path.PointCount);
+
+ path = new GraphicsPath (FillMode.Winding);
+ Assert.AreEqual (FillMode.Winding, path.FillMode);
+ Assert.AreEqual (0, path.PathData.Points.Length);
+ Assert.AreEqual (0, path.PointCount);
+ }
+
+ [Test]
+ public void ctor_PointArr_ByteArr()
+ {
+ Point [] points = new Point [] { new Point (0, 0),
+ new Point (250, 250),
+ new Point (60, 70),
+ new Point (230, 10)};
+
+ byte [] types = new byte [] {(byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ path = new GraphicsPath (points, types);
+
+ Assert.AreEqual (FillMode.Alternate, path.FillMode);
+ Assert.AreEqual (4, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF (0f, 0f),
+ new PointF (250f, 250f),
+ new PointF (60f, 70f),
+ new PointF (230f, 10f)};
+ for(int i = 0; i < path.PointCount; i++) {
+ Assert.AreEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = types;
+ for(int i = 0; i < path.PointCount; i++) {
+ Assert.AreEqual(expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void ctor_PointFArr_ByteArr()
+ {
+ PointF [] points = new PointF [] { new PointF (100.1f, 200.2f),
+ new PointF (10.2f, 150.6f),
+ new PointF (60.3f, 70.7f),
+ new PointF (250.4f, 10.7f)};
+
+ byte [] types = new byte [] {(byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ path = new GraphicsPath (points, types, FillMode.Alternate);
+
+ Assert.AreEqual (FillMode.Alternate, path.FillMode);
+ Assert.AreEqual (4, path.PointCount);
+
+ PointF [] expectedPoints = points;
+ for(int i = 0; i < path.PointCount; i++) {
+ Assert.AreEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = types;
+ for(int i = 0; i < path.PointCount; i++) {
+ Assert.AreEqual(expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void ctor_PointArr_ByteArr_FillMode()
+ {
+ Point [] points = new Point [] {new Point (0, 0),
+ new Point (250, 250),
+ new Point (60, 70),
+ new Point (230, 10)};
+
+ byte [] types = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ path = new GraphicsPath (points, types, FillMode.Alternate);
+
+ Assert.AreEqual (FillMode.Alternate, path.FillMode);
+ Assert.AreEqual (4, path.PointCount);
+
+ t.Graphics.DrawPath(p, path);
+ t.Show();
+
+ path = new GraphicsPath (points, types, FillMode.Winding);
+
+ Assert.AreEqual (FillMode.Winding, path.FillMode);
+ Assert.AreEqual (4, path.PointCount);
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void ctor_PointFArr_ByteArr_FillMode()
+ {
+ PointF [] points = new PointF [] { new PointF (100.1f, 200.2f),
+ new PointF (10.2f, 150.6f),
+ new PointF (60.3f, 70.7f),
+ new PointF (250.4f, 10.7f)};
+
+ byte [] types = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ path = new GraphicsPath (points, types, FillMode.Alternate);
+
+ Assert.AreEqual (FillMode.Alternate, path.FillMode);
+ Assert.AreEqual (4, path.PointCount);
+
+ t.Graphics.DrawPath (p, path);
+ t.Show();
+
+ path = new GraphicsPath (points, types, FillMode.Winding);
+
+ Assert.AreEqual (FillMode.Winding, path.FillMode);
+ Assert.AreEqual (4, path.PointCount);
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddArc_Rectangle_Float_Float()
+ {
+ path = new GraphicsPath ();
+
+ path.AddArc (new Rectangle (50, 50, 150, 170), 10.34f, 240.15f);
+
+ Assert.AreEqual (10, path.PointCount);
+
+ path.AddArc (new Rectangle (50, 50, 70, 95), -45.001f, 135.87f);
+
+ Assert.AreEqual (17, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(199.0466f, 148.5099f),
+ new PointF(192.4631f, 194.8574f),
+ new PointF(153.9743f, 226.3808f),
+ new PointF(113.0795f, 218.9195f),
+ new PointF(72.18465f, 211.4582f),
+ new PointF(44.36986f, 167.8375f),
+ new PointF(50.95338f, 121.4901f),
+ new PointF(55.13617f, 92.0436f),
+ new PointF(72.63087f, 67.23608f),
+ new PointF(97.05219f, 56.12194f),
+ new PointF(113.1766f, 69.32237f),
+ new PointF(124.6434f, 90.44156f),
+ new PointF(121.324f, 120.1776f),
+ new PointF(105.7625f, 135.7396f),
+ new PointF(99.54897f, 141.9534f),
+ new PointF(91.99629f, 145.2055f),
+ new PointF(84.27972f, 144.9899f)};
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [17] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3 };
+
+ for (int i = 0; i < path.PointCount; i++) {
+ Assert.AreEqual(expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddArc_RectangleF_Float_Float()
+ {
+ path = new GraphicsPath ();
+
+ path.AddArc (new RectangleF (20.02f, 30.56f, 150.67f, 170.34f), 10.34f, 240.15f);
+
+ Assert.AreEqual (10, path.PointCount);
+
+ path.AddArc (new RectangleF (50.09f, 50.345f, 70.15f, 95.98f), -45.001f, 135.87f);
+
+ Assert.AreEqual (17, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(169.7277f, 129.2994f),
+ new PointF(163.0989f, 175.7367f),
+ new PointF(124.4274f, 207.3063f),
+ new PointF(83.3525f, 199.8121f),
+ new PointF(42.27758f, 192.3179f),
+ new PointF(14.35347f, 148.5978f),
+ new PointF(20.98226f, 102.1606f),
+ new PointF(25.1958f, 72.64315f),
+ new PointF(42.79146f, 47.78527f),
+ new PointF(67.34177f, 36.66724f),
+ new PointF(113.4824f, 70.01659f),
+ new PointF(124.9132f, 91.4144f),
+ new PointF(121.5016f, 121.4393f),
+ new PointF(105.8624f, 137.0791f),
+ new PointF(99.65379f, 143.288f),
+ new PointF(92.12586f, 146.533f),
+ new PointF(84.43728f, 146.3147f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier };
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddArc_Int_Int_Int_Int_Float_Float()
+ {
+ path = new GraphicsPath ();
+
+ path.AddArc (50, 50, 150, 170, 10.34f, 240.15f);
+
+ Assert.AreEqual (10, path.PointCount);
+
+ path.AddArc (50, 50, 70, 95, -45.001f, 135.87f);
+
+ Assert.AreEqual (17, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(199.0466f, 148.5099f),
+ new PointF(192.4631f, 194.8574f),
+ new PointF(153.9743f, 226.3808f),
+ new PointF(113.0795f, 218.9195f),
+ new PointF(72.18465f, 211.4582f),
+ new PointF(44.36986f, 167.8375f),
+ new PointF(50.95338f, 121.4901f),
+ new PointF(55.13617f, 92.0436f),
+ new PointF(72.63087f, 67.23608f),
+ new PointF(97.05219f, 56.12194f),
+ new PointF(113.1766f, 69.32237f),
+ new PointF(124.6434f, 90.44156f),
+ new PointF(121.324f, 120.1776f),
+ new PointF(105.7625f, 135.7396f),
+ new PointF(99.54897f, 141.9534f),
+ new PointF(91.99629f, 145.2055f),
+ new PointF(84.27972f, 144.9899f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddArc_Float_Float_Float_Float_Float_Float()
+ {
+ path = new GraphicsPath ();
+
+ path.AddArc (20.02f, 30.56f, 150.67f, 170.34f, 10.34f, 240.15f);
+
+ Assert.AreEqual (10, path.PointCount);
+
+ path.AddArc (50.09f, 50.345f, 70.15f, 95.98f, -45.001f, 135.87f);
+
+ Assert.AreEqual (17, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(169.7277f, 129.2994f),
+ new PointF(163.0989f, 175.7367f),
+ new PointF(124.4274f, 207.3063f),
+ new PointF(83.3525f, 199.8121f),
+ new PointF(42.27758f, 192.3179f),
+ new PointF(14.35347f, 148.5978f),
+ new PointF(20.98226f, 102.1606f),
+ new PointF(25.1958f, 72.64315f),
+ new PointF(42.79146f, 47.78527f),
+ new PointF(67.34177f, 36.66724f),
+ new PointF(113.4824f, 70.01659f),
+ new PointF(124.9132f, 91.4144f),
+ new PointF(121.5016f, 121.4393f),
+ new PointF(105.8624f, 137.0791f),
+ new PointF(99.65379f, 143.288f),
+ new PointF(92.12586f, 146.533f),
+ new PointF(84.43728f, 146.3147f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddBezier_Point_Point_Point_Point()
+ {
+ path = new GraphicsPath ();
+ path.AddBezier( new Point (10, 10),
+ new Point (50, 250),
+ new Point (100, 5),
+ new Point (200, 280));
+
+ Assert.AreEqual (4, path.PointCount);
+
+ path.AddBezier( new Point (0, 210),
+ new Point (50, 6),
+ new Point (150, 150),
+ new Point (250, 10));
+
+ Assert.AreEqual (8, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(10f, 10f),
+ new PointF(50f, 250f),
+ new PointF(100f, 5f),
+ new PointF(200f, 280f),
+ new PointF(0f, 210f),
+ new PointF(50f, 6f),
+ new PointF(150f, 150f),
+ new PointF(250f, 10f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddBezier_PointF_PointF_PointF_PointF()
+ {
+ path = new GraphicsPath ();
+ path.AddBezier( new PointF (10.01f, 10.02f),
+ new PointF (50.3f, 250.4f),
+ new PointF (100.005f, 5.006f),
+ new PointF (200.78f, 280.90f));
+
+ Assert.AreEqual (4, path.PointCount);
+
+ path.AddBezier( new PointF (0.15f, 210.23f),
+ new PointF (50.34f, 6.45f),
+ new PointF (150.65f, 150.87f),
+ new PointF (250.0001f, 10.2345f));
+
+ Assert.AreEqual (8, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF (10.01f, 10.02f),
+ new PointF (50.3f, 250.4f),
+ new PointF (100.005f, 5.006f),
+ new PointF (200.78f, 280.90f),
+ new PointF (0.15f, 210.23f),
+ new PointF (50.34f, 6.45f),
+ new PointF (150.65f, 150.87f),
+ new PointF (250.0001f, 10.2345f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddBezier_Int_Int_Int_Int_Int_Int_Int_Int()
+ {
+ path = new GraphicsPath ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+
+ Assert.AreEqual (4, path.PointCount);
+
+ path.AddBezier( 0, 210, 50, 6, 150, 150, 250, 10);
+
+ Assert.AreEqual (8, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(10f, 10f),
+ new PointF(50f, 250f),
+ new PointF(100f, 5f),
+ new PointF(200f, 280f),
+ new PointF(0f, 210f),
+ new PointF(50f, 6f),
+ new PointF(150f, 150f),
+ new PointF(250f, 10f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddBezier_Float_Float_Float_Float_Float_Float_Float_Float()
+ {
+ path = new GraphicsPath ();
+ path.AddBezier( 10.01f, 10.02f, 50.3f, 250.4f, 100.005f, 5.006f, 200.78f, 280.90f);
+
+ Assert.AreEqual (4, path.PointCount);
+
+ path.AddBezier( 0.15f, 210.23f, 50.34f, 6.45f, 150.65f, 150.87f, 250.0001f, 10.2345f);
+
+ Assert.AreEqual (8, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF (10.01f, 10.02f),
+ new PointF (50.3f, 250.4f),
+ new PointF (100.005f, 5.006f),
+ new PointF (200.78f, 280.90f),
+ new PointF (0.15f, 210.23f),
+ new PointF (50.34f, 6.45f),
+ new PointF (150.65f, 150.87f),
+ new PointF (250.0001f, 10.2345f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddBeziers_PointArr()
+ {
+ Point [] points = new Point [] {new Point(20, 100),
+ new Point(40, 75),
+ new Point(60, 125),
+ new Point(80, 100),
+ new Point(100, 50),
+ new Point(120, 150),
+ new Point(140, 100)};
+
+ path = new GraphicsPath();
+ path.AddBeziers(points);
+
+ Assert.AreEqual (7, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 100f),
+ new PointF(40f, 75f),
+ new PointF(60f, 125f),
+ new PointF(80f, 100f),
+ new PointF(100f, 50f),
+ new PointF(120f, 150f),
+ new PointF(140f, 100f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddBeziers_PointFArr()
+ {
+ PointF [] points = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ path = new GraphicsPath();
+ path.AddBeziers(points);
+
+ Assert.AreEqual (7, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddClosedCurve_PointArr()
+ {
+ Point [] points = new Point [] {new Point(20, 100),
+ new Point(40, 75),
+ new Point(60, 125),
+ new Point(80, 100),
+ new Point(100, 50),
+ new Point(120, 150),
+ new Point(140, 100)};
+
+ path = new GraphicsPath();
+ path.AddClosedCurve(points);
+
+ Assert.AreEqual (22, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 100f),
+ new PointF(3.333333f, 95.83333f),
+ new PointF(33.33333f, 70.83333f),
+ new PointF(40f, 75f),
+ new PointF(46.66666f, 79.16666f),
+ new PointF(53.33333f, 120.8333f),
+ new PointF(60f, 125f),
+ new PointF(66.66666f, 129.1667f),
+ new PointF(73.33333f, 112.5f),
+ new PointF(80f, 100f),
+ new PointF(86.66666f, 87.49999f),
+ new PointF(93.33333f, 41.66666f),
+ new PointF(100f, 50f),
+ new PointF(106.6667f, 58.33333f),
+ new PointF(113.3333f, 141.6667f),
+ new PointF(120f, 150f),
+ new PointF(126.6667f, 158.3333f),
+ new PointF(156.6667f, 108.3333f),
+ new PointF(140f, 100f),
+ new PointF(123.3333f, 91.66666f),
+ new PointF(36.66666f, 104.1667f),
+ new PointF(20f, 100f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddClosedCurve_PointFArr()
+ {
+ PointF [] points = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ path = new GraphicsPath();
+ path.AddClosedCurve(points);
+
+ Assert.AreEqual (22, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(3.334998f, 95.84999f),
+ new PointF(33.35f, 70.99999f),
+ new PointF(40.02f, 75.2f),
+ new PointF(46.69f, 79.39999f),
+ new PointF(53.36f, 121.1f),
+ new PointF(60.03f, 125.3f),
+ new PointF(66.7f, 129.5f),
+ new PointF(73.37f, 112.8667f),
+ new PointF(80.04f, 100.4f),
+ new PointF(86.71f, 87.93333f),
+ new PointF(93.38f, 42.13333f),
+ new PointF(100.05f, 50.5f),
+ new PointF(106.72f, 58.86666f),
+ new PointF(113.39f, 142.2333f),
+ new PointF(120.06f, 150.6f),
+ new PointF(126.73f, 158.9667f),
+ new PointF(156.745f, 109.1167f),
+ new PointF(140.07f, 100.7f),
+ new PointF(123.395f, 92.28333f),
+ new PointF(36.685f, 104.35f),
+ new PointF(20.01f, 100.1f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddClosedCurve_PointArr_Float()
+ {
+ Point [] points = new Point [] {new Point(20, 100),
+ new Point(40, 75),
+ new Point(60, 125),
+ new Point(80, 100),
+ new Point(100, 50),
+ new Point(120, 150),
+ new Point(140, 100)};
+
+ path = new GraphicsPath();
+ path.AddClosedCurve(points, 0.9f);
+
+ Assert.AreEqual (22, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 100f),
+ new PointF(-10f, 92.49999f),
+ new PointF(28f, 67.49999f),
+ new PointF(40f, 75f),
+ new PointF(52f, 82.5f),
+ new PointF(48f, 117.5f),
+ new PointF(60f, 125f),
+ new PointF(72f, 132.5f),
+ new PointF(67.99999f, 122.5f),
+ new PointF(80f, 100f),
+ new PointF(92f, 77.49999f),
+ new PointF(87.99999f, 35f),
+ new PointF(100f, 50f),
+ new PointF(112f, 65f),
+ new PointF(108f, 135f),
+ new PointF(120f, 150f),
+ new PointF(132f, 165f),
+ new PointF(170f, 115f),
+ new PointF(140f, 100f),
+ new PointF(110f, 84.99999f),
+ new PointF(50f, 107.5f),
+ new PointF(20f, 100f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddClosedCurve_PointFArr_Float()
+ {
+ PointF [] points = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ path = new GraphicsPath();
+ path.AddClosedCurve(points, 0.8f);
+
+ Assert.AreEqual (22, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(-6.670003f, 93.3f),
+ new PointF(29.348f, 68.47999f),
+ new PointF(40.02f, 75.2f),
+ new PointF(50.692f, 81.92f),
+ new PointF(49.358f, 118.58f),
+ new PointF(60.03f, 125.3f),
+ new PointF(70.702f, 132.02f),
+ new PointF(69.368f, 120.3467f),
+ new PointF(80.04f, 100.4f),
+ new PointF(90.712f, 80.45333f),
+ new PointF(89.378f, 37.11333f),
+ new PointF(100.05f, 50.5f),
+ new PointF(110.722f, 63.88667f),
+ new PointF(109.388f, 137.2133f),
+ new PointF(120.06f, 150.6f),
+ new PointF(130.732f, 163.9867f),
+ new PointF(166.75f, 114.1667f),
+ new PointF(140.07f, 100.7f),
+ new PointF(113.39f, 87.23332f),
+ new PointF(46.69f, 106.9f),
+ new PointF(20.01f, 100.1f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddCurve_PointArr()
+ {
+ Point [] points = new Point [] {new Point(20, 100),
+ new Point(40, 75),
+ new Point(60, 125),
+ new Point(80, 100),
+ new Point(100, 50),
+ new Point(120, 150),
+ new Point(140, 100)};
+
+ path = new GraphicsPath();
+ path.AddCurve(points);
+
+ Assert.AreEqual (19, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 100f),
+ new PointF(23.33333f, 95.83333f),
+ new PointF(33.33333f, 70.83333f),
+ new PointF(40f, 75f),
+ new PointF(46.66666f, 79.16666f),
+ new PointF(53.33333f, 120.8333f),
+ new PointF(60f, 125f),
+ new PointF(66.66666f, 129.1667f),
+ new PointF(73.33333f, 112.5f),
+ new PointF(80f, 100f),
+ new PointF(86.66666f, 87.49999f),
+ new PointF(93.33333f, 41.66666f),
+ new PointF(100f, 50f),
+ new PointF(106.6667f, 58.33333f),
+ new PointF(113.3333f, 141.6667f),
+ new PointF(120f, 150f),
+ new PointF(126.6667f, 158.3333f),
+ new PointF(136.6667f, 108.3333f),
+ new PointF(140f, 100f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddCurve_PointFArr()
+ {
+ PointF [] points = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ path = new GraphicsPath();
+ path.AddCurve(points);
+
+ Assert.AreEqual (19, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(23.345f, 95.95f),
+ new PointF(33.35f, 70.99999f),
+ new PointF(40.02f, 75.2f),
+ new PointF(46.69f, 79.39999f),
+ new PointF(53.36f, 121.1f),
+ new PointF(60.03f, 125.3f),
+ new PointF(66.7f, 129.5f),
+ new PointF(73.37f, 112.8667f),
+ new PointF(80.04f, 100.4f),
+ new PointF(86.71f, 87.93333f),
+ new PointF(93.38f, 42.13333f),
+ new PointF(100.05f, 50.5f),
+ new PointF(106.72f, 58.86666f),
+ new PointF(113.39f, 142.2333f),
+ new PointF(120.06f, 150.6f),
+ new PointF(126.73f, 158.9667f),
+ new PointF(136.735f, 109.0167f),
+ new PointF(140.07f, 100.7f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddCurve_PointArr_Float()
+ {
+ Point [] points = new Point [] {new Point(20, 100),
+ new Point(40, 75),
+ new Point(60, 125),
+ new Point(80, 100),
+ new Point(100, 50),
+ new Point(120, 150),
+ new Point(140, 100)};
+
+ path = new GraphicsPath();
+ path.AddCurve(points, 0.9f);
+
+ Assert.AreEqual (19, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 100f),
+ new PointF(26f, 92.49999f),
+ new PointF(28f, 67.49999f),
+ new PointF(40f, 75f),
+ new PointF(52f, 82.5f),
+ new PointF(48f, 117.5f),
+ new PointF(60f, 125f),
+ new PointF(72f, 132.5f),
+ new PointF(67.99999f, 122.5f),
+ new PointF(80f, 100f),
+ new PointF(92f, 77.49999f),
+ new PointF(87.99999f, 35f),
+ new PointF(100f, 50f),
+ new PointF(112f, 65f),
+ new PointF(108f, 135f),
+ new PointF(120f, 150f),
+ new PointF(132f, 165f),
+ new PointF(134f, 115f),
+ new PointF(140f, 100f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddCurve_PointFArr_Float()
+ {
+ PointF [] points = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ path = new GraphicsPath();
+ path.AddCurve(points, 0.8f);
+
+ Assert.AreEqual (19, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(25.346f, 93.45999f),
+ new PointF(29.348f, 68.47999f),
+ new PointF(40.02f, 75.2f),
+ new PointF(50.692f, 81.92f),
+ new PointF(49.358f, 118.58f),
+ new PointF(60.03f, 125.3f),
+ new PointF(70.702f, 132.02f),
+ new PointF(69.368f, 120.3467f),
+ new PointF(80.04f, 100.4f),
+ new PointF(90.712f, 80.45333f),
+ new PointF(89.378f, 37.11333f),
+ new PointF(100.05f, 50.5f),
+ new PointF(110.722f, 63.88667f),
+ new PointF(109.388f, 137.2133f),
+ new PointF(120.06f, 150.6f),
+ new PointF(130.732f, 163.9867f),
+ new PointF(134.734f, 114.0067f),
+ new PointF(140.07f, 100.7f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddCurve_PointArr_Int_Int_Float()
+ {
+
+ Point [] points = new Point [] {new Point(20, 100),
+ new Point(40, 75),
+ new Point(60, 125),
+ new Point(80, 100),
+ new Point(100, 50),
+ new Point(120, 150),
+ new Point(140, 100)};
+
+ path = new GraphicsPath();
+ path.AddCurve(points, 0, 3, 0.8f);
+
+ Assert.AreEqual (10, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 100f),
+ new PointF(25.33333f, 93.33333f),
+ new PointF(29.33333f, 68.33333f),
+ new PointF(40f, 75f),
+ new PointF(50.66666f, 81.66666f),
+ new PointF(49.33333f, 118.3333f),
+ new PointF(60f, 125f),
+ new PointF(70.66666f, 131.6667f),
+ new PointF(69.33333f, 120f),
+ new PointF(80f, 100f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddCurve_PointFArr_Int_Int_Float()
+ {
+
+ PointF [] points = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ path = new GraphicsPath();
+ path.AddCurve(points, 0, 3, 0.8f);
+
+ Assert.AreEqual (10, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(25.346f, 93.45999f),
+ new PointF(29.348f, 68.47999f),
+ new PointF(40.02f, 75.2f),
+ new PointF(50.692f, 81.92f),
+ new PointF(49.358f, 118.58f),
+ new PointF(60.03f, 125.3f),
+ new PointF(70.702f, 132.02f),
+ new PointF(69.368f, 120.3467f),
+ new PointF(80.04f, 100.4f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddEllipse_Rectangle()
+ {
+ path = new GraphicsPath();
+ path.AddEllipse (new Rectangle(50, 50, 400, 80));
+
+ Assert.AreEqual (13, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(450f, 90f),
+ new PointF(450f, 112.0914f),
+ new PointF(360.4569f, 130f),
+ new PointF(250f, 130f),
+ new PointF(139.543f, 130f),
+ new PointF(50f, 112.0914f),
+ new PointF(50f, 90f),
+ new PointF(50f, 67.90861f),
+ new PointF(139.543f, 50f),
+ new PointF(250f, 50f),
+ new PointF(360.4569f, 50f),
+ new PointF(450f, 67.90861f),
+ new PointF(450f, 90f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddEllipse_RectangleF()
+ {
+ path = new GraphicsPath();
+ path.AddEllipse (new RectangleF(50.1f, 50.4f, 400.12f, 80.123f));
+
+ Assert.AreEqual (13, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(450.22f, 90.4615f),
+ new PointF(450.22f, 112.5869f),
+ new PointF(360.6501f, 130.523f),
+ new PointF(250.16f, 130.523f),
+ new PointF(139.6699f, 130.523f),
+ new PointF(50.09999f, 112.5869f),
+ new PointF(50.09999f, 90.4615f),
+ new PointF(50.09999f, 68.33614f),
+ new PointF(139.6699f, 50.4f),
+ new PointF(250.16f, 50.4f),
+ new PointF(360.6501f, 50.4f),
+ new PointF(450.22f, 68.33614f),
+ new PointF(450.22f, 90.4615f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddEllipse_Int_Int_Int_Int()
+ {
+ path = new GraphicsPath();
+ path.AddEllipse (50, 50, 400, 80);
+
+ Assert.AreEqual (13, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(450f, 90f),
+ new PointF(450f, 112.0914f),
+ new PointF(360.4569f, 130f),
+ new PointF(250f, 130f),
+ new PointF(139.543f, 130f),
+ new PointF(50f, 112.0914f),
+ new PointF(50f, 90f),
+ new PointF(50f, 67.90861f),
+ new PointF(139.543f, 50f),
+ new PointF(250f, 50f),
+ new PointF(360.4569f, 50f),
+ new PointF(450f, 67.90861f),
+ new PointF(450f, 90f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddEllipse_Float_Float_Float_Float()
+ {
+ path = new GraphicsPath();
+ path.AddEllipse (50.1f, 50.4f, 400.12f, 80.123f);
+
+ Assert.AreEqual (13, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(450.22f, 90.4615f),
+ new PointF(450.22f, 112.5869f),
+ new PointF(360.6501f, 130.523f),
+ new PointF(250.16f, 130.523f),
+ new PointF(139.6699f, 130.523f),
+ new PointF(50.09999f, 112.5869f),
+ new PointF(50.09999f, 90.4615f),
+ new PointF(50.09999f, 68.33614f),
+ new PointF(139.6699f, 50.4f),
+ new PointF(250.16f, 50.4f),
+ new PointF(360.6501f, 50.4f),
+ new PointF(450.22f, 68.33614f),
+ new PointF(450.22f, 90.4615f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void AddLine_Point_Point()
+ {
+ path = new GraphicsPath ();
+
+ path.AddLine (new Point (20, 20), new Point (10, 120));
+ Assert.AreEqual (2, path.PointCount);
+
+ path.AddLine (new Point (40, 320), new Point (310, 45));
+ Assert.AreEqual (4, path.PointCount);
+
+ path.AddLine (new Point (300, 300), new Point (48, 62));
+ Assert.AreEqual (6, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 20f),
+ new PointF(10f, 120f),
+ new PointF(40f, 320f),
+ new PointF(310f, 45f),
+ new PointF(300f, 300f),
+ new PointF(48f, 62f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddLine_PointF_PointF()
+ {
+ path = new GraphicsPath ();
+
+ path.AddLine (new PointF (20.02f, 20.123f), new PointF (10.0001f, 120.23f));
+ Assert.AreEqual (2, path.PointCount);
+
+ path.AddLine (new PointF (40.00f, 320.234f), new PointF (310.9999f, 45.33333333f));
+ Assert.AreEqual (4, path.PointCount);
+
+ path.AddLine (new PointF (300f, 300.97f), new PointF (48.18f, 62.54f));
+ Assert.AreEqual (6, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20.02f, 20.123f),
+ new PointF(10.0001f, 120.23f),
+ new PointF(40f, 320.234f),
+ new PointF(310.9999f, 45.33333f),
+ new PointF(300f, 300.97f),
+ new PointF(48.18f, 62.54f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddLine_Int_Int_Int_Int()
+ {
+ path = new GraphicsPath ();
+
+ path.AddLine (20, 20, 10, 120);
+ Assert.AreEqual (2, path.PointCount);
+
+ path.AddLine (40, 320, 310, 45);
+ Assert.AreEqual (4, path.PointCount);
+
+ path.AddLine (300, 300, 48, 62);
+ Assert.AreEqual (6, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 20f),
+ new PointF(10f, 120f),
+ new PointF(40f, 320f),
+ new PointF(310f, 45f),
+ new PointF(300f, 300f),
+ new PointF(48f, 62f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddLine_Float_Float_Float_Float()
+ {
+ path = new GraphicsPath ();
+
+ path.AddLine (20.02f, 20.123f, 10.0001f, 120.23f);
+ Assert.AreEqual (2, path.PointCount);
+
+ path.AddLine (40.00f, 320.234f, 310.9999f, 45.33333333f);
+ Assert.AreEqual (4, path.PointCount);
+
+ path.AddLine (300f, 300.97f, 48.18f, 62.54f);
+ Assert.AreEqual (6, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20.02f, 20.123f),
+ new PointF(10.0001f, 120.23f),
+ new PointF(40f, 320.234f),
+ new PointF(310.9999f, 45.33333f),
+ new PointF(300f, 300.97f),
+ new PointF(48.18f, 62.54f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddLines_PointArr()
+ {
+ Point [] points = new Point [] {new Point(20, 100),
+ new Point(40, 75),
+ new Point(60, 125),
+ new Point(80, 100),
+ new Point(100, 50),
+ new Point(120, 150),
+ new Point(140, 100)};
+
+ path = new GraphicsPath();
+ path.AddLines(points);
+
+ Assert.AreEqual (7, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 100f),
+ new PointF(40f, 75f),
+ new PointF(60f, 125f),
+ new PointF(80f, 100f),
+ new PointF(100f, 50f),
+ new PointF(120f, 150f),
+ new PointF(140f, 100f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddLines_PointFArr()
+ {
+ PointF [] points = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ path = new GraphicsPath();
+ path.AddLines(points);
+
+ Assert.AreEqual (7, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddPath_GraphicsPath_Bool_1()
+ {
+ Point [] points1 = new Point [] { new Point (302, 302),
+ new Point (360, 360),
+ new Point (0, 460),
+ new Point (130, 230)};
+
+ GraphicsPath path1 = new GraphicsPath ();
+ path1.AddLines (points1);
+
+ Point [] points2 = { new Point (350, 350),
+ new Point (0, 0),
+ new Point (260, 100),
+ new Point (310, 30)};
+
+ path = new GraphicsPath ();
+ path.AddLines (points2);
+
+ path.AddPath (path1, true);
+
+ Assert.AreEqual (8, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(350f, 350f),
+ new PointF(0f, 0f),
+ new PointF(260f, 100f),
+ new PointF(310f, 30f),
+ new PointF(302f, 302f),
+ new PointF(360f, 360f),
+ new PointF(0f, 460f),
+ new PointF(130f, 230f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddPath_GraphicsPath_Bool_2()
+ {
+ Point [] points1 = new Point [] { new Point (302, 302),
+ new Point (360, 360),
+ new Point (0, 460),
+ new Point (130, 230)};
+
+ GraphicsPath path1 = new GraphicsPath ();
+ path1.AddLines (points1);
+
+ Point [] points2 = { new Point (350, 350),
+ new Point (0, 0),
+ new Point (260, 100),
+ new Point (310, 30)};
+
+ path = new GraphicsPath ();
+ path.AddLines (points2);
+
+ path.AddPath (path1, false);
+
+ Assert.AreEqual (8, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(350f, 350f),
+ new PointF(0f, 0f),
+ new PointF(260f, 100f),
+ new PointF(310f, 30f),
+ new PointF(302f, 302f),
+ new PointF(360f, 360f),
+ new PointF(0f, 460f),
+ new PointF(130f, 230f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddPie_Rectangle_Float_Float()
+ {
+ path = new GraphicsPath ();
+
+ path.AddPie (new Rectangle (20, 30, 350, 370), 10.34f, 240.15f);
+
+ Assert.AreEqual (11, path.PointCount);
+
+ path.AddPie (new Rectangle (150, 150, 170, 35), -45.001f, 135.87f);
+
+ Assert.AreEqual (19, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(195f, 215f),
+ new PointF(367.4504f, 246.4639f),
+ new PointF(351.0127f, 347.148f),
+ new PointF(260.4786f, 414.6818f),
+ new PointF(165.2368f, 397.3047f),
+ new PointF(69.99509f, 379.9277f),
+ new PointF(6.111823f, 284.2202f),
+ new PointF(22.54954f, 183.5361f),
+ new PointF(33.12234f, 118.7757f),
+ new PointF(75.40034f, 64.80574f),
+ new PointF(133.6162f, 41.75421f),
+ new PointF(235f, 167.5f),
+ new PointF(252.1399f, 150.3595f),
+ new PointF(298.1198f, 152.3084f),
+ new PointF(327.72f, 161.5623f),
+ new PointF(318.254f, 171.0288f),
+ new PointF(310.1f, 179.1831f),
+ new PointF(275.1718f, 185.0259f),
+ new PointF(234.7346f, 184.9999f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddPie_Int_Int_Int_Int_Float_Float()
+ {
+ path = new GraphicsPath ();
+
+ path.AddPie (20, 30, 350, 370, 10.34f, 240.15f);
+
+ Assert.AreEqual (11, path.PointCount);
+
+ path.AddPie (150, 150, 170, 35, -45.001f, 135.87f);
+
+ Assert.AreEqual (19, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(195f, 215f),
+ new PointF(367.4504f, 246.4639f),
+ new PointF(351.0127f, 347.148f),
+ new PointF(260.4786f, 414.6818f),
+ new PointF(165.2368f, 397.3047f),
+ new PointF(69.99509f, 379.9277f),
+ new PointF(6.111823f, 284.2202f),
+ new PointF(22.54954f, 183.5361f),
+ new PointF(33.12234f, 118.7757f),
+ new PointF(75.40034f, 64.80574f),
+ new PointF(133.6162f, 41.75421f),
+ new PointF(235f, 167.5f),
+ new PointF(252.1399f, 150.3595f),
+ new PointF(298.1198f, 152.3084f),
+ new PointF(327.72f, 161.5623f),
+ new PointF(318.254f, 171.0288f),
+ new PointF(310.1f, 179.1831f),
+ new PointF(275.1718f, 185.0259f),
+ new PointF(234.7346f, 184.9999f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddPie_Float_Float_Float_Float_Float_Float()
+ {
+ path = new GraphicsPath ();
+
+ path.AddPie (20f, 30.01f, 350.34f, 370.56f, 10.34f, 240.15f);
+
+ Assert.AreEqual (11, path.PointCount);
+
+ path.AddPie (150.23f, 150.12f, 170.99f, 35.098f, -45.001f, 135.87f);
+
+ Assert.AreEqual (19, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(195.17f, 215.29f),
+ new PointF(367.7906f, 246.785f),
+ new PointF(351.3456f, 347.623f),
+ new PointF(260.7293f, 415.2677f),
+ new PointF(165.3936f, 397.8735f),
+ new PointF(70.05784f, 380.4793f),
+ new PointF(6.104279f, 284.6331f),
+ new PointF(22.54932f, 183.7951f),
+ new PointF(33.12589f, 118.9412f),
+ new PointF(75.43399f, 64.88889f),
+ new PointF(133.6974f, 41.79355f),
+ new PointF(235.725f, 167.669f),
+ new PointF(252.9149f, 150.4784f),
+ new PointF(299.1682f, 152.4271f),
+ new PointF(328.9677f, 161.7033f),
+ new PointF(319.474f, 171.1974f),
+ new PointF(311.2924f, 179.3794f),
+ new PointF(276.1503f, 185.2439f),
+ new PointF(235.4589f, 185.2179f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddPolygon_PointArr()
+ {
+ Point [] points = new Point [] {new Point(20, 100),
+ new Point(40, 75),
+ new Point(60, 125),
+ new Point(80, 100),
+ new Point(100, 50),
+ new Point(120, 150),
+ new Point(140, 100)};
+
+ path = new GraphicsPath();
+ path.AddPolygon(points);
+
+ Assert.AreEqual (7, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 100f),
+ new PointF(40f, 75f),
+ new PointF(60f, 125f),
+ new PointF(80f, 100f),
+ new PointF(100f, 50f),
+ new PointF(120f, 150f),
+ new PointF(140f, 100f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddPolygon_PointFArr()
+ {
+ PointF [] points = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ path = new GraphicsPath();
+ path.AddPolygon(points);
+
+ Assert.AreEqual (7, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20.01f, 100.1f),
+ new PointF(40.02f, 75.2f),
+ new PointF(60.03f, 125.3f),
+ new PointF(80.04f, 100.4f),
+ new PointF(100.05f, 50.5f),
+ new PointF(120.06f, 150.6f),
+ new PointF(140.07f, 100.7f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddRectangle_Rectangle()
+ {
+ path = new GraphicsPath();
+ path.AddRectangle (new Rectangle(50, 50, 400, 80));
+
+ Assert.AreEqual (4, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(50f, 50f),
+ new PointF(450f, 50f),
+ new PointF(450f, 130f),
+ new PointF(50f, 130f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddRectangle_RectangleF()
+ {
+ path = new GraphicsPath();
+ path.AddRectangle (new RectangleF(50.1f, 50.4f, 400.12f, 80.123f));
+
+ Assert.AreEqual (4, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(50.1f, 50.4f),
+ new PointF(450.22f, 50.4f),
+ new PointF(450.22f, 130.523f),
+ new PointF(50.1f, 130.523f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddRectangles_RectangleArr()
+ {
+ path = new GraphicsPath();
+ Rectangle [] rectangles = new Rectangle [] {new Rectangle (50, 50, 400, 80),
+ new Rectangle (150, 150, 100, 400),
+ new Rectangle (0, 0, 200, 480),
+ new Rectangle (450, 450, 40, 80)};
+ path.AddRectangles (rectangles);
+
+ Assert.AreEqual (16, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(50f, 50f),
+ new PointF(450f, 50f),
+ new PointF(450f, 130f),
+ new PointF(50f, 130f),
+ new PointF(150f, 150f),
+ new PointF(250f, 150f),
+ new PointF(250f, 550f),
+ new PointF(150f, 550f),
+ new PointF(0f, 0f),
+ new PointF(200f, 0f),
+ new PointF(200f, 480f),
+ new PointF(0f, 480f),
+ new PointF(450f, 450f),
+ new PointF(490f, 450f),
+ new PointF(490f, 530f),
+ new PointF(450f, 530f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void AddRectangles_RectangleFArr()
+ {
+ path = new GraphicsPath();
+ RectangleF [] rectangles = new RectangleF [] { new RectangleF (50.10f, 50.11f, 400.1f, 80.15f),
+ new RectangleF (150f, 150.87f, 100.09f, 400.99f),
+ new RectangleF (0.123245f, 0.23f, 200.98f, 480.56f),
+ new RectangleF (450.3333333333f, 450.6666666f, 40.8f, 80.4f)};
+ path.AddRectangles (rectangles);
+
+ Assert.AreEqual (16, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(50.1f, 50.11f),
+ new PointF(450.2f, 50.11f),
+ new PointF(450.2f, 130.26f),
+ new PointF(50.1f, 130.26f),
+ new PointF(150f, 150.87f),
+ new PointF(250.09f, 150.87f),
+ new PointF(250.09f, 551.86f),
+ new PointF(150f, 551.86f),
+ new PointF(0.123245f, 0.23f),
+ new PointF(201.1032f, 0.23f),
+ new PointF(201.1032f, 480.79f),
+ new PointF(0.123245f, 480.79f),
+ new PointF(450.3333f, 450.6667f),
+ new PointF(491.1333f, 450.6667f),
+ new PointF(491.1333f, 531.0667f),
+ new PointF(450.3333f, 531.0667f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddString_String_FontFamily_Int_Float_Point_StringFormat()
+ {
+ path = new GraphicsPath();
+
+ string stringText = "System@Drawing";
+ FontFamily family = new FontFamily ("Arial");
+ int fontStyle = (int)FontStyle.Italic;
+ int emSize = 56;
+ Point origin = new Point (10, 120);
+ StringFormat format = StringFormat.GenericDefault;
+
+ path.AddString (stringText, family, fontStyle, emSize, origin, format);
+
+ Assert.AreEqual (939, path.PointCount);
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddString_String_FontFamily_Int_Float_PointF_StringFormat()
+ {
+ path = new GraphicsPath();
+
+ string stringText = "System@Drawing";
+ FontFamily family = new FontFamily ("Arial");
+ int fontStyle = (int)FontStyle.Italic;
+ int emSize = 56;
+ PointF origin = new PointF (10.15f, 120.01f);
+ StringFormat format = StringFormat.GenericDefault;
+
+ path.AddString (stringText, family, fontStyle, emSize, origin, format);
+
+ Assert.AreEqual (939, path.PointCount);
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddString_String_FontFamily_Int_Float_Rectangle_StringFormat()
+ {
+ path = new GraphicsPath();
+
+ string stringText = "System@Drawing";
+ FontFamily family = new FontFamily ("Arial");
+ int fontStyle = (int)FontStyle.Italic;
+ int emSize = 56;
+ Rectangle bound = new Rectangle (10, 120, 335, 50);
+ StringFormat format = StringFormat.GenericDefault;
+
+ path.AddString (stringText, family, fontStyle, emSize, bound, format);
+
+ Assert.AreEqual (657, path.PointCount);
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void AddString_String_FontFamily_Int_Float_RectangleFF_StringFormat()
+ {
+ path = new GraphicsPath();
+
+ string stringText = "System@Drawing";
+ FontFamily family = new FontFamily ("Arial");
+ int fontStyle = (int)FontStyle.Italic;
+ int emSize = 56;
+ RectangleF bound = new RectangleF (10f, 120.1f, 335.13f, 50.99f);
+ StringFormat format = StringFormat.GenericDefault;
+
+ path.AddString (stringText, family, fontStyle, emSize, bound, format);
+
+ Assert.AreEqual (657, path.PointCount);
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void ClearMarkers()
+ {
+ path = new GraphicsPath ();
+ path.AddEllipse (0, 0, 100, 200);
+ path.SetMarkers ();
+ path.AddLine (new Point (100, 100), new Point (200, 100));
+ Rectangle rect = new Rectangle (200, 0, 100, 200);
+ path.AddRectangle (rect);
+ path.SetMarkers ();
+ path.AddLine (new Point (250, 200), new Point (250, 300));
+ path.SetMarkers ();
+
+ path.ClearMarkers();
+
+ GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);
+ pathIterator.Rewind ();
+ int [] pointsNumber = new int [] {21, 0, 0, 0};
+ for (int i=0; i < 4; i ++) {
+ Assert.AreEqual (pointsNumber [i], pathIterator.NextMarker (path));
+ }
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void Clone()
+ {
+ path = new GraphicsPath ();
+ path.AddEllipse (0, 0, 100, 200);
+ path.SetMarkers ();
+ path.AddLine (new Point (100, 100), new Point (200, 100));
+ Rectangle rect = new Rectangle (200, 0, 100, 200);
+ path.AddRectangle (rect);
+ path.SetMarkers ();
+ path.AddLine (new Point (250, 200), new Point (250, 300));
+ path.SetMarkers ();
+
+ GraphicsPath cloned = (GraphicsPath) path.Clone ();
+
+ Assert.AreEqual (path.PointCount, cloned.PointCount);
+
+ for ( int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(path.PathPoints [i], cloned.PathPoints [i]);
+ Assert.AreEqual (path.PathTypes [i], cloned.PathTypes [i]);
+ }
+
+ GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);
+ pathIterator.Rewind ();
+
+ GraphicsPathIterator clonedIterator = new GraphicsPathIterator(cloned);
+ clonedIterator.Rewind ();
+
+ for (int i=0; i < 4; i ++) {
+ Assert.AreEqual (pathIterator.NextMarker (path), clonedIterator.NextMarker (cloned));
+ }
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void CloseAllFigures()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ Assert.AreEqual (14, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
+ new PointF(400f, 100f),
+ new PointF(400f, 200f),
+ new PointF(10f, 100f),
+ new PointF(10f, 10f),
+ new PointF(50f, 250f),
+ new PointF(100f, 5f),
+ new PointF(200f, 280f),
+ new PointF(10f, 20f),
+ new PointF(310f, 20f),
+ new PointF(310f, 420f),
+ new PointF(10f, 420f),
+ new PointF(400f, 400f),
+ new PointF(400f, 10f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ path.CloseAllFigures();
+
+ Assert.AreEqual (14, path.PointCount);
+
+ expectedPoints = new PointF [] { new PointF(100f, 100f),
+ new PointF(400f, 100f),
+ new PointF(400f, 200f),
+ new PointF(10f, 100f),
+ new PointF(10f, 10f),
+ new PointF(50f, 250f),
+ new PointF(100f, 5f),
+ new PointF(200f, 280f),
+ new PointF(10f, 20f),
+ new PointF(310f, 20f),
+ new PointF(310f, 420f),
+ new PointF(10f, 420f),
+ new PointF(400f, 400f),
+ new PointF(400f, 10f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void CloseFigure()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ Assert.AreEqual (14, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
+ new PointF(400f, 100f),
+ new PointF(400f, 200f),
+ new PointF(10f, 100f),
+ new PointF(10f, 10f),
+ new PointF(50f, 250f),
+ new PointF(100f, 5f),
+ new PointF(200f, 280f),
+ new PointF(10f, 20f),
+ new PointF(310f, 20f),
+ new PointF(310f, 420f),
+ new PointF(10f, 420f),
+ new PointF(400f, 400f),
+ new PointF(400f, 10f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ path.CloseFigure();
+
+ Assert.AreEqual (14, path.PointCount);
+
+ expectedPoints = new PointF [] { new PointF(100f, 100f),
+ new PointF(400f, 100f),
+ new PointF(400f, 200f),
+ new PointF(10f, 100f),
+ new PointF(10f, 10f),
+ new PointF(50f, 250f),
+ new PointF(100f, 5f),
+ new PointF(200f, 280f),
+ new PointF(10f, 20f),
+ new PointF(310f, 20f),
+ new PointF(310f, 420f),
+ new PointF(10f, 420f),
+ new PointF(400f, 400f),
+ new PointF(400f, 10f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Flatten()
+ {
+ path = new GraphicsPath ();
+ path.AddBezier( new Point (10, 10),
+ new Point (50, 250),
+ new Point (100, 5),
+ new Point (200, 280));
+
+ path.AddBezier( new Point (0, 210),
+ new Point (50, 6),
+ new Point (150, 150),
+ new Point (250, 10));
+
+ Assert.AreEqual (8, path.PointCount);
+
+ path.Flatten();
+
+ Assert.AreEqual (87, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(10f, 10f),
+ new PointF(11.875f, 20.875f),
+ new PointF(13.75f, 31.125f),
+ new PointF(15.6875f, 40.6875f),
+ new PointF(17.625f, 49.5625f),
+ new PointF(19.5625f, 57.875f),
+ new PointF(21.5625f, 65.5625f),
+ new PointF(23.5625f, 72.6875f),
+ new PointF(25.5625f, 79.25f),
+ new PointF(27.5625f, 85.25f),
+ new PointF(29.625f, 90.8125f),
+ new PointF(31.6875f, 95.875f),
+ new PointF(33.8125f, 100.5f),
+ new PointF(35.9375f, 104.625f),
+ new PointF(38.125f, 108.375f),
+ new PointF(40.3125f, 111.75f),
+ new PointF(42.5f, 114.75f),
+ new PointF(47f, 119.75f),
+ new PointF(51.625f, 123.5625f),
+ new PointF(56.4375f, 126.375f),
+ new PointF(61.3125f, 128.375f),
+ new PointF(66.375f, 129.75f),
+ new PointF(71.5625f, 130.6875f),
+ new PointF(82.5f, 131.875f),
+ new PointF(88.1875f, 132.5625f),
+ new PointF(94.125f, 133.5f),
+ new PointF(100.1875f, 134.9375f),
+ new PointF(106.5f, 137f),
+ new PointF(113f, 139.9375f),
+ new PointF(119.6875f, 143.875f),
+ new PointF(126.625f, 149f),
+ new PointF(130.125f, 152.0625f),
+ new PointF(133.75f, 155.5625f),
+ new PointF(137.4375f, 159.375f),
+ new PointF(141.125f, 163.6875f),
+ new PointF(144.9375f, 168.375f),
+ new PointF(148.75f, 173.5625f),
+ new PointF(152.6875f, 179.1875f),
+ new PointF(156.625f, 185.375f),
+ new PointF(160.6875f, 192.0625f),
+ new PointF(164.75f, 199.3125f),
+ new PointF(168.9375f, 207.125f),
+ new PointF(173.1875f, 215.5625f),
+ new PointF(177.4375f, 224.5625f),
+ new PointF(181.8125f, 234.3125f),
+ new PointF(186.25f, 244.625f),
+ new PointF(190.75f, 255.6875f),
+ new PointF(195.375f, 267.5f),
+ new PointF(200f, 280f),
+ new PointF(0f, 210f),
+ new PointF(2.375f, 200.6875f),
+ new PointF(4.8125f, 191.875f),
+ new PointF(7.375f, 183.5625f),
+ new PointF(9.9375f, 175.6875f),
+ new PointF(12.625f, 168.25f),
+ new PointF(15.3125f, 161.25f),
+ new PointF(18.125f, 154.75f),
+ new PointF(21f, 148.5625f),
+ new PointF(23.9375f, 142.8125f),
+ new PointF(26.9375f, 137.4375f),
+ new PointF(33.0625f, 127.8125f),
+ new PointF(39.4375f, 119.4375f),
+ new PointF(46.125f, 112.375f),
+ new PointF(52.9375f, 106.375f),
+ new PointF(60f, 101.4375f),
+ new PointF(67.25f, 97.3125f),
+ new PointF(74.6875f, 94f),
+ new PointF(82.3125f, 91.3125f),
+ new PointF(90.125f, 89.125f),
+ new PointF(98.125f, 87.4375f),
+ new PointF(106.25f, 86f),
+ new PointF(122.9375f, 83.625f),
+ new PointF(140.125f, 81f),
+ new PointF(148.9375f, 79.375f),
+ new PointF(157.75f, 77.3125f),
+ new PointF(166.75f, 74.8125f),
+ new PointF(175.8125f, 71.625f),
+ new PointF(184.875f, 67.75f),
+ new PointF(194.0625f, 62.9375f),
+ new PointF(203.3125f, 57.25f),
+ new PointF(212.625f, 50.4375f),
+ new PointF(221.9375f, 42.375f),
+ new PointF(231.25f, 33.0625f),
+ new PointF(235.9375f, 27.875f),
+ new PointF(240.625f, 22.3125f),
+ new PointF(245.3125f, 16.375f),
+ new PointF(250f, 10f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Flatten_Matrix()
+ {
+ path = new GraphicsPath ();
+ path.AddBezier( new Point (10, 10),
+ new Point (50, 250),
+ new Point (100, 5),
+ new Point (200, 280));
+
+ path.AddBezier( new Point (0, 210),
+ new Point (50, 6),
+ new Point (150, 150),
+ new Point (250, 10));
+
+ Assert.AreEqual (8, path.PointCount);
+
+ Matrix matrix = new Matrix();
+ matrix.Scale(2f,3f);
+ path.Flatten(matrix);
+
+ Assert.AreEqual (141, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 30f),
+ new PointF(21.875f, 46.625f),
+ new PointF(23.75f, 62.6875f),
+ new PointF(25.6875f, 78.25f),
+ new PointF(27.5625f, 93.3125f),
+ new PointF(29.5f, 107.875f),
+ new PointF(31.375f, 122f),
+ new PointF(33.3125f, 135.5625f),
+ new PointF(35.25f, 148.6875f),
+ new PointF(37.1875f, 161.3125f),
+ new PointF(39.125f, 173.5625f),
+ new PointF(41.125f, 185.3125f),
+ new PointF(43.0625f, 196.625f),
+ new PointF(45.0625f, 207.5f),
+ new PointF(47.0625f, 218f),
+ new PointF(49.0625f, 228f),
+ new PointF(51.125f, 237.6875f),
+ new PointF(53.125f, 246.9375f),
+ new PointF(55.1875f, 255.8125f),
+ new PointF(57.1875f, 264.3125f),
+ new PointF(59.25f, 272.4375f),
+ new PointF(63.4375f, 287.625f),
+ new PointF(67.625f, 301.375f),
+ new PointF(71.875f, 313.875f),
+ new PointF(76.1875f, 325.1875f),
+ new PointF(80.5625f, 335.25f),
+ new PointF(85f, 344.25f),
+ new PointF(89.5f, 352.25f),
+ new PointF(94f, 359.25f),
+ new PointF(98.625f, 365.375f),
+ new PointF(103.3125f, 370.6875f),
+ new PointF(108.0625f, 375.25f),
+ new PointF(112.8125f, 379.125f),
+ new PointF(117.6875f, 382.375f),
+ new PointF(122.6875f, 385.0625f),
+ new PointF(127.6875f, 387.3125f),
+ new PointF(132.75f, 389.125f),
+ new PointF(143.1875f, 391.875f),
+ new PointF(153.9375f, 393.75f),
+ new PointF(165f, 395.4375f),
+ new PointF(176.4375f, 397.375f),
+ new PointF(188.25f, 400.1875f),
+ new PointF(194.25f, 402.125f),
+ new PointF(200.375f, 404.4375f),
+ new PointF(206.625f, 407.25f),
+ new PointF(213f, 410.625f),
+ new PointF(219.4375f, 414.5625f),
+ new PointF(225.9375f, 419.3125f),
+ new PointF(232.625f, 424.75f),
+ new PointF(239.375f, 431.0625f),
+ new PointF(246.25f, 438.25f),
+ new PointF(253.1875f, 446.375f),
+ new PointF(260.3125f, 455.625f),
+ new PointF(267.5f, 465.9375f),
+ new PointF(274.8125f, 477.4375f),
+ new PointF(282.25f, 490.1875f),
+ new PointF(289.8125f, 504.25f),
+ new PointF(297.5f, 519.6875f),
+ new PointF(301.4375f, 527.9375f),
+ new PointF(305.3125f, 536.625f),
+ new PointF(309.3125f, 545.625f),
+ new PointF(313.25f, 555.0625f),
+ new PointF(317.3125f, 564.8125f),
+ new PointF(321.3125f, 575.0625f),
+ new PointF(325.4375f, 585.6875f),
+ new PointF(329.5625f, 596.75f),
+ new PointF(333.6875f, 608.25f),
+ new PointF(337.875f, 620.1875f),
+ new PointF(342.0625f, 632.5625f),
+ new PointF(346.3125f, 645.375f),
+ new PointF(350.625f, 658.6875f),
+ new PointF(354.9375f, 672.4375f),
+ new PointF(359.25f, 686.75f),
+ new PointF(363.625f, 701.5f),
+ new PointF(368.0625f, 716.75f),
+ new PointF(372.5f, 732.5f),
+ new PointF(377f, 748.8125f),
+ new PointF(381.5625f, 765.625f),
+ new PointF(386.125f, 782.9375f),
+ new PointF(390.6875f, 800.875f),
+ new PointF(395.3125f, 819.3125f),
+ new PointF(400f, 838.3125f),
+ new PointF(0f, 630f),
+ new PointF(2.375f, 615.875f),
+ new PointF(4.75f, 602.0625f),
+ new PointF(9.6875f, 575.625f),
+ new PointF(14.6875f, 550.625f),
+ new PointF(19.875f, 527f),
+ new PointF(25.25f, 504.75f),
+ new PointF(30.6875f, 483.8125f),
+ new PointF(36.25f, 464.1875f),
+ new PointF(42f, 445.75f),
+ new PointF(47.8125f, 428.5f),
+ new PointF(53.8125f, 412.375f),
+ new PointF(59.9375f, 397.3125f),
+ new PointF(66.125f, 383.375f),
+ new PointF(72.4375f, 370.375f),
+ new PointF(78.9375f, 358.375f),
+ new PointF(85.5f, 347.3125f),
+ new PointF(92.1875f, 337.125f),
+ new PointF(98.9375f, 327.75f),
+ new PointF(105.875f, 319.1875f),
+ new PointF(112.875f, 311.375f),
+ new PointF(119.9375f, 304.25f),
+ new PointF(127.1875f, 297.8125f),
+ new PointF(134.4375f, 291.9375f),
+ new PointF(141.875f, 286.6875f),
+ new PointF(149.3125f, 281.9375f),
+ new PointF(156.9375f, 277.6875f),
+ new PointF(164.5625f, 273.875f),
+ new PointF(172.375f, 270.5f),
+ new PointF(180.1875f, 267.4375f),
+ new PointF(196.125f, 262.25f),
+ new PointF(212.3125f, 258f),
+ new PointF(228.875f, 254.3125f),
+ new PointF(245.625f, 250.8125f),
+ new PointF(262.6875f, 247.125f),
+ new PointF(279.9375f, 243.0625f),
+ new PointF(297.4375f, 238.125f),
+ new PointF(306.25f, 235.25f),
+ new PointF(315.125f, 232f),
+ new PointF(324f, 228.375f),
+ new PointF(333f, 224.375f),
+ new PointF(342f, 219.875f),
+ new PointF(351f, 214.875f),
+ new PointF(360.0625f, 209.3125f),
+ new PointF(369.1875f, 203.1875f),
+ new PointF(378.3125f, 196.375f),
+ new PointF(387.4375f, 188.875f),
+ new PointF(396.625f, 180.6875f),
+ new PointF(405.8125f, 171.6875f),
+ new PointF(415.0625f, 161.9375f),
+ new PointF(424.3125f, 151.25f),
+ new PointF(433.5625f, 139.6875f),
+ new PointF(442.8125f, 127.25f),
+ new PointF(452.125f, 113.75f),
+ new PointF(461.4375f, 99.25f),
+ new PointF(470.75f, 83.625f),
+ new PointF(480.0625f, 66.9375f),
+ new PointF(489.375f, 49.0625f),
+ new PointF(498.6875f, 30f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Flatten_Matrix_Float()
+ {
+ path = new GraphicsPath ();
+ path.AddBezier( new Point (10, 10),
+ new Point (50, 250),
+ new Point (100, 5),
+ new Point (200, 280));
+
+ Assert.AreEqual (4, path.PointCount);
+
+ Matrix matrix = new Matrix();
+ matrix.Scale(2f,3f);
+ path.Flatten(matrix, 0.1f);
+
+ Assert.AreEqual (78, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(20f, 30f),
+ new PointF(21.875f, 46.6f),
+ new PointF(23.775f, 62.7f),
+ new PointF(25.65f, 78.27499f),
+ new PointF(27.55f, 93.325f),
+ new PointF(29.475f, 107.9f),
+ new PointF(31.4f, 121.975f),
+ new PointF(33.325f, 135.575f),
+ new PointF(35.25f, 148.675f),
+ new PointF(37.2f, 161.35f),
+ new PointF(39.15f, 173.55f),
+ new PointF(41.125f, 185.3f),
+ new PointF(43.1f, 196.625f),
+ new PointF(45.075f, 207.5f),
+ new PointF(47.075f, 217.975f),
+ new PointF(49.075f, 228.025f),
+ new PointF(51.1f, 237.675f),
+ new PointF(55.15f, 255.825f),
+ new PointF(59.275f, 272.425f),
+ new PointF(63.425f, 287.6f),
+ new PointF(67.625f, 301.425f),
+ new PointF(71.89999f, 313.925f),
+ new PointF(76.2f, 325.2f),
+ new PointF(80.575f, 335.3f),
+ new PointF(85f, 344.3f),
+ new PointF(89.475f, 352.275f),
+ new PointF(94.02499f, 359.3f),
+ new PointF(98.625f, 365.425f),
+ new PointF(103.3f, 370.75f),
+ new PointF(108.025f, 375.3f),
+ new PointF(112.85f, 379.175f),
+ new PointF(117.7f, 382.45f),
+ new PointF(122.65f, 385.175f),
+ new PointF(127.675f, 387.4f),
+ new PointF(132.775f, 389.25f),
+ new PointF(143.175f, 392f),
+ new PointF(153.925f, 393.925f),
+ new PointF(165f, 395.625f),
+ new PointF(176.425f, 397.625f),
+ new PointF(188.225f, 400.5f),
+ new PointF(194.25f, 402.425f),
+ new PointF(200.4f, 404.775f),
+ new PointF(206.625f, 407.6f),
+ new PointF(212.975f, 411f),
+ new PointF(219.4f, 415.025f),
+ new PointF(225.95f, 419.75f),
+ new PointF(232.6f, 425.25f),
+ new PointF(239.35f, 431.575f),
+ new PointF(246.225f, 438.825f),
+ new PointF(253.2f, 447.025f),
+ new PointF(260.3f, 456.275f),
+ new PointF(267.5f, 466.65f),
+ new PointF(274.825f, 478.175f),
+ new PointF(282.275f, 490.975f),
+ new PointF(289.825f, 505.1f),
+ new PointF(297.525f, 520.6f),
+ new PointF(305.325f, 537.55f),
+ new PointF(313.275f, 556.05f),
+ new PointF(317.275f, 565.875f),
+ new PointF(321.325f, 576.125f),
+ new PointF(325.425f, 586.775f),
+ new PointF(329.525f, 597.85f),
+ new PointF(333.675f, 609.375f),
+ new PointF(337.85f, 621.35f),
+ new PointF(342.075f, 633.75f),
+ new PointF(346.325f, 646.625f),
+ new PointF(350.6f, 659.95f),
+ new PointF(354.925f, 673.775f),
+ new PointF(359.275f, 688.075f),
+ new PointF(363.65f, 702.85f),
+ new PointF(368.075f, 718.15f),
+ new PointF(372.525f, 733.95f),
+ new PointF(377.025f, 750.275f),
+ new PointF(381.55f, 767.125f),
+ new PointF(386.1f, 784.525f),
+ new PointF(390.7f, 802.45f),
+ new PointF(395.325f, 820.95f),
+ new PointF(400f, 840f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void GetBounds()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ RectangleF actual = path.GetBounds ();
+ RectangleF expected = new RectangleF (10f, 5f, 390f, 415f);
+
+ DrawingTest.AssertAlmostEqual(expected.X, actual.X);
+ DrawingTest.AssertAlmostEqual(expected.Y, actual.Y);
+ DrawingTest.AssertAlmostEqual(expected.Width, actual.Width);
+ DrawingTest.AssertAlmostEqual(expected.Height, actual.Height);
+
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void GetBounds_Matrix()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ Matrix matrix = new Matrix ();
+ matrix.Scale (1.2f,1.3f);
+ matrix.Shear (1.5f, 1.9f);
+
+ RectangleF actual = path.GetBounds (matrix);
+ RectangleF expected = new RectangleF (21f, 31.2f, 1215f, 1502.8f);
+
+ DrawingTest.AssertAlmostEqual(expected.X, actual.X);
+ DrawingTest.AssertAlmostEqual(expected.Y, actual.Y);
+ DrawingTest.AssertAlmostEqual(expected.Width, actual.Width);
+ DrawingTest.AssertAlmostEqual(expected.Height, actual.Height);
+
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void GetBounds_Matrix_Pen()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ Matrix matrix = new Matrix ();
+ matrix.Scale (0.2f,0.3f);
+ matrix.Shear (0.5f, 0.5f);
+
+ Pen p = new Pen (Color.AliceBlue, 45);
+
+ RectangleF actual = path.GetBounds (matrix, p);
+ RectangleF expected = new RectangleF (21f, 31.2f, 2758.363f, 3046.163f);
+
+ // we do not know exacly how the bounding rectangle
+ // is calculated so we just want to obtain bounds
+ // that still contain the path widened by oen and transformed by matrix
+ path.Widen (p, matrix);
+ RectangleF widened = path.GetBounds ();
+ Assert.IsTrue (actual.Contains (widened));
+
+// DrawingTest.AssertAlmostEqual(expected.X, actual.X);
+// DrawingTest.AssertAlmostEqual(expected.Y, actual.Y);
+// DrawingTest.AssertAlmostEqual(expected.Width, actual.Width);
+// DrawingTest.AssertAlmostEqual(expected.Height, actual.Height);
+
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ p = new Pen (Color.AliceBlue, 45);
+ p.DashCap = DashCap.Triangle;
+ p.DashStyle = DashStyle.Dash;
+
+ actual = path.GetBounds (matrix, p);
+ expected = new RectangleF (21f, 31.2f, 2758.363f, 3046.163f);
+
+ // we do not know exacly how the bounding rectangle
+ // is calculated so we just want to obtain bounds
+ // that still contain the path widened by oen and transformed by matrix
+ path.Widen (p, matrix);
+ widened = path.GetBounds ();
+ Assert.IsTrue (actual.Contains (widened));
+
+// DrawingTest.AssertAlmostEqual(expected.X, actual.X);
+// DrawingTest.AssertAlmostEqual(expected.Y, actual.Y);
+// DrawingTest.AssertAlmostEqual(expected.Width, actual.Width);
+// DrawingTest.AssertAlmostEqual(expected.Height, actual.Height);
+
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void GetLastPoint()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ PointF expected = new PointF (10f, 100f);
+ PointF actual = path.GetLastPoint ();
+
+ DrawingTest.AssertAlmostEqual(expected, actual);
+
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ expected = new PointF (10f, 420f);
+ actual = path.GetLastPoint ();
+
+ DrawingTest.AssertAlmostEqual(expected, actual);
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ expected = new PointF (400f, 10f);
+ actual = path.GetLastPoint ();
+
+ DrawingTest.AssertAlmostEqual(expected, actual);
+
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void GetLastPoint2()
+ {
+ path = new GraphicsPath ();
+
+ PointF actual = path.GetLastPoint ();
+ }
+
+ [Test]
+ public void IsOutlineVisible_Float_Float_Pen()
+ {
+ path = new GraphicsPath ();
+ path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
+
+ path.StartFigure();
+ path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));
+
+ Pen pen = new Pen (Color.Red, 5);
+
+ Assert.IsFalse (path.IsOutlineVisible (0f, 0f, pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (40f, 40f, pen));
+
+ Assert.IsTrue (path.IsOutlineVisible (9f, 9f, pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (400f, 400f, pen));
+
+ Assert.IsTrue (path.IsOutlineVisible (312f, 312f, pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (313f, 313f, pen));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsOutlineVisible_PointF_Pen()
+ {
+ path = new GraphicsPath ();
+ path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
+
+ path.StartFigure();
+ path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));
+
+ Pen pen = new Pen (Color.Red, 5);
+
+ Assert.IsFalse (path.IsOutlineVisible (new PointF (0f, 0f), pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (new PointF (40f, 40f), pen));
+
+ Assert.IsTrue (path.IsOutlineVisible (new PointF (9f, 9f), pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (new PointF (400f, 400f), pen));
+
+ Assert.IsTrue (path.IsOutlineVisible (new PointF (312f, 312f), pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (new PointF (313f, 313f), pen));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsOutlineVisible_Float_Float_Pen_Graphics()
+ {
+ path = new GraphicsPath ();
+ path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
+
+ path.StartFigure();
+ path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));
+
+ Pen pen = new Pen (Color.Red, 5);
+ Graphics gr = Graphics.FromImage (new Bitmap (512, 512));
+ gr.Clip = new Region (new Rectangle ( 5, 5, 500, 50));
+
+ Assert.IsFalse (path.IsOutlineVisible (0f, 0f, pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (40f, 40f, pen, gr));
+
+ Assert.IsTrue (path.IsOutlineVisible (9f, 9f, pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (400f, 400f, pen, gr));
+
+ Assert.IsTrue (path.IsOutlineVisible (312f, 312f, pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (313f, 313f, pen, gr));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsOutlineVisible_PointF_Pen_Graphics()
+ {
+ path = new GraphicsPath ();
+ path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
+
+ path.StartFigure();
+ path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));
+
+ Pen pen = new Pen (Color.Red, 5);
+ Graphics gr = Graphics.FromImage (new Bitmap (512, 512));
+ gr.Clip = new Region (new Rectangle ( 5, 5, 500, 50));
+
+ Assert.IsFalse (path.IsOutlineVisible (new PointF (0f, 0f), pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (new PointF (40f, 40f), pen, gr));
+
+ Assert.IsTrue (path.IsOutlineVisible (new PointF (9f, 9f), pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (new PointF (400f, 400f), pen, gr));
+
+ Assert.IsTrue (path.IsOutlineVisible (new PointF (312f, 312f), pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (new PointF (313f, 313f), pen, gr));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsOutlineVisible_Int_Int_Pen()
+ {
+ path = new GraphicsPath ();
+ path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
+
+ path.StartFigure();
+ path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));
+
+ Pen pen = new Pen (Color.Red, 5);
+
+ Assert.IsFalse (path.IsOutlineVisible (0, 0, pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (40, 40, pen));
+
+ Assert.IsTrue (path.IsOutlineVisible (9, 9, pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (400, 400, pen));
+
+ Assert.IsTrue (path.IsOutlineVisible (312, 312, pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (313, 313, pen));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsOutlineVisible_Point_Pen()
+ {
+ path = new GraphicsPath ();
+ path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
+
+ path.StartFigure();
+ path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));
+
+ Pen pen = new Pen (Color.Red, 5);
+
+ Assert.IsFalse (path.IsOutlineVisible (new Point (0, 0), pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (new Point (40, 40), pen));
+
+ Assert.IsTrue (path.IsOutlineVisible (new Point (9, 9), pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (new Point (400, 400), pen));
+
+ Assert.IsTrue (path.IsOutlineVisible (new Point (312, 312), pen));
+
+ Assert.IsFalse (path.IsOutlineVisible (new Point (313, 313), pen));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsOutlineVisible_Int_Int_Pen_Graphics()
+ {
+ path = new GraphicsPath ();
+ path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
+
+ path.StartFigure();
+ path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));
+
+ Pen pen = new Pen (Color.Red, 5);
+ Graphics gr = Graphics.FromImage (new Bitmap (512, 512));
+ gr.Clip = new Region (new Rectangle ( 5, 5, 500, 50));
+
+ Assert.IsFalse (path.IsOutlineVisible (0, 0, pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (40, 40, pen, gr));
+
+ Assert.IsTrue (path.IsOutlineVisible (9, 9, pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (400, 400, pen, gr));
+
+ Assert.IsTrue (path.IsOutlineVisible (312, 312, pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (313, 313, pen, gr));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsOutlineVisible_Point_Pen_Graphics()
+ {
+ path = new GraphicsPath ();
+ path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
+
+ path.StartFigure();
+ path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));
+
+ Pen pen = new Pen (Color.Red, 5);
+ Graphics gr = Graphics.FromImage (new Bitmap (512, 512));
+ gr.Clip = new Region (new Rectangle ( 5, 5, 500, 50));
+
+ Assert.IsFalse (path.IsOutlineVisible (new Point (0, 0), pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (new Point (40, 40), pen, gr));
+
+ Assert.IsTrue (path.IsOutlineVisible (new Point (9, 9), pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (new Point (400, 400), pen, gr));
+
+ Assert.IsTrue (path.IsOutlineVisible (new Point (312, 312), pen, gr));
+
+ Assert.IsFalse (path.IsOutlineVisible (new Point (313, 313), pen, gr));
+
+ Assert.IsTrue (path.IsOutlineVisible (new Point (310, 10), pen, gr));
+ Assert.IsTrue (path.IsOutlineVisible (new Point (310, 10), pen, null));
+
+ Assert.IsTrue (path.IsOutlineVisible (new Point (310, 210), pen, gr));
+ Assert.IsTrue (path.IsOutlineVisible (new Point (310, 210), pen, null));
+
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void IsVisible_Float_Float()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (10, 10, 400, 10);
+ path.AddLine (400, 10, 10, 400);
+ path.AddLine (10, 400, 400, 400);
+ path.CloseFigure();
+
+ Assert.IsFalse (path.IsVisible (9f, 9f));
+
+ Assert.IsTrue (path.IsVisible (10f, 10f));
+
+ Assert.IsFalse (path.IsVisible (400f, 400f));
+
+ Assert.IsTrue (path.IsVisible (397f, 399f));
+
+ Assert.IsFalse (path.IsVisible (399f, 397f));
+
+ Assert.IsTrue (path.IsVisible (190f, 190f));
+
+ Assert.IsFalse (path.IsVisible (50f, 190f));
+
+ Assert.IsTrue (path.IsVisible (190f, 50f));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsVisible_PointF()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (10, 10, 400, 10);
+ path.AddLine (400, 10, 10, 400);
+ path.AddLine (10, 400, 400, 400);
+ path.CloseFigure();
+
+ Assert.IsFalse (path.IsVisible (new PointF (9f, 9f)));
+
+ Assert.IsTrue (path.IsVisible (new PointF (10f, 10f)));
+
+ Assert.IsFalse (path.IsVisible (new PointF (400f, 400f)));
+
+ Assert.IsTrue (path.IsVisible (new PointF (397f, 399f)));
+
+ Assert.IsFalse (path.IsVisible (new PointF (399f, 397f)));
+
+ Assert.IsTrue (path.IsVisible (new PointF (190f, 190f)));
+
+ Assert.IsFalse (path.IsVisible (new PointF (50f, 190f)));
+
+ Assert.IsTrue (path.IsVisible (new PointF (190f, 50f)));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsVisible_Float_Float_Graphics()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (10, 10, 400, 10);
+ path.AddLine (400, 10, 10, 400);
+ path.AddLine (10, 400, 400, 400);
+ path.CloseFigure();
+
+ Graphics gr = Graphics.FromImage (new Bitmap (500, 100));
+ gr.Clip = new Region (new Rectangle(0, 0, 50, 50));
+
+ Assert.IsFalse (path.IsVisible (9f, 9f, gr));
+
+ Assert.IsTrue (path.IsVisible (10f, 10f, gr));
+
+ Assert.IsFalse (path.IsVisible (400f, 400f, gr));
+
+ Assert.IsTrue (path.IsVisible (397f, 399f, gr));
+
+ Assert.IsFalse (path.IsVisible (399f, 397f, gr));
+
+ Assert.IsTrue (path.IsVisible (190f, 190f, gr));
+
+ Assert.IsFalse (path.IsVisible (50f, 190f, gr));
+
+ Assert.IsTrue (path.IsVisible (190f, 50f, gr));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsVisible_PointF_Graphics()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (10, 10, 400, 10);
+ path.AddLine (400, 10, 10, 400);
+ path.AddLine (10, 400, 400, 400);
+ path.CloseFigure();
+
+ Graphics gr = Graphics.FromImage (new Bitmap (500, 100));
+ gr.Clip = new Region (new Rectangle(0, 0, 50, 50));
+
+ Assert.IsFalse (path.IsVisible (new PointF (9f, 9f), gr));
+
+ Assert.IsTrue (path.IsVisible (new PointF (10f, 10f), gr));
+
+ Assert.IsFalse (path.IsVisible (new PointF (400f, 400f), gr));
+
+ Assert.IsTrue (path.IsVisible (new PointF (397f, 399f), gr));
+
+ Assert.IsFalse (path.IsVisible (new PointF (399f, 397f), gr));
+
+ Assert.IsTrue (path.IsVisible (new PointF (190f, 190f), gr));
+
+ Assert.IsFalse (path.IsVisible (new PointF (50f, 190f), gr));
+
+ Assert.IsTrue (path.IsVisible (new PointF (190f, 50f), gr));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsVisible_Int_Int()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (10, 10, 400, 10);
+ path.AddLine (400, 10, 10, 400);
+ path.AddLine (10, 400, 400, 400);
+ path.CloseFigure();
+
+ Assert.IsFalse (path.IsVisible (9, 9));
+
+ Assert.IsTrue (path.IsVisible (10, 10));
+
+ Assert.IsFalse (path.IsVisible (400, 400));
+
+ Assert.IsTrue (path.IsVisible (397, 399));
+
+ Assert.IsFalse (path.IsVisible (399, 397));
+
+ Assert.IsTrue (path.IsVisible (190, 190));
+
+ Assert.IsFalse (path.IsVisible (50, 190));
+
+ Assert.IsTrue (path.IsVisible (190, 50));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsVisible_Point()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (10, 10, 400, 10);
+ path.AddLine (400, 10, 10, 400);
+ path.AddLine (10, 400, 400, 400);
+ path.CloseFigure();
+
+ Assert.IsFalse (path.IsVisible (new Point (9, 9)));
+
+ Assert.IsTrue (path.IsVisible (new Point (10, 10)));
+
+ Assert.IsFalse (path.IsVisible (new Point (400, 400)));
+
+ Assert.IsTrue (path.IsVisible (new Point (397, 399)));
+
+ Assert.IsFalse (path.IsVisible (new Point (399, 397)));
+
+ Assert.IsTrue (path.IsVisible (new Point (190, 190)));
+
+ Assert.IsFalse (path.IsVisible (new Point (50, 190)));
+
+ Assert.IsTrue (path.IsVisible (new Point (190, 50)));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsVisible_Int_Int_Graphics()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (10, 10, 400, 10);
+ path.AddLine (400, 10, 10, 400);
+ path.AddLine (10, 400, 400, 400);
+ path.CloseFigure();
+
+ Graphics gr = Graphics.FromImage (new Bitmap (500, 100));
+ gr.Clip = new Region (new Rectangle(0, 0, 50, 50));
+
+ Assert.IsFalse (path.IsVisible (9, 9, gr));
+
+ Assert.IsTrue (path.IsVisible (10, 10, gr));
+
+ Assert.IsFalse (path.IsVisible (400, 400, gr));
+
+ Assert.IsTrue (path.IsVisible (397, 399, gr));
+
+ Assert.IsFalse (path.IsVisible (399, 397, gr));
+
+ Assert.IsTrue (path.IsVisible (190, 190, gr));
+
+ Assert.IsFalse (path.IsVisible (50, 190, gr));
+
+ Assert.IsTrue (path.IsVisible (190, 50));
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void IsVisible_Point_Graphics()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (10, 10, 400, 10);
+ path.AddLine (400, 10, 10, 400);
+ path.AddLine (10, 400, 400, 400);
+ path.CloseFigure();
+
+ Graphics gr = Graphics.FromImage (new Bitmap (500, 100));
+ gr.Clip = new Region (new Rectangle(0, 0, 50, 50));
+
+ Assert.IsFalse (path.IsVisible (new Point (9, 9), gr));
+
+ Assert.IsTrue (path.IsVisible (new Point (10, 10), gr));
+
+ Assert.IsFalse (path.IsVisible (new Point (400, 400), gr));
+
+ Assert.IsTrue (path.IsVisible (new Point (397, 399), gr));
+
+ Assert.IsFalse (path.IsVisible (new Point (399, 397), gr));
+
+ Assert.IsTrue (path.IsVisible (new Point (190, 190), gr));
+
+ Assert.IsFalse (path.IsVisible (new Point (50, 190), gr));
+
+ Assert.IsTrue (path.IsVisible (new Point (190, 50), gr));
+
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void PathData ()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
+ new PointF(400f, 100f),
+ new PointF(400f, 200f),
+ new PointF(10f, 100f),
+ new PointF(10f, 10f),
+ new PointF(50f, 250f),
+ new PointF(100f, 5f),
+ new PointF(200f, 280f),
+ new PointF(10f, 20f),
+ new PointF(310f, 20f),
+ new PointF(310f, 420f),
+ new PointF(10f, 420f),
+ new PointF(400f, 400f),
+ new PointF(400f, 10f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+
+ path = new GraphicsPath ();
+ path.AddEllipse (0, 0, 100, 200);
+ path.SetMarkers ();
+ path.AddLine (new Point (100, 100), new Point (200, 100));
+ Rectangle rect = new Rectangle (200, 0, 100, 200);
+ path.AddRectangle (rect);
+ path.SetMarkers ();
+ path.AddLine (new Point (250, 200), new Point (250, 300));
+ path.SetMarkers ();
+
+ expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) (PathPointType.Line | PathPointType.PathMarker) };
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+ }
+
+ [Test]
+ public void PathData2 ()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ byte [] types = path.PathTypes;
+ PointF [] points = path.PathPoints;
+
+ types [1] = 88;
+ points [1] = new PointF (-88, -88);
+
+ Assert.AreEqual ( 88, types [1]);
+ DrawingTest.AssertAlmostEqual ( new PointF (-88,-88), points [1]);
+
+ Assert.AreEqual ( 1, path.PathData.Types [1]);
+ DrawingTest.AssertAlmostEqual ( new PointF (400,100), path.PathData.Points [1]);
+ }
+
+ [Test]
+ public void Reset()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ path.Reset ();
+
+ Assert.AreEqual (0, path.PointCount);
+ Assert.AreEqual (FillMode.Alternate, path.FillMode);
+
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+ public void Reverse()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.SetMarkers ();
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.SetMarkers ();
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+ path.AddLine (new Point (400, 450), new Point (500, 510));
+ path.SetMarkers ();
+ path.CloseFigure ();
+
+ path.Reverse ();
+
+ PointF [] expectedPoints = new PointF [] { new PointF(500f, 510f),
+ new PointF(400f, 450f),
+ new PointF(400f, 10f),
+ new PointF(400f, 400f),
+ new PointF(10f, 420f),
+ new PointF(310f, 420f),
+ new PointF(310f, 20f),
+ new PointF(10f, 20f),
+ new PointF(200f, 280f),
+ new PointF(100f, 5f),
+ new PointF(50f, 250f),
+ new PointF(10f, 10f),
+ new PointF(10f, 100f),
+ new PointF(400f, 200f),
+ new PointF(400f, 100f),
+ new PointF(100f, 100f)};
+
+
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) (PathPointType.Line | PathPointType.PathMarker),
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void Reverse2()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.SetMarkers ();
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.SetMarkers ();
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+ path.AddBezier( 100, 100, 500, 250, 150, 500, 250, 300);
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 450), new Point (500, 510));
+ path.SetMarkers ();
+ path.CloseFigure ();
+
+ path.Reverse ();
+
+ PointF [] expectedPoints = new PointF [] { new PointF(500f, 510f),
+ new PointF(400f, 450f),
+ new PointF(250f, 300f),
+ new PointF(150f, 500f),
+ new PointF(500f, 250f),
+ new PointF(100f, 100f),
+ new PointF(400f, 10f),
+ new PointF(400f, 400f),
+ new PointF(10f, 420f),
+ new PointF(310f, 420f),
+ new PointF(310f, 20f),
+ new PointF(10f, 20f),
+ new PointF(200f, 280f),
+ new PointF(100f, 5f),
+ new PointF(50f, 250f),
+ new PointF(10f, 10f),
+ new PointF(10f, 100f),
+ new PointF(400f, 200f),
+ new PointF(400f, 100f),
+ new PointF(100f, 100f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) (PathPointType.Line | PathPointType.PathMarker),
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) (PathPointType.Line | PathPointType.PathMarker),
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void SetMarkers()
+ {
+ path = new GraphicsPath ();
+ path.AddEllipse (0, 0, 100, 200);
+ path.SetMarkers ();
+ path.AddLine (new Point (100, 100), new Point (200, 100));
+ Rectangle rect = new Rectangle (200, 0, 100, 200);
+ path.AddRectangle (rect);
+ path.SetMarkers ();
+ path.AddLine (new Point (250, 200), new Point (250, 300));
+ path.SetMarkers ();
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) (PathPointType.Line | PathPointType.PathMarker) };
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void StartFigure()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ path.StartFigure();
+
+ Assert.AreEqual (14, path.PointCount);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
+ new PointF(400f, 100f),
+ new PointF(400f, 200f),
+ new PointF(10f, 100f),
+ new PointF(10f, 10f),
+ new PointF(50f, 250f),
+ new PointF(100f, 5f),
+ new PointF(200f, 280f),
+ new PointF(10f, 20f),
+ new PointF(310f, 20f),
+ new PointF(310f, 420f),
+ new PointF(10f, 420f),
+ new PointF(400f, 400f),
+ new PointF(400f, 10f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ //t.AssertCompare ();
+ }
+
+ [Test]
+ public void Transform_Matrix()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (200, 100));
+ path.AddLine (new Point (200, 200), new Point (10, 100));
+
+ path.StartFigure();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 200, 200));
+
+ path.StartFigure();
+ path.AddLine (new Point (200, 200), new Point (200, 10));
+
+ Matrix matrix = new Matrix ();
+ matrix.Scale (1.2f, 1.4f);
+ matrix.Shear (0.9f, -1.15f);
+ matrix.Rotate (5);
+
+ path.Transform (matrix);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(226.0865f, 5.313778f),
+ new PointF(355.0427f, -142.8718f),
+ new PointF(452.173f, 10.62756f),
+ new PointF(110.0259f, 138.6808f),
+ new PointF(22.60865f, 0.5313778f),
+ new PointF(307.3039f, 309.6555f),
+ new PointF(133.8127f, -140.5106f),
+ new PointF(529.8773f, 133.427f),
+ new PointF(32.32168f, 15.88131f),
+ new PointF(290.234f, -280.4898f),
+ new PointF(484.4947f, 26.50887f),
+ new PointF(226.5823f, 322.8799f),
+ new PointF(452.173f, 10.62756f),
+ new PointF(267.6254f, -281.0212f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Warp_PointFArr_RectangleF()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (200, 100));
+ path.AddLine (new Point (200, 200), new Point (10, 100));
+
+ path.StartFigure();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 200, 200));
+
+ path.StartFigure();
+ path.AddLine (new Point (200, 200), new Point (200, 10));
+
+ RectangleF rectangle = new RectangleF (0f, 0f, 40f, 40f);
+ PointF [] warp = new PointF [] { new PointF (0f, 0f),
+ new PointF (50f, 50f),
+ new PointF (20f, 40f)};
+
+ path.Warp (warp, rectangle);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(175f, 225f),
+ new PointF(300f, 350f),
+ new PointF(350f, 450f),
+ new PointF(62.5f, 112.5f),
+ new PointF(17.5f, 22.5f),
+ new PointF(71.54785f, 111.1621f),
+ new PointF(110.5078f, 167.8906f),
+ new PointF(140.8545f, 205.0488f),
+ new PointF(169.0625f, 235f),
+ new PointF(201.6064f, 270.1074f),
+ new PointF(244.9609f, 322.7344f),
+ new PointF(305.6006f, 405.2441f),
+ new PointF(390f, 530f),
+ new PointF(22.5f, 32.5f),
+ new PointF(272.5f, 282.5f),
+ new PointF(372.5f, 482.5f),
+ new PointF(122.5f, 232.5f),
+ new PointF(350f, 450f),
+ new PointF(255f, 260f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Warp_PointFArr_RectangleF_Matrix()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (200, 100));
+ path.AddLine (new Point (200, 200), new Point (10, 100));
+
+ path.StartFigure();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 200, 200));
+
+ path.StartFigure();
+ path.AddLine (new Point (200, 200), new Point (200, 10));
+
+ RectangleF rectangle = new RectangleF (0f, 0f, 40f, 40f);
+ PointF [] warp = new PointF [] { new PointF (0f, 0f),
+ new PointF (50f, 50f),
+ new PointF (20f, 40f)};
+
+ Matrix matrix = new Matrix();
+ matrix.Scale(1.5f, 0.5f);
+
+ path.Warp (warp, rectangle, matrix);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(262.5f, 112.5f),
+ new PointF(450f, 175f),
+ new PointF(525f, 225f),
+ new PointF(93.75f, 56.25f),
+ new PointF(26.25f, 11.25f),
+ new PointF(107.3218f, 55.58105f),
+ new PointF(165.7617f, 83.94531f),
+ new PointF(211.2817f, 102.5244f),
+ new PointF(253.5938f, 117.5f),
+ new PointF(302.4097f, 135.0537f),
+ new PointF(367.4414f, 161.3672f),
+ new PointF(458.4009f, 202.6221f),
+ new PointF(585f, 265f),
+ new PointF(33.75f, 16.25f),
+ new PointF(408.75f, 141.25f),
+ new PointF(558.75f, 241.25f),
+ new PointF(183.75f, 116.25f),
+ new PointF(525f, 225f),
+ new PointF(382.5f, 130f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Warp_PointFArr_RectangleF_Matrix_WarpMode()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (200, 100));
+ path.AddLine (new Point (200, 200), new Point (10, 100));
+
+ path.StartFigure();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 200, 200));
+
+ path.StartFigure();
+ path.AddLine (new Point (200, 200), new Point (200, 10));
+
+ RectangleF rectangle = new RectangleF (0f, 0f, 40f, 40f);
+ PointF [] warp = new PointF [] { new PointF (0f, 0f),
+ new PointF (50f, 50f),
+ new PointF (20f, 40f)};
+
+ Matrix matrix = new Matrix();
+ matrix.Scale(1.5f, 0.5f);
+
+ path.Warp (warp, rectangle, matrix, WarpMode.Bilinear);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(262.5f, 112.5f),
+ new PointF(449.9999f, 175f),
+ new PointF(524.9999f, 225f),
+ new PointF(412.9687f, 180f),
+ new PointF(292.4999f, 129.375f),
+ new PointF(163.5937f, 73.12499f),
+ new PointF(26.25f, 11.25f),
+ new PointF(153.75f, 83.74999f),
+ new PointF(153.75f, 83.74999f),
+ new PointF(192.6927f, 98.78391f),
+ new PointF(226.0163f, 109.1132f),
+ new PointF(253.6658f, 116.3978f),
+ new PointF(266.8857f, 118.041f),
+ new PointF(254.0196f, 109.4254f),
+ new PointF(213.4754f, 89.22914f),
+ new PointF(408.7499f, 141.25f),
+ new PointF(558.7499f, 241.25f),
+ new PointF(456.5624f, 205.9375f),
+ new PointF(469.4531f, 208.6719f),
+ new PointF(524.9999f, 225f),
+ new PointF(382.5f, 130f),
+ new PointF(5.064195E-08f, 8.370257E-08f),
+ new PointF(3.344191E-06f, 2.124933E-06f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (200, 100));
+ path.AddLine (new Point (200, 200), new Point (10, 100));
+
+ path.StartFigure();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 200, 200));
+
+ path.StartFigure();
+ path.AddLine (new Point (200, 200), new Point (200, 10));
+
+ path.Warp (warp, rectangle, matrix, WarpMode.Perspective);
+
+ expectedPoints = new PointF [] {new PointF(262.5f, 112.5f),
+ new PointF(450f, 175f),
+ new PointF(525f, 225f),
+ new PointF(93.75f, 56.25f),
+ new PointF(26.25f, 11.25f),
+ new PointF(107.3218f, 55.58105f),
+ new PointF(165.7617f, 83.94531f),
+ new PointF(211.2817f, 102.5244f),
+ new PointF(253.5938f, 117.5f),
+ new PointF(302.4097f, 135.0537f),
+ new PointF(367.4414f, 161.3672f),
+ new PointF(458.4009f, 202.6221f),
+ new PointF(585f, 265f),
+ new PointF(33.75f, 16.25f),
+ new PointF(408.75f, 141.25f),
+ new PointF(558.75f, 241.25f),
+ new PointF(183.75f, 116.25f),
+ new PointF(525f, 225f),
+ new PointF(382.5f, 130f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Warp_PointFArr_RectangleF_Matrix_WarpMode_Float()
+ {
+ path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (200, 100));
+ path.AddLine (new Point (200, 200), new Point (10, 100));
+
+ path.StartFigure();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 200, 200));
+
+ path.StartFigure();
+ path.AddLine (new Point (200, 200), new Point (200, 10));
+
+ RectangleF rectangle = new RectangleF (0f, 0f, 40f, 40f);
+ PointF [] warp = new PointF [] { new PointF (0f, 0f),
+ new PointF (50f, 50f),
+ new PointF (20f, 40f)};
+
+ Matrix matrix = new Matrix();
+ matrix.Scale(1.5f, 0.5f);
+
+ path.Warp (warp, rectangle, matrix, WarpMode.Perspective, 0.2f);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(262.5f, 112.5f),
+ new PointF(450f, 175f),
+ new PointF(525f, 225f),
+ new PointF(93.75f, 56.25f),
+ new PointF(26.25f, 11.25f),
+ new PointF(107.3218f, 55.58105f),
+ new PointF(165.7617f, 83.94531f),
+ new PointF(211.2817f, 102.5244f),
+ new PointF(253.5938f, 117.5f),
+ new PointF(302.4097f, 135.0537f),
+ new PointF(367.4414f, 161.3672f),
+ new PointF(458.4009f, 202.6221f),
+ new PointF(585f, 265f),
+ new PointF(33.75f, 16.25f),
+ new PointF(408.75f, 141.25f),
+ new PointF(558.75f, 241.25f),
+ new PointF(183.75f, 116.25f),
+ new PointF(525f, 225f),
+ new PointF(382.5f, 130f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Widen_Pen()
+ {
+ path = new GraphicsPath ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 200, 200));
+
+ Pen pen = new Pen (Color.Red, 15);
+
+ path.Widen (pen);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(17.37995f, 8.663473f),
+ new PointF(21.21328f, 29.83014f),
+ new PointF(21.17457f, 29.63168f),
+ new PointF(25.00791f, 47.96501f),
+ new PointF(24.96026f, 47.75257f),
+ new PointF(28.79359f, 63.75257f),
+ new PointF(28.69803f, 63.39326f),
+ new PointF(32.69803f, 77.05992f),
+ new PointF(32.56306f, 76.64414f),
+ new PointF(36.72973f, 88.31081f),
+ new PointF(36.5541f, 87.86461f),
+ new PointF(40.72076f, 97.53127f),
+ new PointF(40.39609f, 96.86954f),
+ new PointF(44.72942f, 104.7029f),
+ new PointF(44.40704f, 104.1731f),
+ new PointF(48.74038f, 110.6731f),
+ new PointF(48.0747f, 109.8161f),
+ new PointF(52.5747f, 114.8161f),
+ new PointF(51.63366f, 113.9359f),
+ new PointF(56.30032f, 117.6026f),
+ new PointF(55.45956f, 117.0298f),
+ new PointF(60.2929f, 119.8631f),
+ new PointF(59.36763f, 119.4032f),
+ new PointF(64.20096f, 121.4032f),
+ new PointF(62.98528f, 121.0175f),
+ new PointF(73.31861f, 123.3508f),
+ new PointF(72.46971f, 123.2098f),
+ new PointF(83.43214f, 124.3903f),
+ new PointF(95.72781f, 126.1469f),
+ new PointF(109.1111f, 129.9448f),
+ new PointF(116.4476f, 133.3309f),
+ new PointF(123.7762f, 137.5449f),
+ new PointF(131.4605f, 143.2166f),
+ new PointF(138.9887f, 150.2071f),
+ new PointF(146.8953f, 158.8165f),
+ new PointF(154.9268f, 169.1177f),
+ new PointF(163.0379f, 181.3707f),
+ new PointF(171.4102f, 195.7232f),
+ new PointF(179.9099f, 212.2126f),
+ new PointF(188.6968f, 231.3073f),
+ new PointF(197.8003f, 252.886f),
+ new PointF(207.0185f, 277.356f),
+ new PointF(192.9815f, 282.644f),
+ new PointF(183.8148f, 258.3106f),
+ new PointF(183.9231f, 258.5819f),
+ new PointF(174.9231f, 237.2486f),
+ new PointF(175.0201f, 237.4686f),
+ new PointF(166.3534f, 218.6353f),
+ new PointF(166.5002f, 218.9363f),
+ new PointF(158.1669f, 202.7696f),
+ new PointF(158.355f, 203.1124f),
+ new PointF(150.1883f, 189.1124f),
+ new PointF(150.4128f, 189.4732f),
+ new PointF(142.5794f, 177.6399f),
+ new PointF(142.9186f, 178.1115f),
+ new PointF(135.2519f, 168.2781f),
+ new PointF(135.6427f, 168.7397f),
+ new PointF(128.1427f, 160.573f),
+ new PointF(128.5633f, 160.9959f),
+ new PointF(121.5633f, 154.4959f),
+ new PointF(122.2128f, 155.0343f),
+ new PointF(115.2128f, 149.8676f),
+ new PointF(115.9281f, 150.3351f),
+ new PointF(109.2615f, 146.5018f),
+ new PointF(109.8571f, 146.8097f),
+ new PointF(103.3571f, 143.8097f),
+ new PointF(104.4525f, 144.2151f),
+ new PointF(92.11913f, 140.7151f),
+ new PointF(93.106f, 140.9246f),
+ new PointF(81.43933f, 139.2579f),
+ new PointF(81.69695f, 139.2902f),
+ new PointF(70.4351f, 138.0774f),
+ new PointF(59.05708f, 135.5082f),
+ new PointF(53.15385f, 133.0655f),
+ new PointF(47.43391f, 129.7124f),
+ new PointF(41.85787f, 125.3312f),
+ new PointF(36.56138f, 119.4462f),
+ new PointF(31.75414f, 112.2354f),
+ new PointF(27.09196f, 103.8076f),
+ new PointF(22.68428f, 93.58176f),
+ new PointF(18.36339f, 81.48326f),
+ new PointF(14.24973f, 67.42826f),
+ new PointF(10.3477f, 51.14154f),
+ new PointF(6.471401f, 32.6027f),
+ new PointF(2.620048f, 11.33653f),
+ new PointF(2.5f, 12.5f),
+ new PointF(217.5f, 12.5f),
+ new PointF(217.5f, 227.5f),
+ new PointF(2.5f, 227.5f),
+ new PointF(17.5f, 220f),
+ new PointF(10f, 212.5f),
+ new PointF(210f, 212.5f),
+ new PointF(202.5f, 220f),
+ new PointF(202.5f, 20f),
+ new PointF(210f, 27.5f),
+ new PointF(10f, 27.5f),
+ new PointF(17.5f, 20f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Widen_Pen_Matrix()
+ {
+ path = new GraphicsPath ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 200, 200));
+
+ Pen pen = new Pen (Color.Red, 15);
+
+ Matrix matrix = new Matrix();
+ matrix.Scale(1.5f, 0.5f);
+
+ path.Widen (pen, matrix);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(26.07226f, 4.336054f),
+ new PointF(31.73893f, 14.83605f),
+ new PointF(31.68019f, 14.73517f),
+ new PointF(37.51352f, 24.0685f),
+ new PointF(37.43172f, 23.94766f),
+ new PointF(43.26505f, 31.94765f),
+ new PointF(43.13037f, 31.77996f),
+ new PointF(49.13037f, 38.61329f),
+ new PointF(48.90903f, 38.3879f),
+ new PointF(55.07569f, 44.05457f),
+ new PointF(54.85265f, 43.86571f),
+ new PointF(61.01931f, 48.69905f),
+ new PointF(60.29364f, 48.22634f),
+ new PointF(73.29364f, 55.393f),
+ new PointF(71.52402f, 54.64954f),
+ new PointF(85.35734f, 59.14954f),
+ new PointF(82.3909f, 58.45626f),
+ new PointF(96.8909f, 60.78959f),
+ new PointF(94.50352f, 60.51069f),
+ new PointF(109.8369f, 61.67735f),
+ new PointF(108.7007f, 61.61112f),
+ new PointF(125.034f, 62.27779f),
+ new PointF(124.944f, 62.27424f),
+ new PointF(143.4256f, 62.9783f),
+ new PointF(163.835f, 65.00085f),
+ new PointF(185.6939f, 68.67461f),
+ new PointF(208.6403f, 74.99842f),
+ new PointF(232.2171f, 84.42915f),
+ new PointF(244.575f, 90.69513f),
+ new PointF(257.0276f, 97.85966f),
+ new PointF(269.7801f, 106.0213f),
+ new PointF(282.9691f, 115.6594f),
+ new PointF(296.6128f, 126.4395f),
+ new PointF(310.5198f, 138.671f),
+ new PointF(289.4801f, 141.329f),
+ new PointF(275.6468f, 129.1623f),
+ new PointF(275.8013f, 129.2909f),
+ new PointF(262.3013f, 118.6243f),
+ new PointF(262.4312f, 118.7229f),
+ new PointF(249.4311f, 109.2229f),
+ new PointF(249.6888f, 109.3989f),
+ new PointF(237.1888f, 101.3989f),
+ new PointF(237.4324f, 101.5466f),
+ new PointF(225.2657f, 94.54655f),
+ new PointF(225.5994f, 94.72665f),
+ new PointF(213.7661f, 88.72665f),
+ new PointF(214.5241f, 89.06734f),
+ new PointF(192.0241f, 80.06734f),
+ new PointF(193.4982f, 80.55679f),
+ new PointF(172.3315f, 74.72345f),
+ new PointF(174.4351f, 75.18177f),
+ new PointF(154.6017f, 71.84844f),
+ new PointF(156.4607f, 72.0945f),
+ new PointF(137.9607f, 70.26116f),
+ new PointF(139.8892f, 70.3924f),
+ new PointF(122.3442f, 69.72402f),
+ new PointF(105.3928f, 69.03212f),
+ new PointF(88.25542f, 67.7282f),
+ new PointF(70.95618f, 64.94441f),
+ new PointF(54.78223f, 59.68301f),
+ new PointF(40.62651f, 51.87922f),
+ new PointF(34.02815f, 46.70752f),
+ new PointF(27.63626f, 40.83389f),
+ new PointF(21.46311f, 33.80336f),
+ new PointF(15.52437f, 25.65881f),
+ new PointF(9.621692f, 16.21452f),
+ new PointF(3.927732f, 5.663945f),
+ new PointF(3.749999f, 6.249999f),
+ new PointF(326.25f, 6.249999f),
+ new PointF(326.2499f, 113.75f),
+ new PointF(3.749999f, 113.75f),
+ new PointF(26.25f, 110f),
+ new PointF(15f, 106.25f),
+ new PointF(315f, 106.25f),
+ new PointF(303.75f, 110f),
+ new PointF(303.75f, 9.999999f),
+ new PointF(315f, 13.75f),
+ new PointF(15f, 13.75f),
+ new PointF(26.25f, 9.999999f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void Widen_Pen_Matrix_Float()
+ {
+ path = new GraphicsPath ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure();
+ path.AddRectangle (new Rectangle (10, 20, 200, 200));
+
+ Pen pen = new Pen (Color.Red, 15);
+
+ Matrix matrix = new Matrix();
+ matrix.Scale(1.5f, 0.5f);
+
+ path.Widen (pen, matrix, 0.2f);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(26.08857f, 4.367013f),
+ new PointF(28.88857f, 9.817012f),
+ new PointF(28.85975f, 9.763281f),
+ new PointF(31.70975f, 14.86328f),
+ new PointF(31.67857f, 14.80965f),
+ new PointF(34.57857f, 19.60965f),
+ new PointF(34.5436f, 19.55396f),
+ new PointF(37.4436f, 24.00396f),
+ new PointF(37.39977f, 23.93945f),
+ new PointF(40.29977f, 28.03945f),
+ new PointF(40.25008f, 27.972f),
+ new PointF(43.20008f, 31.82199f),
+ new PointF(43.09911f, 31.69899f),
+ new PointF(49.09911f, 38.54898f),
+ new PointF(48.90694f, 38.35032f),
+ new PointF(55.05694f, 44.15032f),
+ new PointF(54.77378f, 43.90996f),
+ new PointF(61.07379f, 48.75996f),
+ new PointF(60.64857f, 48.46797f),
+ new PointF(67.04858f, 52.41797f),
+ new PointF(66.42046f, 52.07551f),
+ new PointF(73.02045f, 55.27551f),
+ new PointF(72.11205f, 54.89137f),
+ new PointF(78.86205f, 57.39137f),
+ new PointF(77.63413f, 57.00044f),
+ new PointF(84.58413f, 58.90044f),
+ new PointF(83.11855f, 58.56083f),
+ new PointF(90.31853f, 59.96083f),
+ new PointF(88.90129f, 59.72806f),
+ new PointF(96.2513f, 60.72805f),
+ new PointF(94.81331f, 60.56914f),
+ new PointF(102.3633f, 61.21914f),
+ new PointF(101.4567f, 61.15424f),
+ new PointF(109.3067f, 61.60424f),
+ new PointF(108.7323f, 61.57637f),
+ new PointF(125.1848f, 62.23045f),
+ new PointF(143.1808f, 63.05786f),
+ new PointF(153.344f, 63.83537f),
+ new PointF(163.8406f, 65.00166f),
+ new PointF(174.5957f, 66.60938f),
+ new PointF(185.6805f, 68.76014f),
+ new PointF(197.0758f, 71.55418f),
+ new PointF(208.587f, 75.10439f),
+ new PointF(220.3038f, 79.37941f),
+ new PointF(232.2803f, 84.50476f),
+ new PointF(244.5031f, 90.61616f),
+ new PointF(256.9783f, 97.77407f),
+ new PointF(263.386f, 101.7725f),
+ new PointF(269.8497f, 106.0477f),
+ new PointF(276.4059f, 110.6218f),
+ new PointF(283.0547f, 115.5449f),
+ new PointF(289.7812f, 120.8047f),
+ new PointF(296.6029f, 126.3632f),
+ new PointF(303.5159f, 132.3174f),
+ new PointF(310.5394f, 138.5884f),
+ new PointF(289.4605f, 141.2115f),
+ new PointF(282.4605f, 134.9615f),
+ new PointF(282.5082f, 135.0034f),
+ new PointF(275.6582f, 129.1034f),
+ new PointF(275.7375f, 129.1699f),
+ new PointF(268.9875f, 123.6699f),
+ new PointF(269.051f, 123.7205f),
+ new PointF(262.401f, 118.5205f),
+ new PointF(262.4915f, 118.5893f),
+ new PointF(255.9415f, 113.7393f),
+ new PointF(256.049f, 113.8166f),
+ new PointF(249.599f, 109.3166f),
+ new PointF(249.7036f, 109.3877f),
+ new PointF(243.3536f, 105.1877f),
+ new PointF(243.477f, 105.2669f),
+ new PointF(237.227f, 101.3669f),
+ new PointF(237.4224f, 101.4837f),
+ new PointF(225.2224f, 94.48374f),
+ new PointF(225.5894f, 94.68011f),
+ new PointF(213.7894f, 88.78011f),
+ new PointF(214.2746f, 89.00435f),
+ new PointF(202.8246f, 84.10435f),
+ new PointF(203.3942f, 84.32931f),
+ new PointF(192.2942f, 80.27931f),
+ new PointF(192.9597f, 80.50254f),
+ new PointF(182.2597f, 77.20254f),
+ new PointF(183.2339f, 77.47076f),
+ new PointF(172.8339f, 74.92076f),
+ new PointF(173.8405f, 75.14091f),
+ new PointF(163.7905f, 73.19091f),
+ new PointF(164.8466f, 73.37167f),
+ new PointF(155.1466f, 71.92167f),
+ new PointF(156.1924f, 72.05755f),
+ new PointF(146.7424f, 71.00755f),
+ new PointF(147.7834f, 71.10496f),
+ new PointF(138.6334f, 70.40496f),
+ new PointF(139.6128f, 70.46482f),
+ new PointF(122.2128f, 69.66482f),
+ new PointF(122.4177f, 69.6736f),
+ new PointF(105.7794f, 69.01213f),
+ new PointF(97.18594f, 68.51952f),
+ new PointF(88.45159f, 67.76756f),
+ new PointF(79.66547f, 66.57217f),
+ new PointF(71.00809f, 64.88879f),
+ new PointF(62.7075f, 62.61956f),
+ new PointF(54.89606f, 59.72644f),
+ new PointF(47.53793f, 56.15886f),
+ new PointF(40.61982f, 51.88909f),
+ new PointF(33.97219f, 46.77147f),
+ new PointF(27.58867f, 40.75123f),
+ new PointF(21.44726f, 33.73978f),
+ new PointF(18.42414f, 29.79435f),
+ new PointF(15.47745f, 25.62836f),
+ new PointF(12.53827f, 21.11823f),
+ new PointF(9.605241f, 16.26356f),
+ new PointF(6.725243f, 11.10988f),
+ new PointF(3.911426f, 5.632986f),
+ new PointF(3.749999f, 6.249999f),
+ new PointF(326.25f, 6.249999f),
+ new PointF(326.2499f, 113.75f),
+ new PointF(3.749999f, 113.75f),
+ new PointF(26.25f, 110f),
+ new PointF(15f, 106.25f),
+ new PointF(315f, 106.25f),
+ new PointF(303.75f, 110f),
+ new PointF(303.75f, 9.999999f),
+ new PointF(315f, 13.75f),
+ new PointF(15f, 13.75f),
+ new PointF(26.25f, 9.999999f)};
+
+ for(int i = 0; i < path.PointCount; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
+ }
+
+ t.Graphics.DrawPath (p, path);
+ t.Show ();
+ //t.AssertCompare ();
+ }
+
+ #region Private helpers
+
+ public void Print (GraphicsPath path)
+ {
+// foreach(PointF point in path.PathPoints) {
+// Console.WriteLine("new PointF({0}f, {1}f), ",point.X, point.Y);
+// }
+// foreach(PathPointType type in path.PathTypes) {
+// Console.WriteLine("(byte) PathPointType.{0}, ",type);
+// }
+
+ for (int i=0; i < path.PointCount; i++) {
+ Console.WriteLine (" ({0},{1}) [{2}]",path.PathPoints[i].X,path.PathPoints[i].Y,ToString ((PathPointType)path.PathTypes[i]));
+ }
+ }
+
+ public string ToString (PathPointType type)
+ {
+ foreach (PathPointType t in Enum.GetValues(typeof (PathPointType)))
+ if (type == t)
+ return type.ToString ();
+
+ string s = (type & PathPointType.PathTypeMask).ToString ();
+
+ foreach (PathPointType t in new PathPointType[] {PathPointType.PathMarker, PathPointType.CloseSubpath})
+ if ((type & t) != 0)
+ s += " | " + t.ToString ();
+
+ return s;
+ }
+
+ #endregion // Private helpers
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPathIterator.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPathIterator.cs
new file mode 100644
index 00000000000..f51a0da5460
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/GraphicsPathIterator.cs
@@ -0,0 +1,749 @@
+using System;
+using NUnit.Framework;
+using System.Drawing.Drawing2D;
+using System.Drawing;
+
+using DrawingTestHelper;
+
+namespace Test.Sys.Drawing
+{
+ [TestFixture]
+ public class GraphicsPathIteratorFixture
+ {
+ [Test]
+ public virtual void NextSubpath_Int_Int_Bool()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.CloseFigure ();
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+
+ int start;
+ int end;
+ bool isClosed;
+
+ int count = iterator.NextSubpath (out start, out end, out isClosed);
+ Assert.AreEqual (4, count);
+ Assert.AreEqual (0, start);
+ Assert.AreEqual (3, end);
+ Assert.IsFalse (isClosed);
+
+ count = iterator.NextSubpath (out start, out end, out isClosed);
+ Assert.AreEqual (4, count);
+ Assert.AreEqual (4, start);
+ Assert.AreEqual (7, end);
+ Assert.IsTrue (isClosed);
+
+ count = iterator.NextSubpath (out start, out end, out isClosed);
+ Assert.AreEqual (4, count);
+ Assert.AreEqual (8, start);
+ Assert.AreEqual (11, end);
+ Assert.IsTrue (isClosed);
+
+ count = iterator.NextSubpath (out start, out end, out isClosed);
+ Assert.AreEqual (2, count);
+ Assert.AreEqual (12, start);
+ Assert.AreEqual (13, end);
+ Assert.IsFalse (isClosed);
+
+ count = iterator.NextSubpath (out start, out end, out isClosed);
+ Assert.AreEqual (0, count);
+ Assert.AreEqual (0, start);
+ Assert.AreEqual (0, end);
+ Assert.IsTrue (isClosed);
+ }
+
+ [Test]
+ public virtual void NextSubpath_GraphicsPath_Bool()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.CloseFigure ();
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+ GraphicsPath path2 = new GraphicsPath ();
+
+ bool isClosed;
+
+ int count = iterator.NextSubpath (path2, out isClosed);
+ Assert.AreEqual (4, count);
+ Assert.IsFalse (isClosed);
+
+ PointF [] actualPoints = path2.PathPoints;
+ byte [] actualTypes = path2.PathTypes;
+
+ PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
+ new PointF(400f, 100f),
+ new PointF(400f, 200f),
+ new PointF(10f, 100f)};
+
+ for(int i = 0; i < expectedPoints.Length; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.PathMarker)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], actualTypes [i]);
+ }
+
+ count = iterator.NextSubpath (path2, out isClosed);
+ Assert.AreEqual (4, count);
+ Assert.IsTrue (isClosed);
+
+ actualPoints = path2.PathPoints;
+ actualTypes = path2.PathTypes;
+
+ expectedPoints = new PointF [] {new PointF(10f, 10f),
+ new PointF(50f, 250f),
+ new PointF(100f, 5f),
+ new PointF(200f, 280f)};
+
+ for(int i = 0; i < expectedPoints.Length; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
+ }
+
+ expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath | PathPointType.PathMarker)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], actualTypes [i]);
+ }
+
+ count = iterator.NextSubpath (path2, out isClosed);
+ Assert.AreEqual (4, count);
+ Assert.IsTrue (isClosed);
+
+ actualPoints = path2.PathPoints;
+ actualTypes = path2.PathTypes;
+
+ expectedPoints = new PointF [] {new PointF(10f, 20f),
+ new PointF(310f, 20f),
+ new PointF(310f, 420f),
+ new PointF(10f, 420f)};
+
+ for(int i = 0; i < expectedPoints.Length; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
+ }
+
+ expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], actualTypes [i]);
+ }
+
+ count = iterator.NextSubpath (path2, out isClosed);
+ Assert.AreEqual (2, count);
+ Assert.IsFalse (isClosed);
+
+ actualPoints = path2.PathPoints;
+ actualTypes = path2.PathTypes;
+
+ expectedPoints = new PointF [] {new PointF(400f, 400f),
+ new PointF(400f, 10f)};
+
+ for(int i = 0; i < expectedPoints.Length; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
+ }
+
+ expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], actualTypes [i]);
+ }
+
+ count = iterator.NextSubpath (path2, out isClosed);
+ Assert.AreEqual (0, count);
+
+ count = iterator.NextSubpath (path2, out isClosed);
+ Assert.AreEqual (0, count);
+ Assert.IsTrue (isClosed);
+ Assert.AreEqual (2, path2.PointCount);
+
+ actualPoints = path2.PathPoints;
+ actualTypes = path2.PathTypes;
+
+ expectedPoints = new PointF [] {new PointF(400f, 400f),
+ new PointF(400f, 10f)};
+
+ for(int i = 0; i < expectedPoints.Length; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
+ }
+
+ expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], actualTypes [i]);
+ }
+
+ path = new GraphicsPath ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ iterator = new GraphicsPathIterator (path);
+
+ path2 = new GraphicsPath ();
+ count = iterator.NextSubpath (path2, out isClosed);
+ Assert.AreEqual (4, count);
+ Assert.IsFalse (isClosed);
+
+ path2 = new GraphicsPath ();
+ count = iterator.NextSubpath (path2, out isClosed);
+ Assert.AreEqual (0, count);
+ Assert.IsTrue (isClosed);
+ }
+
+ [Test]
+ public virtual void NextPathType()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddBezier( 100, 100, 500, 250, 100, 50, 250, 280);
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+
+ byte pathType;
+ int start;
+ int end;
+ bool isClosed;
+
+ int count = iterator.NextPathType (out pathType, out start, out end);
+ Assert.AreEqual (0, count);
+ Assert.AreEqual ((byte)PathPointType.Start, pathType);
+ Assert.AreEqual (0, start);
+ Assert.AreEqual (0, end);
+
+ iterator.NextSubpath (out start, out end, out isClosed);
+ count = iterator.NextPathType (out pathType, out start, out end);
+ Assert.AreEqual (3, count);
+ Assert.AreEqual ((byte)PathPointType.Line, pathType);
+ Assert.AreEqual (0, start);
+ Assert.AreEqual (2, end);
+
+ count = iterator.NextPathType (out pathType, out start, out end);
+ Assert.AreEqual (4, count);
+ Assert.AreEqual ((byte)PathPointType.Bezier3, pathType);
+ Assert.AreEqual (2, start);
+ Assert.AreEqual (5, end);
+
+ count = iterator.NextPathType (out pathType, out start, out end);
+ Assert.AreEqual (3, count);
+ Assert.AreEqual ((byte)PathPointType.Line, pathType);
+ Assert.AreEqual (5, start);
+ Assert.AreEqual (7, end);
+
+ // we don't want to be a bug compliant with .net
+ /*
+ count = iterator.NextPathType (out pathType, out start, out end);
+ Assert.AreEqual (0, count);
+ Assert.AreEqual ((byte)PathPointType.Line, pathType);
+ Assert.AreEqual (5, start);
+ Assert.AreEqual (7, end);
+ */
+
+ iterator.NextSubpath (out start, out end, out isClosed);
+ count = iterator.NextPathType (out pathType, out start, out end);
+ Assert.AreEqual (4, count);
+ Assert.AreEqual ((byte)PathPointType.Bezier3, pathType);
+ Assert.AreEqual (8, start);
+ Assert.AreEqual (11, end);
+
+ iterator.NextSubpath (out start, out end, out isClosed);
+ count = iterator.NextPathType (out pathType, out start, out end);
+ Assert.AreEqual (4, count);
+ Assert.AreEqual ((byte)PathPointType.Line, pathType);
+ Assert.AreEqual (12, start);
+ Assert.AreEqual (15, end);
+
+ iterator.NextSubpath (out start, out end, out isClosed);
+ count = iterator.NextPathType (out pathType, out start, out end);
+ Assert.AreEqual (2, count);
+ Assert.AreEqual ((byte)PathPointType.Line, pathType);
+ Assert.AreEqual (16, start);
+ Assert.AreEqual (17, end);
+
+ iterator.NextSubpath (out start, out end, out isClosed);
+ count = iterator.NextPathType (out pathType, out start, out end);
+ Assert.AreEqual (0, count);
+ Assert.AreEqual ((byte)PathPointType.Line, pathType);
+ Assert.AreEqual (0, start);
+ Assert.AreEqual (0, end);
+ }
+
+ [Test]
+ public virtual void NextMarker_Int32_Int32()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+
+ int start;
+ int end;
+ int count = iterator.NextMarker (out start, out end);
+ Assert.AreEqual (4, count);
+ Assert.AreEqual (0, start);
+ Assert.AreEqual (3, end);
+
+ count = iterator.NextMarker (out start, out end);
+ Assert.AreEqual (4, count);
+ Assert.AreEqual (4, start);
+ Assert.AreEqual (7, end);
+
+ count = iterator.NextMarker (out start, out end);
+ Assert.AreEqual (4, count);
+ Assert.AreEqual (8, start);
+ Assert.AreEqual (11, end);
+
+ count = iterator.NextMarker (out start, out end);
+ Assert.AreEqual (2, count);
+ Assert.AreEqual (12, start);
+ Assert.AreEqual (13, end);
+
+ // FIXME - should return all 0'z?
+ /*
+ count = iterator.NextMarker (out start, out end);
+ Assert.AreEqual (0, count);
+ Assert.AreEqual (12, start);
+ Assert.AreEqual (13, end);
+ */
+ }
+
+ [Test]
+ public void NextSubpath_NextMarker()
+ {
+ GraphicsPath path = new GraphicsPath();
+
+ path.AddLine (10, 10, 50, 50); // figure #1
+ path.AddLine (50, 50, 80, 80);
+ path.AddLine (90, 90, 100, 100);
+ path.SetMarkers (); // marker #1
+ path.AddLine (150, 150, 180, 180);
+ path.SetMarkers (); // marker #2
+ path.StartFigure (); // figure #2
+ path.SetMarkers (); // marker #3 is actually marker #2
+ path.AddRectangle (new Rectangle (200, 200, 200, 200));
+ path.SetMarkers (); // marker #4
+ path.AddLine (150, 150, 180, 180);
+ path.StartFigure (); // figure #3
+ path.AddBezier (400, 400, 500, 500, 600, 600, 700, 700);
+ path.AddBezier (450, 450, 550, 550, 650, 650, 750, 750);
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+
+ int start;
+ int end;
+ bool isClosed;
+ int count = iterator.NextMarker (out start,out end); // marker #1
+ Assert.AreEqual (5, count);
+ Assert.AreEqual (0, start);
+ Assert.AreEqual (4, end);
+
+ count = iterator.NextSubpath (out start,out end,out isClosed); // figure #1
+ Assert.AreEqual (7, count);
+ Assert.AreEqual (0, start);
+ Assert.AreEqual (6, end);
+ Assert.AreEqual (false, isClosed);
+
+ count = iterator.NextMarker (out start,out end); // marker #2 (and #3)
+ Assert.AreEqual (2, count);
+ Assert.AreEqual (5, start);
+ Assert.AreEqual (6, end);
+
+ count = iterator.NextSubpath (out start,out end,out isClosed); // figure #2
+ Assert.AreEqual (4, count);
+ Assert.AreEqual (7, start);
+ Assert.AreEqual (10, end);
+ Assert.AreEqual (true, isClosed);
+
+ count = iterator.NextSubpath (out start,out end,out isClosed); // figure #3
+ Assert.AreEqual (2, count);
+ Assert.AreEqual (11, start);
+ Assert.AreEqual (12, end);
+ Assert.AreEqual (false, isClosed);
+
+ count = iterator.NextMarker (out start,out end); // marker #5 (end)
+ Assert.AreEqual (4, count);
+ Assert.AreEqual (7, start);
+ Assert.AreEqual (10, end);
+
+ count = iterator.NextMarker (out start,out end); // marker #5 (end)
+ Assert.AreEqual (10, count);
+ Assert.AreEqual (11, start);
+ Assert.AreEqual (20, end);
+
+ // we dont want to be bug compliant with .net
+ /*
+ count = iterator.NextMarker (out start,out end); // no more markers
+ Assert.AreEqual (0, count);
+ Assert.AreEqual (11, start);
+ Assert.AreEqual (20, end);
+ */
+
+ count = iterator.NextSubpath (out start,out end,out isClosed); // figure #4
+ Assert.AreEqual (8, count);
+ Assert.AreEqual (13, start);
+ Assert.AreEqual (20, end);
+ Assert.AreEqual (false, isClosed);
+
+ // we dont want to be bug compliant with .net
+ /*
+ count = iterator.NextMarker (out start,out end); // no more markers
+ Assert.AreEqual (0, count);
+ Assert.AreEqual (13, start);
+ Assert.AreEqual (20, end);
+ */
+
+ count = iterator.NextSubpath (out start,out end,out isClosed); // no more figures
+ Assert.AreEqual (0, count);
+ Assert.AreEqual (0, start);
+ Assert.AreEqual (0, end);
+ Assert.AreEqual (true, isClosed);
+
+ count = iterator.NextMarker (out start,out end); // no more markers
+ Assert.AreEqual (0, count);
+ Assert.AreEqual (0, start);
+ Assert.AreEqual (0, end);
+ }
+
+
+ [Test]
+ public virtual void NextMarker_GraphicsPath()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ GraphicsPath path2 = new GraphicsPath ();
+ path.AddLine (new Point (150, 150), new Point (450, 150));
+ path.AddLine (new Point (450, 250), new Point (50, 150));
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+
+ iterator.NextMarker (null);
+ iterator.NextMarker (path2);
+
+ Assert.AreEqual (4, path2.PointCount);
+ PointF [] actualPoints = path2.PathPoints;
+ byte [] actualTypes = path2.PathTypes;
+
+ PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
+ new PointF(400f, 100f),
+ new PointF(400f, 200f),
+ new PointF(10f, 100f)};
+
+ for(int i = 0; i < expectedPoints.Length; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.PathMarker)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], actualTypes [i]);
+ }
+
+ iterator.NextMarker (null);
+ iterator.NextMarker (null);
+ iterator.NextMarker (null);
+ iterator.NextMarker (path2);
+
+ Assert.AreEqual (4, path2.PointCount);
+ actualPoints = path2.PathPoints;
+ actualTypes = path2.PathTypes;
+
+ expectedPoints = new PointF [] {new PointF(10f, 10f),
+ new PointF(50f, 250f),
+ new PointF(100f, 5f),
+ new PointF(200f, 280f)};
+
+ for(int i = 0; i < expectedPoints.Length; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
+ }
+
+ expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) (PathPointType.Bezier3 | PathPointType.PathMarker)};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], actualTypes [i]);
+ }
+
+ }
+
+ [Test]
+ public virtual void Count()
+ {
+ GraphicsPath path = new GraphicsPath ();
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+ Assert.AreEqual (0, iterator.Count);
+
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ iterator = new GraphicsPathIterator (path);
+ Assert.AreEqual (14, iterator.Count);
+ }
+
+ [Test]
+ public virtual void SubpathCount()
+ {
+ GraphicsPath path = new GraphicsPath ();
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+ Assert.AreEqual (0, iterator.SubpathCount);
+
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ iterator = new GraphicsPathIterator (path);
+ Assert.AreEqual (4, iterator.SubpathCount);
+ }
+
+ [Test]
+ public virtual void HasCurve()
+ {
+ GraphicsPath path = new GraphicsPath ();
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+ Assert.IsFalse (iterator.HasCurve ());
+
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ iterator = new GraphicsPathIterator (path);
+ Assert.IsFalse (iterator.HasCurve ());
+
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ iterator = new GraphicsPathIterator (path);
+ Assert.IsTrue (iterator.HasCurve ());
+ }
+
+ [Test]
+ public virtual void Rewind()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+
+ int i;
+ int j;
+ iterator.NextMarker (out i, out j);
+ iterator.NextMarker (out i, out j);
+
+ iterator.Rewind ();
+ iterator.NextMarker (out i, out j);
+
+ Assert.AreEqual (0, i);
+ Assert.AreEqual (3, j);
+ }
+
+ [Test]
+ public virtual void Enumerate()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+
+ path.StartFigure ();
+ path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
+ path.StartFigure ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+
+ path.StartFigure ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ path.Reverse ();
+
+ GraphicsPathIterator iterator = new GraphicsPathIterator (path);
+ PointF [] actualPoints = new PointF [14];
+ byte [] actualTypes = new byte [14];
+ iterator.Enumerate (ref actualPoints, ref actualTypes);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(400f, 10f),
+ new PointF(400f, 400f),
+ new PointF(10f, 420f),
+ new PointF(310f, 420f),
+ new PointF(310f, 20f),
+ new PointF(10f, 20f),
+ new PointF(200f, 280f),
+ new PointF(100f, 5f),
+ new PointF(50f, 250f),
+ new PointF(10f, 10f),
+ new PointF(10f, 100f),
+ new PointF(400f, 200f),
+ new PointF(400f, 100f),
+ new PointF(100f, 100f)};
+
+ for(int i = 0; i < expectedPoints.Length; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Bezier3,
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], actualTypes [i]);
+ }
+ }
+
+ [Test]
+ public virtual void CopyData()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddLine (new Point (100, 100), new Point (400, 100));
+ path.AddLine (new Point (400, 200), new Point (10, 100));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddRectangle (new Rectangle (10, 20, 300, 400));
+ path.StartFigure ();
+ path.SetMarkers ();
+ path.AddLine (new Point (400, 400), new Point (400, 10));
+
+ GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);
+ pathIterator.Rewind ();
+ PointF [] actualPoints = new PointF [10];
+ byte [] actualTypes = new byte [10];
+ pathIterator.CopyData (ref actualPoints, ref actualTypes, 0, 9);
+
+ PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
+ new PointF(400f, 100f),
+ new PointF(400f, 200f),
+ new PointF(10f, 100f),
+ new PointF(10f, 20f),
+ new PointF(310f, 20f),
+ new PointF(310f, 420f),
+ new PointF(10f, 420f),
+ new PointF(400f, 400f),
+ new PointF(400f, 10f)};
+
+ for(int i = 0; i < expectedPoints.Length; i++) {
+ DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
+ }
+
+ byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line,
+ (byte) PathPointType.Line,
+ (byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker),
+ (byte) PathPointType.Start,
+ (byte) PathPointType.Line};
+
+ for (int i=0; i < expectedTypes.Length; i++) {
+ Assert.AreEqual (expectedTypes [i], actualTypes [i]);
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Image.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/Image.cs
new file mode 100644
index 00000000000..2f48076afea
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Image.cs
@@ -0,0 +1,293 @@
+using System;
+using NUnit.Framework;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Drawing.Drawing2D;
+using DrawingTestHelper;
+using System.IO;
+
+namespace Test.Sys.Drawing {
+ [TestFixture]
+ public class ImageFixture {
+ DrawingTest t;
+ [SetUp]
+ public void SetUp () {
+ t = DrawingTest.Create (256, 256);
+ Image im=new Bitmap (@"..\..\Bitmap1.png");
+ t.Graphics.DrawImageUnscaled (im, 0, 0);
+ }
+ [Test]
+ public void Clone () {
+ Image im1 = (Image) t.Bitmap.Clone ();
+ Assert.IsFalse (Object.ReferenceEquals (im1, t.Bitmap));
+ Assert.AreEqual (DrawingTest.CalculateNorm ((Bitmap)im1),
+ DrawingTest.CalculateNorm (t.Bitmap));
+ t.Graphics.FillRectangle (Brushes.Beige, 0, 0, 100, 100);
+ Assert.IsFalse (DrawingTest.CalculateNorm ((Bitmap)im1) ==
+ DrawingTest.CalculateNorm (t.Bitmap));
+ }
+ [Test]
+ public void Clone2 () {
+ Image im1 = (Image) t.Bitmap.Clone (new Rectangle(0, 0, t.Bitmap.Width, t.Bitmap.Height), t.Bitmap.PixelFormat);
+ t.Graphics.FillRectangle (Brushes.Beige, 0, 0, 100, 100);
+ Assert.IsFalse (DrawingTest.CalculateNorm ((Bitmap)im1) ==
+ DrawingTest.CalculateNorm (t.Bitmap));
+ }
+ [Test]
+ public void GetHashCodeTest () {
+ Assert.IsFalse (t.Bitmap.GetHashCode () == 0);
+ Bitmap im1 = new Bitmap (10, 20);
+ Assert.IsFalse (t.Bitmap.GetHashCode () == im1.GetHashCode ());
+ }
+ [Test]
+ public void GetBounds () {
+ GraphicsUnit unit = new GraphicsUnit();
+ Assert.AreEqual (new RectangleF (0, 0, 256, 256),
+ t.Bitmap.GetBounds (ref unit));
+ Assert.AreEqual (GraphicsUnit.Pixel, unit);
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void GetEncoderParameterList () {
+ Assert.Fail ("Test not implemented - undocumented parameter");
+ }
+ [Test]
+ public void GetFrameCount () {
+ Assert.AreEqual (1, t.Bitmap.GetFrameCount (FrameDimension.Page));
+ }
+ [Test]
+ public void GetFrameCount2 () {
+ try {
+ t.Bitmap.GetFrameCount (FrameDimension.Time);
+ }
+ catch (ArgumentException) {
+ Assert.IsTrue( true );
+ }
+ }
+ [Test]
+ public void GetFrameCount3 () {
+ try {
+ t.Bitmap.GetFrameCount (new FrameDimension (Guid.NewGuid ()));
+ }
+ catch (ArgumentException) {
+ Assert.IsTrue( true );
+ }
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void GetPropertyItem () {
+ Assert.Fail ("Test not implemented - undocumented parameter");
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void RemovePropertyItem () {
+ Assert.Fail ("Test not implemented - undocumented parameter");
+ }
+ static bool ThumbnailCallback() {
+ return false;
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: IntPtr
+#endif
+ public void GetThumbnailImage() {
+ t.Show ();
+ Image.GetThumbnailImageAbort myCallback =
+ new Image.GetThumbnailImageAbort(ThumbnailCallback);
+ Image myThumbnail = t.Bitmap.GetThumbnailImage(
+ 10, 10, myCallback, IntPtr.Zero);
+ t.Graphics.DrawImageUnscaled (myThumbnail, 100, 75);
+ t.Show ();
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Image.RotateFlip is not implemented for now.
+#endif
+ public void RotateFlip () {
+ t.Show ();
+ t.Bitmap.RotateFlip (RotateFlipType.Rotate90FlipY);
+ t.Show ();
+ Assert.IsTrue (t.Compare (10));
+ }
+ [Test]
+ public void Save_string () {
+ t.Bitmap.Save ("test.png");
+ using (FileStream r = new FileStream ("test.png", FileMode.Open)) {
+ Bitmap b1 = new Bitmap (r);
+ Assert.AreEqual (DrawingTest.CalculateNorm (t.Bitmap),
+ DrawingTest.CalculateNorm (b1));
+ }
+ File.Delete ("test.png");
+ }
+ [Test]
+ public void Save_Stream_ImageFormat () {
+ using (FileStream w = new FileStream ("test.png", FileMode.OpenOrCreate)) {
+ t.Bitmap.Save (w, ImageFormat.Png);
+ }
+ using (FileStream r = new FileStream ("test.png", FileMode.Open)) {
+ Bitmap b1 = new Bitmap (r);
+ Assert.AreEqual (DrawingTest.CalculateNorm (t.Bitmap),
+ DrawingTest.CalculateNorm (b1));
+ }
+ File.Delete ("test.png");
+ }
+ [Test]
+ public void Save_string_ImageFormat () {
+ t.Bitmap.Save ("test.png", ImageFormat.Png);
+ using (FileStream r = new FileStream ("test.png", FileMode.Open)) {
+ Bitmap b1 = new Bitmap (r);
+ Assert.AreEqual (DrawingTest.CalculateNorm (t.Bitmap),
+ DrawingTest.CalculateNorm (b1));
+ }
+ File.Delete ("test.png");
+ }
+ [Test]
+#if TARGET_JVM
+ [Category("NotWorking")]
+#endif
+ public void Save_Stream_ImageCodecInfo_EncoderParameters () {
+ using (FileStream w = new FileStream ("test.png", FileMode.OpenOrCreate)) {
+ foreach (ImageCodecInfo i in ImageCodecInfo.GetImageEncoders()) {
+ if (i.FilenameExtension.IndexOf ("png") != -1) {
+ t.Bitmap.Save (w, i, new EncoderParameters ());
+ break;
+ }
+ }
+ }
+ using (FileStream r = new FileStream ("test.png", FileMode.Open)) {
+ Bitmap b1 = new Bitmap (r);
+ Assert.AreEqual (DrawingTest.CalculateNorm (t.Bitmap),
+ DrawingTest.CalculateNorm (b1));
+ }
+ File.Delete ("test.png");
+ }
+ [Test]
+#if TARGET_JVM
+ [Category("NotWorking")]
+#endif
+ public void Save_string_ImageCodecInfo_EncoderParameters () {
+ foreach (ImageCodecInfo i in ImageCodecInfo.GetImageEncoders()) {
+ if (i.FilenameExtension.IndexOf ("png") != -1) {
+ t.Bitmap.Save ("test.png", i, new EncoderParameters ());
+ break;
+ }
+ }
+ using (FileStream r = new FileStream ("test.png", FileMode.Open)) {
+ Bitmap b1 = new Bitmap (r);
+ Assert.AreEqual (DrawingTest.CalculateNorm (t.Bitmap),
+ DrawingTest.CalculateNorm (b1));
+ }
+ File.Delete ("test.png");
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void SaveAdd () {
+ Assert.Fail ("Test not implemented");
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
+ public void SelectActiveFrame () {
+ Assert.Fail ("Test not implemented");
+ }
+ [Test]
+ [Category ("NotWorking")]
+ public void SetPropertyItem () {
+ Assert.Fail ("Test not implemented - undocumented parameter");
+ }
+ [Test]
+ public new void ToString () {
+ Assert.IsTrue (t.Bitmap.ToString().ToLower().StartsWith("system.drawing.bitmap"));
+ }
+ [Test]
+ public void Height () {
+ Assert.AreEqual (256, t.Bitmap.Height);
+ }
+ [Test]
+ public void Width () {
+ Assert.AreEqual (256, t.Bitmap.Width);
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Image.HorizontalResolution is not implemented for now.
+#endif
+ public void HorizontalResolution () {
+ Assert.AreEqual (96, t.Bitmap.HorizontalResolution);
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Image.VerticalResolution is not implemented for now.
+#endif
+ public void VerticalResolution () {
+ Assert.AreEqual (96, t.Bitmap.VerticalResolution);
+ }
+ [Test]
+ public void PixelFormatTest () {
+ Assert.AreEqual (PixelFormat.Format32bppArgb, t.Bitmap.PixelFormat);
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Image.PropertyIdList is not implemented for now.
+#endif
+ public void PropertyIdList () {
+ Assert.AreEqual (new int [0], t.Bitmap.PropertyIdList);
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Image.PropertyItems is not implemented for now.
+#endif
+ public void PropertyItems () {
+ Assert.AreEqual (new PropertyItem [0], t.Bitmap.PropertyItems);
+ }
+ [Test]
+ public void FrameDimensionsList () {
+ Assert.AreEqual (new Guid [] {FrameDimension.Page.Guid},
+ t.Bitmap.FrameDimensionsList);
+ }
+ [Test]
+ [Category ("Create")]
+ public void PNG_Interop()
+ {
+
+ string file_name = @"..\..\bitmap_gh.png";
+ using (FileStream r = new FileStream (file_name, FileMode.Open))
+ {
+ Image im = new Bitmap (r);
+ t.Graphics.DrawImageUnscaled (im, 0, 0);
+ Assert.IsTrue(t.Compare(2));
+ }
+
+ file_name = @"..\..\bitmap_net.png";
+ using (FileStream r = new FileStream (file_name, FileMode.Open))
+ {
+ Image im = new Bitmap (r);
+ t.Graphics.DrawImageUnscaled (im, 0, 0);
+ Assert.IsTrue(t.Compare(2));
+ }
+ }
+ [Test]
+ public void DefaultSaveFormat()
+ {
+ Bitmap b = new Bitmap(64, 64);
+ b.Save("saveFormat.xxx");
+
+ StreamReader sr = new StreamReader("saveFormat.xxx");
+ char [] buffer = new char[4];
+ sr.Read(buffer, 0, 4);
+ sr.Close();
+
+ Assert.AreEqual('P', buffer[0]);
+ Assert.AreEqual('N', buffer[1]);
+ Assert.AreEqual('G', buffer[2]);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Makefile b/mcs/class/System.Drawing/Test/DrawingTest/Test/Makefile
new file mode 100644
index 00000000000..96ccddbc3fc
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Makefile
@@ -0,0 +1,17 @@
+MCS=mcs
+NUNIT_FLAGS=/exclude=NotWorking
+
+sources=AssemblyInfo.cs Bitmap.cs Brush.cs Graphics.cs Image.cs Pen.cs Region.cs
+
+DRAWING_TEST_HELPER=DrawingTestHelper.dll
+EXOCORTEX=Exocortex.DSP.dll
+
+Test.dll: $(sources) $(DRAWING_TEST_HELPER)
+ $(MCS) -t:library $(sources) -r:$(DRAWING_TEST_HELPER) -r:$(EXOCORTEX) -r:nunit.framework -r:System.Drawing -out:Test.dll
+
+$(DRAWING_TEST_HELPER):
+ cd ../DrawingTestHelper && make
+ cp ../DrawingTestHelper/*.dll .
+
+run-test: Test.dll
+ MONO_PATH="../../../../../class/lib/default::$(MONO_PATH)" /home/andrews/monobuild/mono/runtime/mono-wrapper --debug ../../../../../class/lib/default/nunit-console.exe Test.dll $(NUNIT_FLAGS)
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Pen.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/Pen.cs
new file mode 100644
index 00000000000..be0dda8967b
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Pen.cs
@@ -0,0 +1,892 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using NUnit.Framework;
+using DrawingTestHelper;
+
+namespace Test.Sys.Drawing
+{
+ /// <summary>
+ /// Summary description for Pen.
+ /// </summary>
+ [TestFixture]
+ public class PenFixture {
+ //TODO: Brush, CompoundArray, CustomEndCap, CustomStartCap,
+ //StartCap, EndCap, PenType, Transform
+ DrawingTest t;
+ Pen p;
+ protected int TOLERANCE = 3;
+
+
+ [SetUp]
+ public void SetUp () {
+ t = DrawingTest.Create (256, 256);
+ p = new Pen (Color.Blue);
+ p.Width = 10;
+ DrawingTest.ShowForms = false;
+ }
+
+ #region InitAlignment
+ [Test]
+ public void InitAlignment () {
+ Pen p = new Pen (Color.Blue);
+ Assert.AreEqual (PenAlignment.Center, p.Alignment);
+ }
+ #endregion
+
+ #region PenWidth
+ [Test]
+ public void PenWidth_1()
+ {
+ Assert.AreEqual(10, p.Width);
+ t.Graphics.DrawLine (p, 20, 200, 200, 20);
+ t.Show();
+ Assert.IsTrue (t.Compare (TOLERANCE * 1.5f)); //FIXME: Pen width in GH is not the same as in .NET
+ }
+ [Test]
+ public void PenWidth_2()
+ {
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 20, 200, 200, 20);
+ t.Show();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void PenWidth_3 ()
+ {
+ t.Graphics.DrawLine (p, 10, 100, 200, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region DashStyle Tests
+ [Test]
+ public void DashStyleTest_1 ()
+ {
+ Assert.AreEqual (DashStyle.Solid, p.DashStyle);
+ p.Width = 14;
+ t.Graphics.DrawLine (p, 20, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void DashStyleTest_2 () {
+ p.DashStyle = DashStyle.Dash;
+ p.Width = 14;
+ t.Graphics.DrawLine (p, 20, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void DashStyleTest_3 () {
+ p.DashStyle = DashStyle.DashDot;
+ p.Width = 14;
+ t.Graphics.FillRectangle (Brushes.Black, 0, 0, 256, 256);
+ t.Graphics.DrawLine (p, 20, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void DashStyleTest_4 () {
+ p.DashStyle = DashStyle.DashDotDot;
+ p.Width = 14;
+ t.Graphics.FillRectangle (Brushes.Black, 0, 0, 256, 256);
+ t.Graphics.DrawLine (p, 20, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void DashStyleTest_5 () {
+ p.DashStyle = DashStyle.Dot;
+ p.Width = 14;
+ t.Graphics.FillRectangle (Brushes.Black, 0, 0, 256, 256);
+ t.Graphics.DrawLine (p, 20, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void DashStyleTest_6 () {
+ p.DashStyle = DashStyle.Custom;
+ p.Width = 14;
+ t.Graphics.FillRectangle (Brushes.Black, 0, 0, 256, 256);
+ t.Graphics.DrawLine (p, 20, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region DashCustomStyle
+ //The following tests DashOffset and DashPattern
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: Bug in dashed line
+#endif
+ public void DashCustomStyle_1 () {
+ p.DashStyle = DashStyle.Custom;
+ p.Width = 10;
+ Assert.AreEqual (new float [] {1F}, p.DashPattern);
+ Assert.AreEqual (0F, p.DashOffset);
+ }
+ [Test]
+ public void DashCustomStyle_2 () {
+ p.DashPattern = new float [] {2, 3, 1.15F, 0.05F};
+ t.Graphics.FillRectangle (Brushes.Black, 0, 0, 256, 256);
+ t.Graphics.DrawLine (p, 20, 100, 200, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void DashCustomStyle_3 () {
+ p.DashOffset = 10F;
+ t.Graphics.DrawLine (p, 20, 100, 200, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: Bug in dashed line
+#endif
+ public void DashCustomStyle_4 () {
+ p.DashPattern = new float [] {2, 3, 1.15F, 0.05F, 1.74321F};
+ p.DashOffset = 10.2F;
+ t.Graphics.DrawLine (p, 20, 100, 200, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: Bug in dashed line
+#endif
+ public void DashCustomStyle_5 () {
+ p.DashPattern = new float [] {2, 3, 1.15F, 0.05F, 1.74321F};
+ p.DashOffset = 10.2F;
+ t.Graphics.DrawLine (p, 20, 100, 200, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region DashCapTest
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: Bug in dashed line
+#endif
+ public void DashCapTest_Flat () {
+ p.Width = 15;
+ Assert.AreEqual (DashCap.Flat, p.DashCap);
+ p.DashStyle = DashStyle.DashDot;
+ t.Graphics.DrawLine (p, 10, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: Bug in dashed line
+#endif
+ public void DashCapTest_Round () {
+ p.Width = 15;
+ p.DashStyle = DashStyle.DashDot;
+ p.DashCap = DashCap.Round;
+ t.Graphics.DrawLine (p, 10, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: DashCap.Triangle is not sopported by GH
+#endif
+ public void DashCapTest_Triangle () {
+ p.Width = 15;
+ p.DashStyle = DashStyle.DashDot;
+ p.DashCap = DashCap.Triangle;
+ t.Graphics.DrawLine (p, 10, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region LineJoin Round
+ [Test]
+ public void LineJoinTest_Round_1 () {
+ Point [] points = new Point [] {
+ new Point(100, 210), new Point (120, 50),
+ new Point (140, 210)};
+ p.Width = 25;
+ p.LineJoin = LineJoin.Round;
+ t.Graphics.DrawPolygon (p, points);
+ t.Graphics.DrawPolygon (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+
+ [Test]
+ public void LineJoinTest_Round_2 () {
+ Point [] points = new Point [] {
+ new Point(50, 210), new Point (120, 50),
+ new Point (190, 210)};
+ p.Width = 25;
+ p.LineJoin = LineJoin.Round;
+ t.Graphics.DrawPolygon (p, points);
+ t.Graphics.DrawPolygon (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region LineJoin Miter
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Currently Only MiterClipper is sopported by GH
+#endif
+ public void LineJoinTest_Miter_1 () {
+ p.LineJoin = LineJoin.Miter;
+ Point [] points = new Point [] {
+ new Point(100, 217), new Point (130, 100),
+ new Point (160, 217)};
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Currently Only MiterClipper is sopported by GH
+#endif
+ public void LineJoinTest_Miter_2 () {
+ p.LineJoin = LineJoin.Miter;
+ Point [] points = new Point [] {
+ new Point(120, 237), new Point (130, 100),
+ new Point (140, 237)};
+ p.Width = 10;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Currently Only MiterClipper is sopported by GH
+#endif
+ public void LineJoinTest_Miter_3 () {
+ p.LineJoin = LineJoin.Miter;
+ Point [] points = new Point [] {
+ new Point(50, 217), new Point (100, 100),
+ new Point (150, 217)};
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region LineJoin MiterClipped
+ [Test]
+ public void LineJoinTest_MiterClipped_1 () {
+ p.LineJoin = LineJoin.MiterClipped;
+ Point [] points = new Point [] {
+ new Point(100, 217), new Point (130, 100),
+ new Point (160, 217)};
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void LineJoinTest_MiterClipped_2 () {
+ p.LineJoin = LineJoin.MiterClipped;
+ Point [] points = new Point [] {
+ new Point(120, 217), new Point (130, 80),
+ new Point (140, 217)};
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void LineJoinTest_MiterClipped_3 () {
+ p.LineJoin = LineJoin.MiterClipped;
+ Point [] points = new Point [] {
+ new Point(50, 217), new Point (100, 100),
+ new Point (150, 217)};
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region "LineJoin Bevel"
+ [Test]
+ public void LineJoinTest_Bevel_1 () {
+ p.LineJoin = LineJoin.Bevel;
+ Point [] points = new Point [] {
+ new Point(90, 217), new Point (115, 55),
+ new Point (140, 217)};
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void LineJoinTest_Bevel_2 () {
+ p.LineJoin = LineJoin.Bevel;
+ Point [] points = new Point [] {
+ new Point(110, 217), new Point (120, 75),
+ new Point (130, 217)};
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void LineJoinTest_Bevel_3 () {
+ p.LineJoin = LineJoin.Bevel;
+ Point [] points = new Point [] {
+ new Point(50, 217), new Point (100, 100),
+ new Point (150, 217)};
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void LineJoinTest_Bevel_4 () {
+ p.LineJoin = LineJoin.Bevel;
+ Point [] points = new Point [] {
+ new Point(143, 210), new Point (170, 100),
+ new Point (180, 20)};
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void LineJoinTest_Bevel_5 () {
+ p.LineJoin = LineJoin.Bevel;
+ Point [] points = new Point [] {
+ new Point(50, 100), new Point (150, 100),
+ new Point (150, 20), new Point (200, 20)};
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region PenAlignment
+ [Test]
+ public void PenAlignmentTest_1 () {
+ Assert.AreEqual (PenAlignment.Center, p.Alignment);
+ Point [] points = new Point [] {
+ new Point (30, 30), new Point (100, 100), new Point (170, 30),
+ new Point (170, 200), new Point (30, 200)};
+ GraphicsPath path = new GraphicsPath ();
+ path.AddPolygon (points);
+
+ p.Width = 25;
+ t.Graphics.DrawPath (p, path);
+ t.Graphics.DrawPath (Pens.White, path);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void PenAlignmentTest_2 () {
+ Point [] points = new Point [] {
+ new Point (30, 30), new Point (100, 100), new Point (170, 30),
+ new Point (170, 200), new Point (30, 200)};
+ GraphicsPath path = new GraphicsPath ();
+ path.AddPolygon (points);
+
+ p.Width = 25;
+ p.Alignment = PenAlignment.Left;
+ t.Graphics.DrawPath (p, path);
+ t.Graphics.DrawPath (Pens.White, path);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: Bug in pen aligment
+#endif
+ public void PenAlignmentTest_3 () {
+ Point [] points = new Point [] {
+ new Point (30, 30), new Point (100, 100), new Point (170, 30),
+ new Point (170, 200), new Point (30, 200)};
+ GraphicsPath path = new GraphicsPath ();
+ path.AddPolygon (points);
+
+ p.Width = 25;
+ p.Alignment = PenAlignment.Inset;
+ t.Graphics.DrawPath (p, path);
+ t.Graphics.DrawPath (Pens.White, path);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+
+ [Test]
+ public void PenAlignmentTest_4 () {
+ Point [] points = new Point [] {
+ new Point (30, 30), new Point (100, 100), new Point (170, 30),
+ new Point (170, 200), new Point (30, 200)};
+ GraphicsPath path = new GraphicsPath ();
+ path.AddPolygon (points);
+
+ p.Width = 25;
+ p.Alignment = PenAlignment.Outset;
+ t.Graphics.DrawPath (p, path);
+ t.Graphics.DrawPath (Pens.White, path);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+
+ [Test]
+ public void PenAlignmentTest_5 () {
+ Point [] points = new Point [] {
+ new Point (30, 30), new Point (100, 100), new Point (170, 30),
+ new Point (170, 200), new Point (30, 200)};
+ GraphicsPath path = new GraphicsPath ();
+ path.AddPolygon (points);
+
+ p.Width = 25;
+ p.Alignment = PenAlignment.Right;
+ t.Graphics.DrawPath (p, path);
+ t.Graphics.DrawPath (Pens.White, path);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region Color test
+ [Test]
+ public void ColorTest_1 () {
+ Assert.AreEqual (Color.Blue, p.Color);
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 10, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void ColorTest_2 () {
+ p.Color = Color.Red;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 10, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void ColorTest_3 () {
+ p.Color = Color.BurlyWood;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 10, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void ColorTest_4 () {
+ p.Color = Color.FromArgb (100, 120, 255);
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 10, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void ColorTest_5 () {
+ p.Color = Color.FromArgb (128, Color.White);
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 10, 100, 230, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region MiterLimit
+ [Test]
+ public void MitterLimit_1 () {
+ p.LineJoin = LineJoin.MiterClipped;
+ Point [] points = new Point [] {new Point (0,30), new Point (180, 30),
+ new Point (0, 90)};
+
+ p.Width = 25;
+ Assert.AreEqual (10F, p.MiterLimit);
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void MitterLimit_2 () {
+ p.MiterLimit=1F;
+ p.LineJoin = LineJoin.MiterClipped;
+ Point [] points = new Point [] {new Point (0,30), new Point (180, 30),
+ new Point (0, 120)};
+
+ p.Width = 25;
+ t.Graphics.DrawLines (p, points);
+ t.Graphics.DrawLines (Pens.White, points);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region TRansform
+ [Test]
+ public void Transform () {
+ p.ScaleTransform (0.5F, 2);
+ t.Graphics.DrawArc (p, 70, 70, 100, 100, 0, 360);
+ t.Graphics.DrawArc (Pens.White, 70, 70, 100, 100, 0, 360);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region Line StartCap
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_Flat() {
+ Assert.AreEqual(LineCap.Flat, p.StartCap);
+ p.StartCap = LineCap.Flat;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_Round() {
+ p.StartCap = LineCap.Round;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_Square() {
+ p.StartCap = LineCap.Square;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_AnchorMask() {
+ p.StartCap = LineCap.AnchorMask;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_ArrowAnchor() {
+ p.StartCap = LineCap.ArrowAnchor;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_DiamondAnchor() {
+ p.StartCap = LineCap.DiamondAnchor;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_NoAnchor() {
+ p.StartCap = LineCap.NoAnchor;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_RoundAnchor() {
+ p.StartCap = LineCap.RoundAnchor;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_SquareAnchor() {
+ p.StartCap = LineCap.SquareAnchor;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_Triangle() {
+ p.StartCap = LineCap.Triangle;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void StartCap_Custom() {
+ p.StartCap = LineCap.Custom;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region Line EndCap
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_Flat()
+ {
+ Assert.AreEqual(LineCap.Flat, p.EndCap);
+ p.EndCap = LineCap.Flat;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_Round()
+ {
+ p.EndCap = LineCap.Round;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_Square() {
+ p.EndCap = LineCap.Square;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_AnchorMask() {
+ p.EndCap = LineCap.AnchorMask;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_ArrowAnchor() {
+ p.EndCap = LineCap.ArrowAnchor;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_DiamondAnchor() {
+ p.EndCap = LineCap.DiamondAnchor;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_NoAnchor() {
+ p.EndCap = LineCap.NoAnchor;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_RoundAnchor() {
+ p.EndCap = LineCap.RoundAnchor;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_SquareAnchor() {
+ p.EndCap = LineCap.SquareAnchor;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_Triangle() {
+ p.EndCap = LineCap.Triangle;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] //FIXME: cannot apply start or end line caps separately
+#endif
+ public void EndCap_Custom() {
+ p.EndCap = LineCap.Custom;
+ p.Width = 25;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+
+ #region Basic LineCaps StartEnd
+ [Test]
+ public void StartEndCapBasic_Flat() {
+ Assert.AreEqual(LineCap.Flat, p.StartCap);
+
+ p.Width = 21;
+ p.EndCap = LineCap.Flat;
+ p.StartCap = LineCap.Flat;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void StartEndCapBasic_Round() {
+ p.Width = 21;
+ p.EndCap = LineCap.Round;
+ p.StartCap = LineCap.Round;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void StartEndCapBasic_Square() {
+ p.Width = 21;
+ p.EndCap = LineCap.Square;
+ p.StartCap = LineCap.Square;
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void SetLineCap_Flat() {
+ Assert.AreEqual(LineCap.Flat, p.StartCap);
+
+ p.Width = 21;
+ p.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void SetLineCap_Round() {
+ p.Width = 21;
+ p.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ [Test]
+ public void SetLineCap_Square() {
+ p.Width = 21;
+ p.SetLineCap(LineCap.Square, LineCap.Square, DashCap.Flat);
+ t.Graphics.DrawLine (p, 50, 100, 150, 100);
+ t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
+ t.Show ();
+ Assert.IsTrue (t.Compare (TOLERANCE));
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Pens.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/Pens.cs
new file mode 100644
index 00000000000..bede472781d
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Pens.cs
@@ -0,0 +1,350 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using NUnit.Framework;
+using DrawingTestHelper;
+using System.Reflection;
+
+namespace Test.Sys.Drawing
+{
+ /// <summary>
+ /// Summary description for Pens.
+ /// </summary>
+
+ [TestFixture]
+ public class PensFixture
+ {
+
+ [SetUp]
+ public void SetUp ()
+ {
+ }
+
+ #region names array
+ private string [] ar_pens = {
+ "Transparent",
+ "AliceBlue",
+ "AntiqueWhite",
+ "Aqua",
+ "Aquamarine",
+ "Azure",
+ "Beige",
+ "Bisque",
+ "Black",
+ "BlanchedAlmond",
+ "Blue",
+ "BlueViolet",
+ "Brown",
+ "BurlyWood",
+ "CadetBlue",
+ "Chartreuse",
+ "Chocolate",
+ "Coral",
+ "CornflowerBlue",
+ "Cornsilk",
+ "Crimson",
+ "Cyan",
+ "DarkBlue",
+ "DarkCyan",
+ "DarkGoldenrod",
+ "DarkGray",
+ "DarkGreen",
+ "DarkKhaki",
+ "DarkMagenta",
+ "DarkOliveGreen",
+ "DarkOrange",
+ "DarkOrchid",
+ "DarkRed",
+ "DarkSalmon",
+ "DarkSeaGreen",
+ "DarkSlateBlue",
+ "DarkSlateGray",
+ "DarkTurquoise",
+ "DarkViolet",
+ "DeepPink",
+ "DeepSkyBlue",
+ "DimGray",
+ "DodgerBlue",
+ "Firebrick",
+ "FloralWhite",
+ "ForestGreen",
+ "Fuchsia",
+ "Gainsboro",
+ "GhostWhite",
+ "Gold",
+ "Goldenrod",
+ "Gray",
+ "Green",
+ "GreenYellow",
+ "Honeydew",
+ "HotPink",
+ "IndianRed",
+ "Indigo",
+ "Ivory",
+ "Khaki",
+ "Lavender",
+ "LavenderBlush",
+ "LawnGreen",
+ "LemonChiffon",
+ "LightBlue",
+ "LightCoral",
+ "LightCyan",
+ "LightGoldenrodYellow",
+ "LightGreen",
+ "LightGray",
+ "LightPink",
+ "LightSalmon",
+ "LightSeaGreen",
+ "LightSkyBlue",
+ "LightSlateGray",
+ "LightSteelBlue",
+ "LightYellow",
+ "Lime",
+ "LimeGreen",
+ "Linen",
+ "Magenta",
+ "Maroon",
+ "MediumAquamarine",
+ "MediumBlue",
+ "MediumOrchid",
+ "MediumPurple",
+ "MediumSeaGreen",
+ "MediumSlateBlue",
+ "MediumSpringGreen",
+ "MediumTurquoise",
+ "MediumVioletRed",
+ "MidnightBlue",
+ "MintCream",
+ "MistyRose",
+ "Moccasin",
+ "NavajoWhite",
+ "Navy",
+ "OldLace",
+ "Olive",
+ "OliveDrab",
+ "Orange",
+ "OrangeRed",
+ "Orchid",
+ "PaleGoldenrod",
+ "PaleGreen",
+ "PaleTurquoise",
+ "PaleVioletRed",
+ "PapayaWhip",
+ "PeachPuff",
+ "Peru",
+ "Pink",
+ "Plum",
+ "PowderBlue",
+ "Purple",
+ "Red",
+ "RosyBrown",
+ "RoyalBlue",
+ "SaddleBrown",
+ "Salmon",
+ "SandyBrown",
+ "SeaGreen",
+ "SeaShell",
+ "Sienna",
+ "Silver",
+ "SkyBlue",
+ "SlateBlue",
+ "SlateGray",
+ "Snow",
+ "SpringGreen",
+ "SteelBlue",
+ "Tan",
+ "Teal",
+ "Thistle",
+ "Tomato",
+ "Turquoise",
+ "Violet",
+ "Wheat",
+ "White",
+ "WhiteSmoke",
+ "Yellow",
+ "YellowGreen"};
+
+ string [] ar_system_pens = {
+ "ActiveCaptionText",
+ "Control",
+ "ControlText",
+ "ControlDark",
+ "ControlDarkDark",
+ "ControlLight",
+ "ControlLightLight",
+ "GrayText",
+ "Highlight",
+ "HighlightText",
+ "InactiveCaptionText",
+ "InfoText",
+ "MenuText",
+ "WindowFrame",
+ "WindowText"};
+ #endregion
+
+
+ [Test]
+ public void PensPropertyCount()
+ {
+ Type t = typeof(Pens);
+ PropertyInfo [] pi = t.GetProperties(BindingFlags.Static | BindingFlags.Public);
+
+ int i = 0;
+ foreach (PropertyInfo p in pi)
+ {
+ if (p.PropertyType == typeof(Pen))
+ {
+ i++;
+ }
+ }
+ Assert.AreEqual(ar_pens.Length, i, "Number of Pens");
+ }
+
+ [Test]
+ public void SystemPensPropertyCount()
+ {
+ Type t = typeof(SystemPens);
+ PropertyInfo [] pi = t.GetProperties(BindingFlags.Static | BindingFlags.Public);
+
+ int i = 0;
+ foreach (PropertyInfo p in pi)
+ {
+ if (p.PropertyType == typeof(Pen))
+ {
+ i++;
+ }
+ }
+ Assert.AreEqual(ar_system_pens.Length, i, "Number of System Pens");
+ }
+
+ [Test]
+ public void PensProperties ()
+ {
+ Type t = typeof(Pens);
+ foreach (string s in ar_pens)
+ {
+ MemberInfo [] mi = t.GetMember(s);
+
+ if (mi.Length == 1)
+ {
+ if (mi[0].MemberType == MemberTypes.Property)
+ {
+ PropertyInfo p = (PropertyInfo)mi[0];
+ Pen pen = (Pen)p.GetValue(null, null);
+ Assert.AreEqual("Color [" + s + "]", pen.Color.ToString());
+ }
+ else
+ {
+ Assert.Fail(s + " is not property of Pens class");
+ }
+ }
+ else
+ {
+ Assert.Fail("Property " + s + " not found in Pens class");
+ }
+ }
+ }
+
+ [Test]
+ public void SystemPensProperties ()
+ {
+ Type t = typeof(SystemPens);
+ foreach (string s in ar_system_pens)
+ {
+ MemberInfo [] mi = t.GetMember(s);
+
+ if (mi.Length == 1)
+ {
+ if (mi[0].MemberType == MemberTypes.Property)
+ {
+ PropertyInfo p = (PropertyInfo)mi[0];
+ Pen pen = (Pen)p.GetValue(null, null);
+ Assert.AreEqual("Color [" + s + "]", pen.Color.ToString());
+ }
+ else
+ {
+ Assert.Fail(s + " is not property of SystemPens class");
+ }
+ }
+ else
+ {
+ Assert.Fail("Property " + s + " not found in SystemPens class");
+ }
+ }
+ }
+
+ [Test]
+ public void PenAssignValue ()
+ {
+ Type t = typeof(Pens);
+ foreach (string s in ar_pens)
+ {
+ MemberInfo [] mi = t.GetMember(s);
+
+ if (mi.Length == 1)
+ {
+ if (mi[0].MemberType == MemberTypes.Property)
+ {
+ PropertyInfo p = (PropertyInfo)mi[0];
+ Pen pen = (Pen)p.GetValue(null, null);
+
+ try
+ {
+ pen.Color = Color.AliceBlue;
+ Assert.Fail("Pen.Color must throw exception");
+ }
+ catch(ArgumentException)
+ {
+ Assert.IsTrue(true);
+ }
+ }
+ else
+ {
+ Assert.Fail(s + " is not property of Pens class");
+ }
+ }
+ else
+ {
+ Assert.Fail("Property " + s + " not found in Pens class");
+ }
+ }
+ }
+
+ [Test]
+ public void SystemPenAssignValue ()
+ {
+ Type t = typeof(SystemPens);
+ foreach (string s in ar_system_pens)
+ {
+ MemberInfo [] mi = t.GetMember(s);
+
+ if (mi.Length == 1)
+ {
+ if (mi[0].MemberType == MemberTypes.Property)
+ {
+ PropertyInfo p = (PropertyInfo)mi[0];
+ Pen pen = (Pen)p.GetValue(null, null);
+
+ try
+ {
+ pen.Color = Color.AliceBlue;
+ Assert.Fail("SystemPen.Color must throw exception");
+ }
+ catch(ArgumentException)
+ {
+ Assert.IsTrue(true);
+ }
+ }
+ else
+ {
+ Assert.Fail(s + " is not property of SystemPen class");
+ }
+ }
+ else
+ {
+ Assert.Fail("Property " + s + " not found in SystemPen class");
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/Region.cs b/mcs/class/System.Drawing/Test/DrawingTest/Test/Region.cs
new file mode 100644
index 00000000000..d758c92632b
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/Region.cs
@@ -0,0 +1,238 @@
+using System;
+using NUnit.Framework;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using DrawingTestHelper;
+
+namespace Test.Sys.Drawing {
+ [TestFixture]
+ public class RegionFixture {
+ DrawingTest t;
+ RectangleF rect;
+ Region r;
+ [SetUp]
+ public void SetUp ()
+ {
+ t = DrawingTest.Create (1000, 1000);
+ rect = new RectangleF (50, 50, 50, 50);
+ r = new Region(rect);
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Region.GetRegionData is not implemented
+#endif
+ public void ctor_RegionData () {
+ RegionData rgnData = r.GetRegionData ();
+ Region r1 = new Region (rgnData);
+ Assert.AreEqual (rgnData.Data, r1.GetRegionData ().Data);
+ }
+ [Test]
+ public void ctor_GraphicsPath () {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddRectangle (rect);
+ Region r1 = new Region (path);
+ r1.Xor (r);
+ Assert.IsTrue (r1.IsEmpty (t.Graphics));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Region.GetRegionData is not implemented
+#endif
+ public void ctor_Rectangle () {
+ Region r1 = new Region (new Rectangle ((int)rect.X, (int)rect.Y,
+ (int)rect.Width, (int)rect.Height));
+ Assert.AreEqual (r.GetRegionData ().Data,
+ r1.GetRegionData ().Data);
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Region.GetRegionData is not implemented
+#endif
+ public void ctor_RectangleF () {
+ Region r1 = new Region (rect);
+ Assert.AreEqual (r.GetRegionData ().Data,
+ r1.GetRegionData ().Data);
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Bug in Region.IsInfinite
+#endif
+ public void ctor_void () {
+ Region r1 = new Region ();
+ Assert.IsTrue (r1.IsInfinite (t.Graphics));
+ }
+ [Test]
+ public void Clone () {
+ Region r1 = r.Clone ();
+ Assert.IsFalse (Object.ReferenceEquals (r1, r));
+ Assert.AreEqual (r1.GetBounds (t.Graphics), r.GetBounds (t.Graphics));
+ r1.Xor (r);
+ Assert.IsTrue (r1.IsEmpty (t.Graphics));
+ Assert.IsFalse (r.IsEmpty (t.Graphics));
+ }
+ [Test]
+ public void Complement () {
+ r.Complement (new Rectangle (70, 70, 80, 20));
+ Assert.AreEqual (new RectangleF (100, 70, 50, 20),
+ r.GetBounds (t.Graphics));
+ }
+ [Test]
+ public void Equals_Graphics () {
+ Region r1 = new Region (rect);
+ Assert.IsTrue (r.Equals (r1, t.Graphics));
+ }
+ [Test]
+ public void Exclude () {
+ r.Exclude (new Rectangle (10, 10, 90, 60));
+ Assert.AreEqual (new RectangleF (50, 70, 50, 30),
+ r.GetBounds (t.Graphics));
+ }
+ [Test]
+ public void GetBounds ()
+ {
+ Assert.AreEqual (rect, r.GetBounds (t.Graphics));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Region.GetRegionData is not implemented
+#endif
+ public void GetRegionData () {
+ byte [] actual = r.GetRegionData ().Data;
+ byte [] expected = new byte [] {28, 0, 0, 0, 186, 15, 11, 58, 1, 16,
+ 192, 219, 0, 0, 0, 0, 0, 0, 0, 16,
+ 0, 0, 72, 66, 0, 0, 72, 66, 0, 0,
+ 72, 66, 0, 0, 72, 66};
+ Assert.AreEqual (expected, actual);
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Bug in Region.GetRegionScans
+#endif
+ public void GetRegionScans () {
+ Assert.AreEqual (new RectangleF [] {new Rectangle (50, 50, 50, 50)},
+ r.GetRegionScans (new Matrix ()));
+ r.Union (new Rectangle (100, 100, 50, 50));
+ RectangleF [] rs = new RectangleF [] {
+ new Rectangle (50, 50, 50, 50),
+ new Rectangle (100, 100, 50, 50)};
+ Assert.AreEqual (rs,
+ r.GetRegionScans (new Matrix ()));
+ }
+ [Test]
+ public void Intersect () {
+ r.Intersect (new Rectangle (70, 70, 50, 50));
+ Assert.AreEqual (new RectangleF (70, 70, 30, 30),
+ r.GetBounds (t.Graphics));
+ }
+ [Test]
+ public void IsEmpty () {
+ Assert.IsFalse (r.IsEmpty (t.Graphics));
+ r.Xor (r.Clone ());
+ Assert.IsTrue (r.IsEmpty (t.Graphics));
+ }
+ [Test]
+ public void IsInfinite () {
+ Assert.IsFalse (r.IsInfinite (t.Graphics));
+ r.MakeInfinite ();
+ Assert.IsTrue (r.IsInfinite (t.Graphics));
+ RectangleF infiniteRect = new RectangleF (-0x400000, -0x400000, 0x800000, 0x800000);
+ Assert.AreEqual (new RectangleF [] {infiniteRect},
+ r.GetRegionScans (new Matrix ()));
+ r.Exclude (new Rectangle (10, 10, 10, 10));
+ Assert.IsFalse (r.IsInfinite (t.Graphics));
+ Assert.AreEqual (infiniteRect, r.GetBounds (t.Graphics));
+ }
+ [Test]
+ public void IsVisible_int () {
+ Rectangle rectD = new Rectangle (50, 50, 10000, 10000);
+ r = new Region (rectD);
+ Assert.IsTrue (r.IsVisible (rectD, t.Graphics));
+ Assert.IsTrue (r.IsVisible (rectD.X, rectD.Y, rectD.Height, rectD.Width,
+ t.Graphics));
+ Assert.IsTrue (r.IsVisible (rectD));
+ Assert.IsTrue (r.IsVisible (rectD.X, rectD.Y, rectD.Height, rectD.Width));
+ Assert.IsFalse (r.IsVisible (new Point (rectD.Right, rectD.Bottom),
+ t.Graphics));
+ Assert.IsTrue (r.IsVisible (new Point (rectD.X, rectD.Y)));
+ Assert.IsFalse (r.IsVisible (new Point (rectD.X-1, rectD.Y-1)));
+ Assert.IsTrue (r.IsVisible (100, 100, t.Graphics));
+ Assert.IsTrue (r.IsVisible (100, 100));
+ }
+ [Test]
+ [Category ("NotWorking")]
+ public void IsVisible_float () {
+ t.Graphics.PageScale = 10;
+ rect = new Rectangle (50, 50, 1000, 1000);
+ r = new Region (rect);
+ Assert.IsTrue (r.IsVisible (rect, t.Graphics));
+ Assert.IsTrue (r.IsVisible (rect.X, rect.Y, rect.Height, rect.Width,
+ t.Graphics));
+ Assert.IsTrue (r.IsVisible (rect));
+ Assert.IsTrue (r.IsVisible (rect.X, rect.Y, rect.Height, rect.Width));
+ Assert.IsFalse (r.IsVisible (new PointF (rect.Right, rect.Bottom),
+ t.Graphics));
+ Assert.IsFalse (r.IsVisible (new PointF (rect.Right, rect.Bottom)));
+ Assert.IsFalse (r.IsVisible (new PointF (rect.Right-0.1F,
+ rect.Bottom-0.1F)));
+ Assert.IsTrue (r.IsVisible (new PointF (rect.Right-1,
+ rect.Bottom-1)));
+ Assert.IsTrue (r.IsVisible (100.0F, 100.0F, t.Graphics));
+ Assert.IsTrue (r.IsVisible (100.0F, 100.0F));
+ Assert.IsTrue (r.IsVisible (new PointF (rect.X, rect.Y)));
+ Assert.IsFalse (r.IsVisible (new PointF (rect.X-0.4F,
+ rect.Y-0.4F)));
+ }
+ [Test]
+ public void MakeEmpty () {
+ Assert.IsFalse (r.IsEmpty (t.Graphics));
+ r.MakeEmpty ();
+ Assert.IsTrue (r.IsEmpty (t.Graphics));
+ Assert.AreEqual (new RectangleF (0,0,0,0), r.GetBounds (t.Graphics));
+ Assert.IsFalse (r.IsVisible (new Rectangle (0, 0, 0, 0)));
+ }
+ [Test]
+ public void MakeInfinite () {
+ Assert.IsFalse (r.IsInfinite (t.Graphics));
+ r.MakeInfinite ();
+ Assert.IsTrue (r.IsInfinite (t.Graphics));
+ RectangleF infiniteRect = new RectangleF (-0x400000, -0x400000, 0x800000, 0x800000);
+ Assert.AreEqual (new RectangleF [] {infiniteRect},
+ r.GetRegionScans (new Matrix ()));
+ }
+ [Test]
+ public new void ToString () {
+ Assert.IsTrue (r.ToString ().ToLower().StartsWith("system.drawing.region"));
+ }
+ [Test]
+ public void Transform () {
+ }
+ [Test]
+ public void Translate () {
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Bug in Region.GetRegionScans
+#endif
+ public void Union () {
+ r.Union (new Rectangle (70, 70, 100, 100));
+ RectangleF [] rs = new RectangleF [] {
+ new RectangleF (50, 50, 50, 20),
+ new RectangleF (50, 70, 120, 30),
+ new RectangleF (70, 100, 100, 70)};
+ Assert.AreEqual (rs, r.GetRegionScans (new Matrix()));
+ }
+ [Test]
+#if TARGET_JVM
+ [Category ("NotWorking")] // FIXME: Bug in Region.GetRegionScans
+#endif
+ public void Xor () {
+ r.Xor (new Rectangle (0, 0, 70, 70));
+ RectangleF [] rs = new RectangleF [] {
+ new RectangleF (0, 0, 70, 50),
+ new RectangleF (0, 50, 50, 20),
+ new RectangleF (70, 50, 30, 20),
+ new RectangleF (50, 70, 50, 30)};
+ Assert.AreEqual (rs, r.GetRegionScans (new Matrix()));
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/SampIcon.ico b/mcs/class/System.Drawing/Test/DrawingTest/Test/SampIcon.ico
new file mode 100644
index 00000000000..698d20c06c4
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/SampIcon.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap25.png b/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap25.png
new file mode 100644
index 00000000000..dc84b98cd43
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap25.png
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap50.png b/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap50.png
new file mode 100644
index 00000000000..ca244e0fc47
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap50.png
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap_gh.png b/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap_gh.png
new file mode 100644
index 00000000000..90bd4427ba2
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap_gh.png
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap_net.png b/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap_net.png
new file mode 100644
index 00000000000..74387b7d7b2
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/DrawingTest/Test/bitmap_net.png
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Design/CategoryNameCollectionCas.cs b/mcs/class/System.Drawing/Test/System.Drawing.Design/CategoryNameCollectionCas.cs
new file mode 100644
index 00000000000..39fcc525c8f
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Design/CategoryNameCollectionCas.cs
@@ -0,0 +1,83 @@
+//
+// CategoryNameCollectionCas.cs
+// - CAS unit tests for System.Drawing.Design.CategoryNameCollection
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Drawing.Design;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing.Design {
+
+ [TestFixture]
+ [Category ("CAS")]
+ public class CategoryNameCollectionCas {
+
+ private ConstructorInfo ctor;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ ConstructorInfo[] infos = typeof (CategoryNameCollection).GetConstructors ();
+ ctor = infos[0];
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ [Test]
+ [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+ public void Create ()
+ {
+ new CategoryNameCollection (new string[0]);
+ }
+
+ // we use reflection to call CategoryNameCollection class as it's
+ // protected by a LinkDemand (which will be converted into full demand,
+ // i.e. a stack walk) when reflection is used (i.e. it gets testable).
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void Create_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (ctor, "constructor");
+ ctor.Invoke (new object[1] { (string[])null });
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Design/ChangeLog b/mcs/class/System.Drawing/Test/System.Drawing.Design/ChangeLog
new file mode 100644
index 00000000000..8063081a3c3
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Design/ChangeLog
@@ -0,0 +1,22 @@
+2005-12-05 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * TestToolboxItem.cs: New unit test
+
+2005-09-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * CategoryNameCollectionCas.cs: New. CAS unit tests to check for
+ LinkDemand for SkipVerification.
+ * PaintValueEventArgsCas.cs: New. CAS unit tests to check for
+ LinkDemand for SkipVerification.
+ * PropertyValueUIItemCas.cs: New. CAS unit tests to check for
+ LinkDemand for SkipVerification.
+ * ToolboxComponentsCreatedEventArgsCas.cs: New. CAS unit tests to
+ check for LinkDemand for SkipVerification.
+ * ToolboxComponentsCreatingEventArgsCas.cs: New. CAS unit tests to
+ check for LinkDemand for SkipVerification.
+ * ToolboxItemCas.cs: New. CAS unit tests to check for LinkDemand for
+ SkipVerification.
+ * ToolboxItemCollectionCas.cs: New. CAS unit tests to check for
+ LinkDemand for SkipVerification.
+ * UITypeEditorCas.cs: New. CAS unit tests to check for LinkDemand for
+ SkipVerification.
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Design/PaintValueEventArgsCas.cs b/mcs/class/System.Drawing/Test/System.Drawing.Design/PaintValueEventArgsCas.cs
new file mode 100644
index 00000000000..c28b515877b
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Design/PaintValueEventArgsCas.cs
@@ -0,0 +1,85 @@
+//
+// PaintValueEventArgsCas.cs
+// - CAS unit tests for System.Drawing.Design.PaintValueEventArgs
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Drawing;
+using System.Drawing.Design;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing.Design {
+
+ [TestFixture]
+ [Category ("CAS")]
+ public class PaintValueEventArgsCas {
+
+ private ConstructorInfo ctor;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ ConstructorInfo[] infos = typeof (PaintValueEventArgs).GetConstructors ();
+ ctor = infos[0];
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ [Test]
+ [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+ public void Create ()
+ {
+ Rectangle r = new Rectangle ();
+ new PaintValueEventArgs (null, null, Graphics.FromImage (new Bitmap (10, 10)), r);
+ }
+
+ // we use reflection to call PaintValueEventArgs class as it's protected
+ // by a LinkDemand (which will be converted into full demand, i.e. a
+ // stack walk) when reflection is used (i.e. it gets testable).
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void Create_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (ctor, "constructor");
+ ctor.Invoke (new object[4]);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Design/PropertyValueUIItemCas.cs b/mcs/class/System.Drawing/Test/System.Drawing.Design/PropertyValueUIItemCas.cs
new file mode 100644
index 00000000000..be02541ed34
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Design/PropertyValueUIItemCas.cs
@@ -0,0 +1,89 @@
+//
+// PropertyValueUIItemCas.cs
+// - CAS unit tests for System.Drawing.Design.PropertyValueUIItem
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Design;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing.Design {
+
+ [TestFixture]
+ [NUnit.Framework.Category ("CAS")]
+ public class PropertyValueUIItemCas {
+
+ private ConstructorInfo ctor;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ ConstructorInfo[] infos = typeof (PropertyValueUIItem).GetConstructors ();
+ ctor = infos[0];
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ private void PropertyValueUIItemInvoke (ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem)
+ {
+ }
+
+ [Test]
+ [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+ public void Create ()
+ {
+ new PropertyValueUIItem (new Bitmap (10, 10), PropertyValueUIItemInvoke, null);
+ }
+
+ // we use reflection to call PropertyValueUIItem class as it's protected
+ // by a LinkDemand (which will be converted into full demand, i.e. a stack
+ // walk) when reflection is used (i.e. it gets testable).
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void Create_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (ctor, "constructor");
+ ctor.Invoke (new object [3]);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Design/TestToolboxItem.cs b/mcs/class/System.Drawing/Test/System.Drawing.Design/TestToolboxItem.cs
new file mode 100644
index 00000000000..bc3ee10ae7e
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Design/TestToolboxItem.cs
@@ -0,0 +1,120 @@
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+//
+// Jordi Mas i Hernandez, jordimash@gmail.com
+//
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Drawing;
+using System.Drawing.Design;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing.Design
+{
+ [TestFixture]
+ public class TestToolboxItem
+ {
+ class OurToolboxItem: ToolboxItem
+ {
+ public OurToolboxItem () {}
+ public void _CheckUnlocked ()
+ {
+ CheckUnlocked ();
+ }
+ }
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+ [Test]
+ public void TestProperties ()
+ {
+ ToolboxItem item = new ToolboxItem ();
+ AssemblyName name = new AssemblyName ();
+ name.Name = "OurAssembly";
+ item.AssemblyName = name;
+ Assert.AreEqual (name.Name.ToString (), "OurAssembly", "TP#1");
+
+ item.TypeName = "TypeName1";
+ Assert.AreEqual ("TypeName1", item.TypeName, "TP#2");
+
+ item.DisplayName = "ShowName";
+ Assert.AreEqual (item.DisplayName, "ShowName", "TP#3");
+
+ item.TypeName = "TypeNameSt";
+ Assert.AreEqual (item.TypeName, "TypeNameSt", "TP#4");
+
+ Bitmap bmp = new Bitmap (200, 200);
+ item.Bitmap = bmp;
+ Assert.AreEqual (bmp, item.Bitmap, "TP#5");
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void TestCheckUnlocked1 ()
+ {
+ OurToolboxItem item = new OurToolboxItem ();
+ item.Lock ();
+ item._CheckUnlocked ();
+ }
+
+ [Test]
+ public void TestCheckUnlocked2 ()
+ {
+ OurToolboxItem item = new OurToolboxItem ();
+ item._CheckUnlocked ();
+ }
+
+#if NET_2_0
+ [Test]
+ public void TestNewProperties ()
+ {
+ ToolboxItem item = new ToolboxItem ();
+ item.Company = "OurCompany";
+ Assert.AreEqual ("OurCompany", item.Company, "TNP#1");
+
+ Assert.AreEqual ("DotNET_ComponentType", item.ComponentType, "TNP#2");
+
+ item.Description = "Description";
+ Assert.AreEqual ("Description", item.Description, "TNP#3");
+
+ item.IsTransient = true;
+ Assert.AreEqual (true, item.IsTransient, "TNP#4");
+
+ }
+#endif
+
+
+ }
+}
+
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxComponentsCreatedEventArgsCas.cs b/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxComponentsCreatedEventArgsCas.cs
new file mode 100644
index 00000000000..e2fc4d73db2
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxComponentsCreatedEventArgsCas.cs
@@ -0,0 +1,83 @@
+//
+// ToolboxComponentsCreatedEventArgsCas.cs - CAS unit tests
+// for System.Drawing.Design.ToolboxComponentsCreatedEventArgs
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Drawing.Design;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing.Design {
+
+ [TestFixture]
+ [Category ("CAS")]
+ public class ToolboxComponentsCreatedEventArgsCas {
+
+ private ConstructorInfo ctor;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ ConstructorInfo[] infos = typeof (ToolboxComponentsCreatedEventArgs).GetConstructors ();
+ ctor = infos[0];
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ [Test]
+ [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+ public void Create ()
+ {
+ new ToolboxComponentsCreatedEventArgs (null);
+ }
+
+ // we use reflection to call ToolboxComponentsCreatedEventArgs class as
+ // it's protected by a LinkDemand (which will be converted into full demand,
+ // i.e. a stack walk) when reflection is used (i.e. it gets testable).
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void Create_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (ctor, "constructor");
+ ctor.Invoke (new object[1] { null });
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxComponentsCreatingEventArgsCas.cs b/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxComponentsCreatingEventArgsCas.cs
new file mode 100644
index 00000000000..b7b4264e394
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxComponentsCreatingEventArgsCas.cs
@@ -0,0 +1,83 @@
+//
+// ToolboxComponentsCreatingEventArgsCas.cs - CAS unit tests
+// for System.Drawing.Design.ToolboxComponentsCreatingEventArgs
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Drawing.Design;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing.Design {
+
+ [TestFixture]
+ [Category ("CAS")]
+ public class ToolboxComponentsCreatingEventArgsCas {
+
+ private ConstructorInfo ctor;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ ConstructorInfo[] infos = typeof (ToolboxComponentsCreatingEventArgs).GetConstructors ();
+ ctor = infos[0];
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ [Test]
+ [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+ public void Create ()
+ {
+ new ToolboxComponentsCreatingEventArgs (null);
+ }
+
+ // we use reflection to call ToolboxComponentsCreatingEventArgs class as
+ // it's protected by a LinkDemand (which will be converted into full demand,
+ // i.e. a stack walk) when reflection is used (i.e. it gets testable).
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void Create_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (ctor, "constructor");
+ ctor.Invoke (new object[1] { null });
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxItemCas.cs b/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxItemCas.cs
new file mode 100644
index 00000000000..2efc1ca2fd7
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxItemCas.cs
@@ -0,0 +1,82 @@
+//
+// ToolboxItemCas.cs - CAS unit tests for System.Drawing.Design.ToolboxItem
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Drawing.Design;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing.Design {
+
+ [TestFixture]
+ [Category ("CAS")]
+ public class ToolboxItemCas {
+
+ private ConstructorInfo ctor;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ ConstructorInfo[] infos = typeof (ToolboxItem).GetConstructors ();
+ ctor = infos[0];
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ [Test]
+ [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+ public void Create ()
+ {
+ new ToolboxItem ();
+ }
+
+ // we use reflection to call ToolboxItem class as it's protected by a
+ // LinkDemand (which will be converted into full demand, i.e. a stack
+ // walk) when reflection is used (i.e. it gets testable).
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void Create_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (ctor, "constructor");
+ ctor.Invoke (null);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxItemCollectionCas.cs b/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxItemCollectionCas.cs
new file mode 100644
index 00000000000..3a175310e3e
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Design/ToolboxItemCollectionCas.cs
@@ -0,0 +1,83 @@
+//
+// ToolboxItemCollectionCas.cs
+// - CAS unit tests for System.Drawing.Design.ToolboxItemCollection
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Drawing.Design;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing.Design {
+
+ [TestFixture]
+ [Category ("CAS")]
+ public class ToolboxItemCollectionCas {
+
+ private ConstructorInfo ctor;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ ConstructorInfo[] infos = typeof (ToolboxItemCollection).GetConstructors ();
+ ctor = infos[0];
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ [Test]
+ [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+ public void Create ()
+ {
+ new ToolboxItemCollection (new ToolboxItem [0]);
+ }
+
+ // we use reflection to call ToolboxItemCollection class as it's protected
+ // by a LinkDemand (which will be converted into full demand, i.e. a stack
+ // walk) when reflection is used (i.e. it gets testable).
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void Create_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (ctor, "constructor");
+ ctor.Invoke (new object[1] { new ToolboxItem[0] });
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Design/UITypeEditorCas.cs b/mcs/class/System.Drawing/Test/System.Drawing.Design/UITypeEditorCas.cs
new file mode 100644
index 00000000000..ff56d40d4e8
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Design/UITypeEditorCas.cs
@@ -0,0 +1,82 @@
+//
+// UITypeEditorCas.cs - CAS unit tests for System.Drawing.Design.UITypeEditor
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Drawing.Design;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing.Design {
+
+ [TestFixture]
+ [Category ("CAS")]
+ public class UITypeEditorCas {
+
+ private ConstructorInfo ctor;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ ConstructorInfo[] infos = typeof (UITypeEditor).GetConstructors ();
+ ctor = infos[0];
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ [Test]
+ [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+ public void Create ()
+ {
+ new UITypeEditor ();
+ }
+
+ // we use reflection to call UITypeEditor class as it's protected by a
+ // LinkDemand (which will be converted into full demand, i.e. a stack
+ // walk) when reflection is used (i.e. it gets testable).
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, SkipVerification = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void Create_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (ctor, "constructor");
+ ctor.Invoke (null);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/ChangeLog b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/ChangeLog
new file mode 100644
index 00000000000..4509aa523c8
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/ChangeLog
@@ -0,0 +1,55 @@
+2006-01-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * GraphicsPathTest.cs: Added test cases for GetBounds and re-activated
+ some parts of the tests that checked bounds (Add* tests).
+
+2006-01-13 Sebastien Pouliot <sebastien@ximian.com>
+
+ * GraphicsPathTest.cs: New. Added multiple test cases to check null
+ handling and how the points are generated for the Add* methods.
+ * PathDataTest.cs: New. Added clone test case.
+
+2006-01-12 Sebastien Pouliot <sebastien@ximian.com>
+
+ * GraphicsPathTest.cs: New. Basic test cases for empty path and
+ cloning.
+ * PathDataTest.cs: New. Test cases for PathData.
+
+2005-09-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * TestBlend.cs, TestColorBlend.cs, TestHatchBrush.cs, TestMatrix.cs:
+ Deny UnmanagedCode permission to all tests. This shows (when executed
+ under MS runtime) that S.D API is safe and doesn't requires high
+ privileges to run - even if we know that, deep down, this calls into
+ GDI+.
+
+2005-08-25 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * TestMatrix.cs: New test cases
+
+2005-08-24 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * TestMatrix.cs: New Matrix unit case
+
+2004-06-03 Ravindra <rkumar@novell.com>
+
+ * TestHatchBrush.cs: Added missing test cases for all the hatch
+ styles.
+
+2004-05-18 Ravindra <rkumar@novell.com>
+
+ * TestHatchBrush.cs: Added a test case for HatchBrush.cs.
+ * TestBlend.cs: dos2unix format and namespace changed to
+ MonoTests.System.Drawing.Drawing2D.
+ * TestColorBlend.cs: dos2unix format and namespace changed to
+ MonoTests.System.Drawing.Drawing2D.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+
+ * TestBlend.cs: Added.
+ * TestColorBlend.cs: Added.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * System.Drawing.Drawing2D: Created a repository for
+ System.Drawing.Drawing2D tests.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/GraphicsPathTest.cs b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/GraphicsPathTest.cs
new file mode 100644
index 00000000000..4bacf3efbee
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/GraphicsPathTest.cs
@@ -0,0 +1,1136 @@
+//
+// System.Drawing.GraphicsPath unit tests
+//
+// Authors:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using SC = System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Security.Permissions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing.Drawing2D {
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class GraphicsPathTest {
+
+ private const float Pi4 = (float) (Math.PI / 4);
+ // let's tolerate a few differences
+ private const float Delta = 0.0003f;
+
+ private void CheckEmpty (string prefix, GraphicsPath gp)
+ {
+ Assert.AreEqual (0, gp.PathData.Points.Length, "PathData.Points");
+ Assert.AreEqual (0, gp.PathData.Types.Length, "PathData.Types");
+ Assert.AreEqual (0, gp.PointCount, prefix + "PointCount");
+ }
+
+ [Test]
+ public void Constructor_InvalidFillMode ()
+ {
+ GraphicsPath gp = new GraphicsPath ((FillMode) Int32.MinValue);
+ Assert.AreEqual (Int32.MinValue, (int) gp.FillMode, "FillMode");
+ CheckEmpty ("InvalidFillMode.", gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Constructor_Point_Null_Byte ()
+ {
+ new GraphicsPath ((Point[]) null, new byte[1]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (NullReferenceException))]
+ public void Constructor_Point_Byte_Null ()
+ {
+ new GraphicsPath (new Point[1], null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Constructor_Point_Byte_LengthMismatch ()
+ {
+ new GraphicsPath (new Point[1], new byte [2]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Constructor_PointF_Null_Byte ()
+ {
+ new GraphicsPath ((PointF[])null, new byte [1]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (NullReferenceException))]
+ public void Constructor_PointF_Byte_Null ()
+ {
+ new GraphicsPath ( new PointF[1], null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Constructor_PointF_Byte_LengthMismatch ()
+ {
+ new GraphicsPath (new PointF[2], new byte [1]);
+ }
+
+ [Test]
+ public void GraphicsPath_Empty ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ Assert.AreEqual (FillMode.Alternate, gp.FillMode, "Empty.FillMode");
+ CheckEmpty ("Empty.", gp);
+
+ GraphicsPath clone = (GraphicsPath) gp.Clone ();
+ Assert.AreEqual (FillMode.Alternate, gp.FillMode, "Clone.FillMode");
+ CheckEmpty ("Clone.", gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void GraphicsPath_Empty_PathPoints ()
+ {
+ Assert.IsNull (new GraphicsPath ().PathPoints);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void GraphicsPath_Empty_PathTypes ()
+ {
+ Assert.IsNull (new GraphicsPath ().PathTypes);
+ }
+
+ [Test]
+ [ExpectedException (typeof (SC.InvalidEnumArgumentException))]
+ public void FillMode_Invalid ()
+ {
+ // constructor accept an invalid FillMode
+ GraphicsPath gp = new GraphicsPath ((FillMode) Int32.MaxValue);
+ Assert.AreEqual (Int32.MaxValue, (int) gp.FillMode, "MaxValue");
+ // but you can't set the FillMode property to an invalid value ;-)
+ gp.FillMode = (FillMode) Int32.MaxValue;
+ }
+
+ [Test]
+ public void PathData_CannotChange ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (1, 1, 2, 2));
+
+ Assert.AreEqual (1f, gp.PathData.Points[0].X, "Points[0].X");
+ Assert.AreEqual (1f, gp.PathData.Points[0].Y, "Points[0].Y");
+
+ // now try to change the first point
+ gp.PathData.Points[0] = new Point (0, 0);
+ // the changes isn't reflected in the property
+ Assert.AreEqual (1f, gp.PathData.Points[0].X, "Points[0].X-1");
+ Assert.AreEqual (1f, gp.PathData.Points[0].Y, "Points[0].Y-1");
+ }
+
+ [Test]
+ public void PathPoints_CannotChange ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (1, 1, 2, 2));
+
+ Assert.AreEqual (1f, gp.PathPoints[0].X, "PathPoints[0].X");
+ Assert.AreEqual (1f, gp.PathPoints[0].Y, "PathPoints[0].Y");
+
+ // now try to change the first point
+ gp.PathPoints[0] = new Point (0, 0);
+ // the changes isn't reflected in the property
+ Assert.AreEqual (1f, gp.PathPoints[0].X, "PathPoints[0].X-1");
+ Assert.AreEqual (1f, gp.PathPoints[0].Y, "PathPoints[0].Y-1");
+ }
+
+ [Test]
+ public void PathTypes_CannotChange ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (1, 1, 2, 2));
+
+ Assert.AreEqual (0, gp.PathTypes[0], "PathTypes[0]");
+
+ // now try to change the first type
+ gp.PathTypes[0] = 1;
+ // the changes isn't reflected in the property
+ Assert.AreEqual (0, gp.PathTypes[0], "PathTypes[0]-1");
+ }
+
+ private void CheckArc (GraphicsPath path)
+ {
+ Assert.AreEqual (4, path.PathPoints.Length, "PathPoints");
+ Assert.AreEqual (4, path.PathTypes.Length, "PathPoints");
+ Assert.AreEqual (4, path.PathData.Points.Length, "PathData");
+
+ // GetBounds (well GdipGetPathWorldBounds) isn't implemented
+ RectangleF rect = path.GetBounds ();
+ Assert.AreEqual (2.999624f, rect.X, "Bounds.X");
+ Assert.AreEqual (2.013707f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (0f, rect.Width, Delta, "Bounds.Width");
+ Assert.AreEqual (0.01370478f, rect.Height, "Bounds.Height");
+
+ Assert.AreEqual (2.999906f, path.PathData.Points[0].X, "Points[0].X");
+ Assert.AreEqual (2.013707f, path.PathPoints[0].Y, "Points[0].Y");
+ Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
+ Assert.AreEqual (2.999843f, path.PathData.Points[1].X, "Points[1].X");
+ Assert.AreEqual (2.018276f, path.PathPoints[1].Y, "Points[1].Y");
+ Assert.AreEqual (3, path.PathTypes[1], "Types[1]");
+ Assert.AreEqual (2.99974918f, path.PathData.Points[2].X, "Points[2].X");
+ Assert.AreEqual (2.02284455f, path.PathPoints[2].Y, "Points[2].Y");
+ Assert.AreEqual (3, path.PathData.Types[2], "Types[2]");
+ Assert.AreEqual (2.999624f, path.PathData.Points[3].X, "Points[3].X");
+ Assert.AreEqual (2.027412f, path.PathPoints[3].Y, "Points[3].Y");
+ Assert.AreEqual (3, path.PathTypes[3], "Types[3]");
+ }
+
+ [Test]
+ public void AddArc_Rectangle ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddArc (new Rectangle (1, 1, 2, 2), Pi4, Pi4);
+ CheckArc (gp);
+ }
+
+ [Test]
+ public void AddArc_RectangleF ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddArc (new RectangleF (1f, 1f, 2f, 2f), Pi4, Pi4);
+ CheckArc (gp);
+ }
+
+ [Test]
+ public void AddArc_Int ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddArc (1, 1, 2, 2, Pi4, Pi4);
+ CheckArc (gp);
+ }
+
+ [Test]
+ public void AddArc_Float ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddArc (1f, 1f, 2f, 2f, Pi4, Pi4);
+ CheckArc (gp);
+ }
+
+ private void CheckBezier (GraphicsPath path)
+ {
+ Assert.AreEqual (4, path.PointCount, "PointCount");
+ Assert.AreEqual (4, path.PathPoints.Length, "PathPoints");
+ Assert.AreEqual (4, path.PathTypes.Length, "PathPoints");
+ Assert.AreEqual (4, path.PathData.Points.Length, "PathData");
+
+ // GetBounds (well GdipGetPathWorldBounds) isn't implemented
+ RectangleF rect = path.GetBounds ();
+ Assert.AreEqual (1f, rect.X, "Bounds.X");
+ Assert.AreEqual (1f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (3f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (3f, rect.Height, "Bounds.Height");
+
+ Assert.AreEqual (1f, path.PathData.Points[0].X, "Points[0].X");
+ Assert.AreEqual (1f, path.PathPoints[0].Y, "Points[0].Y");
+ Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
+ Assert.AreEqual (2f, path.PathData.Points[1].X, "Points[1].X");
+ Assert.AreEqual (2f, path.PathPoints[1].Y, "Points[1].Y");
+ Assert.AreEqual (3, path.PathTypes[1], "Types[1]");
+ Assert.AreEqual (3f, path.PathData.Points[2].X, "Points[2].X");
+ Assert.AreEqual (3f, path.PathPoints[2].Y, "Points[2].Y");
+ Assert.AreEqual (3, path.PathData.Types[2], "Types[2]");
+ Assert.AreEqual (4f, path.PathData.Points[3].X, "Points[3].X");
+ Assert.AreEqual (4f, path.PathPoints[3].Y, "Points[3].Y");
+ Assert.AreEqual (3, path.PathTypes[3], "Types[3]");
+ }
+
+ [Test]
+ public void AddBezier_Point ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddBezier (new Point (1, 1), new Point (2, 2), new Point (3, 3), new Point (4, 4));
+ CheckBezier (gp);
+ }
+
+ [Test]
+ public void AddBezier_PointF ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddBezier (new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f), new PointF (4f, 4f));
+ CheckBezier (gp);
+ }
+
+ [Test]
+ public void AddBezier_Int ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddBezier (1, 1, 2, 2, 3, 3, 4, 4);
+ CheckBezier (gp);
+ }
+
+ [Test]
+ public void AddBezier_Float ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddBezier (1f, 1f, 2f, 2f, 3f, 3f, 4f, 4f);
+ CheckBezier (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddBeziers_Point_Null ()
+ {
+ new GraphicsPath ().AddBeziers ((Point[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddBeziers_3_Points ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddBeziers (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
+ }
+
+ [Test]
+ public void AddBeziers_Point ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddBeziers (new Point[4] { new Point (1, 1), new Point (2, 2), new Point (3, 3), new Point (4, 4) });
+ CheckBezier (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddBeziers_PointF_Null ()
+ {
+ new GraphicsPath ().AddBeziers ((PointF[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddBeziers_3_PointFs ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddBeziers (new PointF[3] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f) });
+ }
+
+ [Test]
+ public void AddBeziers_PointF ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddBeziers (new PointF[4] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f), new PointF (4f, 4f) });
+ CheckBezier (gp);
+ }
+
+ private void CheckEllipse (GraphicsPath path)
+ {
+ Assert.AreEqual (13, path.PathPoints.Length, "PathPoints");
+ Assert.AreEqual (13, path.PathTypes.Length, "PathPoints");
+ Assert.AreEqual (13, path.PathData.Points.Length, "PathData");
+
+ // GetBounds (well GdipGetPathWorldBounds) isn't implemented
+ RectangleF rect = path.GetBounds ();
+ Assert.AreEqual (1f, rect.X, "Bounds.X");
+ Assert.AreEqual (1f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (2f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (2f, rect.Height, "Bounds.Height");
+
+ Assert.AreEqual (0, path.PathData.Types[0], "PathData.Types[0]");
+ for (int i = 1; i < 12; i++)
+ Assert.AreEqual (3, path.PathTypes[i], "PathTypes" + i.ToString ());
+ Assert.AreEqual (131, path.PathData.Types[12], "PathData.Types[12]");
+ }
+
+ [Test]
+ public void AddEllipse_Rectangle ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddEllipse (new Rectangle (1, 1, 2, 2));
+ CheckEllipse (gp);
+ }
+
+ [Test]
+ public void AddEllipse_RectangleF ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddEllipse (new RectangleF (1f, 1f, 2f, 2f));
+ CheckEllipse (gp);
+ }
+
+ [Test]
+ public void AddEllipse_Int ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddEllipse (1, 1, 2, 2);
+ CheckEllipse (gp);
+ }
+
+ [Test]
+ public void AddEllipse_Float ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddEllipse (1f, 1f, 2f, 2f);
+ CheckEllipse (gp);
+ }
+
+ private void CheckLine (GraphicsPath path)
+ {
+ Assert.AreEqual (2, path.PathPoints.Length, "PathPoints");
+ Assert.AreEqual (2, path.PathTypes.Length, "PathPoints");
+ Assert.AreEqual (2, path.PathData.Points.Length, "PathData");
+
+ // GetBounds (well GdipGetPathWorldBounds) isn't implemented
+ RectangleF rect = path.GetBounds ();
+ Assert.AreEqual (1f, rect.X, "Bounds.X");
+ Assert.AreEqual (1f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (1f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (1f, rect.Height, "Bounds.Height");
+
+ Assert.AreEqual (1f, path.PathData.Points[0].X, "Points[0].X");
+ Assert.AreEqual (1f, path.PathPoints[0].Y, "Points[0].Y");
+ Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
+ Assert.AreEqual (2f, path.PathData.Points[1].X, "Points[1].X");
+ Assert.AreEqual (2f, path.PathPoints[1].Y, "Points[1].Y");
+ Assert.AreEqual (1, path.PathTypes[1], "Types[1]");
+ }
+
+ [Test]
+ public void AddLine_Point ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLine (new Point (1, 1), new Point (2, 2));
+ CheckLine (gp);
+ }
+
+ [Test]
+ public void AddLine_PointF ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLine (new PointF (1f, 1f), new PointF (2f, 2f));
+ CheckLine (gp);
+ }
+
+ [Test]
+ public void AddLine_Int ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLine (1, 1, 2, 2);
+ CheckLine (gp);
+ }
+
+ [Test]
+ public void AddLine_Float ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLine (1f, 1f, 2f, 2f);
+ CheckLine (gp);
+ }
+
+ [Test]
+ public void AddLine_SamePoint ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLine (new Point (1, 1), new Point (1, 1));
+ Assert.AreEqual (2, gp.PointCount, "PointCount");
+ Assert.AreEqual (0, gp.PathTypes[0], "PathTypes[0]");
+ Assert.AreEqual (1, gp.PathTypes[1], "PathTypes[1]");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddLines_Point_Null ()
+ {
+ new GraphicsPath ().AddLines ((Point[])null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddLines_Point_0 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLines (new Point[0]);
+ CheckLine (gp);
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void AddLines_Point_1 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLines (new Point[1] { new Point (1, 1) });
+ // Special case - a line with a single point is valid
+ Assert.AreEqual (1, gp.PointCount, "PointCount");
+ Assert.AreEqual (0, gp.PathTypes[0], "PathTypes[0]");
+ }
+
+ [Test]
+ public void AddLines_Point ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLines (new Point[2] { new Point (1, 1), new Point (2, 2) });
+ CheckLine (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddLines_PointF_Null ()
+ {
+ new GraphicsPath ().AddLines ((PointF[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddLines_PointF_0 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLines (new PointF[0]);
+ CheckLine (gp);
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void AddLines_PointF_1 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLines (new PointF[1] { new PointF (1f, 1f) });
+ // Special case - a line with a single point is valid
+ Assert.AreEqual (1, gp.PointCount, "PointCount");
+ Assert.AreEqual (0, gp.PathTypes[0], "PathTypes[0]");
+ }
+
+ [Test]
+ public void AddLines_PointF ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddLines (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
+ CheckLine (gp);
+ }
+
+ private void CheckPie (GraphicsPath path)
+ {
+ // the number of points generated for a Pie isn't the same between Mono and MS
+#if false
+ Assert.AreEqual (5, path.PathPoints.Length, "PathPoints");
+ Assert.AreEqual (5, path.PathTypes.Length, "PathPoints");
+ Assert.AreEqual (5, path.PathData.Points.Length, "PathData");
+
+ // GetBounds (well GdipGetPathWorldBounds) isn't implemented
+ RectangleF rect = path.GetBounds ();
+ Assert.AreEqual (2f, rect.X, "Bounds.X");
+ Assert.AreEqual (2f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (0.9999058f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (0.0274119377f, rect.Height, "Bounds.Height");
+
+ Assert.AreEqual (2f, path.PathData.Points[0].X, "Points[0].X");
+ Assert.AreEqual (2f, path.PathPoints[0].Y, "Points[0].Y");
+ Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
+ Assert.AreEqual (2.99990582f, path.PathData.Points[1].X, "Points[1].X");
+ Assert.AreEqual (2.01370716f, path.PathPoints[1].Y, "Points[1].Y");
+ Assert.AreEqual (1, path.PathTypes[1], "Types[1]");
+ Assert.AreEqual (2.99984312f, path.PathData.Points[2].X, "Points[2].X");
+ Assert.AreEqual (2.018276f, path.PathPoints[2].Y, "Points[2].Y");
+ Assert.AreEqual (3, path.PathData.Types[2], "Types[2]");
+ Assert.AreEqual (2.99974918f, path.PathData.Points[3].X, "Points[2].X");
+ Assert.AreEqual (2.02284455f, path.PathPoints[3].Y, "Points[2].Y");
+ Assert.AreEqual (3, path.PathData.Types[3], "Types[2]");
+ Assert.AreEqual (2.999624f, path.PathData.Points[4].X, "Points[3].X");
+ Assert.AreEqual (2.027412f, path.PathPoints[4].Y, "Points[3].Y");
+ Assert.AreEqual (131, path.PathTypes[4], "Types[3]");
+#endif
+ }
+
+ [Test]
+ public void AddPie_Rect ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPie (new Rectangle (1, 1, 2, 2), Pi4, Pi4);
+ CheckPie (gp);
+ }
+
+ [Test]
+ public void AddPie_Int ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPie (1, 1, 2, 2, Pi4, Pi4);
+ CheckPie (gp);
+ }
+
+ [Test]
+ public void AddPie_Float ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPie (1f, 1f, 2f, 2f, Pi4, Pi4);
+ CheckPie (gp);
+ }
+
+ private void CheckPolygon (GraphicsPath path)
+ {
+ // an extra point is generated by Mono (libgdiplus)
+#if false
+ Assert.AreEqual (3, path.PathPoints.Length, "PathPoints");
+ Assert.AreEqual (3, path.PathTypes.Length, "PathPoints");
+ Assert.AreEqual (3, path.PathData.Points.Length, "PathData");
+#endif
+ // GetBounds (well GdipGetPathWorldBounds) isn't implemented
+ RectangleF rect = path.GetBounds ();
+ Assert.AreEqual (1f, rect.X, "Bounds.X");
+ Assert.AreEqual (1f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (2f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (2f, rect.Height, "Bounds.Height");
+
+ Assert.AreEqual (1f, path.PathData.Points[0].X, "Points[0].X");
+ Assert.AreEqual (1f, path.PathPoints[0].Y, "Points[0].Y");
+ Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
+ Assert.AreEqual (2f, path.PathData.Points[1].X, "Points[1].X");
+ Assert.AreEqual (2f, path.PathPoints[1].Y, "Points[1].Y");
+ Assert.AreEqual (1, path.PathTypes[1], "Types[1]");
+ Assert.AreEqual (3f, path.PathData.Points[2].X, "Points[2].X");
+ Assert.AreEqual (3f, path.PathPoints[2].Y, "Points[2].Y");
+ // the extra point change the type of the last point
+#if false
+ Assert.AreEqual (129, path.PathData.Types[2], "Types[2]");
+#endif
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddPolygon_Point_Null ()
+ {
+ new GraphicsPath ().AddPolygon ((Point[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddPolygon_Point_Empty ()
+ {
+ new GraphicsPath ().AddPolygon (new Point[0]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddPolygon_Point_1 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPolygon (new Point[1] { new Point (1, 1) });
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddPolygon_Point_2 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPolygon (new Point[2] { new Point (1, 1), new Point (2, 2) });
+ }
+
+ [Test]
+ public void AddPolygon_Point_3 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPolygon (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
+ CheckPolygon (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddPolygon_PointF_Null ()
+ {
+ new GraphicsPath ().AddPolygon ((PointF[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddPolygon_PointF_Empty ()
+ {
+ new GraphicsPath ().AddPolygon (new PointF[0]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddPolygon_PointF_1 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPolygon (new PointF[1] { new PointF (1f, 1f) });
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddPolygon_PointF_2 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPolygon (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
+ }
+
+ [Test]
+ public void AddPolygon_PointF_3 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPolygon (new PointF[3] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f) });
+ CheckPolygon (gp);
+ }
+
+ private void CheckRectangle (GraphicsPath path, int count)
+ {
+ Assert.AreEqual (count, path.PathPoints.Length, "PathPoints");
+ Assert.AreEqual (count, path.PathTypes.Length, "PathPoints");
+ Assert.AreEqual (count, path.PathData.Points.Length, "PathData");
+
+ // GetBounds (well GdipGetPathWorldBounds) isn't implemented
+ RectangleF rect = path.GetBounds ();
+ Assert.AreEqual (1f, rect.X, "Bounds.X");
+ Assert.AreEqual (1f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (2f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (2f, rect.Height, "Bounds.Height");
+
+ // check first four points (first rectangle)
+ Assert.AreEqual (1f, path.PathData.Points[0].X, "Points[0].X");
+ Assert.AreEqual (1f, path.PathPoints[0].Y, "Points[0].Y");
+ Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
+ Assert.AreEqual (3f, path.PathData.Points[1].X, "Points[1].X");
+ Assert.AreEqual (1f, path.PathPoints[1].Y, "Points[1].Y");
+ Assert.AreEqual (1, path.PathTypes[1], "Types[1]");
+ Assert.AreEqual (3f, path.PathData.Points[2].X, "Points[2].X");
+ Assert.AreEqual (3f, path.PathPoints[2].Y, "Points[2].Y");
+ Assert.AreEqual (1, path.PathData.Types[2], "Types[2]");
+ Assert.AreEqual (1f, path.PathData.Points[3].X, "Points[3].X");
+ Assert.AreEqual (3f, path.PathPoints[3].Y, "Points[3].Y");
+ Assert.AreEqual (129, path.PathTypes[3], "Types[3]");
+ }
+
+ [Test]
+ public void AddRectangle_Int ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (1, 1, 2, 2));
+ CheckRectangle (gp, 4);
+ }
+
+ [Test]
+ public void AddRectangle_Float ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new RectangleF (1f, 1f, 2f, 2f));
+ CheckRectangle (gp, 4);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddRectangles_Int_Null ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangles ((Rectangle[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddRectangles_Int_Empty ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangles (new Rectangle[0]);
+ CheckRectangle (gp, 4);
+ }
+
+ [Test]
+ public void AddRectangles_Int ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangles (new Rectangle[1] { new Rectangle (1, 1, 2, 2) });
+ CheckRectangle (gp, 4);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddRectangles_Float_Null ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangles ((RectangleF[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddRectangles_Float_Empty ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangles ( new RectangleF[0]);
+ CheckRectangle (gp, 4);
+ }
+
+ [Test]
+ public void AddRectangles_Float ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangles (new RectangleF [1] { new RectangleF (1f, 1f, 2f, 2f) });
+ CheckRectangle (gp, 4);
+ }
+
+ [Test]
+ public void AddRectangles_Two ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangles (new RectangleF[2] {
+ new RectangleF (1f, 1f, 2f, 2f),
+ new RectangleF (2f, 2f, 1f, 1f) } );
+ RectangleF rect = gp.GetBounds ();
+ Assert.AreEqual (1f, rect.X, "Bounds.X");
+ Assert.AreEqual (1f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (2f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (2f, rect.Height, "Bounds.Height");
+ // second rectangle is completely within the first one
+ CheckRectangle (gp, 8);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddPath_Null ()
+ {
+ new GraphicsPath ().AddPath (null, false);
+ }
+
+ [Test]
+ public void AddPath ()
+ {
+ GraphicsPath gpr = new GraphicsPath ();
+ gpr.AddRectangle (new Rectangle (1, 1, 2, 2));
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPath (gpr, true);
+ CheckRectangle (gp, 4);
+ }
+
+ private void CheckClosedCurve (GraphicsPath path)
+ {
+ Assert.AreEqual (10, path.PathPoints.Length, "PathPoints");
+ Assert.AreEqual (10, path.PathTypes.Length, "PathPoints");
+ Assert.AreEqual (10, path.PathData.Points.Length, "PathData");
+
+ // GetBounds (well GdipGetPathWorldBounds) isn't implemented
+ RectangleF rect = path.GetBounds ();
+ Assert.AreEqual (0.8333333f, rect.X, "Bounds.X");
+ Assert.AreEqual (0.8333333f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (2.33333278f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (2.33333278f, rect.Height, "Bounds.Height");
+
+ Assert.AreEqual (0, path.PathData.Types[0], "PathData.Types[0]");
+ for (int i = 1; i < 9; i++)
+ Assert.AreEqual (3, path.PathTypes[i], "PathTypes" + i.ToString ());
+ Assert.AreEqual (131, path.PathData.Types[9], "PathData.Types[9]");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddClosedCurve_Point_Null ()
+ {
+ new GraphicsPath ().AddClosedCurve ((Point[])null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddClosedCurve_Point_0 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddClosedCurve (new Point [0]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddClosedCurve_Point_1 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddClosedCurve (new Point[1] { new Point (1, 1) });
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddClosedCurve_Point_2 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddClosedCurve (new Point[2] { new Point (1, 1), new Point (2, 2) });
+ }
+
+ [Test]
+ public void AddClosedCurve_Point_3 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddClosedCurve (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
+ CheckClosedCurve (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddClosedCurve_PointF_Null ()
+ {
+ new GraphicsPath ().AddClosedCurve ((PointF[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddClosedCurve_PointF_0 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddClosedCurve (new PointF[0]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddClosedCurve_PointF_1 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddClosedCurve (new PointF[1] { new PointF (1f, 1f) });
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddClosedCurve_PointF_2 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddClosedCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
+ }
+
+ [Test]
+ public void AddClosedCurve_PointF_3 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddClosedCurve (new PointF[3] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f) });
+ CheckClosedCurve (gp);
+ }
+
+ private void CheckCurve (GraphicsPath path)
+ {
+ Assert.AreEqual (4, path.PathPoints.Length, "PathPoints");
+ Assert.AreEqual (4, path.PathTypes.Length, "PathPoints");
+ Assert.AreEqual (4, path.PathData.Points.Length, "PathData");
+
+ // GetBounds (well GdipGetPathWorldBounds) isn't implemented
+ RectangleF rect = path.GetBounds ();
+ Assert.AreEqual (1.0f, rect.X, "Bounds.X");
+ Assert.AreEqual (1.0f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (1.0f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (1.0f, rect.Height, "Bounds.Height");
+
+ Assert.AreEqual (1f, path.PathData.Points[0].X, "Points[0].X");
+ Assert.AreEqual (1f, path.PathPoints[0].Y, "Points[0].Y");
+ Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
+ // Mono has wrong? results
+#if false
+ Assert.AreEqual (1.16666663f, path.PathData.Points[1].X, "Points[1].X");
+ Assert.AreEqual (1.16666663f, path.PathPoints[1].Y, "Points[1].Y");
+#endif
+ Assert.AreEqual (3, path.PathTypes[1], "Types[1]");
+ // Mono has wrong? results
+#if false
+ Assert.AreEqual (1.83333325f, path.PathData.Points[2].X, "Points[2].X");
+ Assert.AreEqual (1.83333325f, path.PathPoints[2].Y, "Points[2].Y");
+#endif
+ Assert.AreEqual (3, path.PathData.Types[2], "Types[2]");
+ Assert.AreEqual (2f, path.PathData.Points[3].X, "Points[3].X");
+ Assert.AreEqual (2f, path.PathPoints[3].Y, "Points[3].Y");
+ Assert.AreEqual (3, path.PathTypes[3], "Types[3]");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddCurve_Point_Null ()
+ {
+ new GraphicsPath ().AddCurve ((Point[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddCurve_Point_0 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddCurve (new Point[0]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddCurve_Point_1 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddCurve (new Point[1] { new Point (1, 1) });
+ }
+
+ [Test]
+ public void AddCurve_Point_2 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddCurve (new Point[2] { new Point (1, 1), new Point (2, 2) });
+ CheckCurve (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void AddCurve_PointF_Null ()
+ {
+ new GraphicsPath ().AddCurve ((PointF[]) null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddCurve_PointF_0 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddCurve (new PointF[0]);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddCurve_PointF_1 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddCurve (new PointF[1] { new PointF (1f, 1f) });
+ }
+
+ [Test]
+ public void AddCurve_PointF_2 ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
+ CheckCurve (gp);
+ }
+
+ [Test]
+ public void GetBounds_Empty_Empty ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ RectangleF rect = gp.GetBounds ();
+ Assert.AreEqual (0.0f, rect.X, "Bounds.X");
+ Assert.AreEqual (0.0f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (0.0f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (0.0f, rect.Height, "Bounds.Height");
+ }
+
+ private void CheckRectangleBounds (RectangleF rect)
+ {
+ Assert.AreEqual (1.0f, rect.X, "Bounds.X");
+ Assert.AreEqual (1.0f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (2.0f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (2.0f, rect.Height, "Bounds.Height");
+ }
+
+ [Test]
+ public void GetBounds_Empty_Rectangle ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (1, 1, 2, 2));
+ CheckRectangleBounds (gp.GetBounds ());
+ }
+
+ [Test]
+ public void GetBounds_Null_Rectangle ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (1, 1, 2, 2));
+ CheckRectangleBounds (gp.GetBounds (null));
+ }
+
+ [Test]
+ public void GetBounds_MatrixEmpty_Rectangle ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (1, 1, 2, 2));
+ CheckRectangleBounds (gp.GetBounds (new Matrix ()));
+ }
+
+ [Test]
+ public void GetBounds_NullNull_Rectangle ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (1, 1, 2, 2));
+ CheckRectangleBounds (gp.GetBounds (null, null));
+ }
+
+ [Test]
+ [Category ("NotWorking")] // bounds+pen support is missing in libgdiplus
+ public void GetBounds_WithPen ()
+ {
+ Rectangle rect = new Rectangle (1, 1, 2, 2);
+ Pen p = new Pen (Color.Aqua, 0);
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (rect);
+
+ RectangleF bounds = gp.GetBounds (null, p);
+ Assert.AreEqual (-6.09999943f, bounds.X, "NullMatrix.Bounds.X");
+ Assert.AreEqual (-6.09999943f, bounds.Y, "NullMatrix.Bounds.Y");
+ Assert.AreEqual (16.1999989f, bounds.Width, "NullMatrix.Bounds.Width");
+ Assert.AreEqual (16.1999989f, bounds.Height, "NullMatrix.Bounds.Height");
+
+ Matrix m = new Matrix ();
+ // an empty matrix is different than a null matrix
+ bounds = gp.GetBounds (m, p);
+ Assert.AreEqual (-0.419999957f, bounds.X, "EmptyMatrix.Bounds.X");
+ Assert.AreEqual (-0.419999957f, bounds.Y, "EmptyMatrix.Bounds.Y");
+ Assert.AreEqual (4.83999968f, bounds.Width, "EmptyMatrix.Bounds.Width");
+ Assert.AreEqual (4.83999968f, bounds.Height, "EmptyMatrix.Bounds.Height");
+
+ gp = new GraphicsPath ();
+ gp.AddRectangle (rect);
+ gp.Widen (p);
+ bounds = gp.GetBounds (null);
+ Assert.AreEqual (0.499999523f, bounds.X, "WidenNullMatrix.Bounds.X");
+ Assert.AreEqual (0.499999523f, bounds.Y, "WidenNullMatrix.Bounds.Y");
+ Assert.AreEqual (3.000001f, bounds.Width, "WidenNullMatrix.Bounds.Width");
+ Assert.AreEqual (3.000001f, bounds.Height, "WidenNullMatrix.Bounds.Height");
+
+ bounds = gp.GetBounds (m);
+ Assert.AreEqual (0.499999523f, bounds.X, "WidenEmptyMatrix.Bounds.X");
+ Assert.AreEqual (0.499999523f, bounds.Y, "WidenEmptyMatrix.Bounds.Y");
+ Assert.AreEqual (3.000001f, bounds.Width, "WidenEmptyMatrix.Bounds.Width");
+ Assert.AreEqual (3.000001f, bounds.Height, "WidenEmptyMatrix.Bounds.Height");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Transform_Null ()
+ {
+ new GraphicsPath ().Transform (null);
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void Flatten_Null ()
+ {
+ new GraphicsPath ().Flatten (null);
+ // no ArgumentNullException or NullReferenceException
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void Flatten_NullFloat ()
+ {
+ new GraphicsPath ().Flatten (null, 1f);
+ // no ArgumentNullException or NullReferenceException
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Warp_Null ()
+ {
+ new GraphicsPath ().Warp (null, new RectangleF ());
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/PathDataTest.cs b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/PathDataTest.cs
new file mode 100644
index 00000000000..cf3aa4d1002
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/PathDataTest.cs
@@ -0,0 +1,87 @@
+//
+// System.Drawing.Drawing2D.PathData unit tests
+//
+// Authors:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Security.Permissions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing.Drawing2D {
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class PathDataTest {
+
+ [Test]
+ public void PathData_Empty ()
+ {
+ PathData data = new PathData ();
+ Assert.IsNull (data.Points, "Points");
+ Assert.IsNull (data.Types, "Types");
+
+ data.Points = new PointF[0];
+ data.Types = new byte[0];
+ Assert.AreEqual (0, data.Points.Length, "Points-0");
+ Assert.AreEqual (0, data.Types.Length, "Types-0");
+
+ data.Points = null;
+ data.Types = null;
+ Assert.IsNull (data.Points, "Points-1");
+ Assert.IsNull (data.Types, "Types-1");
+ }
+
+ [Test]
+ public void PathData_LengthMismatch ()
+ {
+ PathData data = new PathData ();
+ data.Points = new PointF[2];
+ data.Types = new byte[1];
+ Assert.AreEqual (2, data.Points.Length, "Points-2");
+ Assert.AreEqual (1, data.Types.Length, "Types-1");
+ }
+
+ [Test]
+ public void PathData_UnclonedProperties ()
+ {
+ PathData data = new PathData ();
+ data.Points = new PointF[1] { new PointF (1f, 1f) };
+ data.Types = new byte[1] { 1 };
+ Assert.AreEqual (1f, data.Points[0].X, "Points.X");
+ Assert.AreEqual (1f, data.Points[0].Y, "Points.Y");
+ Assert.AreEqual (1, data.Types[0], "Types");
+
+ data.Points[0] = new PointF (0f, 0f);
+ Assert.AreEqual (0f, data.Points[0].X, "Points.X.1");
+ Assert.AreEqual (0f, data.Points[0].Y, "Points.Y.1");
+
+ data.Types[0] = 0;
+ Assert.AreEqual (0, data.Types[0], "Types-1");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestBlend.cs b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestBlend.cs
new file mode 100644
index 00000000000..f66ea61094b
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestBlend.cs
@@ -0,0 +1,83 @@
+//
+// Tests for System.Drawing.Drawing2D.Blend.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing.Drawing2D
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class BlendTest : Assertion
+ {
+ [TearDown]
+ public void TearDown () { }
+
+ [SetUp]
+ public void SetUp () { }
+
+ [Test]
+ public void TestConstructors ()
+ {
+ Blend blend0 = new Blend ();
+
+ AssertEquals ("C#1", 1, blend0.Factors.Length);
+ AssertEquals ("C#2", 1, blend0.Positions.Length);
+
+ Blend blend1 = new Blend (1);
+
+ AssertEquals ("C#3", 1, blend1.Factors.Length);
+ AssertEquals ("C#4", 1, blend1.Positions.Length);
+ }
+
+ [Test]
+ public void TestProperties ()
+ {
+ Blend blend0 = new Blend ();
+
+ AssertEquals ("P#1", 0, blend0.Factors[0]);
+ AssertEquals ("P#2", 0, blend0.Positions[0]);
+
+ Blend blend1 = new Blend (1);
+ float[] positions = {0.0F, 0.5F, 1.0F};
+ float[] factors = {0.0F, 0.5F, 1.0F};
+ blend1.Factors = factors;
+ blend1.Positions = positions;
+
+ AssertEquals ("P#3", factors[0], blend1.Factors[0]);
+ AssertEquals ("P#4", factors[1], blend1.Factors[1]);
+ AssertEquals ("P#5", factors[2], blend1.Factors[2]);
+ AssertEquals ("P#6", positions[0], blend1.Positions[0]);
+ AssertEquals ("P#7", positions[1], blend1.Positions[1]);
+ AssertEquals ("P#8", positions[2], blend1.Positions[2]);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestColorBlend.cs b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestColorBlend.cs
new file mode 100644
index 00000000000..2ddc9b539e6
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestColorBlend.cs
@@ -0,0 +1,83 @@
+//
+// Tests for System.Drawing.Drawing2D.ColorBlend.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing.Drawing2D
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class ColorBlendTest : Assertion
+ {
+ [TearDown]
+ public void TearDown () { }
+
+ [SetUp]
+ public void SetUp () { }
+
+ [Test]
+ public void TestConstructors ()
+ {
+ ColorBlend cb0 = new ColorBlend ();
+
+ AssertEquals ("C#1", 1, cb0.Colors.Length);
+ AssertEquals ("C#2", 1, cb0.Positions.Length);
+
+ ColorBlend cb1 = new ColorBlend (1);
+
+ AssertEquals ("C#3", 1, cb1.Colors.Length);
+ AssertEquals ("C#4", 1, cb1.Positions.Length);
+ }
+
+ [Test]
+ public void TestProperties ()
+ {
+ ColorBlend cb0 = new ColorBlend ();
+
+ AssertEquals ("P#1", Color.Empty, cb0.Colors[0]);
+ AssertEquals ("P#2", 0, cb0.Positions[0]);
+
+ ColorBlend cb1 = new ColorBlend (1);
+ float[] positions = {0.0F, 0.5F, 1.0F};
+ Color[] colors = {Color.Red, Color.White, Color.Black};
+ cb1.Colors = colors;
+ cb1.Positions = positions;
+
+ AssertEquals ("P#3", colors[0], cb1.Colors[0]);
+ AssertEquals ("P#4", colors[1], cb1.Colors[1]);
+ AssertEquals ("P#5", colors[2], cb1.Colors[2]);
+ AssertEquals ("P#6", positions[0], cb1.Positions[0]);
+ AssertEquals ("P#7", positions[1], cb1.Positions[1]);
+ AssertEquals ("P#8", positions[2], cb1.Positions[2]);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestHatchBrush.cs b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestHatchBrush.cs
new file mode 100644
index 00000000000..1972f82c7cc
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestHatchBrush.cs
@@ -0,0 +1,621 @@
+//
+// System.Drawing.Drawing2D.TestHatchBrush.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Drawing.Drawing2D;
+using System.Security.Permissions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing.Drawing2D
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class HatchBrushTest : Assertion
+ {
+ Graphics gr;
+ Bitmap bmp;
+ Font font;
+ Color bgColor; // background color
+ Color fgColor; // foreground color
+ int currentTop; // the location for next drawing operation
+ int spacing; // space between two consecutive drawing operations
+ int fontSize; // text size
+ int textStart; // text starting location
+ int lineStart; // line starting location
+ int length; // length of the line
+ int penWidth; // width of the Pen used to draw lines
+
+ [SetUp]
+ public void GetReady () { }
+
+ [TearDown]
+ public void Clear () { }
+
+ public HatchBrushTest ()
+ {
+ fontSize = 16;
+ textStart = 10;
+ lineStart = 200;
+ length = 400;
+ penWidth = 50;
+ currentTop = 0;
+ spacing = 50;
+
+ bgColor = Color.Yellow;
+ fgColor = Color.Red;
+ }
+
+ [Test]
+ public void TestProperties ()
+ {
+ HatchBrush hbr = new HatchBrush(HatchStyle.SolidDiamond, fgColor);
+
+ AssertEquals ("Props#1", hbr.HatchStyle, HatchStyle.SolidDiamond);
+ AssertEquals ("Props#2", hbr.ForegroundColor.ToArgb(), fgColor.ToArgb());
+ AssertEquals ("Props#3", hbr.BackgroundColor.ToArgb(), Color.Black.ToArgb());
+
+ hbr = new HatchBrush(HatchStyle.Cross, fgColor, bgColor);
+
+ AssertEquals ("Props#4", hbr.HatchStyle, HatchStyle.Cross);
+ AssertEquals ("Props#5", hbr.ForegroundColor.ToArgb(), fgColor.ToArgb());
+ AssertEquals ("Props#6", hbr.BackgroundColor.ToArgb(), bgColor.ToArgb());
+ }
+
+ [Test]
+ public void TestClone ()
+ {
+ HatchBrush hbr = new HatchBrush(HatchStyle.Cross, fgColor, bgColor);
+
+ HatchBrush clone = (HatchBrush) hbr.Clone ();
+
+ AssertEquals ("Clone#1", hbr.HatchStyle, clone.HatchStyle);
+ AssertEquals ("Clone#2", hbr.ForegroundColor, clone.ForegroundColor);
+ AssertEquals ("Clone#3", hbr.BackgroundColor, clone.BackgroundColor);
+ }
+
+ [Test]
+ public void TestDrawing ()
+ {
+ // create a bitmap with big enough dimensions
+ // to accomodate all the tests
+ bmp = new Bitmap (700, 6000); // width, height
+ gr = Graphics.FromImage (bmp);
+ font = new Font (new FontFamily ("Arial"), fontSize);
+
+ // make the background white
+ gr.Clear (Color.White);
+
+ // draw figures using hatch brush constructed
+ // using different constructors
+ Constructors ();
+
+ // draw figures using different hatchstyles
+ HatchStyles ();
+
+ // save the drawing
+ string file = "TestHatchBrush" + getOutSufix() + ".png";
+ bmp.Save (file, ImageFormat.Png);
+ }
+
+ private void Constructors ()
+ {
+ int top = currentTop;
+ SolidBrush br = new SolidBrush (Color.Black);
+
+ top += spacing;
+
+ gr.DrawString ("Test Constructors", font, br, textStart, top);
+
+ // #1
+ top += spacing;
+ gr.DrawString ("Test #1 Horizontal, BackgroundColor=Black, ForegroundColor=White", font, br, textStart, top);
+
+ top += spacing;
+ Pen pen = new Pen (new HatchBrush (HatchStyle.Horizontal, Color.White), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #2
+ top += spacing;
+ gr.DrawString ("Test #2 Vertical, BackgroundColor=Blue, ForegroundColor=Red", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Vertical, Color.Red, Color.Blue), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ currentTop = top;
+ }
+
+ private void HatchStyles ()
+ {
+ int top = currentTop;
+ HatchBrush hbr;
+ Pen pen;
+ SolidBrush br = new SolidBrush (Color.Black);
+
+ top += spacing;
+
+ gr.DrawString ("Test HatchStyles", font, br, textStart, top);
+
+ // #1
+ top += spacing;
+ gr.DrawString ("Test #1 Horizontal", font, br, textStart, top);
+
+ top += spacing;
+ hbr = new HatchBrush (HatchStyle.Horizontal, fgColor, bgColor);
+ pen = new Pen (hbr, penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #2
+ top += spacing;
+ gr.DrawString ("Test #2 Min", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.Min, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #3
+ top += spacing;
+ gr.DrawString ("Test #3 DarkHorizontal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.DarkHorizontal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #4
+ top += spacing;
+ gr.DrawString ("Test #4 LightHorizontal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.LightHorizontal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #5
+ top += spacing;
+ gr.DrawString ("Test #5 NarrowHorizontal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.NarrowHorizontal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart,top, lineStart + length,top);
+
+ // #6
+ top += spacing;
+ gr.DrawString ("Test #6 Vertical", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.Vertical, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #7
+ top += spacing;
+ gr.DrawString ("Test #7 DarkVertical", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.DarkVertical, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #8
+ top += spacing;
+ gr.DrawString ("Test #8 LightVertical", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.LightVertical, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #9
+ top += spacing;
+ gr.DrawString ("Test #9 NarrowVertical", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.NarrowVertical, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #10
+ top += spacing;
+ gr.DrawString ("Test #10 Cross", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.Cross, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #11
+ top += spacing;
+ gr.DrawString ("Test #11 LargeGrid", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.LargeGrid, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #12
+ top += spacing;
+ gr.DrawString ("Test #12 SmallGrid", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.SmallGrid, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #13
+ top += spacing;
+ gr.DrawString ("Test #13 DottedGrid", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.DottedGrid, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart,top, lineStart + length,top);
+
+ // #14
+ top += spacing;
+ gr.DrawString ("Test #14 DiagonalCross", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.DiagonalCross, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #15
+ top += spacing;
+ gr.DrawString ("Test #15 BackwardDiagonal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.BackwardDiagonal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #16
+ top += spacing;
+ gr.DrawString ("Test #16 ForwardDiagonal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.ForwardDiagonal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #17
+ top += spacing;
+ gr.DrawString ("Test #17 LightDownwardDiagonal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.LightDownwardDiagonal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #18
+ top += spacing;
+ gr.DrawString ("Test #18 DarkDownwardDiagonal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.DarkDownwardDiagonal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #19
+ top += spacing;
+ gr.DrawString ("Test #19 WideDownwardDiagonal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.WideDownwardDiagonal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #20
+ top += spacing;
+ gr.DrawString ("Test #20 LightUpwardDiagonal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.LightUpwardDiagonal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #21
+ top += spacing;
+ gr.DrawString ("Test #21 DarkUpwardDiagonal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.DarkUpwardDiagonal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #22
+ top += spacing;
+ gr.DrawString ("Test #22 WideUpwardDiagonal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.WideUpwardDiagonal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #23
+ top += spacing;
+ gr.DrawString ("Test #23 DashedHorizontal", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.DashedHorizontal, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #24
+ top += spacing;
+ gr.DrawString ("Test #24 DashedVertical", font, br, textStart, top);
+
+ top += spacing;
+ hbr = new HatchBrush (HatchStyle.DashedVertical, fgColor, bgColor);
+ gr.FillRectangle (hbr, lineStart, top, length, penWidth);
+
+ // #25
+ top += spacing;
+ gr.DrawString ("Test #25 DashedDownwardDiagonal", font, br, textStart, top);
+
+ top += spacing;
+ hbr = new HatchBrush (HatchStyle.DashedDownwardDiagonal, fgColor, bgColor);
+ gr.FillRectangle (hbr, lineStart, top, length, penWidth);
+
+ // #26
+ top += spacing;
+ gr.DrawString ("Test #26 DashedUpwardDiagonal", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.DashedUpwardDiagonal, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #27
+ top += spacing;
+ gr.DrawString ("Test #27 05Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent05, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #28
+ top += spacing;
+ gr.DrawString ("Test #28 10Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent10, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #29
+ top += spacing;
+ gr.DrawString ("Test #29 20Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent20, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #30
+ top += spacing;
+ gr.DrawString ("Test #30 25Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent25, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #31
+ top += spacing;
+ gr.DrawString ("Test #31 30Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent30, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #32
+ top += spacing;
+ gr.DrawString ("Test #32 40Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent40, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #33
+ top += spacing;
+ gr.DrawString ("Test #33 50Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent50, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #34
+ top += spacing;
+ gr.DrawString ("Test #34 60Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent60, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #35
+ top += spacing;
+ gr.DrawString ("Test #35 70Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent70, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #36
+ top += spacing;
+ gr.DrawString ("Test #36 75Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent75, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #37
+ top += spacing;
+ gr.DrawString ("Test #37 80Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent70, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #38
+ top += spacing;
+ gr.DrawString ("Test #38 90Percent", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Percent70, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #39
+ top += spacing;
+ gr.DrawString ("Test #39 SmallConfetti", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.SmallConfetti, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #40
+ top += spacing;
+ gr.DrawString ("Test #40 LargeConfetti", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.LargeConfetti, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #41
+ top += spacing;
+ gr.DrawString ("Test #41 ZigZag", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.ZigZag, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #42
+ top += spacing;
+ gr.DrawString ("Test #42 Wave", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Wave, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #43
+ top += spacing;
+ gr.DrawString ("Test #43 HorizontalBrick", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.HorizontalBrick, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #44
+ top += spacing;
+ gr.DrawString ("Test #44 DiagonalBrick", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.DiagonalBrick, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #45
+ top += spacing;
+ gr.DrawString ("Test #45 Weave", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Weave, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #46
+ top += spacing;
+ gr.DrawString ("Test #46 Plaid", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Plaid, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #47
+ top += spacing;
+ gr.DrawString ("Test #47 Divot", font, br, textStart, top);
+
+ top += spacing;
+ pen = new Pen (new HatchBrush (HatchStyle.Divot, fgColor, bgColor), penWidth);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #48
+ top += spacing;
+ gr.DrawString ("Test #48 SmallCheckerBoard", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.SmallCheckerBoard, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #49
+ top += spacing;
+ gr.DrawString ("Test #49 LargeCheckerBoard", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.LargeCheckerBoard, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #50
+ top += spacing;
+ gr.DrawString ("Test #50 OutlinedDiamond", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.OutlinedDiamond, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #51
+ top += spacing;
+ gr.DrawString ("Test #51 SolidDiamond", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.SolidDiamond, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #52
+ top += spacing;
+ gr.DrawString ("Test #52 DottedDiamond", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.DottedDiamond, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #53
+ top += spacing;
+ gr.DrawString ("Test #53 Shingle", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.Shingle, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #54
+ top += spacing;
+ gr.DrawString ("Test #54 Trellis", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.Trellis, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ // #55
+ top += spacing;
+ gr.DrawString ("Test #55 Sphere", font, br, textStart, top);
+
+ top += spacing;
+ pen.Brush = new HatchBrush (HatchStyle.Sphere, fgColor, bgColor);
+ gr.DrawLine (pen, lineStart, top, lineStart + length, top);
+
+ currentTop = top;
+ }
+
+ internal string getOutSufix()
+ {
+ if (Environment.GetEnvironmentVariable("MSNet")==null)
+ return "-mono";
+
+ return "";
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestMatrix.cs b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestMatrix.cs
new file mode 100644
index 00000000000..5b02ee7c43f
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/TestMatrix.cs
@@ -0,0 +1,308 @@
+//
+// Tests for System.Drawing.Drawing2D.Matrix.cs
+//
+// Author:
+// Jordi Mas i Hernandez <jordi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing.Drawing2D
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class MatrixTest : Assertion
+ {
+ [TearDown]
+ public void TearDown () { }
+
+ [SetUp]
+ public void SetUp () { }
+
+ [Test]
+ public void Constructors ()
+ {
+ {
+ Matrix matrix = new Matrix ();
+ AssertEquals ("C#1", 6, matrix.Elements.Length);
+ }
+
+ {
+
+ Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
+ AssertEquals ("C#2", 6, matrix.Elements.Length);
+ AssertEquals ("C#3", 10, matrix.Elements[0]);
+ AssertEquals ("C#4", 20, matrix.Elements[1]);
+ AssertEquals ("C#5", 30, matrix.Elements[2]);
+ AssertEquals ("C#6", 40, matrix.Elements[3]);
+ AssertEquals ("C#7", 50, matrix.Elements[4]);
+ AssertEquals ("C#8", 60, matrix.Elements[5]);
+ }
+ }
+
+ // Properties
+
+ [Test]
+ public void Invertible ()
+ {
+ Matrix matrix = new Matrix (123, 24, 82, 16, 47, 30);
+ AssertEquals ("I#1", false, matrix.IsInvertible);
+
+ matrix = new Matrix (156, 46, 0, 0, 106, 19);
+ AssertEquals ("I#2", false, matrix.IsInvertible);
+
+ matrix = new Matrix (146, 66, 158, 104, 42, 150);
+ AssertEquals ("I#3", true, matrix.IsInvertible);
+
+ matrix = new Matrix (119, 140, 145, 74, 102, 58);
+ AssertEquals ("I#4", true, matrix.IsInvertible);
+ }
+
+ [Test]
+ public void IsIdentity ()
+ {
+ Matrix matrix = new Matrix (123, 24, 82, 16, 47, 30);
+ AssertEquals ("N#1", false, matrix.IsIdentity);
+
+ matrix = new Matrix (1, 0, 0, 1, 0, 0);
+ AssertEquals ("N#2", true, matrix.IsIdentity);
+ }
+
+ [Test]
+ public void IsOffsetX ()
+ {
+ Matrix matrix = new Matrix (123, 24, 82, 16, 47, 30);
+ AssertEquals ("X#1", 47, matrix.OffsetX);
+ }
+
+ [Test]
+ public void IsOffsetY ()
+ {
+ Matrix matrix = new Matrix (123, 24, 82, 16, 47, 30);
+ AssertEquals ("Y#1", 30, matrix.OffsetY);
+ }
+
+ // Elements Property is checked implicity in other test
+
+ //
+ // Methods
+ //
+
+
+ [Test]
+ public void Clone ()
+ {
+ Matrix matsrc = new Matrix (10, 20, 30, 40, 50, 60);
+ Matrix matrix = matsrc.Clone ();
+
+ AssertEquals ("D#1", 6, matrix.Elements.Length);
+ AssertEquals ("D#2", 10, matrix.Elements[0]);
+ AssertEquals ("D#3", 20, matrix.Elements[1]);
+ AssertEquals ("D#4", 30, matrix.Elements[2]);
+ AssertEquals ("D#5", 40, matrix.Elements[3]);
+ AssertEquals ("D#6", 50, matrix.Elements[4]);
+ AssertEquals ("D#7", 60, matrix.Elements[5]);
+ }
+
+ [Test]
+ public void Reset ()
+ {
+ Matrix matrix = new Matrix (51, 52, 53, 54, 55, 56);
+ matrix.Reset ();
+
+ AssertEquals ("F#1", 6, matrix.Elements.Length);
+ AssertEquals ("F#2", 1, matrix.Elements[0]);
+ AssertEquals ("F#3", 0, matrix.Elements[1]);
+ AssertEquals ("F#4", 0, matrix.Elements[2]);
+ AssertEquals ("F#5", 1, matrix.Elements[3]);
+ AssertEquals ("F#6", 0, matrix.Elements[4]);
+ AssertEquals ("F#7", 0, matrix.Elements[5]);
+ }
+
+ [Test]
+ public void Rotate ()
+ {
+ Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
+ matrix.Rotate (180);
+
+ AssertEquals ("H#1", -10, matrix.Elements[0]);
+ AssertEquals ("H#2", -20, matrix.Elements[1]);
+ AssertEquals ("H#3", -30, matrix.Elements[2]);
+ AssertEquals ("H#4", -40, matrix.Elements[3]);
+ AssertEquals ("H#5", 50, matrix.Elements[4]);
+ AssertEquals ("H#6", 60, matrix.Elements[5]);
+ }
+
+ [Test]
+ public void RotateAt ()
+ {
+ Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
+ matrix.RotateAt (180, new PointF (10, 10));
+
+ AssertEquals ("I#1", -10, matrix.Elements[0]);
+ AssertEquals ("I#2", -20, matrix.Elements[1]);
+ AssertEquals ("I#3", -30, matrix.Elements[2]);
+ AssertEquals ("I#4", -40, matrix.Elements[3]);
+ AssertEquals ("I#5", 850, matrix.Elements[4]);
+ AssertEquals ("I#6", 1260, matrix.Elements[5]);
+ }
+
+ [Test]
+ public void Multiply ()
+ {
+ Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
+ matrix.Multiply (new Matrix (10, 20, 30, 40, 50, 60));
+
+ AssertEquals ("J#1", 700, matrix.Elements[0]);
+ AssertEquals ("J#2", 1000, matrix.Elements[1]);
+ AssertEquals ("J#3", 1500, matrix.Elements[2]);
+ AssertEquals ("J#4", 2200, matrix.Elements[3]);
+ AssertEquals ("J#5", 2350, matrix.Elements[4]);
+ AssertEquals ("J#6", 3460, matrix.Elements[5]);
+ }
+
+ [Test]
+ public void Equals ()
+ {
+ Matrix mat1 = new Matrix (10, 20, 30, 40, 50, 60);
+ Matrix mat2 = new Matrix (10, 20, 30, 40, 50, 60);
+ Matrix mat3 = new Matrix (10, 20, 30, 40, 50, 10);
+
+ AssertEquals ("E#1", true, mat1.Equals (mat2));
+ AssertEquals ("E#2", false, mat2.Equals (mat3));
+ AssertEquals ("E#3", false, mat1.Equals (mat3));
+ }
+
+ [Test]
+ public void Invert ()
+ {
+ Matrix matrix = new Matrix (1, 2, 3, 4, 5, 6);
+ matrix.Invert ();
+
+ AssertEquals ("V#1", -2, matrix.Elements[0]);
+ AssertEquals ("V#2", 1, matrix.Elements[1]);
+ AssertEquals ("V#3", 1.5, matrix.Elements[2]);
+ AssertEquals ("V#4", -0.5, matrix.Elements[3]);
+ AssertEquals ("V#5", 1, matrix.Elements[4]);
+ AssertEquals ("V#6", -2, matrix.Elements[5]);
+ }
+
+ [Test]
+ public void Scale ()
+ {
+ Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
+ matrix.Scale (2, 4);
+
+ AssertEquals ("S#1", 20, matrix.Elements[0]);
+ AssertEquals ("S#2", 40, matrix.Elements[1]);
+ AssertEquals ("S#3", 120, matrix.Elements[2]);
+ AssertEquals ("S#4", 160, matrix.Elements[3]);
+ AssertEquals ("S#5", 50, matrix.Elements[4]);
+ AssertEquals ("S#6", 60, matrix.Elements[5]);
+ }
+
+ [Test]
+ public void Shear ()
+ {
+ Matrix matrix = new Matrix (10, 20, 30, 40, 50, 60);
+ matrix.Shear (2, 4);
+
+ AssertEquals ("H#1", 130, matrix.Elements[0]);
+ AssertEquals ("H#2", 180, matrix.Elements[1]);
+ AssertEquals ("H#3", 50, matrix.Elements[2]);
+ AssertEquals ("H#4", 80, matrix.Elements[3]);
+ AssertEquals ("H#5", 50, matrix.Elements[4]);
+ AssertEquals ("H#6", 60, matrix.Elements[5]);
+
+ matrix = new Matrix (5, 3, 9, 2, 2, 1);
+ matrix.Shear (10, 20);
+
+ AssertEquals ("H#7", 185, matrix.Elements[0]);
+ AssertEquals ("H#8", 43, matrix.Elements[1]);
+ AssertEquals ("H#9", 59, matrix.Elements[2]);
+ AssertEquals ("H#10", 32, matrix.Elements[3]);
+ AssertEquals ("H#11", 2, matrix.Elements[4]);
+ AssertEquals ("H#12", 1, matrix.Elements[5]);
+ }
+
+ [Test]
+ public void TransformPoints ()
+ {
+ Matrix matrix = new Matrix (2, 4, 6, 8, 10, 12);
+ PointF [] pointsF = new PointF [] {new PointF (2, 4), new PointF (4, 8)};
+ matrix.TransformPoints (pointsF);
+
+ AssertEquals ("K#1", 38, pointsF[0].X);
+ AssertEquals ("K#2", 52, pointsF[0].Y);
+ AssertEquals ("K#3", 66, pointsF[1].X);
+ AssertEquals ("K#4", 92, pointsF[1].Y);
+
+ Point [] points = new Point [] {new Point (2, 4), new Point (4, 8)};
+ matrix.TransformPoints (points);
+ AssertEquals ("K#5", 38, pointsF[0].X);
+ AssertEquals ("K#6", 52, pointsF[0].Y);
+ AssertEquals ("K#7", 66, pointsF[1].X);
+ AssertEquals ("K#8", 92, pointsF[1].Y);
+ }
+
+ [Test]
+ public void TransformVectors ()
+ {
+ Matrix matrix = new Matrix (2, 4, 6, 8, 10, 12);
+ PointF [] pointsF = new PointF [] {new PointF (2, 4), new PointF (4, 8)};
+ matrix.TransformVectors (pointsF);
+
+ AssertEquals ("N#1", 28, pointsF[0].X);
+ AssertEquals ("N#2", 40, pointsF[0].Y);
+ AssertEquals ("N#3", 56, pointsF[1].X);
+ AssertEquals ("N#4", 80, pointsF[1].Y);
+
+ Point [] points = new Point [] {new Point (2, 4), new Point (4, 8)};
+ matrix.TransformVectors (points);
+ AssertEquals ("N#5", 28, pointsF[0].X);
+ AssertEquals ("N#6", 40, pointsF[0].Y);
+ AssertEquals ("N#7", 56, pointsF[1].X);
+ AssertEquals ("N#8", 80, pointsF[1].Y);
+ }
+
+ [Test]
+ public void Translate ()
+ {
+ Matrix matrix = new Matrix (2, 4, 6, 8, 10, 12);
+ matrix.Translate (5, 10);
+
+ AssertEquals ("Y#1", 2, matrix.Elements[0]);
+ AssertEquals ("Y#2", 4, matrix.Elements[1]);
+ AssertEquals ("Y#3", 6, matrix.Elements[2]);
+ AssertEquals ("Y#4", 8, matrix.Elements[3]);
+ AssertEquals ("Y#5", 80, matrix.Elements[4]);
+ AssertEquals ("Y#6", 112, matrix.Elements[5]);
+
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog
new file mode 100644
index 00000000000..75122b31a50
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/ChangeLog
@@ -0,0 +1,48 @@
+2005-11-13 Kornél Pál <kornelpal@hotmail.com>
+
+ * TestImageFormat.cs: Added ToStringTest.
+
+2005-10-31 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * TestImageFormat.cs: New test unit
+
+2005-09-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * TestBmpCodec.cs, TestColorMatrix.cs, TestImageAttributes.cs,
+ TestImageCodecInfo.cs, TestJpegCodec.cs: Deny UnmanagedCode permission
+ to all tests. This shows (when executed under MS runtime) that S.D API
+ is safe and doesn't requires high privileges to run - even if we know
+ that, deep down, this calls into GDI+.
+
+2005-08-19 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * TestBmpCodec.cs: Enable PixelFormat tests
+
+2005-08-16 Andrew Skiba <andrews@mainsoft.com>
+
+ * TestImageCodecInfo.cs: use regular expressions for results that may vary
+ while still in correct format, so same tests can be used for jvm
+
+2005-08-09 Andrew Skiba <andrews@mainsoft.com>
+
+ * TestImageCodecInfo.cs: FormatID, CodecName, DllName, FilenameExtension,
+ Flags, FormatDescription, MimeType properties checked
+
+2005-08-09 Andrew Skiba <andrews@mainsoft.com>
+
+ * TestImageCodecInfo.cs: refactor to make possible to add tests for all
+ properties, not only FormatID.
+
+2004-03-22 Jordi Mas i Hernandez <jordi@ximian.com>
+
+ * TestColorMatrix.cs: added test case
+ * TestImageAttributes.cs: added test case
+
+2004-06-10 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestBmpCodec.cs, TestImageCodecInfo.cs, TestJpedCodec.cs: Removed
+ dependency on obsolete class, Assertion from NUnit.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Created this repository for System.Drawing.Imaging tests.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestBmpCodec.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestBmpCodec.cs
new file mode 100644
index 00000000000..dac4ffe1695
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestBmpCodec.cs
@@ -0,0 +1,159 @@
+//
+// BMPCodec class testing unit
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jordi@ximian.com)
+//
+// (C) 2004 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Permissions;
+using System.Text;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestBmpCodec
+ {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+ /* Get suffix to add to the filename */
+ internal string getOutSufix()
+ {
+ if (Environment.GetEnvironmentVariable("MSNet")==null)
+ return "-mono";
+
+ return "";
+ }
+
+ /* Get the input directory depending on the runtime*/
+ internal string getInFile(string file)
+ {
+ string sRslt, local;
+
+ local = "../System.Drawing/" + file;
+
+ sRslt = Path.GetFullPath (local);
+
+ if (File.Exists(sRslt)==false)
+ sRslt = "Test/System.Drawing/" + file;
+
+ return sRslt;
+ }
+
+ /* Checks bitmap features on a know 24-bits bitmap */
+ [Test]
+ public void Bitmap24bitFeatures()
+ {
+ string sInFile = getInFile ("bitmaps/almogaver24bits.bmp");
+ Bitmap bmp = new Bitmap(sInFile);
+ RectangleF rect;
+ GraphicsUnit unit = GraphicsUnit.World;
+
+ rect = bmp.GetBounds(ref unit);
+
+ Assert.AreEqual (PixelFormat.Format24bppRgb, bmp.PixelFormat);
+ Assert.AreEqual (173, bmp.Width);
+ Assert.AreEqual (183, bmp.Height);
+
+ Assert.AreEqual (0, rect.X);
+ Assert.AreEqual (0, rect.Y);
+ Assert.AreEqual (173, rect.Width);
+ Assert.AreEqual (183, rect.Height);
+
+ Assert.AreEqual (173, bmp.Size.Width);
+ Assert.AreEqual (183, bmp.Size.Height);
+ }
+
+
+
+ /* Checks bitmap features on a know 32-bits bitmap (codec)*/
+ [Test]
+ public void Bitmap32bitFeatures()
+ {
+ string sInFile = getInFile ("bitmaps/almogaver32bits.bmp");
+ Bitmap bmp = new Bitmap(sInFile);
+ RectangleF rect;
+ GraphicsUnit unit = GraphicsUnit.World;
+
+ rect = bmp.GetBounds(ref unit);
+
+ Assert.AreEqual (173, bmp.Width);
+ Assert.AreEqual (183, bmp.Height);
+
+ Assert.AreEqual (0, rect.X);
+ Assert.AreEqual (0, rect.Y);
+ Assert.AreEqual (173, rect.Width);
+ Assert.AreEqual (183, rect.Height);
+
+ Assert.AreEqual (173, bmp.Size.Width);
+ Assert.AreEqual (183, bmp.Size.Height);
+ }
+
+ [Test]
+ public void Save()
+ {
+ string sOutFile = "linerect" + getOutSufix() + ".bmp";
+
+ // Save
+ Bitmap bmp = new Bitmap(100,100, PixelFormat.Format32bppRgb);
+ Graphics gr = Graphics.FromImage(bmp);
+
+ Pen p = new Pen(Color.Red, 2);
+ gr.DrawLine(p, 10.0F, 10.0F, 90.0F, 90.0F);
+ gr.DrawRectangle(p, 10.0F, 10.0F, 80.0F, 80.0F);
+ p.Dispose();
+ bmp.Save(sOutFile, ImageFormat.Bmp);
+ gr.Dispose();
+ bmp.Dispose();
+
+ // Load
+ Bitmap bmpLoad = new Bitmap(sOutFile);
+
+ Color color = bmpLoad.GetPixel(10,10);
+
+ //Assert.AreEqual (Color.FromArgb(255,255,0,0), color);
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestColorMatrix.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestColorMatrix.cs
new file mode 100644
index 00000000000..ceb64b45593
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestColorMatrix.cs
@@ -0,0 +1,172 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//
+// Author:
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Permissions;
+using System.Text;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestColorMatrix
+ {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+
+ [Test]
+ public void DefaultConstructor ()
+ {
+ ColorMatrix cm = new ColorMatrix ();
+
+ Assert.AreEqual (cm.Matrix00, 1);
+ Assert.AreEqual (cm.Matrix11, 1);
+ Assert.AreEqual (cm.Matrix22, 1);
+ Assert.AreEqual (cm.Matrix33, 1);
+ Assert.AreEqual (cm.Matrix44, 1);
+ Assert.AreEqual (cm.Matrix01, 0);
+ Assert.AreEqual (cm.Matrix02, 0);
+ Assert.AreEqual (cm.Matrix03, 0);
+ Assert.AreEqual (cm.Matrix04, 0);
+ Assert.AreEqual (cm.Matrix10, 0);
+ Assert.AreEqual (cm.Matrix12, 0);
+ Assert.AreEqual (cm.Matrix13, 0);
+ Assert.AreEqual (cm.Matrix14, 0);
+ Assert.AreEqual (cm.Matrix20, 0);
+ Assert.AreEqual (cm.Matrix21, 0);
+ Assert.AreEqual (cm.Matrix23, 0);
+ Assert.AreEqual (cm.Matrix24, 0);
+ Assert.AreEqual (cm.Matrix30, 0);
+ Assert.AreEqual (cm.Matrix31, 0);
+ Assert.AreEqual (cm.Matrix32, 0);
+ Assert.AreEqual (cm.Matrix34, 0);
+ Assert.AreEqual (cm.Matrix40, 0);
+ Assert.AreEqual (cm.Matrix41, 0);
+ Assert.AreEqual (cm.Matrix42, 0);
+ Assert.AreEqual (cm.Matrix43, 0);
+
+ }
+
+ [Test]
+ public void ConstructorArrayAndMethods ()
+ {
+ ColorMatrix cm = new ColorMatrix (new float[][] {
+ new float[] {0.393f, 0.349f, 0.272f, 0, 0},
+ new float[] {0.769f, 0.686f, 0.534f, 0, 0},
+ new float[] {0.189f, 0.168f, 0.131f, 0, 0},
+ new float[] { 0, 0, 0, 1, 0},
+ new float[] { 0, 0, 0, 0, 1}
+ });
+
+ Assert.AreEqual (cm.Matrix00, 0.393f);
+ Assert.AreEqual (cm.Matrix01, 0.349f);
+ Assert.AreEqual (cm.Matrix02, 0.272f);
+ Assert.AreEqual (cm.Matrix03, 0);
+ Assert.AreEqual (cm.Matrix04, 0);
+
+ Assert.AreEqual (cm.Matrix10, 0.769f);
+ Assert.AreEqual (cm.Matrix11, 0.686f);
+ Assert.AreEqual (cm.Matrix12, 0.534f);
+ Assert.AreEqual (cm.Matrix13, 0);
+ Assert.AreEqual (cm.Matrix14, 0);
+
+ Assert.AreEqual (cm.Matrix20, 0.189f);
+ Assert.AreEqual (cm.Matrix21, 0.168f);
+ Assert.AreEqual (cm.Matrix22, 0.131f);
+ Assert.AreEqual (cm.Matrix23, 0);
+ Assert.AreEqual (cm.Matrix24, 0);
+
+ Assert.AreEqual (cm.Matrix30, 0);
+ Assert.AreEqual (cm.Matrix31, 0);
+ Assert.AreEqual (cm.Matrix32, 0);
+ Assert.AreEqual (cm.Matrix33, 1);
+ Assert.AreEqual (cm.Matrix34, 0);
+
+ Assert.AreEqual (cm.Matrix40, 0);
+ Assert.AreEqual (cm.Matrix41, 0);
+ Assert.AreEqual (cm.Matrix42, 0);
+ Assert.AreEqual (cm.Matrix43, 0);
+ Assert.AreEqual (cm.Matrix44, 1);
+ }
+
+ [Test]
+ public void Property ()
+ {
+ ColorMatrix cm = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0},
+ new float[] {0.5f, 1, 0, 0, 0},
+ new float[] {0, 0.1f, 1.5f, 0, 0},
+ new float[] {0.5f, 3, 0.5f, 1, 0},
+ new float[] {0, 0, 0, 0, 0}
+ });
+
+ Assert.AreEqual (cm[0,0], 1);
+ Assert.AreEqual (cm[0,1], 0);
+ Assert.AreEqual (cm[0,2], 0);
+ Assert.AreEqual (cm[0,3], 0);
+ Assert.AreEqual (cm[0,4], 0);
+
+ Assert.AreEqual (cm[1,0], 0.5f);
+ Assert.AreEqual (cm[1,1], 1);
+ Assert.AreEqual (cm[1,2], 0);
+ Assert.AreEqual (cm[1,3], 0);
+ Assert.AreEqual (cm[1,4], 0);
+
+ Assert.AreEqual (cm[2,0], 0);
+ Assert.AreEqual (cm[2,1], 0.1f);
+ Assert.AreEqual (cm[2,2], 1.5f);
+ Assert.AreEqual (cm[2,3], 0);
+ Assert.AreEqual (cm[2,4], 0);
+
+ Assert.AreEqual (cm[3,0], 0.5f);
+ Assert.AreEqual (cm[3,1], 3);
+ Assert.AreEqual (cm[3,2], 0.5f);
+ Assert.AreEqual (cm[3,3], 1);
+ Assert.AreEqual (cm[3,4], 0);
+
+ Assert.AreEqual (cm[4,0], 0);
+ Assert.AreEqual (cm[4,1], 0);
+ Assert.AreEqual (cm[4,2], 0);
+ Assert.AreEqual (cm[4,3], 0);
+ Assert.AreEqual (cm[4,4], 0);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageAttributes.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageAttributes.cs
new file mode 100644
index 00000000000..644458c6bb4
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageAttributes.cs
@@ -0,0 +1,103 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//
+// Author:
+// Jordi Mas i Hernandez (jordi@ximian.com)
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Permissions;
+using System.Text;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestImageAttributes
+ {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+ private static Color ProcessColorMatrix (Color color, ColorMatrix colorMatrix)
+ {
+ Bitmap bmp = new Bitmap (64, 64);
+ Graphics gr = Graphics.FromImage (bmp);
+ ImageAttributes imageAttr = new ImageAttributes ();
+
+ bmp.SetPixel (0,0, color);
+
+ imageAttr.SetColorMatrix (colorMatrix);
+ gr.DrawImage (bmp, new Rectangle (0, 0, 64,64), 0,0, 64,64, GraphicsUnit.Pixel, imageAttr);
+ return bmp.GetPixel (0,0);
+ }
+
+
+ // Text Color Matrix processing
+ [Test]
+ public void ColorMatrix ()
+ {
+ Color clr_src, clr_rslt;
+
+ ColorMatrix cm = new ColorMatrix (new float[][] {
+ new float[] {2, 0, 0, 0, 0}, //R
+ new float[] {0, 1, 0, 0, 0}, //G
+ new float[] {0, 0, 1, 0, 0}, //B
+ new float[] {0, 0, 0, 1, 0}, //A
+ new float[] {0.2f, 0, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 20, 50);
+ clr_rslt = ProcessColorMatrix (clr_src, cm);
+
+ Assert.AreEqual (clr_rslt, Color.FromArgb (255, 251, 20, 50));
+
+
+ cm = new ColorMatrix (new float[][] {
+ new float[] {1, 0, 0, 0, 0}, //R
+ new float[] {0, 1, 0, 0, 0}, //G
+ new float[] {0, 0, 1.5f, 0, 0}, //B
+ new float[] {0, 0, 0.5f, 1, 0}, //A
+ new float[] {0, 0, 0, 0, 0}, //Translation
+ });
+
+ clr_src = Color.FromArgb (255, 100, 40, 25);
+ clr_rslt = ProcessColorMatrix (clr_src, cm);
+ Assert.AreEqual (clr_rslt, Color.FromArgb (255, 100, 40, 165));
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageCodecInfo.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageCodecInfo.cs
new file mode 100644
index 00000000000..39ef67ef733
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageCodecInfo.cs
@@ -0,0 +1,183 @@
+//
+// ImageCodecInfo class testing unit
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jordi@ximian.com)
+//
+// (C) 2004 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.Collections;
+using System.Security.Permissions;
+using System.Text.RegularExpressions;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestImageCodecInfo
+ {
+ Hashtable decoders;
+ Hashtable encoders;
+
+ ImageCodecInfo GetEncoder (Guid clsid)
+ {
+ return (ImageCodecInfo) encoders [clsid];
+ }
+
+ ImageCodecInfo GetDecoder (Guid clsid) {
+ return (ImageCodecInfo) decoders [clsid];
+ }
+
+ [TestFixtureSetUp]
+ public void FixtureGetReady()
+ {
+ ImageCodecInfo [] arrEnc = ImageCodecInfo.GetImageDecoders ();
+ ImageCodecInfo [] arrDec = ImageCodecInfo.GetImageEncoders ();
+ decoders = new Hashtable ();
+ encoders = new Hashtable ();
+
+ foreach (ImageCodecInfo decoder in arrDec)
+ decoders[decoder.Clsid] = decoder;
+
+ foreach (ImageCodecInfo encoder in arrEnc)
+ encoders[encoder.Clsid] = encoder;
+ }
+
+ static void Check (ImageCodecInfo e, ImageCodecInfo d, Guid FormatID, string CodecName, string DllName,
+ string FilenameExtension, ImageCodecFlags Flags, string FormatDescription,
+ string MimeType, int Version)
+ {
+ Regex extRegex = new Regex (@"^(\*\.\w+(;(\*\.\w+))*;)?"+
+ Regex.Escape (FilenameExtension)+@"(;\*\.\w+(;(\*\.\w+))*)?$",
+ RegexOptions.IgnoreCase | RegexOptions.Singleline);
+
+ if (e != null) {
+ Assert.AreEqual (FormatID, e.FormatID, "Encoder.FormatID");
+ Assert.IsTrue (e.CodecName.IndexOf (CodecName)>=0,
+ "Encoder.CodecName contains "+CodecName);
+ Assert.AreEqual (DllName, e.DllName, "Encoder.DllName");
+ Assert.IsTrue (extRegex.IsMatch (e.FilenameExtension),
+ "Encoder.FilenameExtension is a right list with "+FilenameExtension);
+ Assert.AreEqual (Flags, e.Flags, "Encoder.Flags");
+ Assert.IsTrue (e.FormatDescription.IndexOf (FormatDescription)>=0,
+ "Encoder.FormatDescription contains "+FormatDescription);
+ Assert.IsTrue (e.MimeType.IndexOf (MimeType)>=0,
+ "Encoder.MimeType contains "+MimeType);
+ }
+ if (d != null) {
+ Assert.AreEqual (FormatID, d.FormatID, "Decoder.FormatID");
+ Assert.IsTrue (d.CodecName.IndexOf (CodecName)>=0,
+ "Decoder.CodecName contains "+CodecName);
+ Assert.AreEqual (DllName, d.DllName, "Decoder.DllName");
+ Assert.IsTrue (extRegex.IsMatch (d.FilenameExtension),
+ "Decoder.FilenameExtension is a right list with "+FilenameExtension);
+ Assert.AreEqual (Flags, d.Flags, "Decoder.Flags");
+ Assert.IsTrue (d.FormatDescription.IndexOf (FormatDescription)>=0,
+ "Decoder.FormatDescription contains "+FormatDescription);
+ Assert.IsTrue (d.MimeType.IndexOf (MimeType)>=0,
+ "Decoder.MimeType contains "+MimeType);
+ }
+ /*
+ if (SignatureMasks == null) {
+ Assert.AreEqual (null, e.SignatureMasks, "Encoder.SignatureMasks");
+ Assert.AreEqual (null, d.SignatureMasks, "Decoder.SignatureMasks");
+ }
+ else {
+ Assert.AreEqual (SignatureMasks.Length, e.SignatureMasks.Length, "Encoder.SignatureMasks.Length");
+ Assert.AreEqual (SignatureMasks.Length, d.SignatureMasks.Length, "Decoder.SignatureMasks.Length");
+ for (int i = 0; i < SignatureMasks.Length; i++) {
+ Assert.AreEqual (SignatureMasks[i].Length, e.SignatureMasks[i].Length,
+ "Encoder.SignatureMasks["+i.ToString ()+"].Length");
+ Assert.AreEqual (SignatureMasks[i].Length, d.SignatureMasks[i].Length,
+ "Decoder.SignatureMasks["+i.ToString ()+"].Length");
+ for (int j = 0; j < SignatureMasks[i].Length; j++) {
+ Assert.AreEqual (SignatureMasks[i][j], e.SignatureMasks[i][j],
+ "Encoder.SignatureMasks["+i.ToString ()+"]["+j.ToString ()+"]");
+ Assert.AreEqual (SignatureMasks[i][j], d.SignatureMasks[i][j],
+ "Decoder.SignatureMasks["+i.ToString ()+"]["+j.ToString ()+"]");
+ }
+ }
+ }
+ */
+
+ }
+
+ [Test]
+ public void BMPCodec()
+ {
+ Guid g = new Guid ("557cf400-1a04-11d3-9a73-0000f81ef32e");
+ Check (GetEncoder (g), GetDecoder (g), ImageFormat.Bmp.Guid,
+ "BMP", null, "*.BMP",
+ ImageCodecFlags.Builtin|ImageCodecFlags.Encoder|ImageCodecFlags.Decoder|ImageCodecFlags.SupportBitmap,
+ "BMP", "image/bmp", 1);
+ }
+
+ [Test]
+ public void GifCodec()
+ {
+ Guid g = new Guid ("557cf402-1a04-11d3-9a73-0000f81ef32e");
+ Check (GetEncoder (g), GetDecoder (g), ImageFormat.Gif.Guid,
+ "GIF", null, "*.GIF",
+ ImageCodecFlags.Builtin|ImageCodecFlags.Encoder|ImageCodecFlags.Decoder|ImageCodecFlags.SupportBitmap,
+ "GIF", "image/gif", 1);
+ }
+
+ [Test]
+ public void JpegCodec()
+ {
+ Guid g = new Guid ("557cf401-1a04-11d3-9a73-0000f81ef32e");
+ Check (GetEncoder (g), GetDecoder (g), ImageFormat.Jpeg.Guid,
+ "JPEG", null, "*.JPG",
+ ImageCodecFlags.Builtin|ImageCodecFlags.Encoder|ImageCodecFlags.Decoder|ImageCodecFlags.SupportBitmap,
+ "JPEG", "image/jpeg", 1);
+ }
+
+ [Test]
+ public void PngCodec()
+ {
+ Guid g = new Guid ("557cf406-1a04-11d3-9a73-0000f81ef32e");
+ Check (GetEncoder (g), GetDecoder (g), ImageFormat.Png.Guid,
+ "PNG", null, "*.PNG",
+ ImageCodecFlags.Builtin|ImageCodecFlags.Encoder|ImageCodecFlags.Decoder|ImageCodecFlags.SupportBitmap,
+ "PNG", "image/png", 1);
+ }
+ [Test]
+ public void IconCodec() {
+ Guid g = new Guid ("557cf407-1a04-11d3-9a73-0000f81ef32e");
+ Check (null, GetDecoder (g), ImageFormat.Bmp.Guid,
+ "ICO", null, "*.ICO",
+ ImageCodecFlags.Builtin|ImageCodecFlags.Encoder|ImageCodecFlags.SupportBitmap,
+ "ICO", "image/x-icon", 1);
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageFormat.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageFormat.cs
new file mode 100644
index 00000000000..f83bed886a9
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestImageFormat.cs
@@ -0,0 +1,87 @@
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jordi@ximian.com)
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Permissions;
+using System.Text;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestImageFormat
+ {
+ private static ImageFormat BmpImageFormat = new ImageFormat (new Guid ("b96b3cab-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat EmfImageFormat = new ImageFormat (new Guid ("b96b3cac-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat ExifImageFormat = new ImageFormat (new Guid ("b96b3cb2-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat GifImageFormat = new ImageFormat (new Guid ("b96b3cb0-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat TiffImageFormat = new ImageFormat (new Guid ("b96b3cb1-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat PngImageFormat = new ImageFormat(new Guid("b96b3caf-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat MemoryBmpImageFormat = new ImageFormat (new Guid ("b96b3caa-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat IconImageFormat = new ImageFormat (new Guid ("b96b3cb5-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat JpegImageFormat = new ImageFormat(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat WmfImageFormat = new ImageFormat (new Guid ("b96b3cad-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat CustomImageFormat = new ImageFormat (new Guid ("48749428-316f-496a-ab30-c819a92b3137"));
+
+ [Test]
+ public void DefaultImageFormats ()
+ {
+ Assert.AreEqual (BmpImageFormat.Guid, ImageFormat.Bmp.Guid, "DefaultImageFormats#1");
+ Assert.AreEqual (EmfImageFormat.Guid, ImageFormat.Emf.Guid, "DefaultImageFormats#2");
+ Assert.AreEqual (ExifImageFormat.Guid, ImageFormat.Exif.Guid, "DefaultImageFormats#3");
+ Assert.AreEqual (GifImageFormat.Guid, ImageFormat.Gif.Guid, "DefaultImageFormats#4");
+ Assert.AreEqual (TiffImageFormat.Guid, ImageFormat.Tiff.Guid, "DefaultImageFormats#5");
+ Assert.AreEqual (PngImageFormat.Guid, ImageFormat.Png.Guid, "DefaultImageFormats#6");
+ Assert.AreEqual (MemoryBmpImageFormat.Guid, ImageFormat.MemoryBmp.Guid, "DefaultImageFormats#7");
+ Assert.AreEqual (IconImageFormat.Guid, ImageFormat.Icon.Guid, "DefaultImageFormats#8");
+ Assert.AreEqual (JpegImageFormat.Guid, ImageFormat.Jpeg.Guid, "DefaultImageFormats#9");
+ Assert.AreEqual (WmfImageFormat.Guid, ImageFormat.Wmf.Guid, "DefaultImageFormats#10");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ Assert.AreEqual (BmpImageFormat.ToString (), "Bmp", "ToStringTest#1");
+ Assert.AreEqual (EmfImageFormat.ToString (), "Emf", "ToStringTest#2");
+ Assert.AreEqual (ExifImageFormat.ToString (), "Exif", "ToStringTest#3");
+ Assert.AreEqual (GifImageFormat.ToString (), "Gif", "ToStringTest#4");
+ Assert.AreEqual (TiffImageFormat.ToString (), "Tiff", "ToStringTest#5");
+ Assert.AreEqual (PngImageFormat.ToString (), "Png", "ToStringTest#6");
+ Assert.AreEqual (MemoryBmpImageFormat.ToString (), "MemoryBmp", "ToStringTest#7");
+ Assert.AreEqual (IconImageFormat.ToString (), "Icon", "ToStringTest#8");
+ Assert.AreEqual (JpegImageFormat.ToString (), "Jpeg", "ToStringTest#9");
+ Assert.AreEqual (WmfImageFormat.ToString (), "Wmf", "ToStringTest#10");
+ Assert.AreEqual (CustomImageFormat.ToString (), "[ImageFormat: 48749428-316f-496a-ab30-c819a92b3137]", "ToStringTest#11");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestJpegCodec.cs b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestJpegCodec.cs
new file mode 100644
index 00000000000..54aaa327b4b
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/TestJpegCodec.cs
@@ -0,0 +1,133 @@
+//
+// JpegCodec class testing unit
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jordi@ximian.com)
+//
+// (C) 2004 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestJpegCodec
+ {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+ /* Get suffix to add to the filename */
+ internal string getOutSufix()
+ {
+ if (Environment.GetEnvironmentVariable("MSNet")==null)
+ return "-mono";
+
+ return "";
+ }
+
+ /* Get the input directory depending on the runtime*/
+ internal string getInFile(string file)
+ {
+ string sRslt, local;
+
+ local = "../System.Drawing/" + file;
+
+ sRslt = Path.GetFullPath (local);
+
+ if (File.Exists(sRslt)==false)
+ sRslt = "Test/System.Drawing/" + file;
+
+ return sRslt;
+ }
+
+ /* Checks bitmap features on a know 24-bits bitmap */
+ //[Test]
+ public void Bitmap24bitFeatures()
+ {
+ string sInFile = getInFile ("bitmaps/nature24bits.jpg");
+ Bitmap bmp = new Bitmap(sInFile);
+ RectangleF rect;
+ GraphicsUnit unit = GraphicsUnit.World;
+
+ rect = bmp.GetBounds(ref unit);
+
+ Assert.AreEqual (PixelFormat.Format24bppRgb, bmp.PixelFormat);
+ Assert.AreEqual (110, bmp.Width);
+ Assert.AreEqual (100, bmp.Height);
+
+ Assert.AreEqual (0, rect.X);
+ Assert.AreEqual (0, rect.Y);
+ Assert.AreEqual (110, rect.Width);
+ Assert.AreEqual (100, rect.Height);
+
+ Assert.AreEqual (110, bmp.Size.Width);
+ Assert.AreEqual (100, bmp.Size.Height);
+
+ }
+
+ //[Test]
+ public void Save()
+ {
+ string sOutFile = "linerect" + getOutSufix() + ".jpeg";
+
+ // Save
+ Bitmap bmp = new Bitmap(100,100, PixelFormat.Format32bppRgb);
+ Graphics gr = Graphics.FromImage(bmp);
+
+ Pen p = new Pen(Color.Red, 2);
+ gr.DrawLine(p, 10.0F, 10.0F, 90.0F, 90.0F);
+ gr.DrawRectangle(p, 10.0F, 10.0F, 80.0F, 80.0F);
+ p.Dispose();
+ bmp.Save(sOutFile, ImageFormat.Bmp);
+ gr.Dispose();
+ bmp.Dispose();
+
+ // Load
+ Bitmap bmpLoad = new Bitmap(sOutFile);
+
+ Color color = bmpLoad.GetPixel(10,10);
+
+ //Assert.AreEqual (Color.FromArgb(255,255,0,0), color);
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh
new file mode 100755
index 00000000000..98b2c00dbe8
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests-ms.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+ echo "You should give a list of test names such as: "
+ echo "$0 System.Drawing.TestStringFormat"
+ echo "or"
+ echo "$0 all"
+ exit 1
+fi
+
+export MSNet=Yes
+cp ../../System.Drawing_test.dll .
+topdir=../../../..
+NUNITCONSOLE=$topdir/class/lib/nunit-console.exe
+MONO_PATH=$topdir/nunit20:$topdir/class/lib:.
+
+for i in $@; do
+ if [ "$i" = "all" ]; then
+ fixture=""
+ else
+ fixture="/fixture:MonoTests.${i}"
+ fi
+ MONO_PATH=$MONO_PATH \
+ ${NUNITCONSOLE} System.Drawing_test.dll $fixture
+done
+
+
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh
new file mode 100755
index 00000000000..511cfcd6ee6
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Imaging/tests.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+ echo "You should give a list of test names such as: "
+ echo "$0 System.Drawing.TestStringFormat"
+ echo "or"
+ echo "$0 all"
+ exit 1
+fi
+
+cp ../../System.Drawing_test_default.dll .
+
+topdir=../../../..
+NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe
+MONO_PATH=$topdir/nunit20:$topdir/class/lib/default:.
+
+
+for i in $@; do
+ if [ "$i" = "all" ]; then
+ fixture=""
+ else
+ fixture="/fixture:MonoTests.${i}"
+ fi
+ MONO_PATH=$MONO_PATH \
+ mono --debug ${NUNITCONSOLE} System.Drawing_test_default.dll $fixture
+done
+
+
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Printing/ChangeLog b/mcs/class/System.Drawing/Test/System.Drawing.Printing/ChangeLog
new file mode 100644
index 00000000000..43632bc7c22
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Printing/ChangeLog
@@ -0,0 +1,28 @@
+2005-09-22 Sebastien Pouliot <sebastien@ximian.com>
+
+ * PrintingPermissionAttributeTest.cs: Removed *Choice security actions
+
+2005-09-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * PrintingPermissionTest.cs: Before 2.0 some test cases throws
+ ArgumentException.
+
+2005-08-26 Atsushi Enomoto <atsushi@ximian.com>
+
+ * PrintingPermissionTest.cs, PrintingPermissionAttributeTest.cs :
+ removed BOM. LF as eol.
+
+2005-05-30 Sebastien Pouliot <sebastien@ximian.com>
+
+ * PrintingPermissionTest.cs: Added tests for unification as this
+ assembly is signed by the "MS final" key (not the ECMA key).
+
+2004-09-09 Sebastien Pouliot <sebastien@ximian.com>
+
+ * PrintingPermissionAttributeTest.cs: New. Unit tests for Printing
+ PermissionAttribute.
+ * PrintingPermissionTest.cs: New. Unit tests for PrintingPermission.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Created this repository for System.Drawing.Printing tests.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Printing/PrinterUnitConvertTest.cs b/mcs/class/System.Drawing/Test/System.Drawing.Printing/PrinterUnitConvertTest.cs
new file mode 100644
index 00000000000..5272323b433
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Printing/PrinterUnitConvertTest.cs
@@ -0,0 +1,139 @@
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Author:
+//
+// Jordi Mas i Hernandez, jordimash@gmail.com
+//
+
+using NUnit.Framework;
+using System;
+using System.IO;
+using System.Drawing.Printing;
+using System.Security;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing.Printing {
+
+ [TestFixture]
+ public class PrinterUnitConvertTest
+ {
+ static int n = 100, r;
+
+ [Test]
+ public void ConvertFromDisplay ()
+ {
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.Display,
+ PrinterUnit.Display);
+
+ Assert.AreEqual (100, r, "CFD#1");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.Display,
+ PrinterUnit.HundredthsOfAMillimeter);
+
+ Assert.AreEqual (2540, r, "CFD#2");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.Display,
+ PrinterUnit.TenthsOfAMillimeter);
+
+ Assert.AreEqual (254, r, "CFD#3");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.Display,
+ PrinterUnit.ThousandthsOfAnInch);
+
+ Assert.AreEqual (1000, r, "CFD#4");
+ }
+
+ [Test]
+ public void ConvertFromHundredthsOfAMillimeter ()
+ {
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.HundredthsOfAMillimeter,
+ PrinterUnit.Display);
+
+ Assert.AreEqual (4, r, "CFH#1");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.HundredthsOfAMillimeter,
+ PrinterUnit.HundredthsOfAMillimeter);
+
+ Assert.AreEqual (100, r, "CFH#2");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.HundredthsOfAMillimeter,
+ PrinterUnit.TenthsOfAMillimeter);
+
+ Assert.AreEqual (10, r, "CFH#3");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.HundredthsOfAMillimeter,
+ PrinterUnit.ThousandthsOfAnInch);
+
+ Assert.AreEqual (39, r, "CFH#4");
+ }
+
+ [Test]
+ public void ConvertFromTenthsOfAMillimeter ()
+ {
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.TenthsOfAMillimeter,
+ PrinterUnit.Display);
+
+ Assert.AreEqual (39, r, "CFT#1");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.TenthsOfAMillimeter,
+ PrinterUnit.HundredthsOfAMillimeter);
+
+ Assert.AreEqual (1000, r, "CFT#2");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.TenthsOfAMillimeter,
+ PrinterUnit.TenthsOfAMillimeter);
+
+ Assert.AreEqual (100, r, "CFT#3");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.TenthsOfAMillimeter,
+ PrinterUnit.ThousandthsOfAnInch);
+
+ Assert.AreEqual (394, r, "CFT#4");
+ }
+
+ [Test]
+ public void ConvertFromThousandthsOfAnInch ()
+ {
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.ThousandthsOfAnInch,
+ PrinterUnit.Display);
+
+ Assert.AreEqual (10, r, "CFI#1");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.ThousandthsOfAnInch,
+ PrinterUnit.HundredthsOfAMillimeter);
+
+ Assert.AreEqual (254, r, "CFI#2");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.ThousandthsOfAnInch,
+ PrinterUnit.TenthsOfAMillimeter);
+
+ Assert.AreEqual (25, r, "CFI#3");
+
+ r = PrinterUnitConvert.Convert (n, PrinterUnit.ThousandthsOfAnInch,
+ PrinterUnit.ThousandthsOfAnInch);
+
+ Assert.AreEqual (100, r, "CFI#4");
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Printing/PrintingPermissionAttributeTest.cs b/mcs/class/System.Drawing/Test/System.Drawing.Printing/PrintingPermissionAttributeTest.cs
new file mode 100644
index 00000000000..91575d2d3e2
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Printing/PrintingPermissionAttributeTest.cs
@@ -0,0 +1,134 @@
+//
+// PrintingPermissionAttributeTest.cs -
+// NUnit Test Cases for PrintingPermissionAttribute
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+using System;
+using System.Drawing.Printing;
+using System.Security;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing.Printing {
+
+ [TestFixture]
+ public class PrintingPermissionAttributeTest {
+
+ [Test]
+ public void Default ()
+ {
+ PrintingPermissionAttribute a = new PrintingPermissionAttribute (SecurityAction.Assert);
+ Assert.AreEqual (a.ToString (), a.TypeId.ToString (), "TypeId");
+ Assert.IsFalse (a.Unrestricted, "Unrestricted");
+ Assert.AreEqual (PrintingPermissionLevel.NoPrinting, a.Level, "PrintingPermissionLevel");
+
+ PrintingPermission sp = (PrintingPermission)a.CreatePermission ();
+ Assert.IsFalse (sp.IsUnrestricted (), "IsUnrestricted");
+ }
+
+ [Test]
+ public void Action ()
+ {
+ PrintingPermissionAttribute a = new PrintingPermissionAttribute (SecurityAction.Assert);
+ Assert.AreEqual (SecurityAction.Assert, a.Action, "Action=Assert");
+ a.Action = SecurityAction.Demand;
+ Assert.AreEqual (SecurityAction.Demand, a.Action, "Action=Demand");
+ a.Action = SecurityAction.Deny;
+ Assert.AreEqual (SecurityAction.Deny, a.Action, "Action=Deny");
+ a.Action = SecurityAction.InheritanceDemand;
+ Assert.AreEqual (SecurityAction.InheritanceDemand, a.Action, "Action=InheritanceDemand");
+ a.Action = SecurityAction.LinkDemand;
+ Assert.AreEqual (SecurityAction.LinkDemand, a.Action, "Action=LinkDemand");
+ a.Action = SecurityAction.PermitOnly;
+ Assert.AreEqual (SecurityAction.PermitOnly, a.Action, "Action=PermitOnly");
+ a.Action = SecurityAction.RequestMinimum;
+ Assert.AreEqual (SecurityAction.RequestMinimum, a.Action, "Action=RequestMinimum");
+ a.Action = SecurityAction.RequestOptional;
+ Assert.AreEqual (SecurityAction.RequestOptional, a.Action, "Action=RequestOptional");
+ a.Action = SecurityAction.RequestRefuse;
+ Assert.AreEqual (SecurityAction.RequestRefuse, a.Action, "Action=RequestRefuse");
+ }
+
+ [Test]
+ public void Action_Invalid ()
+ {
+ PrintingPermissionAttribute a = new PrintingPermissionAttribute ((SecurityAction)Int32.MinValue);
+ // no validation in attribute
+ }
+
+ [Test]
+ public void Unrestricted ()
+ {
+ PrintingPermissionAttribute a = new PrintingPermissionAttribute (SecurityAction.Assert);
+ a.Unrestricted = true;
+ PrintingPermission wp = (PrintingPermission)a.CreatePermission ();
+ Assert.IsTrue (wp.IsUnrestricted (), "IsUnrestricted");
+ Assert.AreEqual (PrintingPermissionLevel.NoPrinting, a.Level, "NoPrinting");
+
+ a.Unrestricted = false;
+ wp = (PrintingPermission)a.CreatePermission ();
+ Assert.IsFalse (wp.IsUnrestricted (), "!IsUnrestricted");
+ }
+
+ [Test]
+ public void Level ()
+ {
+ PrintingPermissionAttribute a = new PrintingPermissionAttribute (SecurityAction.Assert);
+ a.Level = PrintingPermissionLevel.NoPrinting;
+ Assert.AreEqual (PrintingPermissionLevel.NoPrinting, a.Level, "NoPrinting");
+ a.Level = PrintingPermissionLevel.SafePrinting;
+ Assert.AreEqual (PrintingPermissionLevel.SafePrinting, a.Level, "SafePrinting");
+ a.Level = PrintingPermissionLevel.DefaultPrinting;
+ Assert.AreEqual (PrintingPermissionLevel.DefaultPrinting, a.Level, "DefaultPrintin.");
+ a.Level = PrintingPermissionLevel.AllPrinting;
+ Assert.AreEqual (PrintingPermissionLevel.AllPrinting, a.Level, "AllPrinting");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Level_Invalid ()
+ {
+ PrintingPermissionAttribute a = new PrintingPermissionAttribute (SecurityAction.Assert);
+ a.Level = (PrintingPermissionLevel) Int32.MinValue;
+ }
+
+ [Test]
+ public void Attributes ()
+ {
+ Type t = typeof (PrintingPermissionAttribute);
+ Assert.IsFalse (t.IsSerializable, "IsSerializable");
+
+ object [] attrs = t.GetCustomAttributes (typeof (AttributeUsageAttribute), false);
+ Assert.AreEqual (1, attrs.Length, "AttributeUsage");
+ AttributeUsageAttribute aua = (AttributeUsageAttribute)attrs [0];
+ Assert.IsTrue (aua.AllowMultiple, "AllowMultiple");
+ Assert.IsTrue (aua.Inherited, "Inherited");
+ AttributeTargets at = AttributeTargets.All;
+ Assert.AreEqual (at, aua.ValidOn, "ValidOn");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Printing/PrintingPermissionTest.cs b/mcs/class/System.Drawing/Test/System.Drawing.Printing/PrintingPermissionTest.cs
new file mode 100644
index 00000000000..1f38dfd130a
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Printing/PrintingPermissionTest.cs
@@ -0,0 +1,482 @@
+//
+// PrintingPermissionTest.cs - NUnit Test Cases for PrintingPermission
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+using System;
+using System.IO;
+using System.Drawing.Printing;
+using System.Security;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing.Printing {
+
+ [TestFixture]
+ public class PrintingPermissionTest {
+
+ static PrintingPermissionLevel[] AllLevel = {
+ PrintingPermissionLevel.NoPrinting,
+ PrintingPermissionLevel.SafePrinting,
+ PrintingPermissionLevel.DefaultPrinting,
+ PrintingPermissionLevel.AllPrinting,
+ };
+
+ static PrintingPermissionLevel[] AllLevelExceptNoLevel = {
+ PrintingPermissionLevel.SafePrinting,
+ PrintingPermissionLevel.DefaultPrinting,
+ PrintingPermissionLevel.AllPrinting,
+ };
+
+ static PrintingPermissionLevel[] AllLevelExceptAllLevel = {
+ PrintingPermissionLevel.NoPrinting,
+ PrintingPermissionLevel.SafePrinting,
+ PrintingPermissionLevel.DefaultPrinting,
+ };
+
+ static PrintingPermissionLevel[] AllLevelExceptNoAndAllLevel = {
+ PrintingPermissionLevel.SafePrinting,
+ PrintingPermissionLevel.DefaultPrinting,
+ };
+
+ [Test]
+ public void PermissionState_None ()
+ {
+ PermissionState ps = PermissionState.None;
+ PrintingPermission pp = new PrintingPermission (ps);
+ Assert.AreEqual (PrintingPermissionLevel.NoPrinting, pp.Level, "Level");
+ Assert.IsFalse (pp.IsUnrestricted (), "IsUnrestricted");
+
+ SecurityElement se = pp.ToXml ();
+ // only class and version are present
+ Assert.AreEqual ("NoPrinting", se.Attribute ("Level"), "Xml-Level");
+ Assert.IsNull (se.Children, "Xml-Children");
+
+ PrintingPermission copy = (PrintingPermission)pp.Copy ();
+ Assert.IsFalse (Object.ReferenceEquals (pp, copy), "ReferenceEquals");
+ Assert.AreEqual (pp.Level, copy.Level, "Level");
+ Assert.AreEqual (pp.IsUnrestricted (), copy.IsUnrestricted (), "IsUnrestricted ()");
+ }
+
+ [Test]
+ public void PermissionState_Unrestricted ()
+ {
+ PermissionState ps = PermissionState.Unrestricted;
+ PrintingPermission pp = new PrintingPermission (ps);
+ Assert.AreEqual (PrintingPermissionLevel.AllPrinting, pp.Level, "Level");
+ Assert.IsTrue (pp.IsUnrestricted (), "IsUnrestricted");
+
+ SecurityElement se = pp.ToXml ();
+ // only class and version are present
+ Assert.AreEqual ("true", se.Attribute ("Unrestricted"), "Xml-Unrestricted");
+ Assert.IsNull (se.Children, "Xml-Children");
+
+ PrintingPermission copy = (PrintingPermission)pp.Copy ();
+ Assert.IsFalse (Object.ReferenceEquals (pp, copy), "ReferenceEquals");
+ Assert.AreEqual (pp.Level, copy.Level, "Level");
+ Assert.AreEqual (pp.IsUnrestricted (), copy.IsUnrestricted (), "IsUnrestricted ()");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void PermissionState_Bad ()
+ {
+ PermissionState ps = (PermissionState)77;
+ PrintingPermission pp = new PrintingPermission (ps);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void PrintingPermissionLevels_Bad ()
+ {
+ PrintingPermissionLevel ppl = (PrintingPermissionLevel)(PrintingPermissionLevel.AllPrinting + 1);
+ PrintingPermission pp = new PrintingPermission (ppl);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void Level_PrintingPermissionLevels_Bad ()
+ {
+ PrintingPermissionLevel ppl = (PrintingPermissionLevel)(PrintingPermissionLevel.AllPrinting + 1);
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ pp.Level = ppl;
+ }
+
+ [Test]
+ public void Copy ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ foreach (PrintingPermissionLevel ppl in AllLevel) {
+ pp.Level = ppl;
+ PrintingPermission copy = (PrintingPermission)pp.Copy ();
+ Assert.AreEqual (ppl, copy.Level, ppl.ToString ());
+ }
+ }
+
+ [Test]
+ public void Intersect_Null ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ // No intersection with null
+ foreach (PrintingPermissionLevel ppl in AllLevel) {
+ pp.Level = ppl;
+ Assert.IsNull (pp.Intersect (null), ppl.ToString ());
+ }
+ }
+
+ [Test]
+ public void Intersect_None ()
+ {
+ PrintingPermission sp1 = new PrintingPermission (PermissionState.None);
+ PrintingPermission sp2 = new PrintingPermission (PermissionState.None);
+ foreach (PrintingPermissionLevel ppl in AllLevelExceptNoLevel) {
+ sp2.Level = ppl;
+ // 1. Intersect None with ppl
+ PrintingPermission result = (PrintingPermission)sp1.Intersect (sp2);
+ Assert.IsNull (result, "None N " + ppl.ToString ());
+ // 2. Intersect ppl with None
+ result = (PrintingPermission)sp2.Intersect (sp1);
+ Assert.IsNull (result, "None N " + ppl.ToString ());
+ }
+ }
+
+ [Test]
+ public void Intersect_Self ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ foreach (PrintingPermissionLevel ppl in AllLevelExceptNoLevel) {
+ pp.Level = ppl;
+ PrintingPermission result = (PrintingPermission)pp.Intersect (pp);
+ Assert.AreEqual (ppl, result.Level, ppl.ToString ());
+ }
+ }
+
+ [Test]
+ public void Intersect_Unrestricted ()
+ {
+ // Intersection with unrestricted == Copy
+ // a. source (this) is unrestricted
+ PrintingPermission sp1 = new PrintingPermission (PermissionState.Unrestricted);
+ PrintingPermission sp2 = new PrintingPermission (PermissionState.None);
+ foreach (PrintingPermissionLevel ppl in AllLevelExceptNoLevel) {
+ sp2.Level = ppl;
+ PrintingPermission result = (PrintingPermission)sp1.Intersect (sp2);
+ Assert.AreEqual (sp2.Level, result.Level, "target " + ppl.ToString ());
+ }
+ // b. destination (target) is unrestricted
+ foreach (PrintingPermissionLevel ppl in AllLevelExceptNoLevel) {
+ sp2.Level = ppl;
+ PrintingPermission result = (PrintingPermission)sp2.Intersect (sp1);
+ Assert.AreEqual (sp2.Level, result.Level, "source " + ppl.ToString ());
+ }
+ // exceptions for NoLevel
+ sp2.Level = PrintingPermissionLevel.NoPrinting;
+ Assert.IsNull (sp1.Intersect (sp2), "target NoLevel");
+ Assert.IsNull (sp2.Intersect (sp1), "source NoLevel");
+ }
+
+ [Test]
+ public void IsSubset_Null ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ Assert.IsTrue (pp.IsSubsetOf (null), "NoLevel");
+ foreach (PrintingPermissionLevel ppl in AllLevelExceptNoLevel) {
+ pp.Level = ppl;
+ Assert.IsFalse (pp.IsSubsetOf (null), ppl.ToString ());
+ }
+ }
+
+ [Test]
+ public void IsSubset_None ()
+ {
+ // IsSubset with none
+ // a. source (this) is none -> target is never a subset
+ PrintingPermission sp1 = new PrintingPermission (PermissionState.None);
+ PrintingPermission sp2 = new PrintingPermission (PermissionState.None);
+ foreach (PrintingPermissionLevel ppl in AllLevel) {
+ sp2.Level = ppl;
+ Assert.IsTrue (sp1.IsSubsetOf (sp2), "target " + ppl.ToString ());
+ }
+ // b. destination (target) is none -> target is always a subset
+ foreach (PrintingPermissionLevel ppl in AllLevelExceptNoLevel) {
+ sp2.Level = ppl;
+ Assert.IsFalse (sp2.IsSubsetOf (sp1), "source " + ppl.ToString ());
+ }
+ // exception of NoLevel
+ sp2.Level = PrintingPermissionLevel.NoPrinting;
+ Assert.IsTrue (sp2.IsSubsetOf (sp1), "source NoLevel");
+ }
+
+ [Test]
+ public void IsSubset_Self ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ foreach (PrintingPermissionLevel ppl in AllLevel) {
+ pp.Level = ppl;
+ PrintingPermission result = (PrintingPermission)pp.Intersect (pp);
+ Assert.IsTrue (pp.IsSubsetOf (pp), ppl.ToString ());
+ }
+ }
+
+ [Test]
+ public void IsSubset_Unrestricted ()
+ {
+ // IsSubset with unrestricted
+ // a. source (this) is unrestricted -> target is never a subset
+ PrintingPermission sp1 = new PrintingPermission (PermissionState.Unrestricted);
+ PrintingPermission sp2 = new PrintingPermission (PermissionState.None);
+ foreach (PrintingPermissionLevel ppl in AllLevelExceptAllLevel) {
+ sp2.Level = ppl;
+ Assert.IsFalse (sp1.IsSubsetOf (sp2), "target " + ppl.ToString ());
+ }
+ // exception of AllLevel
+ sp2.Level = PrintingPermissionLevel.AllPrinting;
+ Assert.IsTrue (sp1.IsSubsetOf (sp2), "target AllLevel");
+ // b. destination (target) is unrestricted -> target is always a subset
+ foreach (PrintingPermissionLevel ppl in AllLevel) {
+ sp2.Level = ppl;
+ Assert.IsTrue (sp2.IsSubsetOf (sp1), "source " + ppl.ToString ());
+ }
+ }
+
+ [Test]
+ public void Union_Null ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ // Union with null is a simple copy
+ foreach (PrintingPermissionLevel ppl in AllLevel) {
+ pp.Level = ppl;
+ PrintingPermission union = (PrintingPermission)pp.Union (null);
+ Assert.AreEqual (ppl, union.Level, ppl.ToString ());
+ }
+ }
+
+ [Test]
+ public void Union_None ()
+ {
+ // Union with none is same
+ PrintingPermission pp1 = new PrintingPermission (PermissionState.None);
+ PrintingPermission pp2 = new PrintingPermission (PermissionState.None);
+ PrintingPermission union = null;
+
+ // a. source (this) is none
+ pp2.Level = PrintingPermissionLevel.NoPrinting;
+ union = (PrintingPermission)pp1.Union (pp2);
+ Assert.IsNull (union, "target NoPrinting");
+ foreach (PrintingPermissionLevel ppl in AllLevelExceptNoAndAllLevel) {
+ pp2.Level = ppl;
+ union = (PrintingPermission)pp1.Union (pp2);
+ Assert.IsFalse (union.IsUnrestricted (), "target " + ppl.ToString ());
+ }
+ pp2.Level = PrintingPermissionLevel.AllPrinting;
+ union = (PrintingPermission)pp1.Union (pp2);
+ Assert.IsTrue (union.IsUnrestricted (), "target AllPrinting");
+
+ // b. destination (target) is none
+ pp2.Level = PrintingPermissionLevel.NoPrinting;
+ union = (PrintingPermission)pp2.Union (pp1);
+ Assert.IsNull (union, "source NoPrinting");
+ foreach (PrintingPermissionLevel ppl in AllLevelExceptNoAndAllLevel) {
+ pp2.Level = ppl;
+ union = (PrintingPermission)pp2.Union (pp1);
+ Assert.IsFalse (union.IsUnrestricted (), "source " + ppl.ToString ());
+ }
+ pp2.Level = PrintingPermissionLevel.AllPrinting;
+ union = (PrintingPermission)pp2.Union (pp1);
+ Assert.IsTrue (union.IsUnrestricted (), "source AllPrinting");
+ }
+
+ [Test]
+ public void Union_Self ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ foreach (PrintingPermissionLevel ppl in AllLevelExceptNoLevel) {
+ pp.Level = ppl;
+ PrintingPermission result = (PrintingPermission)pp.Union (pp);
+ Assert.AreEqual (ppl, result.Level, ppl.ToString ());
+ }
+ // union of NoPrinting with NoPrinting == null
+ pp.Level = PrintingPermissionLevel.NoPrinting;
+ Assert.IsNull (pp.Union (pp), "NoPrinting");
+ }
+
+ [Test]
+ public void Union_Unrestricted ()
+ {
+ // Union with unrestricted is unrestricted
+ PrintingPermission sp1 = new PrintingPermission (PermissionState.Unrestricted);
+ PrintingPermission sp2 = new PrintingPermission (PermissionState.None);
+ // a. source (this) is unrestricted
+ foreach (PrintingPermissionLevel ppl in AllLevel) {
+ sp2.Level = ppl;
+ PrintingPermission union = (PrintingPermission)sp1.Union (sp2);
+ Assert.IsTrue (union.IsUnrestricted (), "target " + ppl.ToString ());
+ }
+ // b. destination (target) is unrestricted
+ foreach (PrintingPermissionLevel ppl in AllLevel) {
+ sp2.Level = ppl;
+ PrintingPermission union = (PrintingPermission)sp2.Union (sp1);
+ Assert.IsTrue (union.IsUnrestricted (), "source " + ppl.ToString ());
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void FromXml_Null ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ pp.FromXml (null);
+ }
+
+ [Test]
+ public void FromXml_WrongTag ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ SecurityElement se = pp.ToXml ();
+ se.Tag = "IMono";
+ pp.FromXml (se);
+ // note: normally IPermission classes (in corlib) DO care about the
+ // IPermission tag
+ }
+
+ [Test]
+ public void FromXml_WrongTagCase ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ SecurityElement se = pp.ToXml ();
+ se.Tag = "IPERMISSION"; // instead of IPermission
+ pp.FromXml (se);
+ // note: normally IPermission classes (in corlib) DO care about the
+ // IPermission tag
+ }
+
+ [Test]
+#if !NET_2_0
+ [ExpectedException (typeof (ArgumentException))]
+#endif
+ public void FromXml_WrongClass ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ SecurityElement se = pp.ToXml ();
+
+ SecurityElement w = new SecurityElement (se.Tag);
+ w.AddAttribute ("class", "Wrong" + se.Attribute ("class"));
+ w.AddAttribute ("version", se.Attribute ("version"));
+ pp.FromXml (w);
+ // doesn't care of the class name at that stage
+ // anyway the class has already be created so...
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromXml_NoClass ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ SecurityElement se = pp.ToXml ();
+
+ SecurityElement w = new SecurityElement (se.Tag);
+ w.AddAttribute ("version", se.Attribute ("version"));
+ pp.FromXml (w);
+ // note: normally IPermission classes (in corlib) DO NOT care about
+ // attribute "class" name presence in the XML
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromXml_WrongVersion ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ SecurityElement se = pp.ToXml ();
+ se.Attributes.Remove ("version");
+ se.Attributes.Add ("version", "2");
+ pp.FromXml (se);
+ }
+
+ [Test]
+#if !NET_2_0
+ [ExpectedException (typeof (ArgumentException))]
+#endif
+ public void FromXml_NoVersion ()
+ {
+ PrintingPermission pp = new PrintingPermission (PermissionState.None);
+ SecurityElement se = pp.ToXml ();
+
+ SecurityElement w = new SecurityElement (se.Tag);
+ w.AddAttribute ("class", se.Attribute ("class"));
+ pp.FromXml (w);
+ }
+
+ // Unification tests (with the MS final key)
+ // note: corlib already test the ECMA key support for unification
+ private const string PermissionPattern = "<PermissionSet class=\"System.Security.PermissionSet\" version=\"1\"><IPermission class=\"System.Drawing.Printing.PrintingPermission, System.Drawing, Version={0}, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\" version=\"1\" Level=\"NoPrinting\"/></PermissionSet>";
+ private const string fx10version = "1.0.3300.0";
+ private const string fx11version = "1.0.5000.0";
+ private const string fx20version = "2.0.0.0";
+
+ private void Unification (string xml)
+ {
+ PermissionSetAttribute psa = new PermissionSetAttribute (SecurityAction.Assert);
+ psa.XML = xml;
+ string pset = psa.CreatePermissionSet ().ToString ();
+ string currentVersion = typeof (string).Assembly.GetName ().Version.ToString ();
+ Assert.IsTrue ((pset.IndexOf (currentVersion) > 0), currentVersion);
+ }
+
+ [Test]
+ public void Unification_FromFx10 ()
+ {
+ Unification (String.Format (PermissionPattern, fx10version));
+ }
+
+ [Test]
+ public void Unification_FromFx11 ()
+ {
+ Unification (String.Format (PermissionPattern, fx11version));
+ }
+
+ [Test]
+ public void Unification_FromFx20 ()
+ {
+ Unification (String.Format (PermissionPattern, fx20version));
+ }
+
+#if NET_2_0
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (FileLoadException))]
+ public void Unification_FromFx99 ()
+ {
+ Type.GetType (String.Format (PermissionPattern, "9.99.999.9999"));
+ }
+#else
+ [Test]
+ public void Unification_FromFx99 ()
+ {
+ Unification (String.Format (PermissionPattern, "9.99.999.9999"));
+ }
+#endif
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing.Text/ChangeLog b/mcs/class/System.Drawing/Test/System.Drawing.Text/ChangeLog
new file mode 100644
index 00000000000..b56d47cc206
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing.Text/ChangeLog
@@ -0,0 +1,3 @@
+2004-03-17 Ravindra <rkumar@novell.com>
+ * Created this repository for System.Drawing.Text tests.
+ * ChangeLog: Added.
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/BitmapCas.cs b/mcs/class/System.Drawing/Test/System.Drawing/BitmapCas.cs
new file mode 100644
index 00000000000..fefbf4a0b1b
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/BitmapCas.cs
@@ -0,0 +1,133 @@
+//
+// BitmapCas.cs - CAS unit tests for System.Drawing.Bitmap
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Drawing;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing {
+
+ [TestFixture]
+ [Category ("CAS")]
+ public class BitmapCas {
+
+ private MethodInfo getHbitmap1;
+ private MethodInfo getHbitmap2;
+ private MethodInfo getHicon;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ getHbitmap1 = typeof (Bitmap).GetMethod ("GetHbitmap", new Type[0]);
+ getHbitmap2 = typeof (Bitmap).GetMethod ("GetHbitmap", new Type[1] { typeof (Color) });
+ getHicon = typeof (Bitmap).GetMethod ("GetHicon");
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public void GetHbitmap ()
+ {
+ Bitmap b = new Bitmap (10, 10);
+ try {
+ Assert.IsTrue (b.GetHbitmap () != IntPtr.Zero, "GetHbitmap");
+ }
+ catch (NotImplementedException) {
+ // not available on Mono
+ }
+ try {
+ Assert.IsTrue (b.GetHbitmap (Color.Aqua) != IntPtr.Zero, "GetHbitmap(Color)");
+ }
+ catch (NotImplementedException) {
+ // not available on Mono
+ }
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public void GetHicon ()
+ {
+ Bitmap b = new Bitmap (10, 10);
+ try {
+ Assert.IsTrue (b.GetHicon () != IntPtr.Zero, "GetHicon");
+ }
+ catch (NotImplementedException) {
+ // not available on Mono
+ }
+ }
+
+ // we use reflection to call Bitmap as it's GetHbitmap and GetHicon methods
+ // are protected by a LinkDemand (which will be converted into full demand,
+ // i.e. a stack walk) when reflection is used (i.e. it gets testable).
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void GetHbitmap_Empty_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (getHbitmap1, "GetHbitmap");
+ Bitmap b = new Bitmap (10, 10);
+ getHbitmap1.Invoke (b, null);
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void GetHbitmap_Color_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (getHbitmap2, "GetHbitmap(Color)");
+ Bitmap b = new Bitmap (10, 10);
+ getHbitmap2.Invoke (b, new object[1] { Color.Aqua });
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void GetHicon_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (getHicon, "GetHicon");
+ Bitmap b = new Bitmap (10, 10);
+ getHicon.Invoke (b, null);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog b/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
new file mode 100644
index 00000000000..c854cc17e5d
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
@@ -0,0 +1,357 @@
+2006-01-18 Sebastien Pouliot <sebastien@ximian.com>
+
+ * RegionDataTest.cs: New. Unit tests for RegionData.
+ * RegionNonRectTest.cs: New. Unit tests for non-rectangular regions.
+ * TestRegion.cs: Added new test cases for empty region and IsInfinite
+ behaviour with multiple rectangles / path-rectangle regions.
+
+2006-01-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * TestRegion.cs: Mark a test case as NotWorking as it caused a
+ regression in SWF.
+
+2006-01-11 Sebastien Pouliot <sebastien@ximian.com>
+
+ * RegionCas.cs: New. CAS unit tests for Region.
+ * TestRegion.cs: Added test cases to check for expected exceptions.
+
+2005-12-05 Peter Dennis Bartok <pbartok@novell.com>
+
+ * TestFont.cs: Added test for LogFont conversion
+
+2005-12-05 Jordi Mas i Hernandez <jordimash@gmail.com>
+
+ * TestPoint.cs: Test new methods for .Net 2.0
+ * TestPointF.cs Test new methods for .Net 2.0
+ * ColorConverter.cs: Fixes for .Net 2.0
+ * TestSizeF.cs: Test new methods for .Net 2.0
+ * TestSize.cs: Test new methods for .Net 2.0
+
+2005-12-02 Jonathan Gilbert <logic@deltaq.org>
+
+ * TestBitmap.cs (LockUnlockBitmap): Added test for the copying back
+ of bitmap data in Bitmap.UnlockBits for non-readonly ImageLockMode
+ values.
+
+2005-11-17 Vladimir Krasnov <vladimirk@mainsoft.com>
+
+ * ColorConverter.cs: added testcases for ConvertFrom and
+ three digit notaion color.
+
+2005-10-23 Jonathan Gilbert <logic@deltaq.org>
+
+ * TestBitmap.cs (Rotate1bit4bit): Added test for rotation & flipping
+ of indexed (1- and 4-bit) Bitmaps.
+ * 1bit.png, 4bit.png: Added to 'bitmaps' subdirectory.
+
+2005-09-19 Miguel de Icaza <miguel@novell.com>
+
+ * TestGraphics.cs (LoadIndexed): Add test for the indexed bug.
+
+2005-09-16 Sebastien Pouliot <sebastien@ximian.com>
+
+ * BitmapCas.cs: New. CAS unit tests for Bitmap.
+ * GraphicsCas.cs: New. CAS unit tests for Graphics.
+ * ColorConverter.cs, ColorTranslator.cs, TestBrushes.cs, TestBitmap.cs
+ TestColor.cs, TestFont.cs, TestIcon.cs, TestIconConverter.cs,
+ TestImage.cs, TestImageConverter.cs, TestImageFormatConverter.cs,
+ TestPens.cs, TestPoint.cs, TestPointF.cs, TestPointConverter.cs,
+ TestRectangle.cs, TestRectangleF.cs, TestRectangleConverter.cs,
+ TestRegion.cs, TestSizeConverter.cs, TestSize.cs, TestSizeF.cs,
+ TestStringFormat.cs, TestSystemBrushes.cs, TestSystemPens.cs: Deny
+ UnmanagedCode permission to all tests. This shows (when executed under
+ MS runtime) that S.D API is safe and doesn't requires high privileges
+ to run - even if we know that, deep down, this calls into GDI+.
+
+2005-09-14 Jordi Mas i Hernandez <jordi@ximan.com>
+
+ * TestGraphics.cs: Adds default properties, properties set/get and save
+ and restore status test
+
+2005-09-13 Jordi Mas i Hernandez <jordi@ximan.com>
+
+ * TestGraphics.cs: resets graphics object status before every SetClip test
+
+2005-09-12 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * TestImageConverter.cs: Re-enabled GetProperties test.
+ * TestPointConverter.cs: same.
+ * TestRectangleConverter.cs: same.
+ * TestSizeConverter.cs: same.
+
+2005-09-06 Jordi Mas i Hernandez <jordi@ximan.com>
+
+ * TestImagge.cs: File not found exception, related to fix r49744
+ * TestBimap.cs: File not found exception, related to fix r49744
+
+2005-09-06 Jordi Mas i Hernandez <jordi@ximan.com>
+
+ * TestGraphics.cs: New test case, only clipping for now
+
+2005-08-26 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * TestPointConverter.cs: Use Assert class instead of deriving from
+ deprecated Assertion class. Tests now pass on both Mono and MS.NET.
+ * TestRectangleConverter.cs: same.
+ * TestSizeConverter.cs: same.
+
+2005-08-26 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * ColorConverter.cs: Add hex string tests. Fixed tests to pass on
+ MS.NET.
+
+2005-08-23 Jordi Mas i Hernandez <jordi@ximan.com>
+
+ * TestPens.cs: Add test for Equals method
+ * TestBrushes.cs: Add test for Equals method
+
+2005-08-19 Jordi Mas i Hernandez <jordi@ximan.com>
+
+ * TestPointConverter.cs: Fixes and changes to make the test locale unsensitive
+ * TestRectangleConverter.cs: Fixes and changes to make the test locale unsensitive
+ * TestSizeConverter.cs: Fixes and changes to make the test locale unsensitive
+ * ColorConverter.cs: Fixes and changes to make the test locale unsensitive
+
+2005-08-17 Jordi Mas i Hernandez <jordi@ximan.com>
+
+ * TestRegion.cs: Adds many new cases for the new region implementation
+
+2005-08-16 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * ColorConverter.cs: Mono now also throws ArgumentException when
+ color value is not between 0 and 255.
+ * TestColor.cs: Added tests for invalid color values.
+ * TestRectangleConverter.cs: Fixed tests for conversion to/from
+ string. Added tests that verify results using specific cultures.
+
+2005-08-14 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * ColorConverter.cs: Merged tests from TestColorConverter.cs. Fixed
+ tests using current culture.
+ * TestColorConverter.cs: Merged tests with ColorConverter.cs and
+ removed.
+
+2005-08-14 Gert Driesen <drieseng@users.sourceforge.net>
+
+ * TestColor.cs: Added test for ToString() on uninitialized color.
+ * TestColorConverter.cs: Added tests for ColorConverter.
+
+2005-08-10 Jordi Mas i Hernandez <jordi@ximan.com>
+
+ * TestRegion.cs: new cases for Combine and Intersect
+
+2005-08-10 Zoltan Varga <vargaz@freemail.hu>
+
+ * TestRectangle.cs: Add new test.
+
+2005-08-09 Andrew Skiba <andrews@mainsoft.com>
+
+ * ColorConverter.cs, ColorTranslator.cs: added
+ * TestPointConverter.cs, TestRectangleConverter.cs, TestSizeConverter.cs: new
+ tests for convert to/from string
+
+2005-08-07 Andrew Skiba <andrews@mainsoft.com>
+
+ * Color.cs: many new testcases added
+
+2005-08-07 Andrew Skiba <andrews@mainsoft.com>
+
+ * Size.cs, SizeF.cs: GetHashCode and ToString tests
+
+2005-08-07 Andrew Skiba <andrews@mainsoft.com>
+
+ * TestRectangle.cs, TestRectangleF.cs: add new testcases
+
+2005-08-07 Andrew Skiba <andrews@mainsoft.com>
+
+ * TestPoint.cs: GetHashCode and ToString tests added
+ * TestPointF.cs: GetHashCode and ToString tests added, Addition and Substraction
+ tests improved
+
+2005-08-07 Andrew Skiba <andrews@mainsoft.com>
+
+ * TestPens.cs, TestSystemBrushes.cs, TestSystemPens.cs: don't rethrow exceptions, keep
+ the original stack trace.
+
+2005-07-27 Andrew Skiba <andrews@mainsoft.com>
+
+ * TestColor.cs: added tests for equality operators, IsEmpty property and fixed GetHBS
+ tests to use tolerance.
+
+2005-05-10 Juraj Skripsky <juraj@hotfeet.ch>
+
+ * TestColor.cs: Added tests for GetHue, GetBrightness
+ and GetSaturation.
+
+2005-02-24 Jordi Mas i Hernandez <jordi@ximan.com>
+ * TestRegion.cs: added new IsVisible cases
+
+2004-06-22 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestIconConverter.cs, TestImageConverter.cs: Commented out some tests.
+
+2004-06-17 Ravindra <rkumar@novell.com>
+
+ * graphicsUi.cs: Formatted and moved to
+ Samples/System.Drawing directory.
+ * image1.cs: Formatted and renamed to bmpsave.cs. Moved to
+ Samples/System.Drawing directory.
+ * hering.cs: Formatted and moved to Samples/General directory.
+ * BmpPaint.cs: Ficed, formatted and moved to
+ Samples/System.Drawing directory.
+ * font1.cs: Formatted and renamed to font.cs. Moved to
+ Samples/System.Drawing directory.
+
+2004-06-10 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestBitmap.cs: Corrected issues from my previous checkin.
+
+2004-06-10 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestImageFormatConverter.cs, TestStringFormat.cs: Removed
+ dependency on obsolete class, Assertion from NUnit.
+
+2004-06-09 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestImageConverter.cs: Removed dependency on obsolete class,
+ Assertion from NUnit.
+
+2004-06-09 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestBitmap.cs, TestIcon.cs, TestIconConverter.cs: Removed
+ dependency on obsolete class, Assertion from NUnit.
+
+2004-05-27 Ravindra <rkumar@novell.com>
+
+ * TestRectangleConverter.cs: Ignored the test that is failing
+ because of bug #58435.
+ * TestPointConverter.cs: Same.
+ * TestSizeConverter.cs: Same.
+ * TestImageConverter.cs: Same.
+
+2004-05-26 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestImageFormatConverter.cs: Minor modification. Removed duplicate
+ assertion numbers.
+
+2004-05-26 Ravindra <rkumar@novell.com>
+
+ * TestColor.cs: Added a test for testing ARGB values for all
+ the static color properties.
+
+2004-05-20 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestIcon.cs: Added.
+ * bitmaps/smiley.ico: Added.
+
+2004-05-18 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestImageFormatConverter.cs: Fixed issues with test case.
+
+2004-05-18 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestImageConverter.cs: Fixed issues with test case.
+
+2004-05-18 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestIconConverter.cs: Fixed issues with test case.
+
+2004-05-18 Ravindra <rkumar@novell.com>
+
+ * TestHatchBrush.cs: Removed. Now, we have a better test for HatchBrush
+ this under Test/System.Drawing.Drawing2D directory.
+
+2004-05-17 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestIconConverter.cs: Added.
+ * bitmaps/VisualPng.ico: Added
+ * bitmaps/VisualPng1.ico: Added
+
+2004-05-14 Sanjay Gupta <gsanjay@novell.com>
+
+ * TestBitmap.cs: Modified method signature to static to be used in other file.
+ * TestImageConverter.cs: Added.
+ * TestImageFormatConverter.cs: Added
+
+2004-05-12 Jordi Mas <jordi@ximan.com>
+ * TestBitmap.cs: added lockbitmap tests
+
+2004-05-07 Jordi Mas <jordi@ximan.com>
+ * TestBitmap.cs: added rotation tests
+
+2004-04-23 Ravindra <rkumar@novell.com>
+
+ * TestSystemPens.cs: Removed some unused exception variables.
+ * TestRectangleConverter.cs: Removed culture dependent tests.
+ * TestPointConverter.cs: Removed culture dependent tests.
+ * TestSizeConverter.cs: Removed culture dependent tests.
+ (These tests were not right because a constant culture specific string
+ was being parsed by using current culture of the thread. It resulted in
+ test failures when cultures do not match.)
+
+2004-04-22 Ravindra <rkumar@novell.com>
+
+ * TestPointConverter.cs: Added.
+ * TestSizeConverter.cs: Added.
+
+2004-04-22 Ravindra <rkumar@novell.com>
+
+ * TestRectangleConverter.cs: Added.
+
+2004-04-21 Ravindra <rkumar@novell.com>
+
+ * TestPens.cs: Added.
+
+2004-04-21 Ravindra <rkumar@novell.com>
+
+ * TestBrushes.cs: Added.
+
+2004-04-16 Ravindra <rkumar@novell.com>
+
+ * TestSystemPens.cs: Added.
+
+2004-03-13 Ravindra <rkumar@novell.com>
+
+ * TestSystemBrushes.cs: Added test fail conditions.
+
+2004-03-12 Ravindra <rkumar@novell.com>
+
+ * TestSystemBrushes.cs: Added.
+
+2004-03-17 Ravindra <rkumar@novell.com>
+ * TestHatchBrush.cs: Added.
+
+2004-01-26 Ravindra <rkumar@novell.com>
+ * TestPointF.cs: Added.
+ * TestSize.cs: Added.
+ * TestSizeF: Added.
+
+2004-01-16 Ravindra <rkumar@novell.com>
+ * BmpPaint.cs did not run on .NET.
+ Modified to make it run on .NET. Specs say
+ "Do not save an image to the same stream
+ that was used to construct the image."
+
+2003-07-30 Alexandre Pigolkine <pigolkine@gmx.de>
+ * BmpPaint.cs modified
+
+2003-06-28 Alexandre Pigolkine <pigolkine@gmx.de>
+ * hering.cs save as Jpeg also
+
+2003-06-22 Alexandre Pigolkine <pigolkine@gmx.de>
+ * font1.cs added
+
+2003-06-17 Alexandre Pigolkine <pigolkine@gmx.de>
+ * hering.cs added
+
+2003-06-15 Alexandre Pigolkine <pigolkine@gmx.de>
+ * BmpPaint.cs ImageFormat specified for Save()
+ * image1.cs added
+
+2003-06-06 Alexandre Pigolkine <pigolkine@gmx.de>
+ * BmpPaint.cs added
+
+2001-10-31 Mike Kestner <mkestner@speakeasy.net>
+
+ * TestPoint.cs : Tests I've had in my node forever.
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/ColorConverter.cs b/mcs/class/System.Drawing/Test/System.Drawing/ColorConverter.cs
new file mode 100644
index 00000000000..e581399ecad
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/ColorConverter.cs
@@ -0,0 +1,401 @@
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Drawing;
+using System.Globalization;
+using System.Security.Permissions;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing {
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class ColorConverterFixture
+ {
+ Color col;
+ Color colnamed;
+ ColorConverter colconv;
+ String colStr;
+ String colStrInvariant;
+ String colnamedStr;
+
+ [SetUp]
+ public void SetUp () {
+ col = Color.FromArgb (10, 20, 30);
+ colStr = string.Format ("10{0} 20{0} 30", CultureInfo.CurrentCulture.TextInfo.ListSeparator);
+ colStrInvariant = string.Format ("10{0} 20{0} 30", CultureInfo.InvariantCulture.TextInfo.ListSeparator);
+
+ colnamed = Color.ForestGreen;
+ colnamedStr = "ForestGreen";
+
+ colconv = (ColorConverter) TypeDescriptor.GetConverter (col);
+ }
+
+ [Test]
+ public void CanConvertFrom () {
+ Assert.IsTrue (colconv.CanConvertFrom (typeof (String)), "CCF#1");
+ Assert.IsTrue (colconv.CanConvertFrom (null, typeof (String)), "CCF#1a");
+ Assert.IsFalse (colconv.CanConvertFrom (null, typeof (Rectangle)), "CCF#2");
+ Assert.IsFalse (colconv.CanConvertFrom (null, typeof (RectangleF)), "CCF#3");
+ Assert.IsFalse (colconv.CanConvertFrom (null, typeof (Point)), "CCF#4");
+ Assert.IsFalse (colconv.CanConvertFrom (null, typeof (PointF)), "CCF#5");
+ Assert.IsFalse (colconv.CanConvertFrom (null, typeof (Color)), "CCF#6");
+ Assert.IsFalse (colconv.CanConvertFrom (null, typeof (SizeF)), "CCF#7");
+ Assert.IsFalse (colconv.CanConvertFrom (null, typeof (Object)), "CCF#8");
+ Assert.IsFalse ( colconv.CanConvertFrom (null, typeof (int)), "CCF#9");
+ Assert.IsTrue (colconv.CanConvertFrom (null, typeof (InstanceDescriptor)), "CCF#10");
+ }
+
+ [Test]
+ public void CanConvertTo () {
+ Assert.IsTrue (colconv.CanConvertTo (typeof (String)), "CCT#1");
+ Assert.IsTrue (colconv.CanConvertTo (null, typeof (String)), "CCT#1a");
+ Assert.IsFalse (colconv.CanConvertTo (null, typeof (Rectangle)), "CCT#2");
+ Assert.IsFalse (colconv.CanConvertTo (null, typeof (RectangleF)), "CCT#3");
+ Assert.IsFalse (colconv.CanConvertTo (null, typeof (Point)), "CCT#4");
+ Assert.IsFalse (colconv.CanConvertTo (null, typeof (PointF)), "CCT#5");
+ Assert.IsFalse (colconv.CanConvertTo (null, typeof (Color)), "CCT#6");
+ Assert.IsFalse (colconv.CanConvertTo (null, typeof (SizeF)), "CCT#7");
+ Assert.IsFalse (colconv.CanConvertTo (null, typeof (Object)), "CCT#8");
+ Assert.IsFalse (colconv.CanConvertTo (null, typeof (int)), "CCT#9");
+ Assert.IsTrue (colconv.CanConvertTo (typeof (InstanceDescriptor)), "CCT#10");
+ }
+
+ [Test]
+ public void ConvertFrom ()
+ {
+ Color color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "#0x23190A44");
+ Assert.AreEqual (35, color.A, "CF1#1");
+ Assert.AreEqual (25, color.R, "CF1#2");
+ Assert.AreEqual (10, color.G, "CF1#3");
+ Assert.AreEqual (68, color.B, "CF1#4");
+
+ color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "#0X190A44");
+ Assert.AreEqual (0, color.A, "CF2#1");
+ Assert.AreEqual (25, color.R, "CF2#2");
+ Assert.AreEqual (10, color.G, "CF2#3");
+ Assert.AreEqual (68, color.B, "CF2#4");
+
+ color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "0x190A44");
+ Assert.AreEqual (255, color.A, "CF3#1");
+ Assert.AreEqual (25, color.R, "CF3#2");
+ Assert.AreEqual (10, color.G, "CF3#3");
+ Assert.AreEqual (68, color.B, "CF3#4");
+
+ color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "0X190A44");
+ Assert.AreEqual (255, color.A, "CF4#1");
+ Assert.AreEqual (25, color.R, "CF4#2");
+ Assert.AreEqual (10, color.G, "CF4#3");
+ Assert.AreEqual (68, color.B, "CF4#4");
+
+ color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "111111");
+ Assert.AreEqual (0, color.A, "CF5#1");
+ Assert.AreEqual (1, color.R, "CF5#2");
+ Assert.AreEqual (178, color.G, "CF5#3");
+ Assert.AreEqual (7, color.B, "CF5#4");
+
+ color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "10");
+ Assert.AreEqual (0, color.A, "CF6#1");
+ Assert.AreEqual (0, color.R, "CF6#2");
+ Assert.AreEqual (0, color.G, "CF6#3");
+ Assert.AreEqual (10, color.B, "CF6#4");
+
+ color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "0");
+ Assert.AreEqual (0, color.A, "CF7#1");
+ Assert.AreEqual (0, color.R, "CF7#2");
+ Assert.AreEqual (0, color.G, "CF7#3");
+ Assert.AreEqual (0, color.B, "CF7#4");
+
+ color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "0x123");
+ Assert.AreEqual (255, color.A, "CF8#1");
+ Assert.AreEqual (17, color.R, "CF8#2");
+ Assert.AreEqual (34, color.G, "CF8#3");
+ Assert.AreEqual (51, color.B, "CF8#4");
+
+ color = (Color) colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "#123");
+ Assert.AreEqual (255, color.A, "CF9#1");
+ Assert.AreEqual (17, color.R, "CF9#2");
+ Assert.AreEqual (34, color.G, "CF9#3");
+ Assert.AreEqual (51, color.B, "CF9#4");
+
+ Assert.AreEqual (col, (Color) colconv.ConvertFrom (null,
+ CultureInfo.InvariantCulture, colStrInvariant), "CF#1");
+ Assert.AreEqual (colnamed, (Color) colconv.ConvertFrom (null,
+ CultureInfo.InvariantCulture, colnamedStr), "CF#2");
+
+ Assert.AreEqual (Color.Empty, colconv.ConvertFrom (string.Empty), "CF#3");
+ Assert.AreEqual (Color.Empty, colconv.ConvertFrom (" "), "CF#4");
+ Assert.AreEqual (Color.Red, colconv.ConvertFrom ("Red"), "CF#5");
+ Assert.AreEqual (Color.Red, colconv.ConvertFrom (" Red "), "CF#6");
+
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFrom_x1 ()
+ {
+ colconv.ConvertFrom (null, CultureInfo.InvariantCulture, "10, 20");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFrom_x2 ()
+ {
+ colconv.ConvertFrom (null, CultureInfo.InvariantCulture, "-10, 20, 30");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFrom_x3 ()
+ {
+ colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "1, 1, 1, 1, 1");
+ }
+
+ [Test]
+ [ExpectedException (typeof (Exception))]
+ public void ConvertFrom_x4 ()
+ {
+ colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "*1, 1");
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void ConvertFrom_x5 ()
+ {
+ colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Point (10, 10));
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void ConvertFrom_x6 ()
+ {
+ colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new PointF (10, 10));
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void ConvertFrom_x7 ()
+ {
+ colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Size (10, 10));
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void ConvertFrom_x8 ()
+ {
+ colconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new SizeF (10, 10));
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void ConvertFrom_x9 ()
+ {
+ colconv.ConvertFrom (null, CultureInfo.InvariantCulture, 0x10);
+ }
+
+ [Test]
+ public void ConvertTo ()
+ {
+ Assert.AreEqual (colStrInvariant, colconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ Color.FromArgb (10, 20, 30), typeof (String)), "CT#1");
+ Assert.AreEqual (colStrInvariant, colconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ Color.FromArgb (255, 10, 20, 30), typeof (String)), "CT#2");
+ Assert.AreEqual ("10, 20, 30, 40", colconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ Color.FromArgb (10, 20, 30, 40), typeof (String)), "CT#3");
+ Assert.AreEqual (colnamedStr, colconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ colnamed, typeof (String)), "CT#4");
+
+ Assert.AreEqual (string.Empty, colconv.ConvertTo (Color.Empty, typeof (string)), "CT#5");
+ Assert.AreEqual ("Red", colconv.ConvertTo (Color.Red, typeof (string)), "CT#6");
+ Assert.AreEqual (string.Empty, colconv.ConvertTo (null, typeof (string)), "CT#7");
+ Assert.AreEqual ("test", colconv.ConvertTo ("test", typeof (string)), "CT#8");
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void ConvertTo_x1 ()
+ {
+ colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
+ typeof (Color));
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void ConvertTo_x2 ()
+ {
+ colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
+ typeof (SizeF));
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void ConvertTo_x3 ()
+ {
+ colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
+ typeof (Point));
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void ConvertTo_x4 ()
+ {
+ colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
+ typeof (PointF));
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void ConvertTo_x5 ()
+ {
+ colconv.ConvertTo (null, CultureInfo.InvariantCulture, col,
+ typeof (int));
+ }
+
+ [Test]
+ public void GetCreateInstanceSupported ()
+ {
+ Assert.IsTrue (!colconv.GetCreateInstanceSupported (), "GCIS#1");
+ Assert.IsTrue (!colconv.GetCreateInstanceSupported (null), "GCIS#2");
+ }
+
+ [Test]
+ public void CreateInstance ()
+ {
+ Hashtable ht = new Hashtable ();
+ ht.Add ("R", 10); ht.Add ("G", 20); ht.Add ("B", 30);
+
+ Assert.AreEqual (null, colconv.CreateInstance (ht), "CI#1");
+
+ ht.Add ("Name", "ForestGreen");
+
+ Assert.AreEqual (null, colconv.CreateInstance (null, ht), "CI#2");
+ }
+
+ [Test]
+ public void GetPropertiesSupported ()
+ {
+ Assert.IsTrue (!colconv.GetPropertiesSupported (), "GPS#1");
+ Assert.IsTrue (!colconv.GetPropertiesSupported (null), "GPS#2");
+ }
+
+ [Test]
+ public void GetProperties ()
+ {
+ Attribute [] attrs;
+
+ Assert.AreEqual (null, colconv.GetProperties (col), "GP1#1");
+
+ Assert.AreEqual (null, colconv.GetProperties (null, col, null), "GP2#1");
+
+ attrs = Attribute.GetCustomAttributes (typeof (Color), true);
+ Assert.AreEqual (null, colconv.GetProperties (null, col, attrs), "GP3#5");
+ }
+
+ [Test]
+ public void ConvertFromInvariantString_string ()
+ {
+ Assert.AreEqual (col, colconv.ConvertFromInvariantString (colStrInvariant), "CFISS#1");
+ Assert.AreEqual (colnamed, colconv.ConvertFromInvariantString (colnamedStr), "CFISS#2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFromInvariantString_InvalidComponentCount ()
+ {
+ colconv.ConvertFromInvariantString ("1, 2, 3, 4, 5");
+ }
+
+ [Test]
+ public void ConvertFromInvariantString_InvalidNumber ()
+ {
+ try {
+ colconv.ConvertFromInvariantString ("hello");
+ Assert.Fail ("#1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.InnerException, "#3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
+ }
+ }
+
+ [Test]
+ public void ConvertFromString_string ()
+ {
+ Assert.AreEqual (col, colconv.ConvertFromString (colStr), "CFSS#1");
+ Assert.AreEqual (colnamed, colconv.ConvertFromString (colnamedStr), "CFSS#2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFromString_InvalidComponentCount ()
+ {
+ CultureInfo culture = CultureInfo.CurrentCulture;
+ colconv.ConvertFromString (string.Format (culture,
+ "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator[0]));
+ }
+
+ [Test]
+ public void ConvertFromString_InvalidNumber ()
+ {
+ try {
+ colconv.ConvertFromString ("hello");
+ Assert.Fail ("#1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.InnerException, "#3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
+ }
+ }
+
+ [Test]
+ public void ConvertToInvariantString_string () {
+ Assert.AreEqual (colStrInvariant, colconv.ConvertToInvariantString (col), "CFISS#1");
+ Assert.AreEqual (colnamedStr, colconv.ConvertToInvariantString (colnamed), "CFISS#2");
+ }
+
+ [Test]
+ public void ConvertToString_string () {
+ Assert.AreEqual (colStr, colconv.ConvertToString (col), "CFISS#1");
+ Assert.AreEqual (colnamedStr, colconv.ConvertToString (colnamed), "CFISS#3");
+ }
+
+ [Test]
+ public void GetStandardValuesSupported () {
+ Assert.IsTrue (colconv.GetStandardValuesSupported ());
+ }
+
+ [Test]
+ public void GetStandardValues () {
+#if NET_2_0
+ Assert.AreEqual ((int)KnownColor.MenuHighlight, colconv.GetStandardValues ().Count);
+ Assert.AreEqual ((int)KnownColor.MenuHighlight, colconv.GetStandardValues (null).Count);
+#else
+ Assert.AreEqual ((int)KnownColor.YellowGreen, colconv.GetStandardValues ().Count);
+ Assert.AreEqual ((int)KnownColor.YellowGreen, colconv.GetStandardValues (null).Count);
+#endif
+ }
+
+ [Test]
+ public void GetStandardValuesExclusive () {
+ Assert.AreEqual (false, colconv.GetStandardValuesExclusive ());
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/ColorTranslator.cs b/mcs/class/System.Drawing/Test/System.Drawing/ColorTranslator.cs
new file mode 100644
index 00000000000..552b77c77b0
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/ColorTranslator.cs
@@ -0,0 +1,128 @@
+using System;
+using System.Drawing;
+using System.Security.Permissions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing {
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class ColorTranslatorFixture {
+ [Test]
+ public void FromHtml ()
+ {
+ Color [] colors = new Color [] {
+Color.Aqua, Color.Black, Color.Blue, Color.Fuchsia, Color.Gray,
+Color.Green, Color.Lime, Color.Maroon, Color.Navy, Color.Olive,
+Color.Purple, Color.Red, Color.Silver, Color.Teal, Color.White,
+Color.Yellow,
+
+SystemColors.ActiveBorder, SystemColors.ActiveCaption,
+SystemColors.Control,
+//SystemColors.ControlLightLight,
+SystemColors.ActiveCaptionText, SystemColors.GrayText,
+//SystemColors.InactiveBorder, SystemColors.InactiveCaption,
+SystemColors.InfoText, SystemColors.Menu,
+SystemColors.ControlDarkDark,
+//SystemColors.ControlText, SystemColors.ControlDark,
+SystemColors.Window,
+SystemColors.AppWorkspace, SystemColors.Desktop,
+//SystemColors.ControlDark,
+SystemColors.ControlText,
+SystemColors.Highlight, SystemColors.HighlightText,
+//SystemColors.InactiveCaptionText,
+SystemColors.Info,
+SystemColors.MenuText, SystemColors.ScrollBar,
+//SystemColors.ControlLight, SystemColors.ControlLightLight
+ };
+ string [] htmlColors = new string [] {
+"Aqua", "Black", "Blue", "Fuchsia", "Gray", "Green",
+"Lime", "Maroon", "Navy", "Olive", "Purple", "Red",
+"Silver", "Teal", "White", "Yellow",
+
+"activeborder", "activecaption", "buttonface",
+//"buhighlight",
+"captiontext", "graytext",
+//"iborder", "Icaption",
+"infotext", "menu", "threeddarkshadow",
+//"thrface", "Threedshadow",
+"window", "appworkspace",
+"background",
+//"bshadow",
+"buttontext", "highlight",
+"highlighttext",
+//"icaptiontext",
+"infobackground",
+"menutext", "scrollbar",
+//"thhighlight", "thlightshadow"
+ };
+
+ for (int i=0; i<colors.Length; i++)
+ Assert.AreEqual (colors[i], ColorTranslator.FromHtml (htmlColors [i]));
+ }
+
+ [Test]
+ public void FromOle ()
+ {
+ Assert.AreEqual (Color.FromArgb (0x10, 0x20, 0x30), ColorTranslator.FromOle (0x302010));
+ Assert.AreEqual (Color.FromArgb (0xbb, 0x20, 0x30), ColorTranslator.FromOle (unchecked ((int)0xee3020bb)));
+ }
+
+ [Test]
+ public void FromWin32 ()
+ {
+ Assert.AreEqual (Color.FromArgb (0x10, 0x20, 0x30), ColorTranslator.FromWin32 (0x302010));
+ Assert.AreEqual (Color.FromArgb (0xbb, 0x20, 0x30), ColorTranslator.FromWin32 (unchecked ((int)0xee3020bb)));
+ }
+
+ [Test]
+ public void ToHtml ()
+ {
+ string [] htmlColors = new string [] {
+"activeborder", "activecaption", "captiontext", "appworkspace", "buttonface",
+"buttonshadow", "threeddarkshadow", "buttonface", "buttonhighlight", "buttontext",
+"background", "graytext", "highlight", "highlighttext", "highlight", "inactiveborder",
+"inactivecaption", "inactivecaptiontext", "infobackground", "infotext", "menu",
+"menutext", "scrollbar", "window", "windowframe", "windowtext",
+
+"Transparent", "AliceBlue", "AntiqueWhite", "Aqua", "Aquamarine", "Azure", "Beige",
+"Bisque", "Black", "BlanchedAlmond", "Blue", "BlueViolet", "Brown", "BurlyWood",
+"CadetBlue", "Chartreuse", "Chocolate", "Coral", "CornflowerBlue", "Cornsilk",
+"Crimson", "Cyan", "DarkBlue", "DarkCyan", "DarkGoldenrod", "DarkGray", "DarkGreen",
+"DarkKhaki", "DarkMagenta", "DarkOliveGreen", "DarkOrange", "DarkOrchid", "DarkRed",
+"DarkSalmon", "DarkSeaGreen", "DarkSlateBlue", "DarkSlateGray", "DarkTurquoise", "DarkViolet",
+"DeepPink", "DeepSkyBlue", "DimGray", "DodgerBlue", "Firebrick", "FloralWhite", "ForestGreen",
+"Fuchsia", "Gainsboro", "GhostWhite", "Gold", "Goldenrod", "Gray", "Green", "GreenYellow",
+"Honeydew", "HotPink", "IndianRed", "Indigo", "Ivory", "Khaki", "Lavender", "LavenderBlush",
+"LawnGreen", "LemonChiffon", "LightBlue", "LightCoral", "LightCyan", "LightGoldenrodYellow",
+"LightGrey", "LightGreen", "LightPink", "LightSalmon", "LightSeaGreen", "LightSkyBlue",
+"LightSlateGray", "LightSteelBlue", "LightYellow", "Lime", "LimeGreen", "Linen", "Magenta",
+"Maroon", "MediumAquamarine", "MediumBlue", "MediumOrchid", "MediumPurple", "MediumSeaGreen",
+"MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise", "MediumVioletRed", "MidnightBlue",
+"MintCream", "MistyRose", "Moccasin", "NavajoWhite", "Navy", "OldLace", "Olive", "OliveDrab",
+"Orange", "OrangeRed", "Orchid", "PaleGoldenrod", "PaleGreen", "PaleTurquoise", "PaleVioletRed",
+"PapayaWhip", "PeachPuff", "Peru", "Pink", "Plum", "PowderBlue", "Purple", "Red", "RosyBrown",
+"RoyalBlue", "SaddleBrown", "Salmon", "SandyBrown", "SeaGreen", "SeaShell", "Sienna", "Silver",
+"SkyBlue", "SlateBlue", "SlateGray", "Snow", "SpringGreen", "SteelBlue", "Tan", "Teal",
+"Thistle", "Tomato", "Turquoise", "Violet", "Wheat", "White", "WhiteSmoke", "Yellow", "YellowGreen",
+ };
+
+ for (KnownColor i=KnownColor.ActiveBorder; i<=KnownColor.YellowGreen; i++)
+ Assert.AreEqual (htmlColors[(int)i-1], ColorTranslator.ToHtml (Color.FromKnownColor (i)));
+ }
+
+ [Test]
+ public void ToOle () {
+ Assert.AreEqual (0x302010, ColorTranslator.ToOle (Color.FromArgb (0x10, 0x20, 0x30)));
+ Assert.AreEqual (unchecked ((int)0x3020bb), ColorTranslator.ToOle (Color.FromArgb (0xee, 0xbb, 0x20, 0x30)));
+ }
+
+ [Test]
+ public void ToWin32 () {
+ Assert.AreEqual (0x302010, ColorTranslator.ToWin32 (Color.FromArgb (0x10, 0x20, 0x30)));
+ Assert.AreEqual (unchecked ((int)0x3020bb), ColorTranslator.ToWin32 (Color.FromArgb (0xee, 0xbb, 0x20, 0x30)));
+ }
+
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/GraphicsCas.cs b/mcs/class/System.Drawing/Test/System.Drawing/GraphicsCas.cs
new file mode 100644
index 00000000000..16a8679c2dd
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/GraphicsCas.cs
@@ -0,0 +1,150 @@
+//
+// GraphicsCas.cs - CAS unit tests for System.Drawing.Graphics
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Drawing;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing {
+
+ [TestFixture]
+ [Category ("CAS")]
+ public class GraphicsCas {
+
+ private MethodInfo fromHdcInternal;
+ private MethodInfo fromHwndInternal;
+ private MethodInfo releaseHdcInternal;
+ private Bitmap bitmap;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ fromHdcInternal = typeof (Graphics).GetMethod ("FromHdcInternal");
+ fromHwndInternal = typeof (Graphics).GetMethod ("FromHwndInternal");
+ releaseHdcInternal = typeof (Graphics).GetMethod ("ReleaseHdcInternal");
+ bitmap = new Bitmap (10, 10);
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ private Graphics GetGraphics ()
+ {
+ return Graphics.FromImage (bitmap);
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public void FromHdcInternal ()
+ {
+ try {
+ Graphics.FromHdcInternal (IntPtr.Zero);
+ }
+ catch (SecurityException) {
+ Assert.Fail ("SecurityException");
+ }
+ catch (Exception) {
+ }
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ [Category ("NotWorking")]
+ public void FromHwndInternal ()
+ {
+ try {
+ Graphics.FromHwndInternal (IntPtr.Zero);
+ }
+ catch (SecurityException) {
+ Assert.Fail ("SecurityException");
+ }
+ catch (Exception) {
+ }
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public void ReleaseHdcInternal ()
+ {
+ try {
+ Graphics g = GetGraphics ();
+ g.ReleaseHdcInternal (IntPtr.Zero);
+ }
+ catch (SecurityException) {
+ Assert.Fail ("SecurityException");
+ }
+ catch (Exception) {
+ }
+ }
+
+ // we use reflection to call Graphics as it's *Internal methods are
+ // protected by a LinkDemand (which will be converted into full demand,
+ // i.e. a stack walk) when reflection is used (i.e. it gets testable).
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void FromHdcInternal_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (fromHdcInternal, "FromHdcInternal");
+ fromHdcInternal.Invoke (null, new object[1] { IntPtr.Zero });
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void FromHwndInternal_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (fromHwndInternal, "FromHwndInternal");
+ fromHwndInternal.Invoke (null, new object[1] { IntPtr.Zero });
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void ReleaseHdcInternal_LinkDemand ()
+ {
+ // requires FullTrust, so denying anything break the requirements
+ Assert.IsNotNull (releaseHdcInternal, "ReleaseHdcInternal");
+ Graphics g = GetGraphics ();
+ releaseHdcInternal.Invoke (g, new object[1] { IntPtr.Zero });
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/README b/mcs/class/System.Drawing/Test/System.Drawing/README
new file mode 100644
index 00000000000..957903d11bb
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/README
@@ -0,0 +1,12 @@
+README
+
+* To run the tests using the Mono rutime
+
+cd mcs/class/System.Drawing
+make run-test
+
+* test-ms.sh runs the test using the MS .Net runtime and stores the bimaps
+created by tests in the directory called MsNet.
+
+
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/RegionCas.cs b/mcs/class/System.Drawing/Test/System.Drawing/RegionCas.cs
new file mode 100644
index 00000000000..9cd6acbd03e
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/RegionCas.cs
@@ -0,0 +1,97 @@
+//
+// GraphicsCas.cs - CAS unit tests for System.Drawing.Graphics
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Drawing;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.Drawing {
+
+ [TestFixture]
+ [Category ("CAS")]
+ public class RegionCas {
+
+ private MethodInfo fromHdcInternal;
+ private MethodInfo fromHwndInternal;
+ private MethodInfo releaseHdcInternal;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ // this executes at fulltrust
+ fromHdcInternal = typeof (Graphics).GetMethod ("FromHdcInternal");
+ fromHwndInternal = typeof (Graphics).GetMethod ("FromHwndInternal");
+ releaseHdcInternal = typeof (Graphics).GetMethod ("ReleaseHdcInternal");
+ }
+
+ [SetUp]
+ public void SetUp ()
+ {
+ if (!SecurityManager.SecurityEnabled)
+ Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void FromHrgn_Deny_UnmanagedCode ()
+ {
+ Region.FromHrgn (IntPtr.Zero);
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromHrgn_PermitOnly_UnmanagedCode ()
+ {
+ Region.FromHrgn (IntPtr.Zero);
+ }
+#if NET_2_0
+ [Test]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ [ExpectedException (typeof (SecurityException))]
+ public void ReleaseHrgn_Deny_UnmanagedCode ()
+ {
+ new Region ().ReleaseHrgn (IntPtr.Zero);
+ }
+
+ [Test]
+ [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void ReleaseHrgn_PermitOnly_UnmanagedCode ()
+ {
+ new Region ().ReleaseHrgn (IntPtr.Zero);
+ }
+#endif
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/RegionDataTest.cs b/mcs/class/System.Drawing/Test/System.Drawing/RegionDataTest.cs
new file mode 100755
index 00000000000..82e134936f7
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/RegionDataTest.cs
@@ -0,0 +1,101 @@
+//
+// System.Drawing.RegionData unit tests
+//
+// Authors:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
+using System.Security.Permissions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing {
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class RegionDataTest {
+
+ private Bitmap bitmap;
+ private Graphics graphic;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ bitmap = new Bitmap (10, 10);
+ graphic = Graphics.FromImage (bitmap);
+ }
+
+ [Test]
+ [ExpectedException (typeof (NullReferenceException))]
+ public void RegionData_Null ()
+ {
+ RegionData data = new Region ().GetRegionData ();
+ data.Data = null;
+ Assert.IsNull (data.Data, "Data");
+ Region region = new Region (data);
+ }
+
+ [Test]
+ public void RegionData_EmptyData ()
+ {
+ RegionData data = new Region ().GetRegionData ();
+ data.Data = new byte[0];
+ Assert.AreEqual (0, data.Data.Length, "Data");
+ try {
+ new Region (data);
+ }
+ catch (ExternalException) {
+ // MS
+ }
+ catch (ArgumentException) {
+ // Mono
+ }
+ }
+
+ [Test]
+ public void EmptyRegion ()
+ {
+ // note: an empty region is (for libgdiplus) a rectangular based region
+ Region empty = new Region ();
+ RegionData data = empty.GetRegionData ();
+ Assert.IsNotNull (data.Data, "Data");
+ Region region = new Region (data);
+ }
+
+ [Test]
+ public void PathRegion ()
+ {
+ GraphicsPath path = new GraphicsPath ();
+ path.AddCurve (new Point[2] { new Point (1, 1), new Point (2, 2) });
+ Region r = new Region (path);
+ RegionData data = r.GetRegionData ();
+ Assert.IsNotNull (data.Data, "Data");
+ Region region = new Region (data);
+ Assert.IsTrue (r.GetBounds (graphic).Equals (region.GetBounds (graphic)), "Bounds");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/RegionNonRectTest.cs b/mcs/class/System.Drawing/Test/System.Drawing/RegionNonRectTest.cs
new file mode 100644
index 00000000000..48ec18379db
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/RegionNonRectTest.cs
@@ -0,0 +1,160 @@
+//
+// System.Drawing.Region non-rectangular unit tests
+//
+// Authors:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Imaging;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Security.Permissions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing {
+
+ /* NOTE: General tests and rectangular region tests are located in TestRegion.cs */
+ /* Here we exclusively tests non-rectangular (GraphicsPath based) regions. */
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class RegionNonRectTest {
+
+ private Bitmap bitmap;
+ private Graphics graphic;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ bitmap = new Bitmap (10, 10);
+ graphic = Graphics.FromImage (bitmap);
+ }
+
+ // a region with an "empty ctor" graphic path is "empty" (i.e. not infinite)
+ private void CheckEmpty (string prefix, Region region)
+ {
+ Assert.IsTrue (region.IsEmpty (graphic), prefix + "IsEmpty");
+ Assert.IsFalse (region.IsInfinite (graphic), prefix + "graphic");
+
+ RectangleF rect = region.GetBounds (graphic);
+ Assert.AreEqual (0f, rect.X, prefix + "GetBounds.X");
+ Assert.AreEqual (0f, rect.Y, prefix + "GetBounds.Y");
+ Assert.AreEqual (0f, rect.Width, prefix + "GetBounds.Width");
+ Assert.AreEqual (0f, rect.Height, prefix + "GetBounds.Height");
+ }
+
+ [Test]
+ public void Region_Ctor_GraphicsPath_Empty ()
+ {
+ Region region = new Region (new GraphicsPath ());
+ CheckEmpty ("GraphicsPath.", region);
+
+ Region clone = region.Clone ();
+ CheckEmpty ("Clone.", region);
+ }
+
+ [Test]
+ [Category ("NotDotNet")] // MS.NET (atleast 2.0) throws an ExternalException in this case
+ public void Region_Ctor_RegionData ()
+ {
+ Region region = new Region (new GraphicsPath ());
+ RegionData data = region.GetRegionData ();
+ Region r2 = new Region (data);
+ CheckEmpty ("RegionData.", region);
+ }
+
+ [Test]
+ public void Region_Ctor_GraphicsPath ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ Region region = new Region (gp);
+ CheckEmpty ("GraphicsPath.", region);
+
+ Region clone = region.Clone ();
+ CheckEmpty ("Clone.", region);
+ }
+
+ private void CheckInfiniteBounds (GraphicsPath path)
+ {
+ RectangleF rect = path.GetBounds ();
+ Assert.AreEqual (-4194304f, rect.X, "Bounds.X");
+ Assert.AreEqual (-4194304f, rect.Y, "Bounds.Y");
+ Assert.AreEqual (8388608f, rect.Width, "Bounds.Width");
+ Assert.AreEqual (8388608f, rect.Height, "Bounds.Height");
+ }
+
+ [Test]
+ public void Region_Curve_IsInfinite ()
+ {
+ Point[] points = new Point[2] { new Point (-4194304, -4194304), new Point (4194304, 4194304) };
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddCurve (points);
+ CheckInfiniteBounds (gp);
+
+ Region region = new Region (gp);
+ Assert.IsFalse (region.IsInfinite (graphic), "IsInfinite");
+ // note: infinity isn't based on the bounds
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void Region_Polygon4_IsInfinite ()
+ {
+ Point[] points = new Point[4] { new Point (-4194304, -4194304), new Point (-4194304, 4194304), new Point (4194304, 4194304), new Point (4194304, -4194304) };
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPolygon (points);
+ CheckInfiniteBounds (gp);
+
+ Region region = new Region (gp);
+ Assert.IsTrue (region.IsInfinite (graphic), "IsInfinite");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void Region_Polygon5_IsInfinite ()
+ {
+ // overlap the first/last point
+ Point[] points = new Point[5] { new Point (-4194304, -4194304), new Point (-4194304, 4194304), new Point (4194304, 4194304), new Point (4194304, -4194304), new Point (-4194304, -4194304) };
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddPolygon (points);
+ CheckInfiniteBounds (gp);
+
+ Region region = new Region (gp);
+ Assert.IsTrue (region.IsInfinite (graphic), "IsInfinite");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void Region_Rectangle_IsInfinite ()
+ {
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (-4194304, -4194304, 8388608, 8388608));
+ CheckInfiniteBounds (gp);
+
+ Region region = new Region (gp);
+ Assert.IsTrue (region.IsInfinite (graphic), "IsInfinite");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestBitmap.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestBitmap.cs
new file mode 100644
index 00000000000..67d421ea7a2
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestBitmap.cs
@@ -0,0 +1,551 @@
+//
+// Bitmap class testing unit
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jmas@softcatala.org>
+// Jonathan Gilbert <logic@deltaq.org>
+//
+// (C) 2004 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestBitmap {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+ [Test]
+ public void TestPixels()
+ {
+ // Tests GetSetPixel/SetPixel
+ Bitmap bmp= new Bitmap(100,100, PixelFormat.Format32bppRgb);
+ bmp.SetPixel(0,0,Color.FromArgb(255,128,128,128));
+ Color color = bmp.GetPixel(0,0);
+
+ Assert.AreEqual (Color.FromArgb(255,128,128,128), color);
+
+ bmp.SetPixel(99,99,Color.FromArgb(255,255,0,155));
+ Color color2 = bmp.GetPixel(99,99);
+ Assert.AreEqual (Color.FromArgb(255,255,0,155), color2);
+ }
+
+ /* Get the output directory depending on the runtime and location*/
+ public static string getOutSubDir()
+ {
+ string sSub, sRslt;
+
+ if (Environment.GetEnvironmentVariable("MSNet")==null)
+ sSub = "mono/";
+ else
+ sSub = "MSNet/";
+
+ sRslt = Path.GetFullPath (sSub);
+
+ if (Directory.Exists(sRslt) == false)
+ sRslt = "Test/System.Drawing/" + sSub;
+
+ if (sRslt.Length > 0)
+ if (sRslt[sRslt.Length-1] != '\\' && sRslt[sRslt.Length-1] != '/')
+ sRslt += "/";
+
+ return sRslt;
+ }
+
+ /* Get the input directory depending on the runtime*/
+ public static string getInFile(string file)
+ {
+ string sRslt;
+
+ sRslt = Path.GetFullPath (file);
+
+ if (File.Exists(file)==false)
+ sRslt = "Test/System.Drawing/" + file;
+
+ return sRslt;
+ }
+
+ //[Test]
+ public void MakeTransparent()
+ {
+ string sInFile = getInFile("bitmaps/maketransparent.bmp");
+ string sOutFile = getOutSubDir() + "transparent.bmp";
+
+ Bitmap bmp = new Bitmap(sInFile);
+
+ bmp.MakeTransparent();
+ bmp.Save(sOutFile);
+
+ Color color = bmp.GetPixel(1,1);
+ Assert.AreEqual (Color.Black.R, color.R);
+ Assert.AreEqual (Color.Black.G, color.G);
+ Assert.AreEqual (Color.Black.B, color.B);
+ }
+
+ [Test]
+ public void Clone()
+ {
+ string sInFile = getInFile ("bitmaps/almogaver24bits.bmp");
+ string sOutFile = getOutSubDir() + "clone24.bmp";
+
+ Rectangle rect = new Rectangle(0,0,50,50);
+ Bitmap bmp = new Bitmap(sInFile);
+
+ Bitmap bmpNew = bmp.Clone (rect, PixelFormat.Format32bppArgb);
+
+ Color colororg0 = bmp.GetPixel(0,0);
+ Color colororg50 = bmp.GetPixel(49,49);
+ Color colornew0 = bmpNew.GetPixel(0,0);
+ Color colornew50 = bmpNew.GetPixel(49,49);
+
+ Assert.AreEqual (colororg0, colornew0);
+ Assert.AreEqual (colororg50, colornew50);
+ }
+
+ [Test]
+ public void CloneImage()
+ {
+ string sInFile = getInFile ("bitmaps/almogaver24bits.bmp");
+ Bitmap bmp = new Bitmap(sInFile);
+
+ Bitmap bmpNew = (Bitmap) bmp.Clone ();
+
+ Assert.AreEqual (bmp.Width, bmpNew.Width);
+ Assert.AreEqual (bmp.Height, bmpNew.Height);
+ Assert.AreEqual (bmp.PixelFormat, bmpNew.PixelFormat);
+
+ }
+
+ [Test]
+ public void Frames()
+ {
+ string sInFile = getInFile ("bitmaps/almogaver24bits.bmp");
+ Bitmap bmp = new Bitmap(sInFile);
+ int cnt = bmp.GetFrameCount(FrameDimension.Page);
+ int active = bmp.SelectActiveFrame (FrameDimension.Page, 0);
+
+ Assert.AreEqual (1, cnt);
+ Assert.AreEqual (0, active);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FileDoesNotExists ()
+ {
+ Bitmap bmp = new Bitmap ("FileDoesNotExists.jpg");
+ }
+
+ static string ByteArrayToString(byte[] arrInput)
+ {
+ int i;
+ StringBuilder sOutput = new StringBuilder(arrInput.Length);
+ for (i=0;i < arrInput.Length -1; i++)
+ {
+ sOutput.Append(arrInput[i].ToString("X2"));
+ }
+ return sOutput.ToString();
+ }
+
+
+ public string RotateBmp (Bitmap src, RotateFlipType rotate)
+ {
+ int witdh = 150, height = 150, index = 0;
+ byte[] pixels = new byte [witdh * height * 3];
+ Bitmap bmp_rotate;
+ byte[] hash;
+ Color clr;
+
+
+ bmp_rotate = src.Clone (new RectangleF (0,0, witdh, height), PixelFormat.Format32bppArgb);
+ bmp_rotate.RotateFlip (rotate);
+
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < witdh; x++) {
+ clr = bmp_rotate.GetPixel (x,y);
+ pixels[index++] = clr.R; pixels[index++] = clr.G; pixels[index++] = clr.B;
+ }
+ }
+
+ hash = new MD5CryptoServiceProvider().ComputeHash (pixels);
+ return ByteArrayToString (hash);
+ }
+
+ public string RotateIndexedBmp (Bitmap src, RotateFlipType type)
+ {
+ int pixels_per_byte;
+
+ switch (src.PixelFormat)
+ {
+ case PixelFormat.Format1bppIndexed: pixels_per_byte = 8; break;
+ case PixelFormat.Format4bppIndexed: pixels_per_byte = 2; break;
+ case PixelFormat.Format8bppIndexed: pixels_per_byte = 1; break;
+
+ default: throw new Exception("Cannot pass a bitmap of format " + src.PixelFormat + " to RotateIndexedBmp");
+ }
+
+ Bitmap test = src.Clone () as Bitmap;
+
+ test.RotateFlip (type);
+
+ BitmapData data = null;
+ byte[] pixel_data;
+
+ try
+ {
+ data = test.LockBits (new Rectangle (0, 0, test.Width, test.Height), ImageLockMode.ReadOnly, test.PixelFormat);
+
+ int scan_size = (data.Width + pixels_per_byte - 1) / pixels_per_byte;
+ pixel_data = new byte[data.Height * scan_size];
+
+ for (int y=0; y < data.Height; y++) {
+ IntPtr src_ptr = (IntPtr)(y * data.Stride + data.Scan0.ToInt64 ());
+ int dest_offset = y * scan_size;
+ for (int x=0; x < scan_size; x++)
+ pixel_data[dest_offset + x] = Marshal.ReadByte (src_ptr, x);
+ }
+ }
+ finally
+ {
+ if (test != null) {
+ if (data != null)
+ try { test.UnlockBits(data); } catch {}
+
+ try { test.Dispose(); } catch {}
+ }
+ }
+
+ if (pixel_data == null)
+ return "--ERROR--";
+
+ byte[] hash = new MD5CryptoServiceProvider().ComputeHash (pixel_data);
+ return ByteArrayToString (hash);
+ }
+
+
+ /*
+ Rotate bitmap in diffent ways, and check the result
+ pixels using MD5
+ */
+ [Test]
+ public void Rotate()
+ {
+ string sInFile = getInFile ("bitmaps/almogaver24bits.bmp");
+ Bitmap bmp = new Bitmap(sInFile);
+
+ Assert.AreEqual ("312958A3C67402E1299413794988A3", RotateBmp (bmp, RotateFlipType.Rotate90FlipNone));
+ Assert.AreEqual ("BF70D8DA4F1545AEDD77D0296B47AE", RotateBmp (bmp, RotateFlipType.Rotate180FlipNone));
+ Assert.AreEqual ("15AD2ADBDC7090C0EC744D0F7ACE2F", RotateBmp (bmp, RotateFlipType.Rotate270FlipNone));
+ Assert.AreEqual ("2E10FEC1F4FD64ECC51D7CE68AEB18", RotateBmp (bmp, RotateFlipType.RotateNoneFlipX));
+ Assert.AreEqual ("E63204779B566ED01162B90B49BD9E", RotateBmp (bmp, RotateFlipType.Rotate90FlipX));
+ Assert.AreEqual ("B1ECB17B5093E13D04FF55CFCF7763", RotateBmp (bmp, RotateFlipType.Rotate180FlipX));
+ Assert.AreEqual ("71A173882C16755D86F4BC26532374", RotateBmp (bmp, RotateFlipType.Rotate270FlipX));
+
+ }
+
+ /*
+ Rotate 1- and 4-bit bitmaps in different ways and check the
+ resulting pixels using MD5
+ */
+ [Test]
+ public void Rotate1bit4bit()
+ {
+ string[] files = {
+ getInFile ("bitmaps/1bit.png"),
+ getInFile ("bitmaps/4bit.png")
+ };
+
+ StringBuilder md5s = new StringBuilder();
+
+ foreach (string file in files)
+ using (Bitmap bmp = new Bitmap(file))
+ foreach (RotateFlipType type in Enum.GetValues (typeof(RotateFlipType)))
+ md5s.Append (RotateIndexedBmp (bmp, type));
+
+ using (StreamWriter writer = new StreamWriter("/tmp/md5s.txt"))
+ writer.WriteLine(md5s);
+
+ Assert.AreEqual (
+ "A4DAF507C92BDE10626BC7B34FEFE5" + // 1-bit RotateNoneFlipNone
+ "A4DAF507C92BDE10626BC7B34FEFE5" + // 1-bit Rotate180FlipXY
+ "C0975EAFD2FC1CC9CC7AF20B92FC9F" + // 1-bit Rotate90FlipNone
+ "C0975EAFD2FC1CC9CC7AF20B92FC9F" + // 1-bit Rotate270FlipXY
+ "64AE60858A02228F7B1B18C7812FB6" + // 1-bit Rotate180FlipNone
+ "64AE60858A02228F7B1B18C7812FB6" + // 1-bit RotateNoneFlipXY
+ "E96D3390938350F9DE2608C4364424" + // 1-bit Rotate270FlipNone
+ "E96D3390938350F9DE2608C4364424" + // 1-bit Rotate90FlipXY
+ "23947CE822C1DDE6BEA69C01F8D0D9" + // 1-bit RotateNoneFlipX
+ "23947CE822C1DDE6BEA69C01F8D0D9" + // 1-bit Rotate180FlipY
+ "BE45F685BDEBD7079AA1B2CBA46723" + // 1-bit Rotate90FlipX
+ "BE45F685BDEBD7079AA1B2CBA46723" + // 1-bit Rotate270FlipY
+ "353E937CFF31B1BF6C3DD0A031ACB5" + // 1-bit Rotate180FlipX
+ "353E937CFF31B1BF6C3DD0A031ACB5" + // 1-bit RotateNoneFlipY
+ "AEA18A770A845E25B6A8CE28DD6DCB" + // 1-bit Rotate270FlipX
+ "AEA18A770A845E25B6A8CE28DD6DCB" + // 1-bit Rotate90FlipY
+ "3CC874B571902366AACED5D619E87D" + // 4-bit RotateNoneFlipNone
+ "3CC874B571902366AACED5D619E87D" + // 4-bit Rotate180FlipXY
+ "8DE25C7E1BE4A3B535DB5D83198D83" + // 4-bit Rotate90FlipNone
+ "8DE25C7E1BE4A3B535DB5D83198D83" + // 4-bit Rotate270FlipXY
+ "27CF5E9CE70BE9EBC47FB996721B95" + // 4-bit Rotate180FlipNone
+ "27CF5E9CE70BE9EBC47FB996721B95" + // 4-bit RotateNoneFlipXY
+ "A919CCB8F97CAD7DC1F01026D11A5D" + // 4-bit Rotate270FlipNone
+ "A919CCB8F97CAD7DC1F01026D11A5D" + // 4-bit Rotate90FlipXY
+ "545876C99ACF833E69FBFFBF436034" + // 4-bit RotateNoneFlipX
+ "545876C99ACF833E69FBFFBF436034" + // 4-bit Rotate180FlipY
+ "5DB56687757CDEFC52D89C77CA9223" + // 4-bit Rotate90FlipX
+ "5DB56687757CDEFC52D89C77CA9223" + // 4-bit Rotate270FlipY
+ "05A77EDDCDF20D5B0AC0169E95D7D7" + // 4-bit Rotate180FlipX
+ "05A77EDDCDF20D5B0AC0169E95D7D7" + // 4-bit RotateNoneFlipY
+ "B6B6245796C836923ABAABDF368B29" + // 4-bit Rotate270FlipX
+ "B6B6245796C836923ABAABDF368B29", // 4-bit Rotate90FlipY
+ md5s.ToString ());
+ }
+
+ public void LockBmp (PixelFormat fmt, PixelFormat fmtlock, string output,
+ int lwidth , int lheight, ref string hash1, ref string hash2)
+ {
+ int width = 100, height = 100, bbps, cur, pos;
+ Bitmap bmp = new Bitmap (width, height, fmt);
+ Graphics gr = Graphics.FromImage (bmp);
+ byte[] hash;
+ Color clr;
+ byte[] btv = new byte[1];
+ int y, x, len = width * height * 4, index = 0;
+ byte[] pixels = new byte [len];
+ hash1 = hash2 ="";
+
+ bbps = Image.GetPixelFormatSize (fmt);
+
+ Pen p = new Pen (Color.FromArgb (255, 100, 200, 250), 2);
+ gr.DrawRectangle(p, 1.0F, 1.0F, 80.0F, 80.0F);
+
+ BitmapData bd = bmp.LockBits (new Rectangle (0, 0, lwidth, lheight), ImageLockMode.ReadOnly, fmtlock);
+
+ pos = bd.Scan0.ToInt32();
+ for (y = 0; y < bd.Height; y++) {
+ for (x = 0; x < bd.Width; x++) {
+
+ /* Read the pixels*/
+ for (int bt =0; bt < bbps/8; bt++, index++) {
+ cur = pos;
+ cur+= y * bd.Stride;
+ cur+= x * bbps/8;
+ cur+= bt;
+ Marshal.Copy ((IntPtr)cur, btv, 0, 1);
+ pixels[index] = btv[0];
+
+ /* Make change of all the colours = 250 to 10*/
+ if (btv[0] == 250) {
+ btv[0] = 10;
+ Marshal.Copy (btv, 0, (IntPtr)cur, 1);
+ }
+ }
+ }
+ }
+
+ for (int i = index; i < len; i++)
+ pixels[index] = 0;
+
+ hash = new MD5CryptoServiceProvider().ComputeHash (pixels);
+ bmp.UnlockBits (bd);
+
+ hash1 = ByteArrayToString (hash);
+
+ /* MD5 of the changed bitmap*/
+ for (y = 0, index = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ clr = bmp.GetPixel (x,y);
+ pixels[index++] = clr.R; pixels[index++] = clr.G; pixels[index++] = clr.B;
+ }
+ }
+
+ hash = new MD5CryptoServiceProvider().ComputeHash (pixels);
+ hash2 = ByteArrayToString (hash);
+
+ /*bmp.Save (output, ImageFormat.Bmp);*/
+ }
+ /*
+ Tests the LockBitmap functions. Makes a hash of the block of pixels that it returns
+ firsts, changes them, and then using GetPixel does another check of the changes.
+ The results match the .Net framework
+ */
+ //[Test]
+ public void LockBitmap ()
+ {
+ string hash = "";
+ string hashchg = "";
+
+ /* Locks the whole bitmap*/
+ LockBmp (PixelFormat.Format32bppArgb, PixelFormat.Format32bppArgb, "output32bppArgb.bmp", 100, 100, ref hash, ref hashchg);
+ Assert.AreEqual ("AF5BFD4E98D6708FF4C9982CC9C68F", hash);
+ Assert.AreEqual ("BBEE27DC85563CB58EE11E8951230F", hashchg);
+
+ LockBmp (PixelFormat.Format32bppPArgb, PixelFormat.Format32bppPArgb, "output32bppPArgb.bmp", 100, 100, ref hash, ref hashchg);
+ Assert.AreEqual ("AF5BFD4E98D6708FF4C9982CC9C68F", hash);
+ Assert.AreEqual ("BBEE27DC85563CB58EE11E8951230F", hashchg);
+
+ LockBmp (PixelFormat.Format32bppRgb, PixelFormat.Format32bppRgb, "output32bppRgb.bmp", 100, 100, ref hash, ref hashchg);
+ Assert.AreEqual ("AF5BFD4E98D6708FF4C9982CC9C68F", hash);
+ Assert.AreEqual ("BBEE27DC85563CB58EE11E8951230F", hashchg);
+
+ LockBmp (PixelFormat.Format24bppRgb, PixelFormat.Format24bppRgb, "output24bppRgb.bmp", 100, 100, ref hash, ref hashchg);
+ Assert.AreEqual ("A8A071D0B3A3743905B4E193A62769", hash);
+ Assert.AreEqual ("EEE846FA8F892339C64082DFF775CF", hashchg);
+
+ /* Locks a portion of the bitmap*/
+ LockBmp (PixelFormat.Format32bppArgb, PixelFormat.Format32bppArgb, "output32bppArgb.bmp", 50, 50, ref hash, ref hashchg);
+ Assert.AreEqual ("C361FBFD82A4F3C278605AE9EC5385", hash);
+ Assert.AreEqual ("8C2C04B361E1D5875EE8ACF5073F4E", hashchg);
+
+ LockBmp (PixelFormat.Format32bppPArgb, PixelFormat.Format32bppPArgb, "output32bppPArgb.bmp", 50, 50, ref hash, ref hashchg);
+ Assert.AreEqual ("C361FBFD82A4F3C278605AE9EC5385", hash);
+ Assert.AreEqual ("8C2C04B361E1D5875EE8ACF5073F4E", hashchg);
+
+ LockBmp (PixelFormat.Format32bppRgb, PixelFormat.Format32bppRgb, "output32bppRgb.bmp", 50, 50, ref hash, ref hashchg);
+ Assert.AreEqual ("C361FBFD82A4F3C278605AE9EC5385", hash);
+ Assert.AreEqual ("8C2C04B361E1D5875EE8ACF5073F4E", hashchg);
+
+ LockBmp (PixelFormat.Format24bppRgb, PixelFormat.Format24bppRgb, "output24bppRgb.bmp", 50, 50, ref hash, ref hashchg);
+ Assert.AreEqual ("FFE86628478591D1A1EB30E894C34F", hash);
+ Assert.AreEqual ("8C2C04B361E1D5875EE8ACF5073F4E", hashchg);
+
+ }
+
+ /*
+ Tests the LockBitmap and UnlockBitmap functions, specifically the copying
+ of bitmap data in the directions indicated by the ImageLockMode.
+ */
+ [Test]
+ public void LockUnlockBitmap()
+ {
+ BitmapData data;
+ int pixel_value;
+ Color pixel_colour;
+
+ Color red = Color.FromArgb (Color.Red.A, Color.Red.R, Color.Red.G, Color.Red.B);
+ Color blue = Color.FromArgb (Color.Blue.A, Color.Blue.R, Color.Blue.G, Color.Blue.B);
+
+ using (Bitmap bmp = new Bitmap (1, 1, PixelFormat.Format24bppRgb))
+ {
+ bmp.SetPixel (0, 0, red);
+
+ data = bmp.LockBits (new Rectangle (0, 0, 1, 1), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
+ pixel_value = Marshal.ReadInt32 (data.Scan0);
+ pixel_colour = Color.FromArgb (pixel_value);
+
+ // Disregard alpha information in the test
+ pixel_colour = Color.FromArgb(red.A, pixel_colour.R, pixel_colour.G, pixel_colour.B);
+
+ Assert.AreEqual (red, pixel_colour);
+
+ Marshal.WriteInt32 (data.Scan0, blue.ToArgb ());
+
+ bmp.UnlockBits (data);
+
+ pixel_colour = bmp.GetPixel (0, 0);
+
+ // Disregard alpha information in the test
+ pixel_colour = Color.FromArgb(red.A, pixel_colour.R, pixel_colour.G, pixel_colour.B);
+
+ Assert.AreEqual (red, pixel_colour);
+
+ data = bmp.LockBits (new Rectangle (0, 0, 1, 1), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
+
+ Marshal.WriteInt32 (data.Scan0, blue.ToArgb ());
+
+ bmp.UnlockBits (data);
+
+ pixel_colour = bmp.GetPixel (0, 0);
+
+ // Disregard alpha information in the test
+ pixel_colour = Color.FromArgb(blue.A, pixel_colour.R, pixel_colour.G, pixel_colour.B);
+
+ Assert.AreEqual (blue, pixel_colour);
+ }
+
+ using (Bitmap bmp = new Bitmap(1, 1, PixelFormat.Format32bppArgb))
+ {
+ bmp.SetPixel (0, 0, red);
+
+ data = bmp.LockBits (new Rectangle (0, 0, 1, 1), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
+
+ int r, g, b;
+
+ b = Marshal.ReadByte (data.Scan0, 0);
+ g = Marshal.ReadByte (data.Scan0, 1);
+ r = Marshal.ReadByte (data.Scan0, 2);
+ pixel_colour = Color.FromArgb (red.A, r, g, b);
+
+ Assert.AreEqual (red, pixel_colour);
+
+ Marshal.WriteByte (data.Scan0, 0, blue.B);
+ Marshal.WriteByte (data.Scan0, 1, blue.G);
+ Marshal.WriteByte (data.Scan0, 2, blue.R);
+
+ bmp.UnlockBits (data);
+
+ pixel_colour = bmp.GetPixel (0, 0);
+
+ // Disregard alpha information in the test
+ pixel_colour = Color.FromArgb(red.A, pixel_colour.R, pixel_colour.G, pixel_colour.B);
+
+ Assert.AreEqual (red, bmp.GetPixel (0, 0));
+
+ data = bmp.LockBits (new Rectangle (0, 0, 1, 1), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
+
+ Marshal.WriteByte (data.Scan0, 0, blue.B);
+ Marshal.WriteByte (data.Scan0, 1, blue.G);
+ Marshal.WriteByte (data.Scan0, 2, blue.R);
+
+ bmp.UnlockBits(data);
+
+ pixel_colour = bmp.GetPixel (0, 0);
+
+ // Disregard alpha information in the test
+ pixel_colour = Color.FromArgb(blue.A, pixel_colour.R, pixel_colour.G, pixel_colour.B);
+
+ Assert.AreEqual (blue, bmp.GetPixel (0, 0));
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestBrushes.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestBrushes.cs
new file mode 100644
index 00000000000..d1bad184fa0
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestBrushes.cs
@@ -0,0 +1,1074 @@
+// Tests for System.Drawing.Brushes.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class BrushesTest : Assertion
+ {
+ [SetUp]
+ public void SetUp () { }
+
+ [TearDown]
+ public void TearDown () { }
+
+ [Test]
+ public void TestEquals ()
+ {
+ Brush brush1 = Brushes.Blue;
+ Brush brush2 = Brushes.Blue;
+
+ AssertEquals ("Equals", true, brush1.Equals (brush2));
+ }
+
+ [Test]
+ public void TestProperties ()
+ {
+ Brush br;
+ SolidBrush solid;
+
+ br = Brushes.AliceBlue;
+ Assert ("P1#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P1#2", solid.Color, Color.AliceBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P1#3", solid.Color, Color.Red);
+
+ br = Brushes.AntiqueWhite;
+ Assert ("P2#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P2#2", solid.Color, Color.AntiqueWhite);
+ solid.Color = Color.Red;
+ AssertEquals ("P2#3", solid.Color, Color.Red);
+
+ br = Brushes.Aqua;
+ Assert ("P3#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P3#2", solid.Color, Color.Aqua);
+ solid.Color = Color.Red;
+ AssertEquals ("P3#3", solid.Color, Color.Red);
+
+ br = Brushes.Aquamarine;
+ Assert ("P4#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P4#2", solid.Color, Color.Aquamarine);
+ solid.Color = Color.Red;
+ AssertEquals ("P4#3", solid.Color, Color.Red);
+
+ br = Brushes.Azure;
+ Assert ("P5#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P5#2", solid.Color, Color.Azure);
+ solid.Color = Color.Red;
+ AssertEquals ("P5#3", solid.Color, Color.Red);
+
+ br = Brushes.Beige;
+ Assert ("P6#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P6#2", solid.Color, Color.Beige);
+ solid.Color = Color.Red;
+ AssertEquals ("P6#3", solid.Color, Color.Red);
+
+ br = Brushes.Bisque;
+ Assert ("P7#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P7#2", solid.Color, Color.Bisque);
+ solid.Color = Color.Red;
+ AssertEquals ("P7#3", solid.Color, Color.Red);
+
+ br = Brushes.Black;
+ Assert ("P8#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P8#2", solid.Color, Color.Black);
+ solid.Color = Color.Red;
+ AssertEquals ("P8#3", solid.Color, Color.Red);
+
+ br = Brushes.BlanchedAlmond;
+ Assert ("P9#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P9#2", solid.Color, Color.BlanchedAlmond);
+ solid.Color = Color.Red;
+ AssertEquals ("P9#3", solid.Color, Color.Red);
+
+ br = Brushes.Blue;
+ Assert ("P10#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P10#2", solid.Color, Color.Blue);
+ solid.Color = Color.Red;
+ AssertEquals ("P10#3", solid.Color, Color.Red);
+
+ br = Brushes.BlueViolet;
+ Assert ("P11#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P11#2", solid.Color, Color.BlueViolet);
+ solid.Color = Color.Red;
+ AssertEquals ("P11#3", solid.Color, Color.Red);
+
+ br = Brushes.Brown;
+ Assert ("P12#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P12#2", solid.Color, Color.Brown);
+ solid.Color = Color.Red;
+ AssertEquals ("P12#3", solid.Color, Color.Red);
+
+ br = Brushes.BurlyWood;
+ Assert ("P13#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P13#2", solid.Color, Color.BurlyWood);
+ solid.Color = Color.Red;
+ AssertEquals ("P13#3", solid.Color, Color.Red);
+
+ br = Brushes.CadetBlue;
+ Assert ("P14#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P14#2", solid.Color, Color.CadetBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P14#3", solid.Color, Color.Red);
+
+ br = Brushes.Chartreuse;
+ Assert ("P15#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P15#2", solid.Color, Color.Chartreuse);
+ solid.Color = Color.Red;
+ AssertEquals ("P15#3", solid.Color, Color.Red);
+
+ br = Brushes.Chocolate;
+ Assert ("P16#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P16#2", solid.Color, Color.Chocolate);
+ solid.Color = Color.Red;
+ AssertEquals ("P16#3", solid.Color, Color.Red);
+
+ br = Brushes.Coral;
+ Assert ("P17#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P17#2", solid.Color, Color.Coral);
+ solid.Color = Color.Red;
+ AssertEquals ("P17#3", solid.Color, Color.Red);
+
+ br = Brushes.CornflowerBlue;
+ Assert ("P18#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P18#2", solid.Color, Color.CornflowerBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P18#3", solid.Color, Color.Red);
+
+ br = Brushes.Cornsilk;
+ Assert ("P19#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P19#2", solid.Color, Color.Cornsilk);
+ solid.Color = Color.Red;
+ AssertEquals ("P19#3", solid.Color, Color.Red);
+
+ br = Brushes.Crimson;
+ Assert ("P20#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P20#2", solid.Color, Color.Crimson);
+ solid.Color = Color.Red;
+ AssertEquals ("P20#3", solid.Color, Color.Red);
+
+ br = Brushes.Cyan;
+ Assert ("P21#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P21#2", solid.Color, Color.Cyan);
+ solid.Color = Color.Red;
+ AssertEquals ("P21#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkBlue;
+ Assert ("P22#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P22#2", solid.Color, Color.DarkBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P22#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkCyan;
+ Assert ("P23#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P23#2", solid.Color, Color.DarkCyan);
+ solid.Color = Color.Red;
+ AssertEquals ("P23#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkGoldenrod;
+ Assert ("P24#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P24#2", solid.Color, Color.DarkGoldenrod);
+ solid.Color = Color.Red;
+ AssertEquals ("P24#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkGray;
+ Assert ("P25#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P25#2", solid.Color, Color.DarkGray);
+ solid.Color = Color.Red;
+ AssertEquals ("P25#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkGreen;
+ Assert ("P26#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P26#2", solid.Color, Color.DarkGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P26#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkKhaki;
+ Assert ("P27#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P27#2", solid.Color, Color.DarkKhaki);
+ solid.Color = Color.Red;
+ AssertEquals ("P27#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkMagenta;
+ Assert ("P28#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P28#2", solid.Color, Color.DarkMagenta);
+ solid.Color = Color.Red;
+ AssertEquals ("P28#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkOliveGreen;
+ Assert ("P29#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P29#2", solid.Color, Color.DarkOliveGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P29#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkOrange;
+ Assert ("P30#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P30#2", solid.Color, Color.DarkOrange);
+ solid.Color = Color.Red;
+ AssertEquals ("P30#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkOrchid;
+ Assert ("P31#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P31#2", solid.Color, Color.DarkOrchid);
+ solid.Color = Color.Red;
+ AssertEquals ("P31#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkRed;
+ Assert ("P32#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P32#2", solid.Color, Color.DarkRed);
+ solid.Color = Color.Red;
+ AssertEquals ("P32#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkSalmon;
+ Assert ("P33#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P33#2", solid.Color, Color.DarkSalmon);
+ solid.Color = Color.Red;
+ AssertEquals ("P33#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkSeaGreen;
+ Assert ("P34#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P34#2", solid.Color, Color.DarkSeaGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P34#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkSlateBlue;
+ Assert ("P35#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P35#2", solid.Color, Color.DarkSlateBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P35#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkSlateGray;
+ Assert ("P36#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P36#2", solid.Color, Color.DarkSlateGray);
+ solid.Color = Color.Red;
+ AssertEquals ("P36#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkTurquoise;
+ Assert ("P37#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P37#2", solid.Color, Color.DarkTurquoise);
+ solid.Color = Color.Red;
+ AssertEquals ("P37#3", solid.Color, Color.Red);
+
+ br = Brushes.DarkViolet;
+ Assert ("P38#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P38#2", solid.Color, Color.DarkViolet);
+ solid.Color = Color.Red;
+ AssertEquals ("P38#3", solid.Color, Color.Red);
+
+ br = Brushes.DeepPink;
+ Assert ("P39#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P39#2", solid.Color, Color.DeepPink);
+ solid.Color = Color.Red;
+ AssertEquals ("P39#3", solid.Color, Color.Red);
+
+ br = Brushes.DeepSkyBlue;
+ Assert ("P40#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P40#2", solid.Color, Color.DeepSkyBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P40#3", solid.Color, Color.Red);
+
+ br = Brushes.DimGray;
+ Assert ("P41#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P41#2", solid.Color, Color.DimGray);
+ solid.Color = Color.Red;
+ AssertEquals ("P41#3", solid.Color, Color.Red);
+
+ br = Brushes.DodgerBlue;
+ Assert ("P42#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P42#2", solid.Color, Color.DodgerBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P42#3", solid.Color, Color.Red);
+
+ br = Brushes.Firebrick;
+ Assert ("P43#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P43#2", solid.Color, Color.Firebrick);
+ solid.Color = Color.Red;
+ AssertEquals ("P43#3", solid.Color, Color.Red);
+
+ br = Brushes.FloralWhite;
+ Assert ("P44#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P44#2", solid.Color, Color.FloralWhite);
+ solid.Color = Color.Red;
+ AssertEquals ("P44#3", solid.Color, Color.Red);
+
+ br = Brushes.ForestGreen;
+ Assert ("P45#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P45#2", solid.Color, Color.ForestGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P45#3", solid.Color, Color.Red);
+
+ br = Brushes.Fuchsia;
+ Assert ("P46#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P46#2", solid.Color, Color.Fuchsia);
+ solid.Color = Color.Red;
+ AssertEquals ("P46#3", solid.Color, Color.Red);
+
+ br = Brushes.Gainsboro;
+ Assert ("P47#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P47#2", solid.Color, Color.Gainsboro);
+ solid.Color = Color.Red;
+ AssertEquals ("P47#3", solid.Color, Color.Red);
+
+ br = Brushes.GhostWhite;
+ Assert ("P48#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P48#2", solid.Color, Color.GhostWhite);
+ solid.Color = Color.Red;
+ AssertEquals ("P48#3", solid.Color, Color.Red);
+
+ br = Brushes.Gold;
+ Assert ("P49#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P49#2", solid.Color, Color.Gold);
+ solid.Color = Color.Red;
+ AssertEquals ("P49#3", solid.Color, Color.Red);
+
+ br = Brushes.Goldenrod;
+ Assert ("P50#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P50#2", solid.Color, Color.Goldenrod);
+ solid.Color = Color.Red;
+ AssertEquals ("P50#3", solid.Color, Color.Red);
+
+ br = Brushes.Gray;
+ Assert ("P51#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P51#2", solid.Color, Color.Gray);
+ solid.Color = Color.Red;
+ AssertEquals ("P51#3", solid.Color, Color.Red);
+
+ br = Brushes.Green;
+ Assert ("P52#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P52#2", solid.Color, Color.Green);
+ solid.Color = Color.Red;
+ AssertEquals ("P52#3", solid.Color, Color.Red);
+
+ br = Brushes.GreenYellow;
+ Assert ("P53#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P53#2", solid.Color, Color.GreenYellow);
+ solid.Color = Color.Red;
+ AssertEquals ("P53#3", solid.Color, Color.Red);
+
+ br = Brushes.Honeydew;
+ Assert ("P54#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P54#2", solid.Color, Color.Honeydew);
+ solid.Color = Color.Red;
+ AssertEquals ("P54#3", solid.Color, Color.Red);
+
+ br = Brushes.HotPink;
+ Assert ("P55#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P55#2", solid.Color, Color.HotPink);
+ solid.Color = Color.Red;
+ AssertEquals ("P55#3", solid.Color, Color.Red);
+
+ br = Brushes.IndianRed;
+ Assert ("P56#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P56#2", solid.Color, Color.IndianRed);
+ solid.Color = Color.Red;
+ AssertEquals ("P56#3", solid.Color, Color.Red);
+
+ br = Brushes.Indigo;
+ Assert ("P57#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P57#2", solid.Color, Color.Indigo);
+ solid.Color = Color.Red;
+ AssertEquals ("P57#3", solid.Color, Color.Red);
+
+ br = Brushes.Ivory;
+ Assert ("P58#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P58#2", solid.Color, Color.Ivory);
+ solid.Color = Color.Red;
+ AssertEquals ("P58#3", solid.Color, Color.Red);
+
+ br = Brushes.Khaki;
+ Assert ("P59#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P59#2", solid.Color, Color.Khaki);
+ solid.Color = Color.Red;
+ AssertEquals ("P59#3", solid.Color, Color.Red);
+
+ br = Brushes.Lavender;
+ Assert ("P60#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P60#2", solid.Color, Color.Lavender);
+ solid.Color = Color.Red;
+ AssertEquals ("P60#3", solid.Color, Color.Red);
+
+ br = Brushes.LavenderBlush;
+ Assert ("P61#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P61#2", solid.Color, Color.LavenderBlush);
+ solid.Color = Color.Red;
+ AssertEquals ("P61#3", solid.Color, Color.Red);
+
+ br = Brushes.LawnGreen;
+ Assert ("P62#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P62#2", solid.Color, Color.LawnGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P62#3", solid.Color, Color.Red);
+
+ br = Brushes.LemonChiffon;
+ Assert ("P63#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P63#2", solid.Color, Color.LemonChiffon);
+ solid.Color = Color.Red;
+ AssertEquals ("P63#3", solid.Color, Color.Red);
+
+ br = Brushes.LightBlue;
+ Assert ("P64#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P64#2", solid.Color, Color.LightBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P64#3", solid.Color, Color.Red);
+
+ br = Brushes.LightCoral;
+ Assert ("P65#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P65#2", solid.Color, Color.LightCoral);
+ solid.Color = Color.Red;
+ AssertEquals ("P65#3", solid.Color, Color.Red);
+
+ br = Brushes.LightCyan;
+ Assert ("P66#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P66#2", solid.Color, Color.LightCyan);
+ solid.Color = Color.Red;
+ AssertEquals ("P66#3", solid.Color, Color.Red);
+
+ br = Brushes.LightGoldenrodYellow;
+ Assert ("P67#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P67#2", solid.Color, Color.LightGoldenrodYellow);
+ solid.Color = Color.Red;
+ AssertEquals ("P67#3", solid.Color, Color.Red);
+
+ br = Brushes.LightGray;
+ Assert ("P68#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P68#2", solid.Color, Color.LightGray);
+ solid.Color = Color.Red;
+ AssertEquals ("P68#3", solid.Color, Color.Red);
+
+ br = Brushes.LightGreen;
+ Assert ("P69#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P69#2", solid.Color, Color.LightGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P69#3", solid.Color, Color.Red);
+
+ br = Brushes.LightPink;
+ Assert ("P70#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P70#2", solid.Color, Color.LightPink);
+ solid.Color = Color.Red;
+ AssertEquals ("P70#3", solid.Color, Color.Red);
+
+ br = Brushes.LightSalmon;
+ Assert ("P71#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P71#2", solid.Color, Color.LightSalmon);
+ solid.Color = Color.Red;
+ AssertEquals ("P71#3", solid.Color, Color.Red);
+
+ br = Brushes.LightSeaGreen;
+ Assert ("P72#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P72#2", solid.Color, Color.LightSeaGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P72#3", solid.Color, Color.Red);
+
+ br = Brushes.LightSkyBlue;
+ Assert ("P73#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P73#2", solid.Color, Color.LightSkyBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P73#3", solid.Color, Color.Red);
+
+ br = Brushes.LightSlateGray;
+ Assert ("P74#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P74#2", solid.Color, Color.LightSlateGray);
+ solid.Color = Color.Red;
+ AssertEquals ("P74#3", solid.Color, Color.Red);
+
+ br = Brushes.LightSteelBlue;
+ Assert ("P75#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P75#2", solid.Color, Color.LightSteelBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P75#3", solid.Color, Color.Red);
+
+ br = Brushes.LightYellow;
+ Assert ("P76#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P76#2", solid.Color, Color.LightYellow);
+ solid.Color = Color.Red;
+ AssertEquals ("P76#3", solid.Color, Color.Red);
+
+ br = Brushes.Lime;
+ Assert ("P77#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P77#2", solid.Color, Color.Lime);
+ solid.Color = Color.Red;
+ AssertEquals ("P77#3", solid.Color, Color.Red);
+
+ br = Brushes.LimeGreen;
+ Assert ("P78#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P78#2", solid.Color, Color.LimeGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P78#3", solid.Color, Color.Red);
+
+ br = Brushes.Linen;
+ Assert ("P79#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P79#2", solid.Color, Color.Linen);
+ solid.Color = Color.Red;
+ AssertEquals ("P79#3", solid.Color, Color.Red);
+
+ br = Brushes.Magenta;
+ Assert ("P80#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P80#2", solid.Color, Color.Magenta);
+ solid.Color = Color.Red;
+ AssertEquals ("P80#3", solid.Color, Color.Red);
+
+ br = Brushes.Maroon;
+ Assert ("P81#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P81#2", solid.Color, Color.Maroon);
+ solid.Color = Color.Red;
+ AssertEquals ("P81#3", solid.Color, Color.Red);
+
+ br = Brushes.MediumAquamarine;
+ Assert ("P82#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P82#2", solid.Color, Color.MediumAquamarine);
+ solid.Color = Color.Red;
+ AssertEquals ("P82#3", solid.Color, Color.Red);
+
+ br = Brushes.MediumBlue;
+ Assert ("P83#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P83#2", solid.Color, Color.MediumBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P83#3", solid.Color, Color.Red);
+
+ br = Brushes.MediumOrchid;
+ Assert ("P84#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P84#2", solid.Color, Color.MediumOrchid);
+ solid.Color = Color.Red;
+ AssertEquals ("P84#3", solid.Color, Color.Red);
+
+ br = Brushes.MediumPurple;
+ Assert ("P85#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P85#2", solid.Color, Color.MediumPurple);
+ solid.Color = Color.Red;
+ AssertEquals ("P85#3", solid.Color, Color.Red);
+
+ br = Brushes.MediumSeaGreen;
+ Assert ("P86#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P86#2", solid.Color, Color.MediumSeaGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P86#3", solid.Color, Color.Red);
+
+ br = Brushes.MediumSlateBlue;
+ Assert ("P87#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P87#2", solid.Color, Color.MediumSlateBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P87#3", solid.Color, Color.Red);
+
+ br = Brushes.MediumSpringGreen;
+ Assert ("P88#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P88#2", solid.Color, Color.MediumSpringGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P88#3", solid.Color, Color.Red);
+
+ br = Brushes.MediumTurquoise;
+ Assert ("P89#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P89#2", solid.Color, Color.MediumTurquoise);
+ solid.Color = Color.Red;
+ AssertEquals ("P89#3", solid.Color, Color.Red);
+
+ br = Brushes.MediumVioletRed;
+ Assert ("P90#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P90#2", solid.Color, Color.MediumVioletRed);
+ solid.Color = Color.Red;
+ AssertEquals ("P90#3", solid.Color, Color.Red);
+
+ br = Brushes.MidnightBlue;
+ Assert ("P91#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P91#2", solid.Color, Color.MidnightBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P91#3", solid.Color, Color.Red);
+
+ br = Brushes.MintCream;
+ Assert ("P92#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P92#2", solid.Color, Color.MintCream);
+ solid.Color = Color.Red;
+ AssertEquals ("P92#3", solid.Color, Color.Red);
+
+ br = Brushes.MistyRose;
+ Assert ("P93#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P93#2", solid.Color, Color.MistyRose);
+ solid.Color = Color.Red;
+ AssertEquals ("P93#3", solid.Color, Color.Red);
+
+ br = Brushes.Moccasin;
+ Assert ("P94#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P94#2", solid.Color, Color.Moccasin);
+ solid.Color = Color.Red;
+ AssertEquals ("P94#3", solid.Color, Color.Red);
+
+ br = Brushes.NavajoWhite;
+ Assert ("P95#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P95#2", solid.Color, Color.NavajoWhite);
+ solid.Color = Color.Red;
+ AssertEquals ("P95#3", solid.Color, Color.Red);
+
+ br = Brushes.Navy;
+ Assert ("P96#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P96#2", solid.Color, Color.Navy);
+ solid.Color = Color.Red;
+ AssertEquals ("P96#3", solid.Color, Color.Red);
+
+ br = Brushes.OldLace;
+ Assert ("P97#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P97#2", solid.Color, Color.OldLace);
+ solid.Color = Color.Red;
+ AssertEquals ("P97#3", solid.Color, Color.Red);
+
+ br = Brushes.Olive;
+ Assert ("P98#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P98#2", solid.Color, Color.Olive);
+ solid.Color = Color.Red;
+ AssertEquals ("P98#3", solid.Color, Color.Red);
+
+ br = Brushes.OliveDrab;
+ Assert ("P99#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P99#2", solid.Color, Color.OliveDrab);
+ solid.Color = Color.Red;
+ AssertEquals ("P99#3", solid.Color, Color.Red);
+
+ br = Brushes.Orange;
+ Assert ("P100#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P100#2", solid.Color, Color.Orange);
+ solid.Color = Color.Red;
+ AssertEquals ("P100#3", solid.Color, Color.Red);
+
+ br = Brushes.OrangeRed;
+ Assert ("P101#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P101#2", solid.Color, Color.OrangeRed);
+ solid.Color = Color.Red;
+ AssertEquals ("P101#3", solid.Color, Color.Red);
+
+ br = Brushes.Orchid;
+ Assert ("P102#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P102#2", solid.Color, Color.Orchid);
+ solid.Color = Color.Red;
+ AssertEquals ("P102#3", solid.Color, Color.Red);
+
+ br = Brushes.PaleGoldenrod;
+ Assert ("P103#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P103#2", solid.Color, Color.PaleGoldenrod);
+ solid.Color = Color.Red;
+ AssertEquals ("P103#3", solid.Color, Color.Red);
+
+ br = Brushes.PaleGreen;
+ Assert ("P104#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P104#2", solid.Color, Color.PaleGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P104#3", solid.Color, Color.Red);
+
+ br = Brushes.PaleTurquoise;
+ Assert ("P105#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P105#2", solid.Color, Color.PaleTurquoise);
+ solid.Color = Color.Red;
+ AssertEquals ("P105#3", solid.Color, Color.Red);
+
+ br = Brushes.PaleVioletRed;
+ Assert ("P106#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P106#2", solid.Color, Color.PaleVioletRed);
+ solid.Color = Color.Red;
+ AssertEquals ("P106#3", solid.Color, Color.Red);
+
+ br = Brushes.PapayaWhip;
+ Assert ("P107#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P107#2", solid.Color, Color.PapayaWhip);
+ solid.Color = Color.Red;
+ AssertEquals ("P107#3", solid.Color, Color.Red);
+
+ br = Brushes.PeachPuff;
+ Assert ("P108#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P108#2", solid.Color, Color.PeachPuff);
+ solid.Color = Color.Red;
+ AssertEquals ("P108#3", solid.Color, Color.Red);
+
+ br = Brushes.Peru;
+ Assert ("P109#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P109#2", solid.Color, Color.Peru);
+ solid.Color = Color.Red;
+ AssertEquals ("P109#3", solid.Color, Color.Red);
+
+ br = Brushes.Pink;
+ Assert ("P110#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P110#2", solid.Color, Color.Pink);
+ solid.Color = Color.Red;
+ AssertEquals ("P110#3", solid.Color, Color.Red);
+
+ br = Brushes.Plum;
+ Assert ("P111#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P111#2", solid.Color, Color.Plum);
+ solid.Color = Color.Red;
+ AssertEquals ("P111#3", solid.Color, Color.Red);
+
+ br = Brushes.PowderBlue;
+ Assert ("P112#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P112#2", solid.Color, Color.PowderBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P112#3", solid.Color, Color.Red);
+
+ br = Brushes.Purple;
+ Assert ("P113#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P113#2", solid.Color, Color.Purple);
+ solid.Color = Color.Red;
+ AssertEquals ("P113#3", solid.Color, Color.Red);
+
+ br = Brushes.Red;
+ Assert ("P114#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P114#2", solid.Color, Color.Red);
+ solid.Color = Color.White;
+ AssertEquals ("P114#3", solid.Color, Color.White);
+
+ br = Brushes.RosyBrown;
+ Assert ("P115#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P115#2", solid.Color, Color.RosyBrown);
+ solid.Color = Color.Red;
+ AssertEquals ("P115#3", solid.Color, Color.Red);
+
+ br = Brushes.RoyalBlue;
+ Assert ("P116#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P116#2", solid.Color, Color.RoyalBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P116#3", solid.Color, Color.Red);
+
+ br = Brushes.SaddleBrown;
+ Assert ("P117#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P117#2", solid.Color, Color.SaddleBrown);
+ solid.Color = Color.Red;
+ AssertEquals ("P117#3", solid.Color, Color.Red);
+
+ br = Brushes.Salmon;
+ Assert ("P118#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P118#2", solid.Color, Color.Salmon);
+ solid.Color = Color.Red;
+ AssertEquals ("P118#3", solid.Color, Color.Red);
+
+ br = Brushes.SandyBrown;
+ Assert ("P119#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P119#2", solid.Color, Color.SandyBrown);
+ solid.Color = Color.Red;
+ AssertEquals ("P119#3", solid.Color, Color.Red);
+
+ br = Brushes.SeaGreen;
+ Assert ("P120#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P120#2", solid.Color, Color.SeaGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P120#3", solid.Color, Color.Red);
+
+ br = Brushes.SeaShell;
+ Assert ("P121#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P121#2", solid.Color, Color.SeaShell);
+ solid.Color = Color.Red;
+ AssertEquals ("P121#3", solid.Color, Color.Red);
+
+ br = Brushes.Sienna;
+ Assert ("P122#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P122#2", solid.Color, Color.Sienna);
+ solid.Color = Color.Red;
+ AssertEquals ("P122#3", solid.Color, Color.Red);
+
+ br = Brushes.Silver;
+ Assert ("P123#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P123#2", solid.Color, Color.Silver);
+ solid.Color = Color.Red;
+ AssertEquals ("P123#3", solid.Color, Color.Red);
+
+ br = Brushes.SkyBlue;
+ Assert ("P124#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P124#2", solid.Color, Color.SkyBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P124#3", solid.Color, Color.Red);
+
+ br = Brushes.SlateBlue;
+ Assert ("P125#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P125#2", solid.Color, Color.SlateBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P125#3", solid.Color, Color.Red);
+
+ br = Brushes.SlateGray;
+ Assert ("P126#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P126#2", solid.Color, Color.SlateGray);
+ solid.Color = Color.Red;
+ AssertEquals ("P126#3", solid.Color, Color.Red);
+
+ br = Brushes.Snow;
+ Assert ("P127#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P127#2", solid.Color, Color.Snow);
+ solid.Color = Color.Red;
+ AssertEquals ("P127#3", solid.Color, Color.Red);
+
+ br = Brushes.SpringGreen;
+ Assert ("P128#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P128#2", solid.Color, Color.SpringGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P128#3", solid.Color, Color.Red);
+
+ br = Brushes.SteelBlue;
+ Assert ("P129#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P129#2", solid.Color, Color.SteelBlue);
+ solid.Color = Color.Red;
+ AssertEquals ("P129#3", solid.Color, Color.Red);
+
+ br = Brushes.Tan;
+ Assert ("P130#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P130#2", solid.Color, Color.Tan);
+ solid.Color = Color.Red;
+ AssertEquals ("P130#3", solid.Color, Color.Red);
+
+ br = Brushes.Teal;
+ Assert ("P131#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P131#2", solid.Color, Color.Teal);
+ solid.Color = Color.Red;
+ AssertEquals ("P131#3", solid.Color, Color.Red);
+
+ br = Brushes.Thistle;
+ Assert ("P132#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P132#2", solid.Color, Color.Thistle);
+ solid.Color = Color.Red;
+ AssertEquals ("P132#3", solid.Color, Color.Red);
+
+ br = Brushes.Tomato;
+ Assert ("P133#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P133#2", solid.Color, Color.Tomato);
+ solid.Color = Color.Red;
+ AssertEquals ("P133#3", solid.Color, Color.Red);
+
+ br = Brushes.Transparent;
+ Assert ("P134#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P134#2", solid.Color, Color.Transparent);
+ solid.Color = Color.Red;
+ AssertEquals ("P134#3", solid.Color, Color.Red);
+
+ br = Brushes.Turquoise;
+ Assert ("P135#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P135#2", solid.Color, Color.Turquoise);
+ solid.Color = Color.Red;
+ AssertEquals ("P135#3", solid.Color, Color.Red);
+
+ br = Brushes.Violet;
+ Assert ("P136#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P136#2", solid.Color, Color.Violet);
+ solid.Color = Color.Red;
+ AssertEquals ("P136#3", solid.Color, Color.Red);
+
+ br = Brushes.Wheat;
+ Assert ("P137#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P137#2", solid.Color, Color.Wheat);
+ solid.Color = Color.Red;
+ AssertEquals ("P137#3", solid.Color, Color.Red);
+
+ br = Brushes.White;
+ Assert ("P138#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P138#2", solid.Color, Color.White);
+ solid.Color = Color.Red;
+ AssertEquals ("P138#3", solid.Color, Color.Red);
+
+ br = Brushes.WhiteSmoke;
+ Assert ("P139#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P139#2", solid.Color, Color.WhiteSmoke);
+ solid.Color = Color.Red;
+ AssertEquals ("P139#3", solid.Color, Color.Red);
+
+ br = Brushes.Yellow;
+ Assert ("P140#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P140#2", solid.Color, Color.Yellow);
+ solid.Color = Color.Red;
+ AssertEquals ("P140#3", solid.Color, Color.Red);
+
+ br = Brushes.YellowGreen;
+ Assert ("P141#1", br is SolidBrush);
+ solid = (SolidBrush) br;
+ AssertEquals ("P141#2", solid.Color, Color.YellowGreen);
+ solid.Color = Color.Red;
+ AssertEquals ("P141#3", solid.Color, Color.Red);
+ }
+ }
+}
+
+// Following code was used to generate the TestProperties method.
+//
+//Type type = typeof (Brushes);
+//PropertyInfo [] properties = type.GetProperties ();
+//int count = 1;
+//foreach (PropertyInfo property in properties) {
+// Console.WriteLine();
+// Console.WriteLine("\t\t\tbr = Brushes." + property.Name + ";");
+// Console.WriteLine("\t\t\tAssert (\"P" + count + "#1\", br is SolidBrush);");
+// Console.WriteLine("\t\t\tsolid = (SolidBrush) br;");
+// Console.WriteLine("\t\t\tAssertEquals (\"P" + count + "#2\", solid.Color, Color." + property.Name + ");");
+//
+// if (property.Name != "Red") {
+// Console.WriteLine("\t\t\tsolid.Color = Color.Red;");
+// Console.WriteLine("\t\t\tAssertEquals (\"P" + count + "#3\", solid.Color, Color.Red);");
+// } else {
+// Console.WriteLine("\t\t\tsolid.Color = Color.White;");
+// Console.WriteLine("\t\t\tAssertEquals (\"P" + count + "#3\", solid.Color, Color.White);");
+// }
+//
+// count++;
+//}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestColor.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestColor.cs
new file mode 100644
index 00000000000..fc7878c3a26
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestColor.cs
@@ -0,0 +1,1161 @@
+//
+// Tests for System.Drawing.Color.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using System.Drawing;
+using System.Security.Permissions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class ColorTest : Assertion
+ {
+ [SetUp]
+ public void GetReady () { }
+
+ [TearDown]
+ public void Clean () { }
+
+ [Test]
+ public void TestArgbValues ()
+ {
+ Color color;
+
+ color = Color.Transparent;
+ AssertEquals ("#Transparent.A", 0, color.A);
+ AssertEquals ("#Transparent.R", 255, color.R);
+ AssertEquals ("#Transparent.G", 255, color.G);
+ AssertEquals ("#Transparent.B", 255, color.B);
+
+ color = Color.AliceBlue;
+ AssertEquals ("#AliceBlue.A", 255, color.A);
+ AssertEquals ("#AliceBlue.R", 240, color.R);
+ AssertEquals ("#AliceBlue.G", 248, color.G);
+ AssertEquals ("#AliceBlue.B", 255, color.B);
+
+ color = Color.AntiqueWhite;
+ AssertEquals ("#AntiqueWhite.A", 255, color.A);
+ AssertEquals ("#AntiqueWhite.R", 250, color.R);
+ AssertEquals ("#AntiqueWhite.G", 235, color.G);
+ AssertEquals ("#AntiqueWhite.B", 215, color.B);
+
+ color = Color.Aqua;
+ AssertEquals ("#Aqua.A", 255, color.A);
+ AssertEquals ("#Aqua.R", 0, color.R);
+ AssertEquals ("#Aqua.G", 255, color.G);
+ AssertEquals ("#Aqua.B", 255, color.B);
+
+ color = Color.Aquamarine;
+ AssertEquals ("#Aquamarine.A", 255, color.A);
+ AssertEquals ("#Aquamarine.R", 127, color.R);
+ AssertEquals ("#Aquamarine.G", 255, color.G);
+ AssertEquals ("#Aquamarine.B", 212, color.B);
+
+ color = Color.Azure;
+ AssertEquals ("#Azure.A", 255, color.A);
+ AssertEquals ("#Azure.R", 240, color.R);
+ AssertEquals ("#Azure.G", 255, color.G);
+ AssertEquals ("#Azure.B", 255, color.B);
+
+ color = Color.Beige;
+ AssertEquals ("#Beige.A", 255, color.A);
+ AssertEquals ("#Beige.R", 245, color.R);
+ AssertEquals ("#Beige.G", 245, color.G);
+ AssertEquals ("#Beige.B", 220, color.B);
+
+ color = Color.Bisque;
+ AssertEquals ("#Bisque.A", 255, color.A);
+ AssertEquals ("#Bisque.R", 255, color.R);
+ AssertEquals ("#Bisque.G", 228, color.G);
+ AssertEquals ("#Bisque.B", 196, color.B);
+
+ color = Color.Black;
+ AssertEquals ("#Black.A", 255, color.A);
+ AssertEquals ("#Black.R", 0, color.R);
+ AssertEquals ("#Black.G", 0, color.G);
+ AssertEquals ("#Black.B", 0, color.B);
+
+ color = Color.BlanchedAlmond;
+ AssertEquals ("#BlanchedAlmond.A", 255, color.A);
+ AssertEquals ("#BlanchedAlmond.R", 255, color.R);
+ AssertEquals ("#BlanchedAlmond.G", 235, color.G);
+ AssertEquals ("#BlanchedAlmond.B", 205, color.B);
+
+ color = Color.Blue;
+ AssertEquals ("#Blue.A", 255, color.A);
+ AssertEquals ("#Blue.R", 0, color.R);
+ AssertEquals ("#Blue.G", 0, color.G);
+ AssertEquals ("#Blue.B", 255, color.B);
+
+ color = Color.BlueViolet;
+ AssertEquals ("#BlueViolet.A", 255, color.A);
+ AssertEquals ("#BlueViolet.R", 138, color.R);
+ AssertEquals ("#BlueViolet.G", 43, color.G);
+ AssertEquals ("#BlueViolet.B", 226, color.B);
+
+ color = Color.Brown;
+ AssertEquals ("#Brown.A", 255, color.A);
+ AssertEquals ("#Brown.R", 165, color.R);
+ AssertEquals ("#Brown.G", 42, color.G);
+ AssertEquals ("#Brown.B", 42, color.B);
+
+ color = Color.BurlyWood;
+ AssertEquals ("#BurlyWood.A", 255, color.A);
+ AssertEquals ("#BurlyWood.R", 222, color.R);
+ AssertEquals ("#BurlyWood.G", 184, color.G);
+ AssertEquals ("#BurlyWood.B", 135, color.B);
+
+ color = Color.CadetBlue;
+ AssertEquals ("#CadetBlue.A", 255, color.A);
+ AssertEquals ("#CadetBlue.R", 95, color.R);
+ AssertEquals ("#CadetBlue.G", 158, color.G);
+ AssertEquals ("#CadetBlue.B", 160, color.B);
+
+ color = Color.Chartreuse;
+ AssertEquals ("#Chartreuse.A", 255, color.A);
+ AssertEquals ("#Chartreuse.R", 127, color.R);
+ AssertEquals ("#Chartreuse.G", 255, color.G);
+ AssertEquals ("#Chartreuse.B", 0, color.B);
+
+ color = Color.Chocolate;
+ AssertEquals ("#Chocolate.A", 255, color.A);
+ AssertEquals ("#Chocolate.R", 210, color.R);
+ AssertEquals ("#Chocolate.G", 105, color.G);
+ AssertEquals ("#Chocolate.B", 30, color.B);
+
+ color = Color.Coral;
+ AssertEquals ("#Coral.A", 255, color.A);
+ AssertEquals ("#Coral.R", 255, color.R);
+ AssertEquals ("#Coral.G", 127, color.G);
+ AssertEquals ("#Coral.B", 80, color.B);
+
+ color = Color.CornflowerBlue;
+ AssertEquals ("#CornflowerBlue.A", 255, color.A);
+ AssertEquals ("#CornflowerBlue.R", 100, color.R);
+ AssertEquals ("#CornflowerBlue.G", 149, color.G);
+ AssertEquals ("#CornflowerBlue.B", 237, color.B);
+
+ color = Color.Cornsilk;
+ AssertEquals ("#Cornsilk.A", 255, color.A);
+ AssertEquals ("#Cornsilk.R", 255, color.R);
+ AssertEquals ("#Cornsilk.G", 248, color.G);
+ AssertEquals ("#Cornsilk.B", 220, color.B);
+
+ color = Color.Crimson;
+ AssertEquals ("#Crimson.A", 255, color.A);
+ AssertEquals ("#Crimson.R", 220, color.R);
+ AssertEquals ("#Crimson.G", 20, color.G);
+ AssertEquals ("#Crimson.B", 60, color.B);
+
+ color = Color.Cyan;
+ AssertEquals ("#Cyan.A", 255, color.A);
+ AssertEquals ("#Cyan.R", 0, color.R);
+ AssertEquals ("#Cyan.G", 255, color.G);
+ AssertEquals ("#Cyan.B", 255, color.B);
+
+ color = Color.DarkBlue;
+ AssertEquals ("#DarkBlue.A", 255, color.A);
+ AssertEquals ("#DarkBlue.R", 0, color.R);
+ AssertEquals ("#DarkBlue.G", 0, color.G);
+ AssertEquals ("#DarkBlue.B", 139, color.B);
+
+ color = Color.DarkCyan;
+ AssertEquals ("#DarkCyan.A", 255, color.A);
+ AssertEquals ("#DarkCyan.R", 0, color.R);
+ AssertEquals ("#DarkCyan.G", 139, color.G);
+ AssertEquals ("#DarkCyan.B", 139, color.B);
+
+ color = Color.DarkGoldenrod;
+ AssertEquals ("#DarkGoldenrod.A", 255, color.A);
+ AssertEquals ("#DarkGoldenrod.R", 184, color.R);
+ AssertEquals ("#DarkGoldenrod.G", 134, color.G);
+ AssertEquals ("#DarkGoldenrod.B", 11, color.B);
+
+ color = Color.DarkGray;
+ AssertEquals ("#DarkGray.A", 255, color.A);
+ AssertEquals ("#DarkGray.R", 169, color.R);
+ AssertEquals ("#DarkGray.G", 169, color.G);
+ AssertEquals ("#DarkGray.B", 169, color.B);
+
+ color = Color.DarkGreen;
+ AssertEquals ("#DarkGreen.A", 255, color.A);
+ AssertEquals ("#DarkGreen.R", 0, color.R);
+ AssertEquals ("#DarkGreen.G", 100, color.G);
+ AssertEquals ("#DarkGreen.B", 0, color.B);
+
+ color = Color.DarkKhaki;
+ AssertEquals ("#DarkKhaki.A", 255, color.A);
+ AssertEquals ("#DarkKhaki.R", 189, color.R);
+ AssertEquals ("#DarkKhaki.G", 183, color.G);
+ AssertEquals ("#DarkKhaki.B", 107, color.B);
+
+ color = Color.DarkMagenta;
+ AssertEquals ("#DarkMagenta.A", 255, color.A);
+ AssertEquals ("#DarkMagenta.R", 139, color.R);
+ AssertEquals ("#DarkMagenta.G", 0, color.G);
+ AssertEquals ("#DarkMagenta.B", 139, color.B);
+
+ color = Color.DarkOliveGreen;
+ AssertEquals ("#DarkOliveGreen.A", 255, color.A);
+ AssertEquals ("#DarkOliveGreen.R", 85, color.R);
+ AssertEquals ("#DarkOliveGreen.G", 107, color.G);
+ AssertEquals ("#DarkOliveGreen.B", 47, color.B);
+
+ color = Color.DarkOrange;
+ AssertEquals ("#DarkOrange.A", 255, color.A);
+ AssertEquals ("#DarkOrange.R", 255, color.R);
+ AssertEquals ("#DarkOrange.G", 140, color.G);
+ AssertEquals ("#DarkOrange.B", 0, color.B);
+
+ color = Color.DarkOrchid;
+ AssertEquals ("#DarkOrchid.A", 255, color.A);
+ AssertEquals ("#DarkOrchid.R", 153, color.R);
+ AssertEquals ("#DarkOrchid.G", 50, color.G);
+ AssertEquals ("#DarkOrchid.B", 204, color.B);
+
+ color = Color.DarkRed;
+ AssertEquals ("#DarkRed.A", 255, color.A);
+ AssertEquals ("#DarkRed.R", 139, color.R);
+ AssertEquals ("#DarkRed.G", 0, color.G);
+ AssertEquals ("#DarkRed.B", 0, color.B);
+
+ color = Color.DarkSalmon;
+ AssertEquals ("#DarkSalmon.A", 255, color.A);
+ AssertEquals ("#DarkSalmon.R", 233, color.R);
+ AssertEquals ("#DarkSalmon.G", 150, color.G);
+ AssertEquals ("#DarkSalmon.B", 122, color.B);
+
+ color = Color.DarkSeaGreen;
+ AssertEquals ("#DarkSeaGreen.A", 255, color.A);
+ AssertEquals ("#DarkSeaGreen.R", 143, color.R);
+ AssertEquals ("#DarkSeaGreen.G", 188, color.G);
+ AssertEquals ("#DarkSeaGreen.B", 139, color.B);
+
+ color = Color.DarkSlateBlue;
+ AssertEquals ("#DarkSlateBlue.A", 255, color.A);
+ AssertEquals ("#DarkSlateBlue.R", 72, color.R);
+ AssertEquals ("#DarkSlateBlue.G", 61, color.G);
+ AssertEquals ("#DarkSlateBlue.B", 139, color.B);
+
+ color = Color.DarkSlateGray;
+ AssertEquals ("#DarkSlateGray.A", 255, color.A);
+ AssertEquals ("#DarkSlateGray.R", 47, color.R);
+ AssertEquals ("#DarkSlateGray.G", 79, color.G);
+ AssertEquals ("#DarkSlateGray.B", 79, color.B);
+
+ color = Color.DarkTurquoise;
+ AssertEquals ("#DarkTurquoise.A", 255, color.A);
+ AssertEquals ("#DarkTurquoise.R", 0, color.R);
+ AssertEquals ("#DarkTurquoise.G", 206, color.G);
+ AssertEquals ("#DarkTurquoise.B", 209, color.B);
+
+ color = Color.DarkViolet;
+ AssertEquals ("#DarkViolet.A", 255, color.A);
+ AssertEquals ("#DarkViolet.R", 148, color.R);
+ AssertEquals ("#DarkViolet.G", 0, color.G);
+ AssertEquals ("#DarkViolet.B", 211, color.B);
+
+ color = Color.DeepPink;
+ AssertEquals ("#DeepPink.A", 255, color.A);
+ AssertEquals ("#DeepPink.R", 255, color.R);
+ AssertEquals ("#DeepPink.G", 20, color.G);
+ AssertEquals ("#DeepPink.B", 147, color.B);
+
+ color = Color.DeepSkyBlue;
+ AssertEquals ("#DeepSkyBlue.A", 255, color.A);
+ AssertEquals ("#DeepSkyBlue.R", 0, color.R);
+ AssertEquals ("#DeepSkyBlue.G", 191, color.G);
+ AssertEquals ("#DeepSkyBlue.B", 255, color.B);
+
+ color = Color.DimGray;
+ AssertEquals ("#DimGray.A", 255, color.A);
+ AssertEquals ("#DimGray.R", 105, color.R);
+ AssertEquals ("#DimGray.G", 105, color.G);
+ AssertEquals ("#DimGray.B", 105, color.B);
+
+ color = Color.DodgerBlue;
+ AssertEquals ("#DodgerBlue.A", 255, color.A);
+ AssertEquals ("#DodgerBlue.R", 30, color.R);
+ AssertEquals ("#DodgerBlue.G", 144, color.G);
+ AssertEquals ("#DodgerBlue.B", 255, color.B);
+
+ color = Color.Firebrick;
+ AssertEquals ("#Firebrick.A", 255, color.A);
+ AssertEquals ("#Firebrick.R", 178, color.R);
+ AssertEquals ("#Firebrick.G", 34, color.G);
+ AssertEquals ("#Firebrick.B", 34, color.B);
+
+ color = Color.FloralWhite;
+ AssertEquals ("#FloralWhite.A", 255, color.A);
+ AssertEquals ("#FloralWhite.R", 255, color.R);
+ AssertEquals ("#FloralWhite.G", 250, color.G);
+ AssertEquals ("#FloralWhite.B", 240, color.B);
+
+ color = Color.ForestGreen;
+ AssertEquals ("#ForestGreen.A", 255, color.A);
+ AssertEquals ("#ForestGreen.R", 34, color.R);
+ AssertEquals ("#ForestGreen.G", 139, color.G);
+ AssertEquals ("#ForestGreen.B", 34, color.B);
+
+ color = Color.Fuchsia;
+ AssertEquals ("#Fuchsia.A", 255, color.A);
+ AssertEquals ("#Fuchsia.R", 255, color.R);
+ AssertEquals ("#Fuchsia.G", 0, color.G);
+ AssertEquals ("#Fuchsia.B", 255, color.B);
+
+ color = Color.Gainsboro;
+ AssertEquals ("#Gainsboro.A", 255, color.A);
+ AssertEquals ("#Gainsboro.R", 220, color.R);
+ AssertEquals ("#Gainsboro.G", 220, color.G);
+ AssertEquals ("#Gainsboro.B", 220, color.B);
+
+ color = Color.GhostWhite;
+ AssertEquals ("#GhostWhite.A", 255, color.A);
+ AssertEquals ("#GhostWhite.R", 248, color.R);
+ AssertEquals ("#GhostWhite.G", 248, color.G);
+ AssertEquals ("#GhostWhite.B", 255, color.B);
+
+ color = Color.Gold;
+ AssertEquals ("#Gold.A", 255, color.A);
+ AssertEquals ("#Gold.R", 255, color.R);
+ AssertEquals ("#Gold.G", 215, color.G);
+ AssertEquals ("#Gold.B", 0, color.B);
+
+ color = Color.Goldenrod;
+ AssertEquals ("#Goldenrod.A", 255, color.A);
+ AssertEquals ("#Goldenrod.R", 218, color.R);
+ AssertEquals ("#Goldenrod.G", 165, color.G);
+ AssertEquals ("#Goldenrod.B", 32, color.B);
+
+ color = Color.Gray;
+ AssertEquals ("#Gray.A", 255, color.A);
+ AssertEquals ("#Gray.R", 128, color.R);
+ AssertEquals ("#Gray.G", 128, color.G);
+ AssertEquals ("#Gray.B", 128, color.B);
+
+ color = Color.Green;
+ AssertEquals ("#Green.A", 255, color.A);
+ AssertEquals ("#Green.R", 0, color.R);
+ // This test should compare Green.G with 255, but
+ // MS is using a value of 128 for Green.G
+ AssertEquals ("#Green.G", 128, color.G);
+ AssertEquals ("#Green.B", 0, color.B);
+
+ color = Color.GreenYellow;
+ AssertEquals ("#GreenYellow.A", 255, color.A);
+ AssertEquals ("#GreenYellow.R", 173, color.R);
+ AssertEquals ("#GreenYellow.G", 255, color.G);
+ AssertEquals ("#GreenYellow.B", 47, color.B);
+
+ color = Color.Honeydew;
+ AssertEquals ("#Honeydew.A", 255, color.A);
+ AssertEquals ("#Honeydew.R", 240, color.R);
+ AssertEquals ("#Honeydew.G", 255, color.G);
+ AssertEquals ("#Honeydew.B", 240, color.B);
+
+ color = Color.HotPink;
+ AssertEquals ("#HotPink.A", 255, color.A);
+ AssertEquals ("#HotPink.R", 255, color.R);
+ AssertEquals ("#HotPink.G", 105, color.G);
+ AssertEquals ("#HotPink.B", 180, color.B);
+
+ color = Color.IndianRed;
+ AssertEquals ("#IndianRed.A", 255, color.A);
+ AssertEquals ("#IndianRed.R", 205, color.R);
+ AssertEquals ("#IndianRed.G", 92, color.G);
+ AssertEquals ("#IndianRed.B", 92, color.B);
+
+ color = Color.Indigo;
+ AssertEquals ("#Indigo.A", 255, color.A);
+ AssertEquals ("#Indigo.R", 75, color.R);
+ AssertEquals ("#Indigo.G", 0, color.G);
+ AssertEquals ("#Indigo.B", 130, color.B);
+
+ color = Color.Ivory;
+ AssertEquals ("#Ivory.A", 255, color.A);
+ AssertEquals ("#Ivory.R", 255, color.R);
+ AssertEquals ("#Ivory.G", 255, color.G);
+ AssertEquals ("#Ivory.B", 240, color.B);
+
+ color = Color.Khaki;
+ AssertEquals ("#Khaki.A", 255, color.A);
+ AssertEquals ("#Khaki.R", 240, color.R);
+ AssertEquals ("#Khaki.G", 230, color.G);
+ AssertEquals ("#Khaki.B", 140, color.B);
+
+ color = Color.Lavender;
+ AssertEquals ("#Lavender.A", 255, color.A);
+ AssertEquals ("#Lavender.R", 230, color.R);
+ AssertEquals ("#Lavender.G", 230, color.G);
+ AssertEquals ("#Lavender.B", 250, color.B);
+
+ color = Color.LavenderBlush;
+ AssertEquals ("#LavenderBlush.A", 255, color.A);
+ AssertEquals ("#LavenderBlush.R", 255, color.R);
+ AssertEquals ("#LavenderBlush.G", 240, color.G);
+ AssertEquals ("#LavenderBlush.B", 245, color.B);
+
+ color = Color.LawnGreen;
+ AssertEquals ("#LawnGreen.A", 255, color.A);
+ AssertEquals ("#LawnGreen.R", 124, color.R);
+ AssertEquals ("#LawnGreen.G", 252, color.G);
+ AssertEquals ("#LawnGreen.B", 0, color.B);
+
+ color = Color.LemonChiffon;
+ AssertEquals ("#LemonChiffon.A", 255, color.A);
+ AssertEquals ("#LemonChiffon.R", 255, color.R);
+ AssertEquals ("#LemonChiffon.G", 250, color.G);
+ AssertEquals ("#LemonChiffon.B", 205, color.B);
+
+ color = Color.LightBlue;
+ AssertEquals ("#LightBlue.A", 255, color.A);
+ AssertEquals ("#LightBlue.R", 173, color.R);
+ AssertEquals ("#LightBlue.G", 216, color.G);
+ AssertEquals ("#LightBlue.B", 230, color.B);
+
+ color = Color.LightCoral;
+ AssertEquals ("#LightCoral.A", 255, color.A);
+ AssertEquals ("#LightCoral.R", 240, color.R);
+ AssertEquals ("#LightCoral.G", 128, color.G);
+ AssertEquals ("#LightCoral.B", 128, color.B);
+
+ color = Color.LightCyan;
+ AssertEquals ("#LightCyan.A", 255, color.A);
+ AssertEquals ("#LightCyan.R", 224, color.R);
+ AssertEquals ("#LightCyan.G", 255, color.G);
+ AssertEquals ("#LightCyan.B", 255, color.B);
+
+ color = Color.LightGoldenrodYellow;
+ AssertEquals ("#LightGoldenrodYellow.A", 255, color.A);
+ AssertEquals ("#LightGoldenrodYellow.R", 250, color.R);
+ AssertEquals ("#LightGoldenrodYellow.G", 250, color.G);
+ AssertEquals ("#LightGoldenrodYellow.B", 210, color.B);
+
+ color = Color.LightGreen;
+ AssertEquals ("#LightGreen.A", 255, color.A);
+ AssertEquals ("#LightGreen.R", 144, color.R);
+ AssertEquals ("#LightGreen.G", 238, color.G);
+ AssertEquals ("#LightGreen.B", 144, color.B);
+
+ color = Color.LightGray;
+ AssertEquals ("#LightGray.A", 255, color.A);
+ AssertEquals ("#LightGray.R", 211, color.R);
+ AssertEquals ("#LightGray.G", 211, color.G);
+ AssertEquals ("#LightGray.B", 211, color.B);
+
+ color = Color.LightPink;
+ AssertEquals ("#LightPink.A", 255, color.A);
+ AssertEquals ("#LightPink.R", 255, color.R);
+ AssertEquals ("#LightPink.G", 182, color.G);
+ AssertEquals ("#LightPink.B", 193, color.B);
+
+ color = Color.LightSalmon;
+ AssertEquals ("#LightSalmon.A", 255, color.A);
+ AssertEquals ("#LightSalmon.R", 255, color.R);
+ AssertEquals ("#LightSalmon.G", 160, color.G);
+ AssertEquals ("#LightSalmon.B", 122, color.B);
+
+ color = Color.LightSeaGreen;
+ AssertEquals ("#LightSeaGreen.A", 255, color.A);
+ AssertEquals ("#LightSeaGreen.R", 32, color.R);
+ AssertEquals ("#LightSeaGreen.G", 178, color.G);
+ AssertEquals ("#LightSeaGreen.B", 170, color.B);
+
+ color = Color.LightSkyBlue;
+ AssertEquals ("#LightSkyBlue.A", 255, color.A);
+ AssertEquals ("#LightSkyBlue.R", 135, color.R);
+ AssertEquals ("#LightSkyBlue.G", 206, color.G);
+ AssertEquals ("#LightSkyBlue.B", 250, color.B);
+
+ color = Color.LightSlateGray;
+ AssertEquals ("#LightSlateGray.A", 255, color.A);
+ AssertEquals ("#LightSlateGray.R", 119, color.R);
+ AssertEquals ("#LightSlateGray.G", 136, color.G);
+ AssertEquals ("#LightSlateGray.B", 153, color.B);
+
+ color = Color.LightSteelBlue;
+ AssertEquals ("#LightSteelBlue.A", 255, color.A);
+ AssertEquals ("#LightSteelBlue.R", 176, color.R);
+ AssertEquals ("#LightSteelBlue.G", 196, color.G);
+ AssertEquals ("#LightSteelBlue.B", 222, color.B);
+
+ color = Color.LightYellow;
+ AssertEquals ("#LightYellow.A", 255, color.A);
+ AssertEquals ("#LightYellow.R", 255, color.R);
+ AssertEquals ("#LightYellow.G", 255, color.G);
+ AssertEquals ("#LightYellow.B", 224, color.B);
+
+ color = Color.Lime;
+ AssertEquals ("#Lime.A", 255, color.A);
+ AssertEquals ("#Lime.R", 0, color.R);
+ AssertEquals ("#Lime.G", 255, color.G);
+ AssertEquals ("#Lime.B", 0, color.B);
+
+ color = Color.LimeGreen;
+ AssertEquals ("#LimeGreen.A", 255, color.A);
+ AssertEquals ("#LimeGreen.R", 50, color.R);
+ AssertEquals ("#LimeGreen.G", 205, color.G);
+ AssertEquals ("#LimeGreen.B", 50, color.B);
+
+ color = Color.Linen;
+ AssertEquals ("#Linen.A", 255, color.A);
+ AssertEquals ("#Linen.R", 250, color.R);
+ AssertEquals ("#Linen.G", 240, color.G);
+ AssertEquals ("#Linen.B", 230, color.B);
+
+ color = Color.Magenta;
+ AssertEquals ("#Magenta.A", 255, color.A);
+ AssertEquals ("#Magenta.R", 255, color.R);
+ AssertEquals ("#Magenta.G", 0, color.G);
+ AssertEquals ("#Magenta.B", 255, color.B);
+
+ color = Color.Maroon;
+ AssertEquals ("#Maroon.A", 255, color.A);
+ AssertEquals ("#Maroon.R", 128, color.R);
+ AssertEquals ("#Maroon.G", 0, color.G);
+ AssertEquals ("#Maroon.B", 0, color.B);
+
+ color = Color.MediumAquamarine;
+ AssertEquals ("#MediumAquamarine.A", 255, color.A);
+ AssertEquals ("#MediumAquamarine.R", 102, color.R);
+ AssertEquals ("#MediumAquamarine.G", 205, color.G);
+ AssertEquals ("#MediumAquamarine.B", 170, color.B);
+
+ color = Color.MediumBlue;
+ AssertEquals ("#MediumBlue.A", 255, color.A);
+ AssertEquals ("#MediumBlue.R", 0, color.R);
+ AssertEquals ("#MediumBlue.G", 0, color.G);
+ AssertEquals ("#MediumBlue.B", 205, color.B);
+
+ color = Color.MediumOrchid;
+ AssertEquals ("#MediumOrchid.A", 255, color.A);
+ AssertEquals ("#MediumOrchid.R", 186, color.R);
+ AssertEquals ("#MediumOrchid.G", 85, color.G);
+ AssertEquals ("#MediumOrchid.B", 211, color.B);
+
+ color = Color.MediumPurple;
+ AssertEquals ("#MediumPurple.A", 255, color.A);
+ AssertEquals ("#MediumPurple.R", 147, color.R);
+ AssertEquals ("#MediumPurple.G", 112, color.G);
+ AssertEquals ("#MediumPurple.B", 219, color.B);
+
+ color = Color.MediumSeaGreen;
+ AssertEquals ("#MediumSeaGreen.A", 255, color.A);
+ AssertEquals ("#MediumSeaGreen.R", 60, color.R);
+ AssertEquals ("#MediumSeaGreen.G", 179, color.G);
+ AssertEquals ("#MediumSeaGreen.B", 113, color.B);
+
+ color = Color.MediumSlateBlue;
+ AssertEquals ("#MediumSlateBlue.A", 255, color.A);
+ AssertEquals ("#MediumSlateBlue.R", 123, color.R);
+ AssertEquals ("#MediumSlateBlue.G", 104, color.G);
+ AssertEquals ("#MediumSlateBlue.B", 238, color.B);
+
+ color = Color.MediumSpringGreen;
+ AssertEquals ("#MediumSpringGreen.A", 255, color.A);
+ AssertEquals ("#MediumSpringGreen.R", 0, color.R);
+ AssertEquals ("#MediumSpringGreen.G", 250, color.G);
+ AssertEquals ("#MediumSpringGreen.B", 154, color.B);
+
+ color = Color.MediumTurquoise;
+ AssertEquals ("#MediumTurquoise.A", 255, color.A);
+ AssertEquals ("#MediumTurquoise.R", 72, color.R);
+ AssertEquals ("#MediumTurquoise.G", 209, color.G);
+ AssertEquals ("#MediumTurquoise.B", 204, color.B);
+
+ color = Color.MediumVioletRed;
+ AssertEquals ("#MediumVioletRed.A", 255, color.A);
+ AssertEquals ("#MediumVioletRed.R", 199, color.R);
+ AssertEquals ("#MediumVioletRed.G", 21, color.G);
+ AssertEquals ("#MediumVioletRed.B", 133, color.B);
+
+ color = Color.MidnightBlue;
+ AssertEquals ("#MidnightBlue.A", 255, color.A);
+ AssertEquals ("#MidnightBlue.R", 25, color.R);
+ AssertEquals ("#MidnightBlue.G", 25, color.G);
+ AssertEquals ("#MidnightBlue.B", 112, color.B);
+
+ color = Color.MintCream;
+ AssertEquals ("#MintCream.A", 255, color.A);
+ AssertEquals ("#MintCream.R", 245, color.R);
+ AssertEquals ("#MintCream.G", 255, color.G);
+ AssertEquals ("#MintCream.B", 250, color.B);
+
+ color = Color.MistyRose;
+ AssertEquals ("#MistyRose.A", 255, color.A);
+ AssertEquals ("#MistyRose.R", 255, color.R);
+ AssertEquals ("#MistyRose.G", 228, color.G);
+ AssertEquals ("#MistyRose.B", 225, color.B);
+
+ color = Color.Moccasin;
+ AssertEquals ("#Moccasin.A", 255, color.A);
+ AssertEquals ("#Moccasin.R", 255, color.R);
+ AssertEquals ("#Moccasin.G", 228, color.G);
+ AssertEquals ("#Moccasin.B", 181, color.B);
+
+ color = Color.NavajoWhite;
+ AssertEquals ("#NavajoWhite.A", 255, color.A);
+ AssertEquals ("#NavajoWhite.R", 255, color.R);
+ AssertEquals ("#NavajoWhite.G", 222, color.G);
+ AssertEquals ("#NavajoWhite.B", 173, color.B);
+
+ color = Color.Navy;
+ AssertEquals ("#Navy.A", 255, color.A);
+ AssertEquals ("#Navy.R", 0, color.R);
+ AssertEquals ("#Navy.G", 0, color.G);
+ AssertEquals ("#Navy.B", 128, color.B);
+
+ color = Color.OldLace;
+ AssertEquals ("#OldLace.A", 255, color.A);
+ AssertEquals ("#OldLace.R", 253, color.R);
+ AssertEquals ("#OldLace.G", 245, color.G);
+ AssertEquals ("#OldLace.B", 230, color.B);
+
+ color = Color.Olive;
+ AssertEquals ("#Olive.A", 255, color.A);
+ AssertEquals ("#Olive.R", 128, color.R);
+ AssertEquals ("#Olive.G", 128, color.G);
+ AssertEquals ("#Olive.B", 0, color.B);
+
+ color = Color.OliveDrab;
+ AssertEquals ("#OliveDrab.A", 255, color.A);
+ AssertEquals ("#OliveDrab.R", 107, color.R);
+ AssertEquals ("#OliveDrab.G", 142, color.G);
+ AssertEquals ("#OliveDrab.B", 35, color.B);
+
+ color = Color.Orange;
+ AssertEquals ("#Orange.A", 255, color.A);
+ AssertEquals ("#Orange.R", 255, color.R);
+ AssertEquals ("#Orange.G", 165, color.G);
+ AssertEquals ("#Orange.B", 0, color.B);
+
+ color = Color.OrangeRed;
+ AssertEquals ("#OrangeRed.A", 255, color.A);
+ AssertEquals ("#OrangeRed.R", 255, color.R);
+ AssertEquals ("#OrangeRed.G", 69, color.G);
+ AssertEquals ("#OrangeRed.B", 0, color.B);
+
+ color = Color.Orchid;
+ AssertEquals ("#Orchid.A", 255, color.A);
+ AssertEquals ("#Orchid.R", 218, color.R);
+ AssertEquals ("#Orchid.G", 112, color.G);
+ AssertEquals ("#Orchid.B", 214, color.B);
+
+ color = Color.PaleGoldenrod;
+ AssertEquals ("#PaleGoldenrod.A", 255, color.A);
+ AssertEquals ("#PaleGoldenrod.R", 238, color.R);
+ AssertEquals ("#PaleGoldenrod.G", 232, color.G);
+ AssertEquals ("#PaleGoldenrod.B", 170, color.B);
+
+ color = Color.PaleGreen;
+ AssertEquals ("#PaleGreen.A", 255, color.A);
+ AssertEquals ("#PaleGreen.R", 152, color.R);
+ AssertEquals ("#PaleGreen.G", 251, color.G);
+ AssertEquals ("#PaleGreen.B", 152, color.B);
+
+ color = Color.PaleTurquoise;
+ AssertEquals ("#PaleTurquoise.A", 255, color.A);
+ AssertEquals ("#PaleTurquoise.R", 175, color.R);
+ AssertEquals ("#PaleTurquoise.G", 238, color.G);
+ AssertEquals ("#PaleTurquoise.B", 238, color.B);
+
+ color = Color.PaleVioletRed;
+ AssertEquals ("#PaleVioletRed.A", 255, color.A);
+ AssertEquals ("#PaleVioletRed.R", 219, color.R);
+ AssertEquals ("#PaleVioletRed.G", 112, color.G);
+ AssertEquals ("#PaleVioletRed.B", 147, color.B);
+
+ color = Color.PapayaWhip;
+ AssertEquals ("#PapayaWhip.A", 255, color.A);
+ AssertEquals ("#PapayaWhip.R", 255, color.R);
+ AssertEquals ("#PapayaWhip.G", 239, color.G);
+ AssertEquals ("#PapayaWhip.B", 213, color.B);
+
+ color = Color.PeachPuff;
+ AssertEquals ("#PeachPuff.A", 255, color.A);
+ AssertEquals ("#PeachPuff.R", 255, color.R);
+ AssertEquals ("#PeachPuff.G", 218, color.G);
+ AssertEquals ("#PeachPuff.B", 185, color.B);
+
+ color = Color.Peru;
+ AssertEquals ("#Peru.A", 255, color.A);
+ AssertEquals ("#Peru.R", 205, color.R);
+ AssertEquals ("#Peru.G", 133, color.G);
+ AssertEquals ("#Peru.B", 63, color.B);
+
+ color = Color.Pink;
+ AssertEquals ("#Pink.A", 255, color.A);
+ AssertEquals ("#Pink.R", 255, color.R);
+ AssertEquals ("#Pink.G", 192, color.G);
+ AssertEquals ("#Pink.B", 203, color.B);
+
+ color = Color.Plum;
+ AssertEquals ("#Plum.A", 255, color.A);
+ AssertEquals ("#Plum.R", 221, color.R);
+ AssertEquals ("#Plum.G", 160, color.G);
+ AssertEquals ("#Plum.B", 221, color.B);
+
+ color = Color.PowderBlue;
+ AssertEquals ("#PowderBlue.A", 255, color.A);
+ AssertEquals ("#PowderBlue.R", 176, color.R);
+ AssertEquals ("#PowderBlue.G", 224, color.G);
+ AssertEquals ("#PowderBlue.B", 230, color.B);
+
+ color = Color.Purple;
+ AssertEquals ("#Purple.A", 255, color.A);
+ AssertEquals ("#Purple.R", 128, color.R);
+ AssertEquals ("#Purple.G", 0, color.G);
+ AssertEquals ("#Purple.B", 128, color.B);
+
+ color = Color.Red;
+ AssertEquals ("#Red.A", 255, color.A);
+ AssertEquals ("#Red.R", 255, color.R);
+ AssertEquals ("#Red.G", 0, color.G);
+ AssertEquals ("#Red.B", 0, color.B);
+
+ color = Color.RosyBrown;
+ AssertEquals ("#RosyBrown.A", 255, color.A);
+ AssertEquals ("#RosyBrown.R", 188, color.R);
+ AssertEquals ("#RosyBrown.G", 143, color.G);
+ AssertEquals ("#RosyBrown.B", 143, color.B);
+
+ color = Color.RoyalBlue;
+ AssertEquals ("#RoyalBlue.A", 255, color.A);
+ AssertEquals ("#RoyalBlue.R", 65, color.R);
+ AssertEquals ("#RoyalBlue.G", 105, color.G);
+ AssertEquals ("#RoyalBlue.B", 225, color.B);
+
+ color = Color.SaddleBrown;
+ AssertEquals ("#SaddleBrown.A", 255, color.A);
+ AssertEquals ("#SaddleBrown.R", 139, color.R);
+ AssertEquals ("#SaddleBrown.G", 69, color.G);
+ AssertEquals ("#SaddleBrown.B", 19, color.B);
+
+ color = Color.Salmon;
+ AssertEquals ("#Salmon.A", 255, color.A);
+ AssertEquals ("#Salmon.R", 250, color.R);
+ AssertEquals ("#Salmon.G", 128, color.G);
+ AssertEquals ("#Salmon.B", 114, color.B);
+
+ color = Color.SandyBrown;
+ AssertEquals ("#SandyBrown.A", 255, color.A);
+ AssertEquals ("#SandyBrown.R", 244, color.R);
+ AssertEquals ("#SandyBrown.G", 164, color.G);
+ AssertEquals ("#SandyBrown.B", 96, color.B);
+
+ color = Color.SeaGreen;
+ AssertEquals ("#SeaGreen.A", 255, color.A);
+ AssertEquals ("#SeaGreen.R", 46, color.R);
+ AssertEquals ("#SeaGreen.G", 139, color.G);
+ AssertEquals ("#SeaGreen.B", 87, color.B);
+
+ color = Color.SeaShell;
+ AssertEquals ("#SeaShell.A", 255, color.A);
+ AssertEquals ("#SeaShell.R", 255, color.R);
+ AssertEquals ("#SeaShell.G", 245, color.G);
+ AssertEquals ("#SeaShell.B", 238, color.B);
+
+ color = Color.Sienna;
+ AssertEquals ("#Sienna.A", 255, color.A);
+ AssertEquals ("#Sienna.R", 160, color.R);
+ AssertEquals ("#Sienna.G", 82, color.G);
+ AssertEquals ("#Sienna.B", 45, color.B);
+
+ color = Color.Silver;
+ AssertEquals ("#Silver.A", 255, color.A);
+ AssertEquals ("#Silver.R", 192, color.R);
+ AssertEquals ("#Silver.G", 192, color.G);
+ AssertEquals ("#Silver.B", 192, color.B);
+
+ color = Color.SkyBlue;
+ AssertEquals ("#SkyBlue.A", 255, color.A);
+ AssertEquals ("#SkyBlue.R", 135, color.R);
+ AssertEquals ("#SkyBlue.G", 206, color.G);
+ AssertEquals ("#SkyBlue.B", 235, color.B);
+
+ color = Color.SlateBlue;
+ AssertEquals ("#SlateBlue.A", 255, color.A);
+ AssertEquals ("#SlateBlue.R", 106, color.R);
+ AssertEquals ("#SlateBlue.G", 90, color.G);
+ AssertEquals ("#SlateBlue.B", 205, color.B);
+
+ color = Color.SlateGray;
+ AssertEquals ("#SlateGray.A", 255, color.A);
+ AssertEquals ("#SlateGray.R", 112, color.R);
+ AssertEquals ("#SlateGray.G", 128, color.G);
+ AssertEquals ("#SlateGray.B", 144, color.B);
+
+ color = Color.Snow;
+ AssertEquals ("#Snow.A", 255, color.A);
+ AssertEquals ("#Snow.R", 255, color.R);
+ AssertEquals ("#Snow.G", 250, color.G);
+ AssertEquals ("#Snow.B", 250, color.B);
+
+ color = Color.SpringGreen;
+ AssertEquals ("#SpringGreen.A", 255, color.A);
+ AssertEquals ("#SpringGreen.R", 0, color.R);
+ AssertEquals ("#SpringGreen.G", 255, color.G);
+ AssertEquals ("#SpringGreen.B", 127, color.B);
+
+ color = Color.SteelBlue;
+ AssertEquals ("#SteelBlue.A", 255, color.A);
+ AssertEquals ("#SteelBlue.R", 70, color.R);
+ AssertEquals ("#SteelBlue.G", 130, color.G);
+ AssertEquals ("#SteelBlue.B", 180, color.B);
+
+ color = Color.Tan;
+ AssertEquals ("#Tan.A", 255, color.A);
+ AssertEquals ("#Tan.R", 210, color.R);
+ AssertEquals ("#Tan.G", 180, color.G);
+ AssertEquals ("#Tan.B", 140, color.B);
+
+ color = Color.Teal;
+ AssertEquals ("#Teal.A", 255, color.A);
+ AssertEquals ("#Teal.R", 0, color.R);
+ AssertEquals ("#Teal.G", 128, color.G);
+ AssertEquals ("#Teal.B", 128, color.B);
+
+ color = Color.Thistle;
+ AssertEquals ("#Thistle.A", 255, color.A);
+ AssertEquals ("#Thistle.R", 216, color.R);
+ AssertEquals ("#Thistle.G", 191, color.G);
+ AssertEquals ("#Thistle.B", 216, color.B);
+
+ color = Color.Tomato;
+ AssertEquals ("#Tomato.A", 255, color.A);
+ AssertEquals ("#Tomato.R", 255, color.R);
+ AssertEquals ("#Tomato.G", 99, color.G);
+ AssertEquals ("#Tomato.B", 71, color.B);
+
+ color = Color.Turquoise;
+ AssertEquals ("#Turquoise.A", 255, color.A);
+ AssertEquals ("#Turquoise.R", 64, color.R);
+ AssertEquals ("#Turquoise.G", 224, color.G);
+ AssertEquals ("#Turquoise.B", 208, color.B);
+
+ color = Color.Violet;
+ AssertEquals ("#Violet.A", 255, color.A);
+ AssertEquals ("#Violet.R", 238, color.R);
+ AssertEquals ("#Violet.G", 130, color.G);
+ AssertEquals ("#Violet.B", 238, color.B);
+
+ color = Color.Wheat;
+ AssertEquals ("#Wheat.A", 255, color.A);
+ AssertEquals ("#Wheat.R", 245, color.R);
+ AssertEquals ("#Wheat.G", 222, color.G);
+ AssertEquals ("#Wheat.B", 179, color.B);
+
+ color = Color.White;
+ AssertEquals ("#White.A", 255, color.A);
+ AssertEquals ("#White.R", 255, color.R);
+ AssertEquals ("#White.G", 255, color.G);
+ AssertEquals ("#White.B", 255, color.B);
+
+ color = Color.WhiteSmoke;
+ AssertEquals ("#WhiteSmoke.A", 255, color.A);
+ AssertEquals ("#WhiteSmoke.R", 245, color.R);
+ AssertEquals ("#WhiteSmoke.G", 245, color.G);
+ AssertEquals ("#WhiteSmoke.B", 245, color.B);
+
+ color = Color.Yellow;
+ AssertEquals ("#Yellow.A", 255, color.A);
+ AssertEquals ("#Yellow.R", 255, color.R);
+ AssertEquals ("#Yellow.G", 255, color.G);
+ AssertEquals ("#Yellow.B", 0, color.B);
+
+ color = Color.YellowGreen;
+ AssertEquals ("#YellowGreen.A", 255, color.A);
+ AssertEquals ("#YellowGreen.R", 154, color.R);
+ AssertEquals ("#YellowGreen.G", 205, color.G);
+ AssertEquals ("#YellowGreen.B", 50, color.B);
+ }
+
+ static bool FloatsAlmostEqual (float v1, float v2)
+ {
+ float error = Math.Abs(v1-v2)/(v1+v2+float.Epsilon);
+ return error < 0.0001;
+ }
+
+ [Test]
+ public void TestHBSValues ()
+ {
+ AssertEquals ("BrightnessBlack", 0.0f, Color.Black.GetBrightness ());
+ AssertEquals ("BrightnessWhite", 1.0f, Color.White.GetBrightness ());
+
+ Color c1 = Color.FromArgb (0, 13, 45, 7); //just some random color
+ Assert ("Hue1", FloatsAlmostEqual (110.5263f, c1.GetHue ()));
+ Assert ("Brightness1", FloatsAlmostEqual (0.1019608f, c1.GetBrightness ()));
+ Assert ("Saturation1", FloatsAlmostEqual (0.7307692f, c1.GetSaturation ()));
+
+ Color c2 = Color.FromArgb (0, 112, 75, 29); //another random color
+ Assert ("Hue2", FloatsAlmostEqual (33.25302f, c2.GetHue ()));
+ Assert ("Brightness2", FloatsAlmostEqual (0.2764706f, c2.GetBrightness ()));
+ Assert ("Saturation2", FloatsAlmostEqual (0.5886525f, c2.GetSaturation ()));
+ }
+ [Test]
+ public void TestEquals ()
+ {
+ Color color = Color.Red;
+ Color color1 = Color.FromArgb (color.R, color.G, color.B);
+ Assert ("Named color not == unnamed color", !(color==color1));
+ Assert ("Named color not equals unnamed color", !color.Equals (color1));
+ Assert ("Named color != unnamed color", color!=color1);
+ color = Color.FromArgb (0, color1);
+ Assert ("Alpha takes part in comparison", !color.Equals (color1));
+ }
+ [Test]
+ public void TestIsEmpty ()
+ {
+ Color color = Color.Empty;
+ Assert ("Empty color", color.IsEmpty);
+ Assert ("Not empty color", !Color.FromArgb (0, Color.Black).IsEmpty);
+ }
+ [Test]
+ public void IsKnownColor ()
+ {
+ Assert ("KnownColor", Color.FromKnownColor(KnownColor.AliceBlue).IsKnownColor);
+ Assert ("KnownColor", Color.FromName("AliceBlue").IsKnownColor);
+ AssertEquals ("Not KnownColor", false,
+ Color.FromArgb (50, 100, 150, 200).IsKnownColor);
+ }
+ [Test]
+ public void IsNamedColor ()
+ {
+ Assert ("NamedColor", Color.AliceBlue.IsNamedColor);
+ Assert ("NamedColor", Color.FromKnownColor(KnownColor.AliceBlue).IsNamedColor);
+ Assert ("NamedColor", Color.FromName("AliceBlue").IsNamedColor);
+ AssertEquals ("Not NamedColor", false,
+ Color.FromArgb (50, 100, 150, 200).IsNamedColor);
+ }
+ [Test]
+ public void IsSystemColor () {
+ Assert ("SystemColor#1", Color.FromKnownColor(KnownColor.ActiveBorder).IsSystemColor);
+ Assert ("SystemColor#2", Color.FromName("ActiveBorder").IsSystemColor);
+ AssertEquals ("Not SystemColor#1", false,
+ Color.FromArgb (50, 100, 150, 200).IsSystemColor);
+ AssertEquals ("Not SystemColor#2", false,
+ Color.FromKnownColor(KnownColor.AliceBlue).IsSystemColor);
+ AssertEquals ("Not SystemColor#3", false,
+ Color.FromName("AliceBlue").IsSystemColor);
+ }
+ [Test]
+ public void Name ()
+ {
+ AssertEquals ("Color.Name#1", "AliceBlue", Color.AliceBlue.Name);
+ AssertEquals ("Color.Name#2", "ActiveBorder",
+ Color.FromKnownColor (KnownColor.ActiveBorder).Name);
+ AssertEquals ("Color.Name#3", "1122ccff",
+ Color.FromArgb(0x11, 0x22, 0xcc, 0xff).Name);
+ }
+ [Test]
+ public void GetHashCodeTest ()
+ {
+ Color c = Color.AliceBlue;
+ AssertEquals ("GHC#1", false, Color.FromArgb (c.A, c.R, c.G, c.B).GetHashCode () ==
+ c.GetHashCode ());
+ AssertEquals ("GHC#2", c.GetHashCode (), Color.FromName ("AliceBlue").GetHashCode ());
+ }
+ [Test]
+ public void ToArgb ()
+ {
+ AssertEquals (0x11cc8833, Color.FromArgb (0x11, 0xcc, 0x88, 0x33).ToArgb());
+ AssertEquals (unchecked((int)0xf1cc8833), Color.FromArgb (0xf1, 0xcc, 0x88, 0x33).ToArgb());
+ }
+
+ [Test]
+ public void ToKnownColor ()
+ {
+ AssertEquals ("TKC#1", KnownColor.ActiveBorder, Color.FromName ("ActiveBorder").ToKnownColor ());
+ AssertEquals ("TKC#2", KnownColor.AliceBlue, Color.AliceBlue.ToKnownColor ());
+ KnownColor zero = Color.FromArgb (1, 2, 3, 4).ToKnownColor ();
+ AssertEquals ("TKC#3", (KnownColor)0, zero);
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ AssertEquals ("TS#1", "Color [AliceBlue]", Color.AliceBlue.ToString ());
+ AssertEquals ("TS#2", "Color [ActiveBorder]",
+ Color.FromKnownColor (KnownColor.ActiveBorder).ToString ());
+ AssertEquals ("TS#3", "Color [A=1, R=2, G=3, B=4]",
+ Color.FromArgb(1, 2, 3, 4).ToString ());
+ AssertEquals ("TS#4", "Color [Empty]", Color.Empty.ToString ());
+ }
+
+ [Test]
+ public void Equality ()
+ {
+ Color c = Color.AliceBlue;
+ Assert ("EQ#1", c == Color.FromName ("AliceBlue"));
+ AssertEquals ("EQ#2", false, c == Color.FromArgb (c.A, c.R, c.G, c.B));
+ Assert ("EQ#3", c.Equals (Color.FromName ("AliceBlue")));
+ AssertEquals ("EQ#4", false, c.Equals(Color.FromArgb (c.A, c.R, c.G, c.B)));
+ AssertEquals ("EQ#5", false, c != Color.FromName ("AliceBlue"));
+ Assert("EQ#6", c != Color.FromArgb (c.A, c.R, c.G, c.B));
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidAlpha1 ()
+ {
+ Color.FromArgb (-1, Color.Red);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidAlpha2 ()
+ {
+ Color.FromArgb (256, Color.Red);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidAlpha3 ()
+ {
+ Color.FromArgb (-1, 0, 0, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidAlpha4 ()
+ {
+ Color.FromArgb (256, 0, 0, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidRed1 ()
+ {
+ Color.FromArgb (-1, 0, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidRed2 ()
+ {
+ Color.FromArgb (256, 0, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidRed3 ()
+ {
+ Color.FromArgb (0, -1, 0, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidRed4 ()
+ {
+ Color.FromArgb (0, 256, 0, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidGreen1 ()
+ {
+ Color.FromArgb (0, -1, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidGreen2 ()
+ {
+ Color.FromArgb (0, 256, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidGreen3 ()
+ {
+ Color.FromArgb (0, 0, -1, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidGreen4 ()
+ {
+ Color.FromArgb (0, 0, 256, 0);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidBlue1 ()
+ {
+ Color.FromArgb (0, 0, -1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidBlue2 ()
+ {
+ Color.FromArgb (0, 0, 256);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidBlue3 ()
+ {
+ Color.FromArgb (0, 0, 0, -1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void FromArgb_InvalidBlue4 ()
+ {
+ Color.FromArgb (0, 0, 0, 256);
+ }
+ }
+}
+
+// Following code was used to generate the TestArgbValues method on MS.
+//
+// Type cType = typeof (Color);
+// PropertyInfo [] properties = cType.GetProperties (BindingFlags.Public | BindingFlags.Static);
+//// Console.WriteLine ("number: " + properties.Length);
+//
+// Console.WriteLine("\t\t[Test]");
+// Console.WriteLine("\t\tpublic void TestArgbValues ()");
+// Console.WriteLine("\t\t{");
+// Console.WriteLine("\t\t\tColor color;");
+// foreach (PropertyInfo property in properties) {
+//
+// Console.WriteLine();
+// Console.WriteLine("\t\t\tcolor = Color.{0};", property.Name);
+// Color color = Color.FromName (property.Name);
+// Console.WriteLine("\t\t\tAssertEquals (\"#{0}.A\", {1}, color.A);", property.Name, color.A);
+// Console.WriteLine("\t\t\tAssertEquals (\"#{0}.R\", {1}, color.R);", property.Name, color.R);
+// Console.WriteLine("\t\t\tAssertEquals (\"#{0}.G\", {1}, color.G);", property.Name, color.G);
+// Console.WriteLine("\t\t\tAssertEquals (\"#{0}.B\", {1}, color.B);", property.Name, color.B);
+// }
+// Console.WriteLine("\t\t}");
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs
new file mode 100644
index 00000000000..581fc22a393
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestFont.cs
@@ -0,0 +1,113 @@
+//
+// Test Font class testing unit
+//
+// Author:
+//
+// Jordi Mas i Hernandez, jordi@ximian.com
+// Peter Dennis Bartok, pbartok@novell.com
+//
+// (C) 2003 Ximian, Inc. http://www.ximian.com
+// (C) 2004-2005 Novell, Inc. http://www.novell.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Security.Permissions;
+using System.Runtime.InteropServices;
+
+namespace MonoTests.System.Drawing{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class FontTest : Assertion {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+ // Test basic Font clone, properties and contructor
+ [Test]
+ public void TestClone()
+ {
+ Font f = new Font("Arial",12);
+ Font f2 = (Font) f.Clone();
+
+ AssertEquals (f.Bold, f2.Bold);
+ AssertEquals (f.FontFamily, f2.FontFamily);
+ AssertEquals (f.GdiCharSet, f2.GdiCharSet);
+ AssertEquals (f.GdiVerticalFont, f2.GdiVerticalFont);
+ AssertEquals (f.Height, f2.Height);
+ AssertEquals (f.Italic, f2.Italic);
+ AssertEquals (f.Name, f2.Name);
+ AssertEquals (f.Size, f2.Size);
+ AssertEquals (f.SizeInPoints, f2.SizeInPoints);
+ AssertEquals (f.Strikeout, f2.Strikeout);
+ AssertEquals (f.Style, f2.Style);
+ AssertEquals (f.Underline, f2.Underline);
+ AssertEquals (f.Unit, f2.Unit);
+ }
+
+ [ StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode) ]
+ class LOGFONT {
+ public int lfHeight = 0;
+ public int lfWidth = 0;
+ public int lfEscapement = 0;
+ public int lfOrientation = 0;
+ public int lfWeight = 0;
+ public byte lfItalic = 0;
+ public byte lfUnderline = 0;
+ public byte lfStrikeOut = 0;
+ public byte lfCharSet = 0;
+ public byte lfOutPrecision = 0;
+ public byte lfClipPrecision = 0;
+ public byte lfQuality = 0;
+ public byte lfPitchAndFamily = 0;
+ [ MarshalAs(UnmanagedType.ByValTStr, SizeConst=32) ]
+ public string lfFaceName = null;
+ }
+
+ [Test]
+ public void TestToLogFont() {
+ Font f;
+ LOGFONT lf;
+
+ lf = new LOGFONT();
+ f = new Font("Arial", 10);
+
+ f.ToLogFont(lf);
+ AssertEquals("lf1", -13, lf.lfHeight);
+ AssertEquals("lf2", 400, lf.lfWeight);
+ AssertEquals("lf3", 1, lf.lfCharSet);
+ AssertEquals("lf4", f.Name, lf.lfFaceName);
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs
new file mode 100644
index 00000000000..b93688af1b4
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs
@@ -0,0 +1,310 @@
+//
+// Graphics class testing unit
+//
+// Author:
+// Jordi Mas, jordi@ximian.com
+//
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Drawing.Drawing2D;
+using System.IO;
+using System.Reflection;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ public class GraphicsTest : Assertion
+ {
+ private RectangleF[] rects;
+
+ [TearDown]
+ public void TearDown () {}
+
+ [SetUp]
+ public void SetUp ()
+ {
+
+ }
+
+ [Test]
+ public void DefaultProperties ()
+ {
+ Bitmap bmp = new Bitmap (200, 200);
+ Graphics g = Graphics.FromImage (bmp);
+ Region r = new Region ();
+
+ AssertEquals ("DefaultProperties1", r.GetBounds (g) , g.ClipBounds);
+ AssertEquals ("DefaultProperties2", CompositingMode.SourceOver, g.CompositingMode);
+ AssertEquals ("DefaultProperties3", CompositingQuality.Default, g.CompositingQuality);
+ AssertEquals ("DefaultProperties4", InterpolationMode.Bilinear, g.InterpolationMode);
+ AssertEquals ("DefaultProperties5", 1, g.PageScale);
+ AssertEquals ("DefaultProperties6", GraphicsUnit.Display, g.PageUnit);
+ AssertEquals ("DefaultProperties7", PixelOffsetMode.Default, g.PixelOffsetMode);
+ AssertEquals ("DefaultProperties8", new Point (0, 0) , g.RenderingOrigin);
+ AssertEquals ("DefaultProperties9", SmoothingMode.None, g.SmoothingMode);
+ AssertEquals ("DefaultProperties10", TextRenderingHint.SystemDefault, g.TextRenderingHint);
+
+ r.Dispose ();
+ }
+
+ [Test]
+ public void SetGetProperties ()
+ {
+ Bitmap bmp = new Bitmap (200, 200);
+ Graphics g = Graphics.FromImage (bmp);
+
+ g.CompositingMode = CompositingMode.SourceCopy;
+ g.CompositingQuality = CompositingQuality.GammaCorrected;
+ g.InterpolationMode = InterpolationMode.HighQualityBilinear;
+ g.PageScale = 2;
+ g.PageUnit = GraphicsUnit.Inch;
+ g.PixelOffsetMode = PixelOffsetMode.Half;
+ g.RenderingOrigin = new Point (10, 20);
+ g.SmoothingMode = SmoothingMode.AntiAlias;
+ g.TextRenderingHint = TextRenderingHint.SystemDefault;
+
+ //Clipping set/get tested in clipping functions
+ AssertEquals ("SetGetProperties2", CompositingMode.SourceCopy, g.CompositingMode);
+ AssertEquals ("SetGetProperties3", CompositingQuality.GammaCorrected, g.CompositingQuality);
+ AssertEquals ("SetGetProperties4", InterpolationMode.HighQualityBilinear, g.InterpolationMode);
+ AssertEquals ("SetGetProperties5", 2, g.PageScale);
+ AssertEquals ("SetGetProperties6", GraphicsUnit.Inch, g.PageUnit);
+ AssertEquals ("SetGetProperties7", PixelOffsetMode.Half, g.PixelOffsetMode);
+ AssertEquals ("SetGetProperties8", new Point (10, 20), g.RenderingOrigin);
+ AssertEquals ("SetGetProperties9", SmoothingMode.AntiAlias, g.SmoothingMode);
+ AssertEquals ("SetGetProperties10", TextRenderingHint.SystemDefault, g.TextRenderingHint);
+ }
+
+ // Properties
+ [Test]
+ public void Clip ()
+ {
+ RectangleF[] rects ;
+ Bitmap bmp = new Bitmap (200, 200);
+ Graphics g = Graphics.FromImage (bmp);
+ g.Clip = new Region (new Rectangle (50, 40, 210, 220));
+ rects = g.Clip.GetRegionScans (new Matrix ());
+
+ AssertEquals ("Clip1", 1, rects.Length);
+ AssertEquals ("Clip2", 50, rects[0].X);
+ AssertEquals ("Clip3", 40, rects[0].Y);
+ AssertEquals ("Clip4", 210, rects[0].Width);
+ AssertEquals ("Clip5", 220, rects[0].Height);
+ }
+
+ [Test]
+ public void ExcludeClip ()
+ {
+ Bitmap bmp = new Bitmap (200, 200);
+ Graphics g = Graphics.FromImage (bmp);
+
+ g.Clip = new Region (new RectangleF (10, 10, 100, 100));
+ g.ExcludeClip (new Rectangle (40, 60, 100, 20));
+ rects = g.Clip.GetRegionScans (new Matrix ());
+
+ AssertEquals ("ExcludeClip1", 3, rects.Length);
+
+ AssertEquals ("ExcludeClip2", 10, rects[0].X);
+ AssertEquals ("ExcludeClip3", 10, rects[0].Y);
+ AssertEquals ("ExcludeClip4", 100, rects[0].Width);
+ AssertEquals ("ExcludeClip5", 50, rects[0].Height);
+
+ AssertEquals ("ExcludeClip6", 10, rects[1].X);
+ AssertEquals ("ExcludeClip7", 60, rects[1].Y);
+ AssertEquals ("ExcludeClip8", 30, rects[1].Width);
+ AssertEquals ("ExcludeClip9", 20, rects[1].Height);
+
+ AssertEquals ("ExcludeClip10", 10, rects[2].X);
+ AssertEquals ("ExcludeClip11", 80, rects[2].Y);
+ AssertEquals ("ExcludeClip12", 100, rects[2].Width);
+ AssertEquals ("ExcludeClip13", 30, rects[2].Height);
+ }
+
+ [Test]
+ public void IntersectClip ()
+ {
+ Bitmap bmp = new Bitmap (200, 200);
+ Graphics g = Graphics.FromImage (bmp);
+
+ g.Clip = new Region (new RectangleF (260, 30, 60, 80));
+ g.IntersectClip (new Rectangle (290, 40, 60, 80));
+ rects = g.Clip.GetRegionScans (new Matrix ());
+
+ AssertEquals ("IntersectClip", 1, rects.Length);
+
+ AssertEquals ("IntersectClip", 290, rects[0].X);
+ AssertEquals ("IntersectClip", 40, rects[0].Y);
+ AssertEquals ("IntersectClip", 30, rects[0].Width);
+ AssertEquals ("IntersectClip", 70, rects[0].Height);
+ }
+
+ [Test]
+ public void ResetClip ()
+ {
+ Bitmap bmp = new Bitmap (200, 200);
+ Graphics g = Graphics.FromImage (bmp);
+
+ g.Clip = new Region (new RectangleF (260, 30, 60, 80));
+ g.IntersectClip (new Rectangle (290, 40, 60, 80));
+ g.ResetClip ();
+ rects = g.Clip.GetRegionScans (new Matrix ());
+
+ AssertEquals ("ResetClip", 1, rects.Length);
+
+ AssertEquals ("ResetClip", -4194304, rects[0].X);
+ AssertEquals ("ResetClip", -4194304, rects[0].Y);
+ AssertEquals ("ResetClip", 8388608, rects[0].Width);
+ AssertEquals ("ResetClip", 8388608, rects[0].Height);
+ }
+
+ [Test]
+ public void SetClip ()
+ {
+ RectangleF[] rects ;
+ Bitmap bmp = new Bitmap (200, 200);
+ Graphics g = Graphics.FromImage (bmp);
+
+ // Region
+ g.SetClip (new Region (new Rectangle (50, 40, 210, 220)), CombineMode.Replace);
+ rects = g.Clip.GetRegionScans (new Matrix ());
+ AssertEquals ("SetClip1", 1, rects.Length);
+ AssertEquals ("SetClip2", 50, rects[0].X);
+ AssertEquals ("SetClip3", 40, rects[0].Y);
+ AssertEquals ("SetClip4", 210, rects[0].Width);
+ AssertEquals ("SetClip5", 220, rects[0].Height);
+
+ // RectangleF
+ g = Graphics.FromImage (bmp);
+ g.SetClip (new RectangleF (50, 40, 210, 220));
+ rects = g.Clip.GetRegionScans (new Matrix ());
+ AssertEquals ("SetClip6", 1, rects.Length);
+ AssertEquals ("SetClip7", 50, rects[0].X);
+ AssertEquals ("SetClip8", 40, rects[0].Y);
+ AssertEquals ("SetClip9", 210, rects[0].Width);
+ AssertEquals ("SetClip10", 220, rects[0].Height);
+
+ // Rectangle
+ g = Graphics.FromImage (bmp);
+ g.SetClip (new Rectangle (50, 40, 210, 220));
+ rects = g.Clip.GetRegionScans (new Matrix ());
+ AssertEquals ("SetClip10", 1, rects.Length);
+ AssertEquals ("SetClip11", 50, rects[0].X);
+ AssertEquals ("SetClip12", 40, rects[0].Y);
+ AssertEquals ("SetClip13", 210, rects[0].Width);
+ AssertEquals ("SetClip14", 220, rects[0].Height);
+ }
+
+ [Test]
+ public void SetSaveReset ()
+ {
+ Bitmap bmp = new Bitmap (200, 200);
+ Graphics g = Graphics.FromImage (bmp);
+ GraphicsState state_default, state_modified;
+
+ state_default = g.Save (); // Default
+
+ g.CompositingMode = CompositingMode.SourceCopy;
+ g.CompositingQuality = CompositingQuality.GammaCorrected;
+ g.InterpolationMode = InterpolationMode.HighQualityBilinear;
+ g.PageScale = 2;
+ g.PageUnit = GraphicsUnit.Inch;
+ g.PixelOffsetMode = PixelOffsetMode.Half;
+ g.Clip = new Region (new Rectangle (0, 0, 100, 100));
+ g.RenderingOrigin = new Point (10, 20);
+ g.SmoothingMode = SmoothingMode.AntiAlias;
+ g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
+
+
+ state_modified = g.Save (); // Modified
+
+ g.CompositingMode = CompositingMode.SourceOver;
+ g.CompositingQuality = CompositingQuality.Default;
+ g.InterpolationMode = InterpolationMode.Bilinear;
+ g.PageScale = 5;
+ g.PageUnit = GraphicsUnit.Display;
+ g.PixelOffsetMode = PixelOffsetMode.Default;
+ g.Clip = new Region (new Rectangle (1, 2, 20, 25));
+ g.RenderingOrigin = new Point (5, 6);
+ g.SmoothingMode = SmoothingMode.None;
+ g.TextRenderingHint = TextRenderingHint.SystemDefault;
+
+ g.Restore (state_modified);
+
+ AssertEquals ("SetSaveReset1", CompositingMode.SourceCopy, g.CompositingMode);
+ AssertEquals ("SetSaveReset2", CompositingQuality.GammaCorrected, g.CompositingQuality);
+ AssertEquals ("SetSaveReset3", InterpolationMode.HighQualityBilinear, g.InterpolationMode);
+ AssertEquals ("SetSaveReset4", 2, g.PageScale);
+ AssertEquals ("SetSaveReset5", GraphicsUnit.Inch, g.PageUnit);
+ AssertEquals ("SetSaveReset6", PixelOffsetMode.Half, g.PixelOffsetMode);
+ AssertEquals ("SetSaveReset7", new Point (10, 20), g.RenderingOrigin);
+ AssertEquals ("SetSaveReset8", SmoothingMode.AntiAlias, g.SmoothingMode);
+ AssertEquals ("SetSaveReset9", TextRenderingHint.ClearTypeGridFit, g.TextRenderingHint);
+ AssertEquals ("SetSaveReset10", 0, (int) g.ClipBounds.X);
+ AssertEquals ("SetSaveReset10", 0, (int) g.ClipBounds.Y);
+
+ g.Restore (state_default);
+
+ AssertEquals ("SetSaveReset11", CompositingMode.SourceOver, g.CompositingMode);
+ AssertEquals ("SetSaveReset12", CompositingQuality.Default, g.CompositingQuality);
+ AssertEquals ("SetSaveReset13", InterpolationMode.Bilinear, g.InterpolationMode);
+ AssertEquals ("SetSaveReset14", 1, g.PageScale);
+ AssertEquals ("SetSaveReset15", GraphicsUnit.Display, g.PageUnit);
+ AssertEquals ("SetSaveReset16", PixelOffsetMode.Default, g.PixelOffsetMode);
+ AssertEquals ("SetSaveReset17", new Point (0, 0) , g.RenderingOrigin);
+ AssertEquals ("SetSaveReset18", SmoothingMode.None, g.SmoothingMode);
+ AssertEquals ("SetSaveReset19", TextRenderingHint.SystemDefault, g.TextRenderingHint);
+
+ Region r = new Region ();
+ AssertEquals ("SetSaveReset20", r.GetBounds (g) , g.ClipBounds);
+
+ g.Dispose ();
+ }
+
+ [Test]
+ public void LoadIndexed ()
+ {
+ //
+ // Tests that we can load an indexed file
+ //
+
+ Stream str = Assembly.GetExecutingAssembly ().GetManifestResourceStream ("indexed.png");
+ Image x = Image.FromStream (str);
+ Graphics g = Graphics.FromImage (x);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void FromImage ()
+ {
+ Graphics g = Graphics.FromImage (null);
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs
new file mode 100644
index 00000000000..6b9bb2a299c
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs
@@ -0,0 +1,112 @@
+//
+// Icon class testing unit
+//
+// Author:
+//
+// Sanjay Gupta <gsanjay@novell.com>
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using NUnit.Framework;
+using System.IO;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestIcon {
+
+ Icon icon;
+ Icon newIcon;
+ FileStream fs;
+ FileStream fs1;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ String path = TestBitmap.getInFile ("bitmaps/smiley.ico");
+ icon = new Icon (path);
+ fs1 = new FileStream (path, FileMode.Open);
+ }
+
+ [Test]
+ public void TestConstructors ()
+ {
+ newIcon = new Icon (fs1, 48, 48);
+ Assert.AreEqual (48, newIcon.Height, "C#1a");
+ Assert.AreEqual (48, newIcon.Width, "C#1b");
+
+ newIcon = new Icon (icon, 16, 16);
+ Assert.AreEqual (16, newIcon.Height, "C#2a");
+ Assert.AreEqual (16, newIcon.Width, "C#2b");
+ }
+
+ [Test]
+ public void TestProperties ()
+ {
+ Assert.AreEqual (32, icon.Height, "P#1");
+ Assert.AreEqual (32, icon.Width, "P#2");
+ Assert.AreEqual (32, icon.Size.Width, "P#3");
+ Assert.AreEqual (32, icon.Size.Height, "P#4");
+
+ }
+
+ [Test]
+ public void TestMethods ()
+ {
+ /*
+
+ TODO: This does not work on Win32
+
+ newIcon = (Icon) icon.Clone ();
+ Assert.AreEqual (32, newIcon.Height, "M#1a");
+ Assert.AreEqual (32, newIcon.Width, "M#1b");
+
+ Bitmap bmp = icon.ToBitmap();
+ Assert.AreEqual (32, bmp.Height, "M#2a");
+ Assert.AreEqual (32, bmp.Width, "M#2b");
+ */
+
+ fs = new FileStream ("newIcon.ico", FileMode.Create);
+ icon.Save (fs);
+
+ Assert.AreEqual (fs1.Length, fs.Length, "M#3");
+ }
+
+ [TearDown]
+ public void TearDown ()
+ {
+ if (fs != null)
+ fs.Close();
+ if (fs1 != null)
+ fs1.Close();
+ if (File.Exists ("newIcon.ico"))
+ File.Delete("newIcon.ico");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestIconConverter.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestIconConverter.cs
new file mode 100644
index 00000000000..a588e8fe9a9
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestIconConverter.cs
@@ -0,0 +1,424 @@
+//
+// Tests for System.Drawing.IconConverter.cs
+//
+// Author:
+// Sanjay Gupta (gsanjay@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.IO;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class IconConverterTest
+ {
+ Icon icon;
+ IconConverter icoConv;
+ IconConverter icoConvFrmTD;
+ String iconStr;
+ byte [] iconBytes;
+
+ [TearDown]
+ public void TearDown () {}
+
+ [SetUp]
+ public void SetUp ()
+ {
+ icon = new Icon (TestBitmap.getInFile ("bitmaps/VisualPng.ico"));
+ iconStr = icon.ToString ();
+
+ icoConv = new IconConverter();
+ icoConvFrmTD = (IconConverter) TypeDescriptor.GetConverter (icon);
+
+ Stream stream = new FileStream (TestBitmap.getInFile ("bitmaps/VisualPng1.ico"), FileMode.Open);
+ int length = (int) stream.Length;
+ iconBytes = new byte [length];
+
+ try {
+ if (stream.Read (iconBytes, 0, length) != length)
+ Assert.Fail ("SU#1: Read Failure");
+ } catch (Exception e) {
+ Assert.Fail ("SU#2 Exception thrown while reading. Exception is: "+e.Message);
+ } finally {
+ stream.Close ();
+ }
+
+ stream.Close ();
+
+ }
+
+ [Test]
+ public void TestCanConvertFrom ()
+ {
+ Assert.IsTrue (icoConv.CanConvertFrom (typeof (byte [])), "CCF#1");
+ Assert.IsTrue (icoConv.CanConvertFrom (null, typeof (byte [])), "CCF#1a");
+ Assert.IsTrue (icoConv.CanConvertFrom (null, iconBytes.GetType ()), "CCF#1b");
+ Assert.IsTrue (! icoConv.CanConvertFrom (null, typeof (String)), "CCF#2");
+ Assert.IsTrue (! icoConv.CanConvertFrom (null, typeof (Rectangle)), "CCF#3");
+ Assert.IsTrue (! icoConv.CanConvertFrom (null, typeof (Point)), "CCF#4");
+ Assert.IsTrue (! icoConv.CanConvertFrom (null, typeof (PointF)), "CCF#5");
+ Assert.IsTrue (! icoConv.CanConvertFrom (null, typeof (Size)), "CCF#6");
+ Assert.IsTrue (! icoConv.CanConvertFrom (null, typeof (SizeF)), "CCF#7");
+ Assert.IsTrue (! icoConv.CanConvertFrom (null, typeof (Object)), "CCF#8");
+ Assert.IsTrue (! icoConv.CanConvertFrom (null, typeof (int)), "CCF#9");
+ Assert.IsTrue (! icoConv.CanConvertFrom (null, typeof (Metafile)), "CCF#10");
+
+ Assert.IsTrue (icoConvFrmTD.CanConvertFrom (typeof (byte [])), "CCF#1A");
+ Assert.IsTrue (icoConvFrmTD.CanConvertFrom (null, typeof (byte [])), "CCF#1aA");
+ Assert.IsTrue (icoConvFrmTD.CanConvertFrom (null, iconBytes.GetType ()), "CCF#1bA");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertFrom (null, typeof (String)), "CCF#2A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertFrom (null, typeof (Rectangle)), "CCF#3A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertFrom (null, typeof (Point)), "CCF#4A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertFrom (null, typeof (PointF)), "CCF#5A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertFrom (null, typeof (Size)), "CCF#6A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertFrom (null, typeof (SizeF)), "CCF#7A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertFrom (null, typeof (Object)), "CCF#8A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertFrom (null, typeof (int)), "CCF#9A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertFrom (null, typeof (Metafile)), "CCF#10A");
+
+ }
+
+ [Test]
+ public void TestCanConvertTo ()
+ {
+ Assert.IsTrue (icoConv.CanConvertTo (typeof (String)), "CCT#1");
+ Assert.IsTrue (icoConv.CanConvertTo (null, typeof (String)), "CCT#1a");
+ Assert.IsTrue (icoConv.CanConvertTo (null, iconStr.GetType ()), "CCT#1b");
+ Assert.IsTrue (icoConv.CanConvertTo (typeof (byte [])), "CCT#2");
+ Assert.IsTrue (icoConv.CanConvertTo (null, typeof (byte [])), "CCT#2a");
+ Assert.IsTrue (icoConv.CanConvertTo (null, iconBytes.GetType ()), "CCT#2b");
+ Assert.IsTrue (! icoConv.CanConvertTo (null, typeof (Rectangle)), "CCT#3");
+ Assert.IsTrue (! icoConv.CanConvertTo (null, typeof (Point)), "CCT#4");
+ Assert.IsTrue (! icoConv.CanConvertTo (null, typeof (PointF)), "CCT#5");
+ Assert.IsTrue (! icoConv.CanConvertTo (null, typeof (Size)), "CCT#6");
+ Assert.IsTrue (! icoConv.CanConvertTo (null, typeof (SizeF)), "CCT#7");
+ Assert.IsTrue (! icoConv.CanConvertTo (null, typeof (Object)), "CCT#8");
+ Assert.IsTrue (! icoConv.CanConvertTo (null, typeof (int)), "CCT#9");
+
+ Assert.IsTrue (icoConvFrmTD.CanConvertTo (typeof (String)), "CCT#1A");
+ Assert.IsTrue (icoConvFrmTD.CanConvertTo (null, typeof (String)), "CCT#1aA");
+ Assert.IsTrue (icoConvFrmTD.CanConvertTo (null, iconStr.GetType ()), "CCT#1bA");
+ Assert.IsTrue (icoConvFrmTD.CanConvertTo (typeof (byte [])), "CCT#2A");
+ Assert.IsTrue (icoConvFrmTD.CanConvertTo (null, typeof (byte [])), "CCT#2aA");
+ Assert.IsTrue (icoConvFrmTD.CanConvertTo (null, iconBytes.GetType ()), "CCT#2bA");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertTo (null, typeof (Rectangle)), "CCT#3A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertTo (null, typeof (Point)), "CCT#4A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertTo (null, typeof (PointF)), "CCT#5A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertTo (null, typeof (Size)), "CCT#6A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertTo (null, typeof (SizeF)), "CCT#7A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertTo (null, typeof (Object)), "CCT#8A");
+ Assert.IsTrue (! icoConvFrmTD.CanConvertTo (null, typeof (int)), "CCT#9A");
+
+ }
+
+ [Test]
+ public void TestConvertFrom ()
+ {
+ Icon newIcon = (Icon) icoConv.ConvertFrom (null, CultureInfo.InvariantCulture, iconBytes);
+
+ Assert.AreEqual (icon.Height, newIcon.Height, "CF#1");
+ Assert.AreEqual (icon.Width, newIcon.Width, "CF#1a" );
+
+ try {
+ icoConv.ConvertFrom ("System.Drawing.String");
+ Assert.Fail ("CF#2: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2");
+ }
+
+ try {
+ icoConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "System.Drawing.String");
+ Assert.Fail ("CF#2a: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2a");
+ }
+
+ try {
+ icoConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Bitmap (20, 20));
+ Assert.Fail ("CF#3: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#3");
+ }
+
+ try {
+ icoConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Point (10, 10));
+ Assert.Fail ("CF#4: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#4");
+ }
+
+ try {
+ icoConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new SizeF (10, 10));
+ Assert.Fail ("CF#5: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#5");
+ }
+
+ try {
+ icoConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Object ());
+ Assert.Fail ("CF#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#6");
+ }
+
+
+ newIcon = (Icon) icoConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, iconBytes);
+
+ Assert.AreEqual (icon.Height, newIcon.Height, "CF#1A");
+ Assert.AreEqual (icon.Width, newIcon.Width, "CF#1Aa");
+
+ try {
+ icoConvFrmTD.ConvertFrom ("System.Drawing.String");
+ Assert.Fail ("CF#2A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "System.Drawing.String");
+ Assert.Fail ("CF#2aA: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2aA");
+ }
+
+ try {
+ icoConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Bitmap (20, 20));
+ Assert.Fail ("CF#3A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#3A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Point (10, 10));
+ Assert.Fail ("CF#4A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#4A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new SizeF (10, 10));
+ Assert.Fail ("CF#5A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#5A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Object ());
+ Assert.Fail ("CF#6A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#6A");
+ }
+
+ }
+
+ [Test]
+ public void TestConvertTo ()
+ {
+ Assert.AreEqual (iconStr, (String) icoConv.ConvertTo (null,
+ CultureInfo.InvariantCulture,
+ icon, typeof (String)), "CT#1");
+
+ Assert.AreEqual (iconStr, (String) icoConv.ConvertTo (icon,
+ typeof (String)), "CT#1a");
+
+ /*byte [] newIconBytes = (byte []) icoConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, iconBytes.GetType ());
+
+ Assert.AreEqual (iconBytes.Length, newIconBytes.Length, "CT#2");
+
+ newIconBytes = (byte []) icoConv.ConvertTo (icon, iconBytes.GetType ());
+
+ Assert.AreEqual (iconBytes.Length, newIconBytes.Length, "CT#2a");
+
+
+ try {
+ icoConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Rectangle));
+ Assert.Fail ("CT#3: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue ( e is NotSupportedException, "CT#3");
+ }
+
+ try {
+ icoConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, icon.GetType ());
+ Assert.Fail ("CT#4: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#4");
+ }
+
+ try {
+ icoConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Size));
+ Assert.Fail ("CT#5: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#5");
+ }
+
+ try {
+ icoConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Bitmap));
+ Assert.Fail ("CT#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue ( e is NotSupportedException, "CT#6");
+ }
+
+ try {
+ icoConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Point));
+ Assert.Fail ("CT#7: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#7");
+ }
+
+ try {
+ icoConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Metafile));
+ Assert.Fail ("CT#8: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#8");
+ }
+
+ try {
+ icoConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Object));
+ Assert.Fail ("CT#9: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#9");
+ }
+
+ try {
+ icoConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (int));
+ Assert.Fail ("CT#10: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#10");
+ }*/
+
+
+ Assert.AreEqual (iconStr, (String) icoConvFrmTD.ConvertTo (null,
+ CultureInfo.InvariantCulture,
+ icon, typeof (String)), "CT#1A");
+
+ Assert.AreEqual (iconStr, (String) icoConvFrmTD.ConvertTo (icon,
+ typeof (String)), "CT#1aA");
+
+ /*newIconBytes = (byte []) icoConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, iconBytes.GetType ());
+
+ Assert.AreEqual (iconBytes.Length, newIconBytes.Length, "CT#2A");
+
+ newIconBytes = (byte []) icoConvFrmTD.ConvertTo (icon, iconBytes.GetType ());
+
+ Assert.AreEqual (iconBytes.Length, newIconBytes.Length, "CT#2aA");
+
+ try {
+ icoConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Rectangle));
+ Assert.Fail ("CT#3A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#3A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, icon.GetType ());
+ Assert.Fail ("CT#4A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#4A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Size));
+ Assert.Fail ("CT#5A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#5A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Bitmap));
+ Assert.Fail ("CT#6A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#6A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Point));
+ Assert.Fail ("CT#7A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#7A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Metafile));
+ Assert.Fail ("CT#8A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#8A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (Object));
+ Assert.Fail ("CT#9A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#9A");
+ }
+
+ try {
+ icoConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ icon, typeof (int));
+ Assert.Fail ("CT#10A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#10A");
+ }*/
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestImage.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestImage.cs
new file mode 100644
index 00000000000..7a77f3da225
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestImage.cs
@@ -0,0 +1,55 @@
+//
+// Image class testing unit
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jmas@softcatala.org>
+//
+// (C) 2005 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NUnit.Framework;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestImage {
+
+
+ [Test]
+ [ExpectedException (typeof (FileNotFoundException))]
+ public void FileDoesNotExists ()
+ {
+ Image img = Image.FromFile ("FileDoesNotExists.jpg");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestImageConverter.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestImageConverter.cs
new file mode 100644
index 00000000000..50752256897
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestImageConverter.cs
@@ -0,0 +1,459 @@
+//
+// Tests for System.Drawing.ImageConverter.cs
+//
+// Author:
+// Sanjay Gupta (gsanjay@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.IO;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class ImageConverterTest
+ {
+ Image image;
+ ImageConverter imgConv;
+ ImageConverter imgConvFrmTD;
+ String imageStr;
+ byte [] imageBytes;
+
+ [TearDown]
+ public void TearDown () {}
+
+ [SetUp]
+ public void SetUp ()
+ {
+ image = Image.FromFile (TestBitmap.getInFile ("bitmaps/almogaver24bits.bmp"));
+ imageStr = image.ToString ();
+
+ imgConv = new ImageConverter();
+ imgConvFrmTD = (ImageConverter) TypeDescriptor.GetConverter (image);
+
+ Stream stream = new FileStream (TestBitmap.getInFile ("bitmaps/almogaver24bits1.bmp"), FileMode.Open);
+ int length = (int) stream.Length;
+ imageBytes = new byte [length];
+
+ try {
+ if (stream.Read (imageBytes, 0, length) != length)
+ Assert.Fail ("SU#1: Read Failure");
+ } catch (Exception e) {
+ Assert.Fail ("SU#2 Exception thrown while reading. Exception is: "+e.Message);
+ } finally {
+ stream.Close ();
+ }
+
+ stream.Close ();
+
+ }
+
+ [Test]
+ public void TestCanConvertFrom ()
+ {
+ Assert.IsTrue (imgConv.CanConvertFrom (typeof (byte [])), "CCF#1");
+ Assert.IsTrue (imgConv.CanConvertFrom (null, typeof (byte [])), "CCF#1a");
+ Assert.IsTrue (imgConv.CanConvertFrom (null, imageBytes.GetType ()), "CCF#1b");
+ Assert.IsTrue (! imgConv.CanConvertFrom (null, typeof (String)), "CCF#2");
+ Assert.IsTrue (! imgConv.CanConvertFrom (null, typeof (Rectangle)), "CCF#3");
+ Assert.IsTrue (! imgConv.CanConvertFrom (null, typeof (Point)), "CCF#4");
+ Assert.IsTrue (! imgConv.CanConvertFrom (null, typeof (PointF)), "CCF#5");
+ Assert.IsTrue (! imgConv.CanConvertFrom (null, typeof (Size)), "CCF#6");
+ Assert.IsTrue (! imgConv.CanConvertFrom (null, typeof (SizeF)), "CCF#7");
+ Assert.IsTrue (! imgConv.CanConvertFrom (null, typeof (Object)), "CCF#8");
+ Assert.IsTrue (! imgConv.CanConvertFrom (null, typeof (int)), "CCF#9");
+ Assert.IsTrue (! imgConv.CanConvertFrom (null, typeof (Metafile)), "CCF#10");
+
+ Assert.IsTrue (imgConvFrmTD.CanConvertFrom (typeof (byte [])), "CCF#1A");
+ Assert.IsTrue (imgConvFrmTD.CanConvertFrom (null, typeof (byte [])), "CCF#1aA");
+ Assert.IsTrue (imgConvFrmTD.CanConvertFrom (null, imageBytes.GetType ()), "CCF#1bA");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertFrom (null, typeof (String)), "CCF#2A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertFrom (null, typeof (Rectangle)), "CCF#3A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertFrom (null, typeof (Point)), "CCF#4A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertFrom (null, typeof (PointF)), "CCF#5A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertFrom (null, typeof (Size)), "CCF#6A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertFrom (null, typeof (SizeF)), "CCF#7A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertFrom (null, typeof (Object)), "CCF#8A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertFrom (null, typeof (int)), "CCF#9A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertFrom (null, typeof (Metafile)), "CCF#10A");
+
+ }
+
+ [Test]
+ public void TestCanConvertTo ()
+ {
+ Assert.IsTrue (imgConv.CanConvertTo (typeof (String)), "CCT#1");
+ Assert.IsTrue (imgConv.CanConvertTo (null, typeof (String)), "CCT#1a");
+ Assert.IsTrue (imgConv.CanConvertTo (null, imageStr.GetType ()), "CCT#1b");
+ Assert.IsTrue (imgConv.CanConvertTo (typeof (byte [])), "CCT#2");
+ Assert.IsTrue (imgConv.CanConvertTo (null, typeof (byte [])), "CCT#2a");
+ Assert.IsTrue (imgConv.CanConvertTo (null, imageBytes.GetType ()), "CCT#2b");
+ Assert.IsTrue (! imgConv.CanConvertTo (null, typeof (Rectangle)), "CCT#3");
+ Assert.IsTrue (! imgConv.CanConvertTo (null, typeof (Point)), "CCT#4");
+ Assert.IsTrue (! imgConv.CanConvertTo (null, typeof (PointF)), "CCT#5");
+ Assert.IsTrue (! imgConv.CanConvertTo (null, typeof (Size)), "CCT#6");
+ Assert.IsTrue (! imgConv.CanConvertTo (null, typeof (SizeF)), "CCT#7");
+ Assert.IsTrue (! imgConv.CanConvertTo (null, typeof (Object)), "CCT#8");
+ Assert.IsTrue (! imgConv.CanConvertTo (null, typeof (int)), "CCT#9");
+
+ Assert.IsTrue (imgConvFrmTD.CanConvertTo (typeof (String)), "CCT#1A");
+ Assert.IsTrue (imgConvFrmTD.CanConvertTo (null, typeof (String)), "CCT#1aA");
+ Assert.IsTrue (imgConvFrmTD.CanConvertTo (null, imageStr.GetType ()), "CCT#1bA");
+ Assert.IsTrue (imgConvFrmTD.CanConvertTo (typeof (byte [])), "CCT#2A");
+ Assert.IsTrue (imgConvFrmTD.CanConvertTo (null, typeof (byte [])), "CCT#2aA");
+ Assert.IsTrue (imgConvFrmTD.CanConvertTo (null, imageBytes.GetType ()), "CCT#2bA");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertTo (null, typeof (Rectangle)), "CCT#3A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertTo (null, typeof (Point)), "CCT#4A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertTo (null, typeof (PointF)), "CCT#5A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertTo (null, typeof (Size)), "CCT#6A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertTo (null, typeof (SizeF)), "CCT#7A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertTo (null, typeof (Object)), "CCT#8A");
+ Assert.IsTrue (! imgConvFrmTD.CanConvertTo (null, typeof (int)), "CCT#9A");
+
+ }
+
+ [Test]
+ public void TestConvertFrom ()
+ {
+ Image newImage = (Image) imgConv.ConvertFrom (null, CultureInfo.InvariantCulture, imageBytes);
+
+ Assert.AreEqual (image.Height, newImage.Height, "CF#1");
+ Assert.AreEqual (image.Width, newImage.Width, "CF#1a");
+
+ try {
+ imgConv.ConvertFrom ("System.Drawing.String");
+ Assert.Fail ("CF#2: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2");
+ }
+
+ try {
+ imgConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "System.Drawing.String");
+ Assert.Fail ("CF#2a: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2a");
+ }
+
+ try {
+ imgConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Bitmap (20, 20));
+ Assert.Fail ("CF#3: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#3");
+ }
+
+ try {
+ imgConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Point (10, 10));
+ Assert.Fail ("CF#4: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#4");
+ }
+
+ try {
+ imgConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new SizeF (10, 10));
+ Assert.Fail ("CF#5: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#5");
+ }
+
+ try {
+ imgConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Object ());
+ Assert.Fail ("CF#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#6");
+ }
+
+
+ newImage = (Image) imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, imageBytes);
+
+ Assert.AreEqual (image.Height, newImage.Height, "CF#1A");
+ Assert.AreEqual (image.Width, newImage.Width, "CF#1aA");
+
+
+ try {
+ imgConvFrmTD.ConvertFrom ("System.Drawing.String");
+ Assert.Fail ("CF#2A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "System.Drawing.String");
+ Assert.Fail ("CF#2aA: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2aA");
+ }
+
+ try {
+ imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Bitmap (20, 20));
+ Assert.Fail ("CF#3A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#3A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Point (10, 10));
+ Assert.Fail ("CF#4A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#4A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new SizeF (10, 10));
+ Assert.Fail ("CF#5A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#5A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Object ());
+ Assert.Fail ("CF#6A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#6A");
+ }
+
+ }
+
+ [Test]
+ public void TestConvertTo ()
+ {
+ Assert.AreEqual (imageStr, (String) imgConv.ConvertTo (null,
+ CultureInfo.InvariantCulture,
+ image, typeof (String)), "CT#1");
+
+ Assert.AreEqual (imageStr, (String) imgConv.ConvertTo (image,
+ typeof (String)), "CT#1a");
+
+ /*byte [] newImageBytes = (byte []) imgConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, imageBytes.GetType ());
+
+ Assert.AreEqual (imageBytes.Length, newImageBytes.Length, "CT#2");
+
+ newImageBytes = (byte []) imgConv.ConvertTo (image, imageBytes.GetType ());
+
+ Assert.AreEqual (imageBytes.Length, newImageBytes.Length, "CT#2a");
+
+ try {
+ imgConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Rectangle));
+ Assert.Fail ("CT#3: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#3");
+ }
+
+ try {
+ imgConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, image.GetType ());
+ Assert.Fail ("CT#4: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#4");
+ }
+
+ try {
+ imgConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Size));
+ Assert.Fail ("CT#5: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#5");
+ }
+
+ try {
+ imgConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Bitmap));
+ Assert.Fail ("CT#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#6");
+ }
+
+ try {
+ imgConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Point));
+ Assert.Fail ("CT#7: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#7");
+ }
+
+ try {
+ imgConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Metafile));
+ Assert.Fail ("CT#8: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#8");
+ }
+
+ try {
+ imgConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Object));
+ Assert.Fail ("CT#9: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#9");
+ }
+
+ try {
+ imgConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (int));
+ Assert.Fail ("CT#10: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#10");
+ }
+ */
+
+ Assert.AreEqual (imageStr, (String) imgConvFrmTD.ConvertTo (null,
+ CultureInfo.InvariantCulture,
+ image, typeof (String)), "CT#1A");
+
+ Assert.AreEqual (imageStr, (String) imgConvFrmTD.ConvertTo (image,
+ typeof (String)), "CT#1aA");
+
+ /*newImageBytes = (byte []) imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, imageBytes.GetType ());
+
+ Assert.AreEqual ( imageBytes.Length, newImageBytes.Length, "CT#2A");
+
+ newImageBytes = (byte []) imgConvFrmTD.ConvertTo (image, imageBytes.GetType ());
+
+ Assert.AreEqual (imageBytes.Length, newImageBytes.Length, "CT#2aA");
+
+ try {
+ imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Rectangle));
+ Assert.Fail ("CT#3A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#3A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, image.GetType ());
+ Assert.Fail ("CT#4A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#4A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Size));
+ Assert.Fail ("CT#5A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#5A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Bitmap));
+ Assert.Fail ("CT#6A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#6A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Point));
+ Assert.Fail ("CT#7A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#7A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Metafile));
+ Assert.Fail ("CT#8A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#8A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (Object));
+ Assert.Fail ("CT#9A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#9A");
+ }
+
+ try {
+ imgConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ image, typeof (int));
+ Assert.Fail ("CT#10A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#10A");
+ }*/
+ }
+
+
+ [Test]
+ public void TestGetPropertiesSupported ()
+ {
+ Assert.IsTrue (imgConv.GetPropertiesSupported (), "GPS#1");
+ Assert.IsTrue (imgConv.GetPropertiesSupported (null), "GPS#2");
+ }
+
+ [Test]
+ public void TestGetProperties ()
+ {
+ PropertyDescriptorCollection propsColl;
+
+ propsColl = imgConv.GetProperties (null, image, null);
+ Assert.AreEqual (13, propsColl.Count, "GP1#1");
+
+ propsColl = imgConv.GetProperties (null, image);
+ Assert.AreEqual (6, propsColl.Count, "GP1#2");
+
+ propsColl = imgConv.GetProperties (image);
+ Assert.AreEqual (6, propsColl.Count, "GP1#3");
+
+ propsColl = TypeDescriptor.GetProperties (typeof (Image));
+ Assert.AreEqual (13, propsColl.Count, "GP1#4");
+
+ propsColl = imgConvFrmTD.GetProperties (null, image, null);
+ Assert.AreEqual (13, propsColl.Count, "GP1#1A");
+
+ propsColl = imgConvFrmTD.GetProperties (null, image);
+ Assert.AreEqual (6, propsColl.Count, "GP1#2A");
+
+ propsColl = imgConvFrmTD.GetProperties (image);
+ Assert.AreEqual (6, propsColl.Count, "GP1#3A");
+
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestImageFormatConverter.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestImageFormatConverter.cs
new file mode 100644
index 00000000000..22ad5f3e00d
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestImageFormatConverter.cs
@@ -0,0 +1,305 @@
+//
+// Tests for System.Drawing.ImageFormatConverter.cs
+//
+// Author:
+// Sanjay Gupta (gsanjay@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Collections;
+using System.ComponentModel;
+using System.Globalization;
+using System.IO;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class ImageFormatConverterTest
+ {
+ ImageFormat imageFmt;
+ ImageFormatConverter imgFmtConv;
+ ImageFormatConverter imgFmtConvFrmTD;
+ String imageFmtStr;
+
+ [TearDown]
+ public void TearDown () {}
+
+ [SetUp]
+ public void SetUp ()
+ {
+ imageFmt = ImageFormat.Bmp;
+ imageFmtStr = imageFmt.ToString ();
+
+ imgFmtConv = new ImageFormatConverter();
+ imgFmtConvFrmTD = (ImageFormatConverter) TypeDescriptor.GetConverter (imageFmt);
+ }
+
+ [Test]
+ public void TestCanConvertFrom ()
+ {
+ Assert.IsTrue (imgFmtConv.CanConvertFrom (typeof (String)), "CCF#1");
+ Assert.IsTrue (imgFmtConv.CanConvertFrom (null, typeof (String)), "CCF#1a");
+ Assert.IsTrue (! imgFmtConv.CanConvertFrom (null, typeof (ImageFormat)), "CCF#2");
+ Assert.IsTrue (! imgFmtConv.CanConvertFrom (null, typeof (Guid)), "CCF#3");
+ Assert.IsTrue (! imgFmtConv.CanConvertFrom (null, typeof (Object)), "CCF#4");
+ Assert.IsTrue (! imgFmtConv.CanConvertFrom (null, typeof (int)), "CCF#5");
+
+ Assert.IsTrue (imgFmtConvFrmTD.CanConvertFrom (typeof (String)), "CCF#1A");
+ Assert.IsTrue (imgFmtConvFrmTD.CanConvertFrom (null, typeof (String)), "CCF#1aA");
+ Assert.IsTrue (! imgFmtConvFrmTD.CanConvertFrom (null, typeof (ImageFormat)), "CCF#2A");
+ Assert.IsTrue (! imgFmtConvFrmTD.CanConvertFrom (null, typeof (Guid)), "CCF#3A");
+ Assert.IsTrue (! imgFmtConvFrmTD.CanConvertFrom (null, typeof (Object)), "CCF#4A");
+ Assert.IsTrue (! imgFmtConvFrmTD.CanConvertFrom (null, typeof (int)), "CCF#5A");
+
+ }
+
+ [Test]
+ public void TestCanConvertTo ()
+ {
+ Assert.IsTrue (imgFmtConv.CanConvertTo (typeof (String)), "CCT#1");
+ Assert.IsTrue (imgFmtConv.CanConvertTo (null, typeof (String)), "CCT#1a");
+ Assert.IsTrue (! imgFmtConv.CanConvertTo (null, typeof (ImageFormat)), "CCT#2");
+ Assert.IsTrue (! imgFmtConv.CanConvertTo (null, typeof (Guid)), "CCT#3");
+ Assert.IsTrue (! imgFmtConv.CanConvertTo (null, typeof (Object)), "CCT#4");
+ Assert.IsTrue (! imgFmtConv.CanConvertTo (null, typeof (int)), "CCT#5");
+
+ Assert.IsTrue (imgFmtConvFrmTD.CanConvertTo (typeof (String)), "CCT#1A");
+ Assert.IsTrue (imgFmtConvFrmTD.CanConvertTo (null, typeof (String)), "CCT#1aA");
+ Assert.IsTrue (! imgFmtConvFrmTD.CanConvertTo (null, typeof (ImageFormat)), "CCT#2A");
+ Assert.IsTrue (! imgFmtConvFrmTD.CanConvertTo (null, typeof (Guid)), "CCT#3A");
+ Assert.IsTrue (! imgFmtConvFrmTD.CanConvertTo (null, typeof (Object)), "CCT#4A");
+ Assert.IsTrue (! imgFmtConvFrmTD.CanConvertTo (null, typeof (int)), "CCT#5A");
+ }
+
+ [Test]
+ public void TestConvertFrom ()
+ {
+ Assert.AreEqual (imageFmt, (ImageFormat) imgFmtConv.ConvertFrom (null,
+ CultureInfo.InvariantCulture,
+ ImageFormat.Bmp.ToString ()), "CF#1");
+
+ try {
+ imgFmtConv.ConvertFrom ("System.Drawing.String");
+ Assert.Fail ("CF#2: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2");
+ }
+
+ try {
+ imgFmtConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "System.Drawing.String");
+ Assert.Fail ("CF#2a: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2a");
+ }
+
+ try {
+ imgFmtConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ ImageFormat.Bmp);
+ Assert.Fail ("CF#3: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#3");
+ }
+
+ try {
+ imgFmtConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ ImageFormat.Bmp.Guid);
+ Assert.Fail ("CF#4: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#4");
+ }
+
+ try {
+ imgFmtConv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Object ());
+ Assert.Fail ("CF#5: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#5");
+ }
+
+ try {
+ imgFmtConv.ConvertFrom (null, CultureInfo.InvariantCulture, 10);
+ Assert.Fail ("CF#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#6");
+ }
+
+
+ Assert.AreEqual (imageFmt, (ImageFormat) imgFmtConvFrmTD.ConvertFrom (null,
+ CultureInfo.InvariantCulture,
+ ImageFormat.Bmp.ToString ()), "CF#1A");
+
+ try {
+ imgFmtConvFrmTD.ConvertFrom ("System.Drawing.String");
+ Assert.Fail ("CF#2A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2A");
+ }
+
+ try {
+ imgFmtConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "System.Drawing.String");
+ Assert.Fail ("CF#2aA: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#2aA");
+ }
+
+ try {
+ imgFmtConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ ImageFormat.Bmp);
+ Assert.Fail ("CF#3A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#3A");
+ }
+
+ try {
+ imgFmtConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ ImageFormat.Bmp.Guid);
+ Assert.Fail ("CF#4A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#4A");
+ }
+
+ try {
+ imgFmtConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Object ());
+ Assert.Fail ("CF#5A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#5A");
+ }
+
+ try {
+ imgFmtConvFrmTD.ConvertFrom (null, CultureInfo.InvariantCulture, 10);
+ Assert.Fail ("CF#6A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#6A");
+ }
+ }
+
+ [Test]
+ public void TestConvertTo ()
+ {
+ Assert.AreEqual (imageFmtStr, (String) imgFmtConv.ConvertTo (null,
+ CultureInfo.InvariantCulture,
+ imageFmt, typeof (String)), "CT#1");
+
+ Assert.AreEqual (imageFmtStr, (String) imgFmtConv.ConvertTo (imageFmt,
+ typeof (String)), "CT#1a");
+
+ try {
+ imgFmtConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ imageFmt, typeof (ImageFormat));
+ Assert.Fail ("CT#2: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#2");
+ }
+
+ try {
+ imgFmtConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ imageFmt, typeof (Guid));
+ Assert.Fail ("CT#2a: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#2a");
+ }
+
+ try {
+ imgFmtConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ imageFmt, typeof (Object));
+ Assert.Fail ("CT#3: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#3");
+ }
+
+ try {
+ imgFmtConv.ConvertTo (null, CultureInfo.InvariantCulture,
+ imageFmt, typeof (int));
+ Assert.Fail ("CT#4: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#4");
+ }
+
+
+ Assert.AreEqual (imageFmtStr, (String) imgFmtConvFrmTD.ConvertTo (null,
+ CultureInfo.InvariantCulture,
+ imageFmt, typeof (String)), "CT#1A");
+
+ Assert.AreEqual (imageFmtStr, (String) imgFmtConvFrmTD.ConvertTo (imageFmt,
+ typeof (String)), "CT#1aA");
+
+ try {
+ imgFmtConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ imageFmt, typeof (ImageFormat));
+ Assert.Fail ("CT#2A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#2A");
+ }
+
+ try {
+ imgFmtConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ imageFmt, typeof (Guid));
+ Assert.Fail ("CT#2aA: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#2aA");
+ }
+
+ try {
+ imgFmtConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ imageFmt, typeof (Object));
+ Assert.Fail ("CT#3A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#3A");
+ }
+
+ try {
+ imgFmtConvFrmTD.ConvertTo (null, CultureInfo.InvariantCulture,
+ imageFmt, typeof (int));
+ Assert.Fail ("CT#4A: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#4A");
+ }
+ }
+
+
+ /*[Test]
+ public void TestGetStandardValuesSupported ()
+ {
+ Assert.IsTrue (imgFmtConv.GetPropertiesSupported (), "GSVS#1");
+ Assert.IsTrue (imgFmtConv.GetPropertiesSupported (null), "GSVS#2");
+ }
+
+ [Test]
+ public void TestGetStandardValues ()
+ {
+ //MONO TODO
+ }*/
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestPens.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestPens.cs
new file mode 100644
index 00000000000..00172e0b1ec
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestPens.cs
@@ -0,0 +1,2197 @@
+// Tests for System.Drawing.Pens.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class PensTest : Assertion
+ {
+ [SetUp]
+ public void SetUp () { }
+
+ [TearDown]
+ public void TearDown () { }
+
+ [Test]
+ public void TestEquals ()
+ {
+ Pen pen1 = Pens.Blue;
+ Pen pen2 = Pens.Blue;
+
+ AssertEquals ("Equals", true, pen1.Equals (pen2));
+ }
+
+ [Test]
+ public void TestAliceBlue ()
+ {
+ Pen pen = Pens.AliceBlue;
+ AssertEquals ("P1#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P1#2", pen.Color, Color.AliceBlue);
+
+ try {
+ pen.Color = Color.AliceBlue;
+ Fail ("P1#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P1#3", true);
+ }
+ }
+
+ [Test]
+ public void TestAntiqueWhite ()
+ {
+ Pen pen = Pens.AntiqueWhite;
+ AssertEquals ("P2#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P2#2", pen.Color, Color.AntiqueWhite);
+
+ try {
+ pen.Color = Color.AntiqueWhite;
+ Fail ("P2#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P2#3", true);
+ }
+ }
+
+ [Test]
+ public void TestAqua ()
+ {
+ Pen pen = Pens.Aqua;
+ AssertEquals ("P3#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P3#2", pen.Color, Color.Aqua);
+
+ try {
+ pen.Color = Color.Aqua;
+ Fail ("P3#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P3#3", true);
+ }
+ }
+
+ [Test]
+ public void TestAquamarine ()
+ {
+ Pen pen = Pens.Aquamarine;
+ AssertEquals ("P4#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P4#2", pen.Color, Color.Aquamarine);
+
+ try {
+ pen.Color = Color.Aquamarine;
+ Fail ("P4#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P4#3", true);
+ }
+ }
+
+ [Test]
+ public void TestAzure ()
+ {
+ Pen pen = Pens.Azure;
+ AssertEquals ("P5#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P5#2", pen.Color, Color.Azure);
+
+ try {
+ pen.Color = Color.Azure;
+ Fail ("P5#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P5#3", true);
+ }
+ }
+
+ [Test]
+ public void TestBeige ()
+ {
+ Pen pen = Pens.Beige;
+ AssertEquals ("P6#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P6#2", pen.Color, Color.Beige);
+
+ try {
+ pen.Color = Color.Beige;
+ Fail ("P6#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P6#3", true);
+ }
+ }
+
+ [Test]
+ public void TestBisque ()
+ {
+ Pen pen = Pens.Bisque;
+ AssertEquals ("P7#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P7#2", pen.Color, Color.Bisque);
+
+ try {
+ pen.Color = Color.Bisque;
+ Fail ("P7#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P7#3", true);
+ }
+ }
+
+ [Test]
+ public void TestBlack ()
+ {
+ Pen pen = Pens.Black;
+ AssertEquals ("P8#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P8#2", pen.Color, Color.Black);
+
+ try {
+ pen.Color = Color.Black;
+ Fail ("P8#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P8#3", true);
+ }
+ }
+
+ [Test]
+ public void TestBlanchedAlmond ()
+ {
+ Pen pen = Pens.BlanchedAlmond;
+ AssertEquals ("P9#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P9#2", pen.Color, Color.BlanchedAlmond);
+
+ try {
+ pen.Color = Color.BlanchedAlmond;
+ Fail ("P9#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P9#3", true);
+ }
+ }
+
+ [Test]
+ public void TestBlue ()
+ {
+ Pen pen = Pens.Blue;
+ AssertEquals ("P10#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P10#2", pen.Color, Color.Blue);
+
+ try {
+ pen.Color = Color.Blue;
+ Fail ("P10#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P10#3", true);
+ }
+ }
+
+ [Test]
+ public void TestBlueViolet ()
+ {
+ Pen pen = Pens.BlueViolet;
+ AssertEquals ("P11#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P11#2", pen.Color, Color.BlueViolet);
+
+ try {
+ pen.Color = Color.BlueViolet;
+ Fail ("P11#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P11#3", true);
+ }
+ }
+
+ [Test]
+ public void TestBrown ()
+ {
+ Pen pen = Pens.Brown;
+ AssertEquals ("P12#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P12#2", pen.Color, Color.Brown);
+
+ try {
+ pen.Color = Color.Brown;
+ Fail ("P12#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P12#3", true);
+ }
+ }
+
+ [Test]
+ public void TestBurlyWood ()
+ {
+ Pen pen = Pens.BurlyWood;
+ AssertEquals ("P13#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P13#2", pen.Color, Color.BurlyWood);
+
+ try {
+ pen.Color = Color.BurlyWood;
+ Fail ("P13#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P13#3", true);
+ }
+ }
+
+ [Test]
+ public void TestCadetBlue ()
+ {
+ Pen pen = Pens.CadetBlue;
+ AssertEquals ("P14#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P14#2", pen.Color, Color.CadetBlue);
+
+ try {
+ pen.Color = Color.CadetBlue;
+ Fail ("P14#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P14#3", true);
+ }
+ }
+
+ [Test]
+ public void TestChartreuse ()
+ {
+ Pen pen = Pens.Chartreuse;
+ AssertEquals ("P15#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P15#2", pen.Color, Color.Chartreuse);
+
+ try {
+ pen.Color = Color.Chartreuse;
+ Fail ("P15#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P15#3", true);
+ }
+ }
+
+ [Test]
+ public void TestChocolate ()
+ {
+ Pen pen = Pens.Chocolate;
+ AssertEquals ("P16#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P16#2", pen.Color, Color.Chocolate);
+
+ try {
+ pen.Color = Color.Chocolate;
+ Fail ("P16#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P16#3", true);
+ }
+ }
+
+ [Test]
+ public void TestCoral ()
+ {
+ Pen pen = Pens.Coral;
+ AssertEquals ("P17#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P17#2", pen.Color, Color.Coral);
+
+ try {
+ pen.Color = Color.Coral;
+ Fail ("P17#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P17#3", true);
+ }
+ }
+
+ [Test]
+ public void TestCornflowerBlue ()
+ {
+ Pen pen = Pens.CornflowerBlue;
+ AssertEquals ("P18#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P18#2", pen.Color, Color.CornflowerBlue);
+
+ try {
+ pen.Color = Color.CornflowerBlue;
+ Fail ("P18#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P18#3", true);
+ }
+ }
+
+ [Test]
+ public void TestCornsilk ()
+ {
+ Pen pen = Pens.Cornsilk;
+ AssertEquals ("P19#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P19#2", pen.Color, Color.Cornsilk);
+
+ try {
+ pen.Color = Color.Cornsilk;
+ Fail ("P19#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P19#3", true);
+ }
+ }
+
+ [Test]
+ public void TestCrimson ()
+ {
+ Pen pen = Pens.Crimson;
+ AssertEquals ("P20#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P20#2", pen.Color, Color.Crimson);
+
+ try {
+ pen.Color = Color.Crimson;
+ Fail ("P20#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P20#3", true);
+ }
+ }
+
+ [Test]
+ public void TestCyan ()
+ {
+ Pen pen = Pens.Cyan;
+ AssertEquals ("P21#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P21#2", pen.Color, Color.Cyan);
+
+ try {
+ pen.Color = Color.Cyan;
+ Fail ("P21#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P21#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkBlue ()
+ {
+ Pen pen = Pens.DarkBlue;
+ AssertEquals ("P22#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P22#2", pen.Color, Color.DarkBlue);
+
+ try {
+ pen.Color = Color.DarkBlue;
+ Fail ("P22#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P22#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkCyan ()
+ {
+ Pen pen = Pens.DarkCyan;
+ AssertEquals ("P23#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P23#2", pen.Color, Color.DarkCyan);
+
+ try {
+ pen.Color = Color.DarkCyan;
+ Fail ("P23#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P23#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkGoldenrod ()
+ {
+ Pen pen = Pens.DarkGoldenrod;
+ AssertEquals ("P24#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P24#2", pen.Color, Color.DarkGoldenrod);
+
+ try {
+ pen.Color = Color.DarkGoldenrod;
+ Fail ("P24#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P24#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkGray ()
+ {
+ Pen pen = Pens.DarkGray;
+ AssertEquals ("P25#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P25#2", pen.Color, Color.DarkGray);
+
+ try {
+ pen.Color = Color.DarkGray;
+ Fail ("P25#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P25#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkGreen ()
+ {
+ Pen pen = Pens.DarkGreen;
+ AssertEquals ("P26#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P26#2", pen.Color, Color.DarkGreen);
+
+ try {
+ pen.Color = Color.DarkGreen;
+ Fail ("P26#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P26#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkKhaki ()
+ {
+ Pen pen = Pens.DarkKhaki;
+ AssertEquals ("P27#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P27#2", pen.Color, Color.DarkKhaki);
+
+ try {
+ pen.Color = Color.DarkKhaki;
+ Fail ("P27#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P27#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkMagenta ()
+ {
+ Pen pen = Pens.DarkMagenta;
+ AssertEquals ("P28#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P28#2", pen.Color, Color.DarkMagenta);
+
+ try {
+ pen.Color = Color.DarkMagenta;
+ Fail ("P28#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P28#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkOliveGreen ()
+ {
+ Pen pen = Pens.DarkOliveGreen;
+ AssertEquals ("P29#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P29#2", pen.Color, Color.DarkOliveGreen);
+
+ try {
+ pen.Color = Color.DarkOliveGreen;
+ Fail ("P29#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P29#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkOrange ()
+ {
+ Pen pen = Pens.DarkOrange;
+ AssertEquals ("P30#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P30#2", pen.Color, Color.DarkOrange);
+
+ try {
+ pen.Color = Color.DarkOrange;
+ Fail ("P30#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P30#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkOrchid ()
+ {
+ Pen pen = Pens.DarkOrchid;
+ AssertEquals ("P31#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P31#2", pen.Color, Color.DarkOrchid);
+
+ try {
+ pen.Color = Color.DarkOrchid;
+ Fail ("P31#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P31#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkRed ()
+ {
+ Pen pen = Pens.DarkRed;
+ AssertEquals ("P32#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P32#2", pen.Color, Color.DarkRed);
+
+ try {
+ pen.Color = Color.DarkRed;
+ Fail ("P32#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P32#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkSalmon ()
+ {
+ Pen pen = Pens.DarkSalmon;
+ AssertEquals ("P33#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P33#2", pen.Color, Color.DarkSalmon);
+
+ try {
+ pen.Color = Color.DarkSalmon;
+ Fail ("P33#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P33#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkSeaGreen ()
+ {
+ Pen pen = Pens.DarkSeaGreen;
+ AssertEquals ("P34#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P34#2", pen.Color, Color.DarkSeaGreen);
+
+ try {
+ pen.Color = Color.DarkSeaGreen;
+ Fail ("P34#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P34#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkSlateBlue ()
+ {
+ Pen pen = Pens.DarkSlateBlue;
+ AssertEquals ("P35#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P35#2", pen.Color, Color.DarkSlateBlue);
+
+ try {
+ pen.Color = Color.DarkSlateBlue;
+ Fail ("P35#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P35#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkSlateGray ()
+ {
+ Pen pen = Pens.DarkSlateGray;
+ AssertEquals ("P36#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P36#2", pen.Color, Color.DarkSlateGray);
+
+ try {
+ pen.Color = Color.DarkSlateGray;
+ Fail ("P36#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P36#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkTurquoise ()
+ {
+ Pen pen = Pens.DarkTurquoise;
+ AssertEquals ("P37#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P37#2", pen.Color, Color.DarkTurquoise);
+
+ try {
+ pen.Color = Color.DarkTurquoise;
+ Fail ("P37#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P37#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDarkViolet ()
+ {
+ Pen pen = Pens.DarkViolet;
+ AssertEquals ("P38#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P38#2", pen.Color, Color.DarkViolet);
+
+ try {
+ pen.Color = Color.DarkViolet;
+ Fail ("P38#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P38#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDeepPink ()
+ {
+ Pen pen = Pens.DeepPink;
+ AssertEquals ("P39#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P39#2", pen.Color, Color.DeepPink);
+
+ try {
+ pen.Color = Color.DeepPink;
+ Fail ("P39#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P39#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDeepSkyBlue ()
+ {
+ Pen pen = Pens.DeepSkyBlue;
+ AssertEquals ("P40#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P40#2", pen.Color, Color.DeepSkyBlue);
+
+ try {
+ pen.Color = Color.DeepSkyBlue;
+ Fail ("P40#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P40#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDimGray ()
+ {
+ Pen pen = Pens.DimGray;
+ AssertEquals ("P41#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P41#2", pen.Color, Color.DimGray);
+
+ try {
+ pen.Color = Color.DimGray;
+ Fail ("P41#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P41#3", true);
+ }
+ }
+
+ [Test]
+ public void TestDodgerBlue ()
+ {
+ Pen pen = Pens.DodgerBlue;
+ AssertEquals ("P42#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P42#2", pen.Color, Color.DodgerBlue);
+
+ try {
+ pen.Color = Color.DodgerBlue;
+ Fail ("P42#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P42#3", true);
+ }
+ }
+
+ [Test]
+ public void TestFirebrick ()
+ {
+ Pen pen = Pens.Firebrick;
+ AssertEquals ("P43#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P43#2", pen.Color, Color.Firebrick);
+
+ try {
+ pen.Color = Color.Firebrick;
+ Fail ("P43#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P43#3", true);
+ }
+ }
+
+ [Test]
+ public void TestFloralWhite ()
+ {
+ Pen pen = Pens.FloralWhite;
+ AssertEquals ("P44#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P44#2", pen.Color, Color.FloralWhite);
+
+ try {
+ pen.Color = Color.FloralWhite;
+ Fail ("P44#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P44#3", true);
+ }
+ }
+
+ [Test]
+ public void TestForestGreen ()
+ {
+ Pen pen = Pens.ForestGreen;
+ AssertEquals ("P45#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P45#2", pen.Color, Color.ForestGreen);
+
+ try {
+ pen.Color = Color.ForestGreen;
+ Fail ("P45#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P45#3", true);
+ }
+ }
+
+ [Test]
+ public void TestFuchsia ()
+ {
+ Pen pen = Pens.Fuchsia;
+ AssertEquals ("P46#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P46#2", pen.Color, Color.Fuchsia);
+
+ try {
+ pen.Color = Color.Fuchsia;
+ Fail ("P46#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P46#3", true);
+ }
+ }
+
+ [Test]
+ public void TestGainsboro ()
+ {
+ Pen pen = Pens.Gainsboro;
+ AssertEquals ("P47#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P47#2", pen.Color, Color.Gainsboro);
+
+ try {
+ pen.Color = Color.Gainsboro;
+ Fail ("P47#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P47#3", true);
+ }
+ }
+
+ [Test]
+ public void TestGhostWhite ()
+ {
+ Pen pen = Pens.GhostWhite;
+ AssertEquals ("P48#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P48#2", pen.Color, Color.GhostWhite);
+
+ try {
+ pen.Color = Color.GhostWhite;
+ Fail ("P48#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P48#3", true);
+ }
+ }
+
+ [Test]
+ public void TestGold ()
+ {
+ Pen pen = Pens.Gold;
+ AssertEquals ("P49#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P49#2", pen.Color, Color.Gold);
+
+ try {
+ pen.Color = Color.Gold;
+ Fail ("P49#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P49#3", true);
+ }
+ }
+
+ [Test]
+ public void TestGoldenrod ()
+ {
+ Pen pen = Pens.Goldenrod;
+ AssertEquals ("P50#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P50#2", pen.Color, Color.Goldenrod);
+
+ try {
+ pen.Color = Color.Goldenrod;
+ Fail ("P50#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P50#3", true);
+ }
+ }
+
+ [Test]
+ public void TestGray ()
+ {
+ Pen pen = Pens.Gray;
+ AssertEquals ("P51#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P51#2", pen.Color, Color.Gray);
+
+ try {
+ pen.Color = Color.Gray;
+ Fail ("P51#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P51#3", true);
+ }
+ }
+
+ [Test]
+ public void TestGreen ()
+ {
+ Pen pen = Pens.Green;
+ AssertEquals ("P52#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P52#2", pen.Color, Color.Green);
+
+ try {
+ pen.Color = Color.Green;
+ Fail ("P52#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P52#3", true);
+ }
+ }
+
+ [Test]
+ public void TestGreenYellow ()
+ {
+ Pen pen = Pens.GreenYellow;
+ AssertEquals ("P53#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P53#2", pen.Color, Color.GreenYellow);
+
+ try {
+ pen.Color = Color.GreenYellow;
+ Fail ("P53#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P53#3", true);
+ }
+ }
+
+ [Test]
+ public void TestHoneydew ()
+ {
+ Pen pen = Pens.Honeydew;
+ AssertEquals ("P54#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P54#2", pen.Color, Color.Honeydew);
+
+ try {
+ pen.Color = Color.Honeydew;
+ Fail ("P54#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P54#3", true);
+ }
+ }
+
+ [Test]
+ public void TestHotPink ()
+ {
+ Pen pen = Pens.HotPink;
+ AssertEquals ("P55#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P55#2", pen.Color, Color.HotPink);
+
+ try {
+ pen.Color = Color.HotPink;
+ Fail ("P55#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P55#3", true);
+ }
+ }
+
+ [Test]
+ public void TestIndianRed ()
+ {
+ Pen pen = Pens.IndianRed;
+ AssertEquals ("P56#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P56#2", pen.Color, Color.IndianRed);
+
+ try {
+ pen.Color = Color.IndianRed;
+ Fail ("P56#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P56#3", true);
+ }
+ }
+
+ [Test]
+ public void TestIndigo ()
+ {
+ Pen pen = Pens.Indigo;
+ AssertEquals ("P57#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P57#2", pen.Color, Color.Indigo);
+
+ try {
+ pen.Color = Color.Indigo;
+ Fail ("P57#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P57#3", true);
+ }
+ }
+
+ [Test]
+ public void TestIvory ()
+ {
+ Pen pen = Pens.Ivory;
+ AssertEquals ("P58#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P58#2", pen.Color, Color.Ivory);
+
+ try {
+ pen.Color = Color.Ivory;
+ Fail ("P58#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P58#3", true);
+ }
+ }
+
+ [Test]
+ public void TestKhaki ()
+ {
+ Pen pen = Pens.Khaki;
+ AssertEquals ("P59#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P59#2", pen.Color, Color.Khaki);
+
+ try {
+ pen.Color = Color.Khaki;
+ Fail ("P59#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P59#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLavender ()
+ {
+ Pen pen = Pens.Lavender;
+ AssertEquals ("P60#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P60#2", pen.Color, Color.Lavender);
+
+ try {
+ pen.Color = Color.Lavender;
+ Fail ("P60#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P60#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLavenderBlush ()
+ {
+ Pen pen = Pens.LavenderBlush;
+ AssertEquals ("P61#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P61#2", pen.Color, Color.LavenderBlush);
+
+ try {
+ pen.Color = Color.LavenderBlush;
+ Fail ("P61#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P61#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLawnGreen ()
+ {
+ Pen pen = Pens.LawnGreen;
+ AssertEquals ("P62#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P62#2", pen.Color, Color.LawnGreen);
+
+ try {
+ pen.Color = Color.LawnGreen;
+ Fail ("P62#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P62#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLemonChiffon ()
+ {
+ Pen pen = Pens.LemonChiffon;
+ AssertEquals ("P63#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P63#2", pen.Color, Color.LemonChiffon);
+
+ try {
+ pen.Color = Color.LemonChiffon;
+ Fail ("P63#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P63#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightBlue ()
+ {
+ Pen pen = Pens.LightBlue;
+ AssertEquals ("P64#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P64#2", pen.Color, Color.LightBlue);
+
+ try {
+ pen.Color = Color.LightBlue;
+ Fail ("P64#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P64#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightCoral ()
+ {
+ Pen pen = Pens.LightCoral;
+ AssertEquals ("P65#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P65#2", pen.Color, Color.LightCoral);
+
+ try {
+ pen.Color = Color.LightCoral;
+ Fail ("P65#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P65#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightCyan ()
+ {
+ Pen pen = Pens.LightCyan;
+ AssertEquals ("P66#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P66#2", pen.Color, Color.LightCyan);
+
+ try {
+ pen.Color = Color.LightCyan;
+ Fail ("P66#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P66#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightGoldenrodYellow ()
+ {
+ Pen pen = Pens.LightGoldenrodYellow;
+ AssertEquals ("P67#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P67#2", pen.Color, Color.LightGoldenrodYellow);
+
+ try {
+ pen.Color = Color.LightGoldenrodYellow;
+ Fail ("P67#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P67#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightGray ()
+ {
+ Pen pen = Pens.LightGray;
+ AssertEquals ("P68#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P68#2", pen.Color, Color.LightGray);
+
+ try {
+ pen.Color = Color.LightGray;
+ Fail ("P68#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P68#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightGreen ()
+ {
+ Pen pen = Pens.LightGreen;
+ AssertEquals ("P69#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P69#2", pen.Color, Color.LightGreen);
+
+ try {
+ pen.Color = Color.LightGreen;
+ Fail ("P69#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P69#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightPink ()
+ {
+ Pen pen = Pens.LightPink;
+ AssertEquals ("P70#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P70#2", pen.Color, Color.LightPink);
+
+ try {
+ pen.Color = Color.LightPink;
+ Fail ("P70#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P70#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightSalmon ()
+ {
+ Pen pen = Pens.LightSalmon;
+ AssertEquals ("P71#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P71#2", pen.Color, Color.LightSalmon);
+
+ try {
+ pen.Color = Color.LightSalmon;
+ Fail ("P71#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P71#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightSeaGreen ()
+ {
+ Pen pen = Pens.LightSeaGreen;
+ AssertEquals ("P72#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P72#2", pen.Color, Color.LightSeaGreen);
+
+ try {
+ pen.Color = Color.LightSeaGreen;
+ Fail ("P72#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P72#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightSkyBlue ()
+ {
+ Pen pen = Pens.LightSkyBlue;
+ AssertEquals ("P73#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P73#2", pen.Color, Color.LightSkyBlue);
+
+ try {
+ pen.Color = Color.LightSkyBlue;
+ Fail ("P73#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P73#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightSlateGray ()
+ {
+ Pen pen = Pens.LightSlateGray;
+ AssertEquals ("P74#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P74#2", pen.Color, Color.LightSlateGray);
+
+ try {
+ pen.Color = Color.LightSlateGray;
+ Fail ("P74#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P74#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightSteelBlue ()
+ {
+ Pen pen = Pens.LightSteelBlue;
+ AssertEquals ("P75#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P75#2", pen.Color, Color.LightSteelBlue);
+
+ try {
+ pen.Color = Color.LightSteelBlue;
+ Fail ("P75#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P75#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLightYellow ()
+ {
+ Pen pen = Pens.LightYellow;
+ AssertEquals ("P76#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P76#2", pen.Color, Color.LightYellow);
+
+ try {
+ pen.Color = Color.LightYellow;
+ Fail ("P76#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P76#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLime ()
+ {
+ Pen pen = Pens.Lime;
+ AssertEquals ("P77#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P77#2", pen.Color, Color.Lime);
+
+ try {
+ pen.Color = Color.Lime;
+ Fail ("P77#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P77#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLimeGreen ()
+ {
+ Pen pen = Pens.LimeGreen;
+ AssertEquals ("P78#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P78#2", pen.Color, Color.LimeGreen);
+
+ try {
+ pen.Color = Color.LimeGreen;
+ Fail ("P78#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P78#3", true);
+ }
+ }
+
+ [Test]
+ public void TestLinen ()
+ {
+ Pen pen = Pens.Linen;
+ AssertEquals ("P79#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P79#2", pen.Color, Color.Linen);
+
+ try {
+ pen.Color = Color.Linen;
+ Fail ("P79#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P79#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMagenta ()
+ {
+ Pen pen = Pens.Magenta;
+ AssertEquals ("P80#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P80#2", pen.Color, Color.Magenta);
+
+ try {
+ pen.Color = Color.Magenta;
+ Fail ("P80#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P80#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMaroon ()
+ {
+ Pen pen = Pens.Maroon;
+ AssertEquals ("P81#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P81#2", pen.Color, Color.Maroon);
+
+ try {
+ pen.Color = Color.Maroon;
+ Fail ("P81#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P81#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMediumAquamarine ()
+ {
+ Pen pen = Pens.MediumAquamarine;
+ AssertEquals ("P82#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P82#2", pen.Color, Color.MediumAquamarine);
+
+ try {
+ pen.Color = Color.MediumAquamarine;
+ Fail ("P82#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P82#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMediumBlue ()
+ {
+ Pen pen = Pens.MediumBlue;
+ AssertEquals ("P83#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P83#2", pen.Color, Color.MediumBlue);
+
+ try {
+ pen.Color = Color.MediumBlue;
+ Fail ("P83#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P83#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMediumOrchid ()
+ {
+ Pen pen = Pens.MediumOrchid;
+ AssertEquals ("P84#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P84#2", pen.Color, Color.MediumOrchid);
+
+ try {
+ pen.Color = Color.MediumOrchid;
+ Fail ("P84#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P84#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMediumPurple ()
+ {
+ Pen pen = Pens.MediumPurple;
+ AssertEquals ("P85#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P85#2", pen.Color, Color.MediumPurple);
+
+ try {
+ pen.Color = Color.MediumPurple;
+ Fail ("P85#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P85#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMediumSeaGreen ()
+ {
+ Pen pen = Pens.MediumSeaGreen;
+ AssertEquals ("P86#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P86#2", pen.Color, Color.MediumSeaGreen);
+
+ try {
+ pen.Color = Color.MediumSeaGreen;
+ Fail ("P86#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P86#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMediumSlateBlue ()
+ {
+ Pen pen = Pens.MediumSlateBlue;
+ AssertEquals ("P87#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P87#2", pen.Color, Color.MediumSlateBlue);
+
+ try {
+ pen.Color = Color.MediumSlateBlue;
+ Fail ("P87#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P87#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMediumSpringGreen ()
+ {
+ Pen pen = Pens.MediumSpringGreen;
+ AssertEquals ("P88#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P88#2", pen.Color, Color.MediumSpringGreen);
+
+ try {
+ pen.Color = Color.MediumSpringGreen;
+ Fail ("P88#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P88#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMediumTurquoise ()
+ {
+ Pen pen = Pens.MediumTurquoise;
+ AssertEquals ("P89#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P89#2", pen.Color, Color.MediumTurquoise);
+
+ try {
+ pen.Color = Color.MediumTurquoise;
+ Fail ("P89#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P89#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMediumVioletRed ()
+ {
+ Pen pen = Pens.MediumVioletRed;
+ AssertEquals ("P90#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P90#2", pen.Color, Color.MediumVioletRed);
+
+ try {
+ pen.Color = Color.MediumVioletRed;
+ Fail ("P90#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P90#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMidnightBlue ()
+ {
+ Pen pen = Pens.MidnightBlue;
+ AssertEquals ("P91#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P91#2", pen.Color, Color.MidnightBlue);
+
+ try {
+ pen.Color = Color.MidnightBlue;
+ Fail ("P91#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P91#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMintCream ()
+ {
+ Pen pen = Pens.MintCream;
+ AssertEquals ("P92#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P92#2", pen.Color, Color.MintCream);
+
+ try {
+ pen.Color = Color.MintCream;
+ Fail ("P92#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P92#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMistyRose ()
+ {
+ Pen pen = Pens.MistyRose;
+ AssertEquals ("P93#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P93#2", pen.Color, Color.MistyRose);
+
+ try {
+ pen.Color = Color.MistyRose;
+ Fail ("P93#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P93#3", true);
+ }
+ }
+
+ [Test]
+ public void TestMoccasin ()
+ {
+ Pen pen = Pens.Moccasin;
+ AssertEquals ("P94#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P94#2", pen.Color, Color.Moccasin);
+
+ try {
+ pen.Color = Color.Moccasin;
+ Fail ("P94#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P94#3", true);
+ }
+ }
+
+ [Test]
+ public void TestNavajoWhite ()
+ {
+ Pen pen = Pens.NavajoWhite;
+ AssertEquals ("P95#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P95#2", pen.Color, Color.NavajoWhite);
+
+ try {
+ pen.Color = Color.NavajoWhite;
+ Fail ("P95#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P95#3", true);
+ }
+ }
+
+ [Test]
+ public void TestNavy ()
+ {
+ Pen pen = Pens.Navy;
+ AssertEquals ("P96#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P96#2", pen.Color, Color.Navy);
+
+ try {
+ pen.Color = Color.Navy;
+ Fail ("P96#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P96#3", true);
+ }
+ }
+
+ [Test]
+ public void TestOldLace ()
+ {
+ Pen pen = Pens.OldLace;
+ AssertEquals ("P97#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P97#2", pen.Color, Color.OldLace);
+
+ try {
+ pen.Color = Color.OldLace;
+ Fail ("P97#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P97#3", true);
+ }
+ }
+
+ [Test]
+ public void TestOlive ()
+ {
+ Pen pen = Pens.Olive;
+ AssertEquals ("P98#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P98#2", pen.Color, Color.Olive);
+
+ try {
+ pen.Color = Color.Olive;
+ Fail ("P98#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P98#3", true);
+ }
+ }
+
+ [Test]
+ public void TestOliveDrab ()
+ {
+ Pen pen = Pens.OliveDrab;
+ AssertEquals ("P99#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P99#2", pen.Color, Color.OliveDrab);
+
+ try {
+ pen.Color = Color.OliveDrab;
+ Fail ("P99#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P99#3", true);
+ }
+ }
+
+ [Test]
+ public void TestOrange ()
+ {
+ Pen pen = Pens.Orange;
+ AssertEquals ("P100#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P100#2", pen.Color, Color.Orange);
+
+ try {
+ pen.Color = Color.Orange;
+ Fail ("P100#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P100#3", true);
+ }
+ }
+
+ [Test]
+ public void TestOrangeRed ()
+ {
+ Pen pen = Pens.OrangeRed;
+ AssertEquals ("P101#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P101#2", pen.Color, Color.OrangeRed);
+
+ try {
+ pen.Color = Color.OrangeRed;
+ Fail ("P101#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P101#3", true);
+ }
+ }
+
+ [Test]
+ public void TestOrchid ()
+ {
+ Pen pen = Pens.Orchid;
+ AssertEquals ("P102#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P102#2", pen.Color, Color.Orchid);
+
+ try {
+ pen.Color = Color.Orchid;
+ Fail ("P102#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P102#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPaleGoldenrod ()
+ {
+ Pen pen = Pens.PaleGoldenrod;
+ AssertEquals ("P103#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P103#2", pen.Color, Color.PaleGoldenrod);
+
+ try {
+ pen.Color = Color.PaleGoldenrod;
+ Fail ("P103#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P103#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPaleGreen ()
+ {
+ Pen pen = Pens.PaleGreen;
+ AssertEquals ("P104#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P104#2", pen.Color, Color.PaleGreen);
+
+ try {
+ pen.Color = Color.PaleGreen;
+ Fail ("P104#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P104#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPaleTurquoise ()
+ {
+ Pen pen = Pens.PaleTurquoise;
+ AssertEquals ("P105#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P105#2", pen.Color, Color.PaleTurquoise);
+
+ try {
+ pen.Color = Color.PaleTurquoise;
+ Fail ("P105#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P105#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPaleVioletRed ()
+ {
+ Pen pen = Pens.PaleVioletRed;
+ AssertEquals ("P106#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P106#2", pen.Color, Color.PaleVioletRed);
+
+ try {
+ pen.Color = Color.PaleVioletRed;
+ Fail ("P106#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P106#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPapayaWhip ()
+ {
+ Pen pen = Pens.PapayaWhip;
+ AssertEquals ("P107#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P107#2", pen.Color, Color.PapayaWhip);
+
+ try {
+ pen.Color = Color.PapayaWhip;
+ Fail ("P107#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P107#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPeachPuff ()
+ {
+ Pen pen = Pens.PeachPuff;
+ AssertEquals ("P108#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P108#2", pen.Color, Color.PeachPuff);
+
+ try {
+ pen.Color = Color.PeachPuff;
+ Fail ("P108#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P108#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPeru ()
+ {
+ Pen pen = Pens.Peru;
+ AssertEquals ("P109#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P109#2", pen.Color, Color.Peru);
+
+ try {
+ pen.Color = Color.Peru;
+ Fail ("P109#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P109#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPink ()
+ {
+ Pen pen = Pens.Pink;
+ AssertEquals ("P110#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P110#2", pen.Color, Color.Pink);
+
+ try {
+ pen.Color = Color.Pink;
+ Fail ("P110#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P110#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPlum ()
+ {
+ Pen pen = Pens.Plum;
+ AssertEquals ("P111#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P111#2", pen.Color, Color.Plum);
+
+ try {
+ pen.Color = Color.Plum;
+ Fail ("P111#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P111#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPowderBlue ()
+ {
+ Pen pen = Pens.PowderBlue;
+ AssertEquals ("P112#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P112#2", pen.Color, Color.PowderBlue);
+
+ try {
+ pen.Color = Color.PowderBlue;
+ Fail ("P112#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P112#3", true);
+ }
+ }
+
+ [Test]
+ public void TestPurple ()
+ {
+ Pen pen = Pens.Purple;
+ AssertEquals ("P113#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P113#2", pen.Color, Color.Purple);
+
+ try {
+ pen.Color = Color.Purple;
+ Fail ("P113#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P113#3", true);
+ }
+ }
+
+ [Test]
+ public void TestRed ()
+ {
+ Pen pen = Pens.Red;
+ AssertEquals ("P114#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P114#2", pen.Color, Color.Red);
+
+ try {
+ pen.Color = Color.Red;
+ Fail ("P114#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P114#3", true);
+ }
+ }
+
+ [Test]
+ public void TestRosyBrown ()
+ {
+ Pen pen = Pens.RosyBrown;
+ AssertEquals ("P115#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P115#2", pen.Color, Color.RosyBrown);
+
+ try {
+ pen.Color = Color.RosyBrown;
+ Fail ("P115#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P115#3", true);
+ }
+ }
+
+ [Test]
+ public void TestRoyalBlue ()
+ {
+ Pen pen = Pens.RoyalBlue;
+ AssertEquals ("P116#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P116#2", pen.Color, Color.RoyalBlue);
+
+ try {
+ pen.Color = Color.RoyalBlue;
+ Fail ("P116#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P116#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSaddleBrown ()
+ {
+ Pen pen = Pens.SaddleBrown;
+ AssertEquals ("P117#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P117#2", pen.Color, Color.SaddleBrown);
+
+ try {
+ pen.Color = Color.SaddleBrown;
+ Fail ("P117#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P117#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSalmon ()
+ {
+ Pen pen = Pens.Salmon;
+ AssertEquals ("P118#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P118#2", pen.Color, Color.Salmon);
+
+ try {
+ pen.Color = Color.Salmon;
+ Fail ("P118#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P118#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSandyBrown ()
+ {
+ Pen pen = Pens.SandyBrown;
+ AssertEquals ("P119#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P119#2", pen.Color, Color.SandyBrown);
+
+ try {
+ pen.Color = Color.SandyBrown;
+ Fail ("P119#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P119#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSeaGreen ()
+ {
+ Pen pen = Pens.SeaGreen;
+ AssertEquals ("P120#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P120#2", pen.Color, Color.SeaGreen);
+
+ try {
+ pen.Color = Color.SeaGreen;
+ Fail ("P120#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P120#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSeaShell ()
+ {
+ Pen pen = Pens.SeaShell;
+ AssertEquals ("P121#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P121#2", pen.Color, Color.SeaShell);
+
+ try {
+ pen.Color = Color.SeaShell;
+ Fail ("P121#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P121#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSienna ()
+ {
+ Pen pen = Pens.Sienna;
+ AssertEquals ("P122#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P122#2", pen.Color, Color.Sienna);
+
+ try {
+ pen.Color = Color.Sienna;
+ Fail ("P122#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P122#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSilver ()
+ {
+ Pen pen = Pens.Silver;
+ AssertEquals ("P123#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P123#2", pen.Color, Color.Silver);
+
+ try {
+ pen.Color = Color.Silver;
+ Fail ("P123#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P123#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSkyBlue ()
+ {
+ Pen pen = Pens.SkyBlue;
+ AssertEquals ("P124#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P124#2", pen.Color, Color.SkyBlue);
+
+ try {
+ pen.Color = Color.SkyBlue;
+ Fail ("P124#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P124#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSlateBlue ()
+ {
+ Pen pen = Pens.SlateBlue;
+ AssertEquals ("P125#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P125#2", pen.Color, Color.SlateBlue);
+
+ try {
+ pen.Color = Color.SlateBlue;
+ Fail ("P125#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P125#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSlateGray ()
+ {
+ Pen pen = Pens.SlateGray;
+ AssertEquals ("P126#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P126#2", pen.Color, Color.SlateGray);
+
+ try {
+ pen.Color = Color.SlateGray;
+ Fail ("P126#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P126#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSnow ()
+ {
+ Pen pen = Pens.Snow;
+ AssertEquals ("P127#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P127#2", pen.Color, Color.Snow);
+
+ try {
+ pen.Color = Color.Snow;
+ Fail ("P127#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P127#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSpringGreen ()
+ {
+ Pen pen = Pens.SpringGreen;
+ AssertEquals ("P128#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P128#2", pen.Color, Color.SpringGreen);
+
+ try {
+ pen.Color = Color.SpringGreen;
+ Fail ("P128#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P128#3", true);
+ }
+ }
+
+ [Test]
+ public void TestSteelBlue ()
+ {
+ Pen pen = Pens.SteelBlue;
+ AssertEquals ("P129#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P129#2", pen.Color, Color.SteelBlue);
+
+ try {
+ pen.Color = Color.SteelBlue;
+ Fail ("P129#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P129#3", true);
+ }
+ }
+
+ [Test]
+ public void TestTan ()
+ {
+ Pen pen = Pens.Tan;
+ AssertEquals ("P130#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P130#2", pen.Color, Color.Tan);
+
+ try {
+ pen.Color = Color.Tan;
+ Fail ("P130#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P130#3", true);
+ }
+ }
+
+ [Test]
+ public void TestTeal ()
+ {
+ Pen pen = Pens.Teal;
+ AssertEquals ("P131#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P131#2", pen.Color, Color.Teal);
+
+ try {
+ pen.Color = Color.Teal;
+ Fail ("P131#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P131#3", true);
+ }
+ }
+
+ [Test]
+ public void TestThistle ()
+ {
+ Pen pen = Pens.Thistle;
+ AssertEquals ("P132#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P132#2", pen.Color, Color.Thistle);
+
+ try {
+ pen.Color = Color.Thistle;
+ Fail ("P132#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P132#3", true);
+ }
+ }
+
+ [Test]
+ public void TestTomato ()
+ {
+ Pen pen = Pens.Tomato;
+ AssertEquals ("P133#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P133#2", pen.Color, Color.Tomato);
+
+ try {
+ pen.Color = Color.Tomato;
+ Fail ("P133#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P133#3", true);
+ }
+ }
+
+ [Test]
+ public void TestTransparent ()
+ {
+ Pen pen = Pens.Transparent;
+ AssertEquals ("P134#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P134#2", pen.Color, Color.Transparent);
+
+ try {
+ pen.Color = Color.Transparent;
+ Fail ("P134#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P134#3", true);
+ }
+ }
+
+ [Test]
+ public void TestTurquoise ()
+ {
+ Pen pen = Pens.Turquoise;
+ AssertEquals ("P135#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P135#2", pen.Color, Color.Turquoise);
+
+ try {
+ pen.Color = Color.Turquoise;
+ Fail ("P135#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P135#3", true);
+ }
+ }
+
+ [Test]
+ public void TestViolet ()
+ {
+ Pen pen = Pens.Violet;
+ AssertEquals ("P136#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P136#2", pen.Color, Color.Violet);
+
+ try {
+ pen.Color = Color.Violet;
+ Fail ("P136#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P136#3", true);
+ }
+ }
+
+ [Test]
+ public void TestWheat ()
+ {
+ Pen pen = Pens.Wheat;
+ AssertEquals ("P137#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P137#2", pen.Color, Color.Wheat);
+
+ try {
+ pen.Color = Color.Wheat;
+ Fail ("P137#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P137#3", true);
+ }
+ }
+
+ [Test]
+ public void TestWhite ()
+ {
+ Pen pen = Pens.White;
+ AssertEquals ("P138#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P138#2", pen.Color, Color.White);
+
+ try {
+ pen.Color = Color.White;
+ Fail ("P138#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P138#3", true);
+ }
+ }
+
+ [Test]
+ public void TestWhiteSmoke ()
+ {
+ Pen pen = Pens.WhiteSmoke;
+ AssertEquals ("P139#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P139#2", pen.Color, Color.WhiteSmoke);
+
+ try {
+ pen.Color = Color.WhiteSmoke;
+ Fail ("P139#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P139#3", true);
+ }
+ }
+
+ [Test]
+ public void TestYellow ()
+ {
+ Pen pen = Pens.Yellow;
+ AssertEquals ("P140#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P140#2", pen.Color, Color.Yellow);
+
+ try {
+ pen.Color = Color.Yellow;
+ Fail ("P140#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P140#3", true);
+ }
+ }
+
+ [Test]
+ public void TestYellowGreen ()
+ {
+ Pen pen = Pens.YellowGreen;
+ AssertEquals ("P141#1", pen.PenType, PenType.SolidColor);
+ AssertEquals ("P141#2", pen.Color, Color.YellowGreen);
+
+ try {
+ pen.Color = Color.YellowGreen;
+ Fail ("P141#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P141#3", true);
+ }
+ }
+ }
+}
+
+// Following code was used to generate the test methods above
+//
+//Type type = typeof (Pens);
+//PropertyInfo [] properties = type.GetProperties ();
+//int count = 1;
+//foreach (PropertyInfo property in properties) {
+// Console.WriteLine();
+// Console.WriteLine("\t\t[Test]");
+// Console.WriteLine("\t\tpublic void Test" + property.Name + " ()");
+// Console.WriteLine("\t\t{");
+// Console.WriteLine("\t\t\tPen pen = Pens." + property.Name + ";");
+// Console.WriteLine("\t\t\tAssertEquals (\"P" + count + "#1\", pen.PenType, PenType.SolidColor);");
+// Console.WriteLine("\t\t\tAssertEquals (\"P" + count + "#2\", pen.Color, Color." + property.Name + ");\n");
+//
+// Console.WriteLine("\t\t\ttry {");
+// Console.WriteLine("\t\t\t\tpen.Color = Color." + property.Name + ";");
+// Console.WriteLine("\t\t\t\tFail (\"P" + count + "#3: must throw ArgumentException\");");
+// Console.WriteLine("\t\t\t} catch (ArgumentException) {");
+// Console.WriteLine("\t\t\t\tAssert (\"P" + count + "#3\", true);");
+// Console.WriteLine("\t\t\t}");
+// Console.WriteLine("\t\t}");
+// count++;
+//}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestPoint.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestPoint.cs
new file mode 100644
index 00000000000..0dc3bbf6d90
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestPoint.cs
@@ -0,0 +1,230 @@
+// Tests for System.Drawing.Point.cs
+//
+// Author: Mike Kestner (mkestner@speakeasy.net)
+// Improvements by Jordi Mas i Hernàndez <jmas@softcatala.org>
+// Copyright (c) 2001 Ximian, Inc.
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class PointTest : Assertion {
+ Point pt1_1;
+ Point pt1_0;
+ Point pt0_1;
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+ pt1_1 = new Point (1, 1);
+ pt1_0 = new Point (1, 0);
+ pt0_1 = new Point (0, 1);
+ }
+
+
+ [Test]
+ public void EqualsTest ()
+ {
+ AssertEquals (pt1_1, pt1_1);
+ AssertEquals (pt1_1, new Point (1, 1));
+ Assert (!pt1_1.Equals (pt1_0));
+ Assert (!pt1_1.Equals (pt0_1));
+ Assert (!pt1_0.Equals (pt0_1));
+ }
+
+ [Test]
+ public void EqualityOpTest ()
+ {
+ Assert (pt1_1 == pt1_1);
+ Assert (pt1_1 == new Point (1, 1));
+ Assert (!(pt1_1 == pt1_0));
+ Assert (!(pt1_1 == pt0_1));
+ Assert (!(pt1_0 == pt0_1));
+ }
+
+ [Test]
+ public void InequalityOpTest ()
+ {
+ Assert (!(pt1_1 != pt1_1));
+ Assert (!(pt1_1 != new Point (1, 1)));
+ Assert (pt1_1 != pt1_0);
+ Assert (pt1_1 != pt0_1);
+ Assert (pt1_0 != pt0_1);
+ }
+
+ [Test]
+ public void CeilingTest ()
+ {
+ PointF ptf = new PointF (0.8f, 0.3f);
+ AssertEquals (pt1_1, Point.Ceiling (ptf));
+ }
+
+ [Test]
+ public void RoundTest ()
+ {
+ PointF ptf = new PointF (0.8f, 1.3f);
+ AssertEquals (pt1_1, Point.Round (ptf));
+ }
+
+ [Test]
+ public void TruncateTest ()
+ {
+ PointF ptf = new PointF (0.8f, 1.3f);
+ AssertEquals (pt0_1, Point.Truncate (ptf));
+ }
+
+ [Test]
+ public void NullTest ()
+ {
+ Point pt = new Point (0, 0);
+ AssertEquals (pt, Point.Empty);
+ }
+
+ [Test]
+ public void AdditionTest ()
+ {
+ AssertEquals (pt1_1, pt1_0 + new Size (0, 1));
+ AssertEquals (pt1_1, pt0_1 + new Size (1, 0));
+ }
+
+ [Test]
+ public void SubtractionTest ()
+ {
+ AssertEquals (pt1_0, pt1_1 - new Size (0, 1));
+ AssertEquals (pt0_1, pt1_1 - new Size (1, 0));
+ }
+
+ [Test]
+ public void Point2SizeTest ()
+ {
+ Size sz1 = new Size (1, 1);
+ Size sz2 = (Size) pt1_1;
+
+ AssertEquals (sz1, sz2);
+ }
+
+ [Test]
+ public void Point2PointFTest ()
+ {
+ PointF ptf1 = new PointF (1, 1);
+ PointF ptf2 = pt1_1;
+
+ AssertEquals (ptf1, ptf2);
+ }
+
+ [Test]
+ public void ConstructorTest ()
+ {
+ int i = (1 << 16) + 1;
+ Size sz = new Size (1, 1);
+ Point pt_i = new Point (i);
+ Point pt_sz = new Point (sz);
+
+ AssertEquals (pt_i, pt_sz);
+ AssertEquals (pt_i, pt1_1);
+ AssertEquals (pt_sz, pt1_1);
+ }
+
+ [Test]
+ public void PropertyTest ()
+ {
+ Point pt = new Point (0, 0);
+
+ Assert (pt.IsEmpty);
+ Assert (!pt1_1.IsEmpty);
+ AssertEquals (1, pt1_0.X);
+ AssertEquals (1, pt0_1.Y);
+ }
+
+ [Test]
+ public void OffsetTest ()
+ {
+ Point pt = new Point (0, 0);
+ pt.Offset (0, 1);
+ AssertEquals (pt, pt0_1);
+ pt.Offset (1, 0);
+ AssertEquals (pt, pt1_1);
+ pt.Offset (0, -1);
+ AssertEquals (pt, pt1_0);
+ }
+
+ [Test]
+ public void GetHashCodeTest ()
+ {
+ AssertEquals (0, pt1_1.GetHashCode ());
+ AssertEquals (1, pt1_0.GetHashCode ());
+ AssertEquals (1, pt0_1.GetHashCode ());
+ Point pt = new Point(0xFF, 0xFF00);
+ AssertEquals (0xFFFF, pt.GetHashCode ());
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ AssertEquals ("{X=1,Y=1}", pt1_1.ToString ());
+ AssertEquals ("{X=1,Y=0}", pt1_0.ToString ());
+ AssertEquals ("{X=0,Y=1}", pt0_1.ToString ());
+ }
+#if NET_2_0
+
+ [Test]
+ public void AddTest ()
+ {
+ AssertEquals (pt1_1, Point.Add (pt1_0, new Size (0, 1)));
+ AssertEquals (pt1_1, Point.Add (pt0_1, new Size (1, 0)));
+ }
+
+ [Test]
+ public void OffsetTestPoint ()
+ {
+ Point pt = new Point (0, 0);
+ pt.Offset (new Point (0, 1));
+ AssertEquals (pt, pt0_1);
+ pt.Offset (new Point (1, 0));
+ AssertEquals (pt, pt1_1);
+ pt.Offset (new Point (0, -1));
+ AssertEquals (pt, pt1_0);
+ }
+
+ [Test]
+ public void SubtractTest ()
+ {
+ AssertEquals (pt1_0, Point.Subtract (pt1_1, new Size (0, 1)));
+ AssertEquals (pt0_1, Point.Subtract (pt1_1, new Size (1, 0)));
+ }
+#endif
+
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestPointConverter.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestPointConverter.cs
new file mode 100644
index 00000000000..af3d2e32966
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestPointConverter.cs
@@ -0,0 +1,455 @@
+//
+// Tests for System.Drawing.PointConverter.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Drawing;
+using System.Globalization;
+using System.Security.Permissions;
+using System.Threading;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class PointConverterTest
+ {
+ Point pt;
+ Point ptneg;
+ PointConverter ptconv;
+ String ptStr;
+ String ptnegStr;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ pt = new Point (1, 2);
+ ptStr = pt.X + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + pt.Y;
+
+ ptneg = new Point (-2, -3);
+ ptnegStr = ptneg.X + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + ptneg.Y;
+
+ ptconv = (PointConverter) TypeDescriptor.GetConverter (pt);
+ }
+
+ [Test]
+ public void TestCanConvertFrom ()
+ {
+ Assert.IsTrue (ptconv.CanConvertFrom (typeof (String)), "CCF#1");
+ Assert.IsTrue (ptconv.CanConvertFrom (null, typeof (String)), "CCF#2");
+ Assert.IsFalse (ptconv.CanConvertFrom (null, typeof (Rectangle)), "CCF#3");
+ Assert.IsFalse (ptconv.CanConvertFrom (null, typeof (RectangleF)), "CCF#4");
+ Assert.IsFalse (ptconv.CanConvertFrom (null, typeof (Point)), "CCF#5");
+ Assert.IsFalse (ptconv.CanConvertFrom (null, typeof (PointF)), "CCF#6");
+ Assert.IsFalse (ptconv.CanConvertFrom (null, typeof (Size)), "CCF#7");
+ Assert.IsFalse (ptconv.CanConvertFrom (null, typeof (SizeF)), "CCF#8");
+ Assert.IsFalse (ptconv.CanConvertFrom (null, typeof (Object)), "CCF#9");
+ Assert.IsFalse (ptconv.CanConvertFrom (null, typeof (int)), "CCF#10");
+ Assert.IsTrue (ptconv.CanConvertFrom (null, typeof (InstanceDescriptor)), "CCF#11");
+ }
+
+ [Test]
+ public void TestCanConvertTo ()
+ {
+ Assert.IsTrue (ptconv.CanConvertTo (typeof (String)), "CCT#1");
+ Assert.IsTrue (ptconv.CanConvertTo (null, typeof (String)), "CCT#2");
+ Assert.IsFalse (ptconv.CanConvertTo (null, typeof (Rectangle)), "CCT#3");
+ Assert.IsFalse (ptconv.CanConvertTo (null, typeof (RectangleF)), "CCT#4");
+ Assert.IsFalse (ptconv.CanConvertTo (null, typeof (Point)), "CCT#5");
+ Assert.IsFalse (ptconv.CanConvertTo (null, typeof (PointF)), "CCT#6");
+ Assert.IsFalse (ptconv.CanConvertTo (null, typeof (Size)), "CCT#7");
+ Assert.IsFalse (ptconv.CanConvertTo (null, typeof (SizeF)), "CCT#8");
+ Assert.IsFalse (ptconv.CanConvertTo (null, typeof (Object)), "CCT#9");
+ Assert.IsFalse (ptconv.CanConvertTo (null, typeof (int)), "CCT#10");
+ }
+
+ [Test]
+ public void TestConvertFrom ()
+ {
+ Assert.AreEqual (pt, (Point) ptconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "1, 2"), "CF#1");
+ Assert.AreEqual (ptneg, (Point) ptconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "-2, -3"), "CF#2");
+
+ try {
+ ptconv.ConvertFrom (null, CultureInfo.InvariantCulture, "1");
+ Assert.Fail ("CF#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#3");
+ }
+
+ try {
+ ptconv.ConvertFrom ("1");
+ Assert.Fail ("CF#3a: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#3a");
+ }
+
+ try {
+ ptconv.ConvertFrom (null, CultureInfo.InvariantCulture, "1, 1, 1");
+ Assert.Fail ("CF#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#4");
+ }
+
+ try {
+ ptconv.ConvertFrom (null, CultureInfo.InvariantCulture, "*1, 1");
+ Assert.Fail ("CF#5-1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "CF#5-2");
+ Assert.IsNotNull (ex.InnerException, "CF#5-3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "CF#5-4");
+ }
+
+ try {
+ ptconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Point (1, 1));
+ Assert.Fail ("CF#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#6");
+ }
+
+ try {
+ ptconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new PointF (1, 1));
+ Assert.Fail ("CF#7: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#7");
+ }
+
+ try {
+ ptconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Size (1, 1));
+ Assert.Fail ("CF#8: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#8");
+ }
+
+ try {
+ ptconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new SizeF (1, 1));
+ Assert.Fail ("CF#9: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#9");
+ }
+
+ try {
+ ptconv.ConvertFrom (null, CultureInfo.InvariantCulture, 0x10);
+ Assert.Fail ("CF#10: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#10");
+ }
+ }
+
+ [Test]
+ public void TestConvertTo ()
+ {
+ Assert.AreEqual (ptStr, (String) ptconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ pt, typeof (String)), "CT#1");
+ Assert.AreEqual (ptnegStr, (String) ptconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ ptneg, typeof (String)), "CT#2");
+
+ try {
+ ptconv.ConvertTo (null, CultureInfo.InvariantCulture, pt,
+ typeof (Size));
+ Assert.Fail ("CT#3: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#3");
+ }
+
+ try {
+ ptconv.ConvertTo (null, CultureInfo.InvariantCulture, pt,
+ typeof (SizeF));
+ Assert.Fail ("CT#4: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#4");
+ }
+
+ try {
+ ptconv.ConvertTo (null, CultureInfo.InvariantCulture, pt,
+ typeof (Point));
+ Assert.Fail ("CT#5: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#5");
+ }
+
+ try {
+ ptconv.ConvertTo (null, CultureInfo.InvariantCulture, pt,
+ typeof (PointF));
+ Assert.Fail ("CT#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#6");
+ }
+
+ try {
+ ptconv.ConvertTo (null, CultureInfo.InvariantCulture, pt,
+ typeof (int));
+ Assert.Fail ("CT#7: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#7");
+ }
+ }
+
+ [Test]
+ public void TestGetCreateInstanceSupported ()
+ {
+ Assert.IsTrue (ptconv.GetCreateInstanceSupported (), "GCIS#1");
+ Assert.IsTrue (ptconv.GetCreateInstanceSupported (null), "GCIS#2");
+ }
+
+ [Test]
+ public void TestCreateInstance ()
+ {
+ Point ptInstance;
+
+ Hashtable ht = new Hashtable ();
+ ht.Add ("X", 1); ht.Add ("Y", 2);
+
+ ptInstance = (Point) ptconv.CreateInstance (ht);
+ Assert.AreEqual (pt, ptInstance, "CI#1");
+
+ ht.Clear ();
+ ht.Add ("X", -2); ht.Add ("Y", -3);
+
+ ptInstance = (Point) ptconv.CreateInstance (null, ht);
+ Assert.AreEqual (ptneg, ptInstance, "CI#2");
+
+ // Property names are case-sensitive. It should throw
+ // NullRefExc if any of the property names does not match
+ ht.Clear ();
+ ht.Add ("x", 2); ht.Add ("Y", 3);
+ try {
+ ptInstance = (Point) ptconv.CreateInstance (null, ht);
+ Assert.Fail ("CI#3: must throw NullReferenceException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NullReferenceException, "CI#3");
+ }
+ }
+
+ [Test]
+ public void TestGetPropertiesSupported ()
+ {
+ Assert.IsTrue (ptconv.GetPropertiesSupported (), "GPS#1");
+ Assert.IsTrue (ptconv.GetPropertiesSupported (null), "GPS#2");
+ }
+
+ [Test]
+ public void TestGetProperties ()
+ {
+ Attribute [] attrs;
+ PropertyDescriptorCollection propsColl;
+
+ propsColl = ptconv.GetProperties (pt);
+ Assert.AreEqual (2, propsColl.Count, "GP1#1");
+ Assert.AreEqual (pt.X, propsColl["X"].GetValue (pt), "GP1#2");
+ Assert.AreEqual (pt.Y, propsColl["Y"].GetValue (pt), "GP1#3");
+
+ propsColl = ptconv.GetProperties (null, ptneg);
+ Assert.AreEqual (2, propsColl.Count, "GP2#1");
+ Assert.AreEqual (ptneg.X, propsColl["X"].GetValue (ptneg), "GP2#2");
+ Assert.AreEqual (ptneg.Y, propsColl["Y"].GetValue (ptneg), "GP2#3");
+
+ propsColl = ptconv.GetProperties (null, pt, null);
+ Assert.AreEqual (3, propsColl.Count, "GP3#1");
+ Assert.AreEqual (pt.X, propsColl["X"].GetValue (pt), "GP3#2");
+ Assert.AreEqual (pt.Y, propsColl["Y"].GetValue (pt), "GP3#3");
+ Assert.AreEqual (pt.IsEmpty, propsColl["IsEmpty"].GetValue (pt), "GP3#4");
+
+ Type type = typeof (Point);
+ attrs = Attribute.GetCustomAttributes (type, true);
+ propsColl = ptconv.GetProperties (null, pt, attrs);
+ Assert.AreEqual (0, propsColl.Count, "GP3#5");
+ }
+
+ [Test]
+ public void ConvertFromInvariantString_string ()
+ {
+ Assert.AreEqual (pt, ptconv.ConvertFromInvariantString ("1, 2"), "CFISS#1");
+ Assert.AreEqual (ptneg, ptconv.ConvertFromInvariantString ("-2, -3"), "CFISS#2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFromInvariantString_string_exc_1 ()
+ {
+ ptconv.ConvertFromInvariantString ("1");
+ }
+
+ [Test]
+ public void ConvertFromInvariantString_string_exc_2 ()
+ {
+ try {
+ ptconv.ConvertFromInvariantString ("hello");
+ Assert.Fail ("#1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.InnerException, "#3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
+ }
+ }
+
+ [Test]
+ public void ConvertFromString_string ()
+ {
+ // save current culture
+ CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ PerformConvertFromStringTest (new CultureInfo ("en-US"));
+ PerformConvertFromStringTest (new CultureInfo ("nl-BE"));
+ PerformConvertFromStringTest (new MyCultureInfo ());
+ } finally {
+ // restore original culture
+ Thread.CurrentThread.CurrentCulture = currentCulture;
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFromString_string_exc_1 ()
+ {
+ ptconv.ConvertFromString ("1");
+ }
+
+ [Test]
+ public void ConvertFromString_string_exc_2 ()
+ {
+ try {
+ ptconv.ConvertFromString ("hello");
+ Assert.Fail ("#1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.InnerException, "#3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
+ }
+ }
+
+ [Test]
+ public void ConvertToInvariantString_string ()
+ {
+ Assert.AreEqual ("1" + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " 2",
+ ptconv.ConvertToInvariantString (pt), "CFISS#1");
+ Assert.AreEqual ("-2" + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " -3",
+ ptconv.ConvertToInvariantString (ptneg), "CFISS#2");
+ }
+
+ [Test]
+ public void ConvertToString_string ()
+ {
+ // save current culture
+ CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ PerformConvertToStringTest (new CultureInfo ("en-US"));
+ PerformConvertToStringTest (new CultureInfo ("nl-BE"));
+ PerformConvertToStringTest (new MyCultureInfo ());
+ } finally {
+ // restore original culture
+ Thread.CurrentThread.CurrentCulture = currentCulture;
+ }
+ }
+
+ [Test]
+ public void GetStandardValuesSupported ()
+ {
+ Assert.IsFalse (ptconv.GetStandardValuesSupported ());
+ }
+
+ [Test]
+ public void GetStandardValues ()
+ {
+ Assert.IsNull (ptconv.GetStandardValues ());
+ }
+
+ [Test]
+ public void GetStandardValuesExclusive ()
+ {
+ Assert.IsFalse (ptconv.GetStandardValuesExclusive ());
+ }
+
+ private void PerformConvertFromStringTest (CultureInfo culture)
+ {
+ // set current culture
+ Thread.CurrentThread.CurrentCulture = culture;
+
+ // perform tests
+ Assert.AreEqual (pt, ptconv.ConvertFromString (CreatePointString (culture, pt)),
+ "CFSS#1-" + culture.Name);
+ Assert.AreEqual (ptneg, ptconv.ConvertFromString (CreatePointString (culture, ptneg)),
+ "CFSS#2-" + culture.Name);
+ }
+
+ private void PerformConvertToStringTest (CultureInfo culture)
+ {
+ // set current culture
+ Thread.CurrentThread.CurrentCulture = culture;
+
+ // perform tests
+ Assert.AreEqual (CreatePointString (culture, pt), ptconv.ConvertToString (pt),
+ "CFISS#1-" + culture.Name);
+ Assert.AreEqual (CreatePointString (culture, ptneg), ptconv.ConvertToString (ptneg),
+ "CFISS#2-" + culture.Name);
+ }
+
+ private static string CreatePointString (Point point)
+ {
+ return CreatePointString (CultureInfo.CurrentCulture, point);
+ }
+
+ private static string CreatePointString (CultureInfo culture, Point point)
+ {
+ return string.Format ("{0}{1} {2}", point.X.ToString (culture),
+ culture.TextInfo.ListSeparator, point.Y.ToString (culture));
+ }
+
+ [Serializable]
+ private sealed class MyCultureInfo : CultureInfo
+ {
+ internal MyCultureInfo () : base ("en-US")
+ {
+ }
+
+ public override object GetFormat (Type formatType)
+ {
+ if (formatType == typeof (NumberFormatInfo)) {
+ NumberFormatInfo nfi = (NumberFormatInfo) ((NumberFormatInfo) base.GetFormat (formatType)).Clone ();
+
+ nfi.NegativeSign = "myNegativeSign";
+ return NumberFormatInfo.ReadOnly (nfi);
+ } else {
+ return base.GetFormat (formatType);
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestPointF.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestPointF.cs
new file mode 100644
index 00000000000..206adfb7bae
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestPointF.cs
@@ -0,0 +1,201 @@
+// Tests for System.Drawing.PointF.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Globalization;
+using System.Security.Permissions;
+using System.Threading;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class PointFTest
+ {
+ PointF pt11_99;
+ PointF pt11_0;
+ PointF pt0_11;
+
+ [TearDown]
+ public void TearDown () {}
+
+ [SetUp]
+ public void SetUp ()
+ {
+ pt11_99 = new PointF (1.1F, 9.9F);
+ pt11_0 = new PointF (1.1F, 0F);
+ pt0_11 = new PointF (0F, 1.1F);
+ }
+
+ [Test]
+ public void TestConstructors ()
+ {
+ PointF pt = new PointF (1.5F, 5.8F);
+ Assert.AreEqual (1.5F, pt.X, "C#1");
+ Assert.AreEqual (5.8F, pt.Y, "C#2");
+ }
+
+ [Test]
+ public void TestEmptyField ()
+ {
+ PointF pt = new PointF (0.0F, 0.0F);
+ Assert.AreEqual (pt, PointF.Empty, "#EMP1");
+ }
+
+ [Test]
+ public void TestProperties ()
+ {
+ PointF pt = new PointF (0.0F, 0.0F);
+
+ Assert.IsTrue (pt.IsEmpty, "P#1");
+ Assert.IsTrue (!pt11_99.IsEmpty, "P#2");
+ Assert.AreEqual (1.1F, pt11_0.X, "P#3");
+ Assert.AreEqual (1.1F, pt0_11.Y, "P#4");
+ }
+
+ [Test]
+ public void TestEquals ()
+ {
+ Assert.AreEqual (pt11_99, pt11_99, "EQ#1");
+ Assert.AreEqual (pt11_99, new PointF (1.1F, 9.9F), "EQ#2");
+ Assert.IsFalse (pt11_99.Equals (pt11_0), "EQ#3");
+ Assert.IsFalse (pt11_99.Equals (pt0_11), "EQ#4");
+ Assert.IsFalse (pt11_0.Equals (pt0_11), "EQ#5");
+ }
+
+
+ [Test]
+ public void TestAddition ()
+ {
+ Assert.AreEqual (pt11_0, pt11_0 + new Size (0, 0), "ADD#1");
+ Assert.AreEqual (pt0_11, pt0_11 + new Size (0, 0), "ADD#2");
+ Assert.AreEqual (new PointF (2, 5.1F), pt0_11 + new Size (2, 4), "ADD#3");
+ }
+
+ [Test]
+ public void TestEqualityOp ()
+ {
+ Assert.IsTrue (pt11_99 == pt11_99, "EOP#1");
+ Assert.IsTrue (pt11_99 == new PointF (1.1F, 9.9F), "EOP#2");
+ Assert.IsFalse (pt11_99 == pt11_0, "EOP#3");
+ Assert.IsFalse (pt11_99 == pt0_11, "EOP#4");
+ Assert.IsFalse (pt11_0 == pt0_11, "EOP#5");
+ }
+
+ [Test]
+ public void TestInequalityOp ()
+ {
+ Assert.IsFalse (pt11_99 != pt11_99, "IOP#1");
+ Assert.IsFalse (pt11_99 != new PointF (1.1F, 9.9F), "IOP#2");
+ Assert.IsTrue (pt11_99 != pt11_0, "IOP#3");
+ Assert.IsTrue (pt11_99 != pt0_11, "IOP#4");
+ Assert.IsTrue (pt11_0 != pt0_11, "IOP#5");
+ }
+
+ [Test]
+ public void TestSubtraction ()
+ {
+ Assert.AreEqual (pt11_0, pt11_0 - new Size (0, 0), "SUB#1");
+ Assert.AreEqual (pt0_11, pt0_11 - new Size (0, 0), "SUB#2");
+ PointF expected = new PointF (0.1F, 1.9F);
+ PointF actual = pt11_99 - new Size (1, 8);
+ //need to permit a small delta on floating point
+ Assert.AreEqual (expected.X, actual.X, 1e-5, "SUB#3");
+ Assert.AreEqual (expected.Y, actual.Y, 1e-5, "SUB#4");
+ }
+
+ [Test]
+ public void GetHashCodeTest ()
+ {
+ PointF pt = new PointF (1.1F, 9.9F);
+ Assert.AreEqual (pt.GetHashCode (), pt11_99.GetHashCode (), "GHC#1");
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ // save current culture
+ CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ PerformToStringTest (new CultureInfo ("en-US"));
+ PerformToStringTest (new CultureInfo ("nl-BE"));
+ } finally {
+ // restore original culture
+ Thread.CurrentThread.CurrentCulture = currentCulture;
+ }
+ }
+
+ private void PerformToStringTest(CultureInfo culture)
+ {
+ // set current culture
+ Thread.CurrentThread.CurrentCulture = culture;
+
+ // perform tests
+ Assert.AreEqual (GetExpectedToString (culture, pt0_11), pt0_11.ToString (),
+ "TS#1-" + culture.Name);
+ Assert.AreEqual (GetExpectedToString (culture, pt11_0), pt11_0.ToString (),
+ "TS#2-" + culture.Name);
+ Assert.AreEqual (GetExpectedToString (culture, pt11_99), pt11_99.ToString (),
+ "TS#3-" + culture.Name);
+ PointF pt = new PointF (float.NaN, float.NegativeInfinity);
+ Assert.AreEqual (GetExpectedToString (culture, pt), pt.ToString (),
+ "TS#4-" + culture.Name);
+ }
+
+ private static string GetExpectedToString (CultureInfo culture, PointF point)
+ {
+ return string.Format ("{{X={0}, Y={1}}}", point.X.ToString (culture),
+ point.Y.ToString (culture));
+ }
+
+#if NET_2_0
+
+ [Test]
+ public void AddTest ()
+ {
+ Assert.AreEqual (new PointF (3, 4), PointF.Add (new PointF (1, 1), new Size (2, 3)), "ADDTEST#1");
+ Assert.AreEqual (new PointF (4, 5), PointF.Add (new PointF (2, 2), new SizeF (2, 3)), "ADDTEST#2");
+ }
+
+ [Test]
+ public void SubtractTest ()
+ {
+ Assert.AreEqual (new PointF (2, 1), PointF.Subtract (new PointF (4, 4), new Size (2, 3)), "SUBTEST#1");
+ Assert.AreEqual (new PointF (3, 3), PointF.Subtract (new PointF (5, 6), new SizeF (2, 3)), "SUBTEST#2");
+ }
+#endif
+
+
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestRectangle.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestRectangle.cs
new file mode 100644
index 00000000000..73f62a3c51c
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestRectangle.cs
@@ -0,0 +1,212 @@
+// Tests for System.Drawing.Rectangle.cs
+
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Author: Jordi Mas i Hernandez <jordi@ximian.com>
+//
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestRectangle : Assertion
+ {
+ Rectangle rect_0;
+ Rectangle rect_1;
+ Rectangle rect_2;
+ Rectangle rect_3;
+ Rectangle rect_4;
+ Rectangle rect_5;
+
+ [TearDown]
+ public void Clean () {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ rect_0 = new Rectangle (10, 10, 40, 40);
+ rect_1 = new Rectangle (5, 5, 5, 5);
+ rect_2 = Rectangle.Empty;
+ rect_3 = new Rectangle (new Point (25, 25), new Size (0, 0));
+ rect_4 = new Rectangle (new Point (25, 252), new Size (10, 20));
+ rect_5 = new Rectangle (40, 40, 50, 50);
+ }
+
+ [Test]
+ public void Contains ()
+ {
+ AssertEquals (false, rect_0.Contains (5, 5));
+ AssertEquals (true, rect_0.Contains (12, 12));
+ AssertEquals (true, rect_0.Contains (new Point (10, 10)));
+ AssertEquals (false, rect_0.Contains (new Point (10, 50)));
+ AssertEquals (false, rect_0.Contains (50, 10));
+ AssertEquals (true, rect_0.Contains (new Rectangle (20, 20, 15, 15)));
+ AssertEquals (false, rect_0.Contains (new Rectangle (5, 5, 20, 20)));
+ AssertEquals (true, rect_2.Contains (rect_2));
+ }
+
+ [Test]
+ public void Empty ()
+ {
+ AssertEquals (rect_2.X, 0);
+ AssertEquals (rect_2.Y, 0);
+ AssertEquals (rect_2.Width, 0);
+ AssertEquals (rect_2.Height, 0);
+ }
+
+ [Test]
+ public void IsEmpty ()
+ {
+ AssertEquals (rect_0.IsEmpty, false);
+ AssertEquals (rect_2.IsEmpty, true);
+ AssertEquals (rect_3.IsEmpty, false);
+ }
+
+ [Test]
+ public void GetContents ()
+ {
+ AssertEquals (rect_4.Right, rect_4.X + rect_4.Width);
+ AssertEquals (rect_4.Left, rect_4.X);
+ AssertEquals (rect_4.Bottom, rect_4.Y + rect_4.Height);
+ AssertEquals (rect_4.Top, rect_4.Y);
+ }
+
+ [Test]
+ public void IntersectsWith ()
+ {
+ AssertEquals (rect_0.IntersectsWith (rect_1), false);
+ AssertEquals (rect_0.IntersectsWith (rect_2), false);
+ AssertEquals (rect_0.IntersectsWith (rect_5), true);
+ AssertEquals (rect_5.IntersectsWith (rect_0), true);
+ AssertEquals (rect_0.IntersectsWith (rect_4), false);
+ }
+
+ [Test]
+ public void Location ()
+ {
+ AssertEquals (new Point (25, 252), rect_4.Location);
+ Point p = new Point (11, 121);
+ rect_4.Location = p;
+ AssertEquals (p, rect_4.Location);
+ AssertEquals (rect_4.X, 11);
+ AssertEquals (rect_4.Y, 121);
+ rect_4.X = 10;
+ rect_4.Y = 15;
+ AssertEquals (new Point (10, 15), rect_4.Location);
+ }
+
+ [Test]
+ public void Size ()
+ {
+ AssertEquals (rect_4.Width, 10);
+ AssertEquals (rect_4.Height, 20);
+ rect_4.Width = 40;
+ rect_4.Height = 100;
+ AssertEquals (rect_4.Size, new Size (40, 100));
+ rect_4.Size = new Size (1, 2);
+ AssertEquals (rect_4.Width, 1);
+ AssertEquals (rect_4.Height, 2);
+ }
+
+ [Test]
+ public void ConvertFromRectangleF ()
+ {
+ AssertEquals (rect_0, Rectangle.Ceiling (
+ new RectangleF (9.9F, 9.1F, 39.04F, 39.999F)));
+ AssertEquals (rect_0, Rectangle.Round (
+ new RectangleF (9.5F, 10.499F, 40.01F, 39.6F)));
+ AssertEquals (rect_0, Rectangle.Truncate (
+ new RectangleF (10.999F, 10.01F, 40.3F, 40.0F)));
+ }
+
+ [Test]
+ public void GetHashCodeTest ()
+ {
+ Assert ("GHC#1", rect_0.GetHashCode () != rect_1.GetHashCode ());
+ }
+
+ [Test]
+ public void Inflate ()
+ {
+ rect_0.Inflate (new Size (8, 5));
+ AssertEquals ("INF#1", new Rectangle (2, 5, 56, 50), rect_0);
+ rect_1.Inflate (4, 4);
+ AssertEquals ("INF#2", new Rectangle (1, 1, 13, 13), rect_1);
+ AssertEquals ("INF#3", new Rectangle (30, 20, 70, 90),
+ Rectangle.Inflate (rect_5, 10, 20));
+ AssertEquals ("INF#4", new Rectangle (40, 40, 50, 50), rect_5);
+ }
+
+ [Test]
+ public void Intersect ()
+ {
+ AssertEquals ("INT#1", new Rectangle (40, 40, 10, 10),
+ Rectangle.Intersect (rect_0, rect_5));
+ AssertEquals ("INT#2", new Rectangle (10, 10, 40, 40), rect_0);
+ rect_0.Intersect (rect_5);
+ AssertEquals ("INT#3", new Rectangle (40, 40, 10, 10), rect_0);
+ AssertEquals ("INT#4", Rectangle.Empty, Rectangle.Intersect (rect_1, rect_5));
+
+ // Two rectangles touching each other
+ AssertEquals ("INT#5", new Rectangle (3, 0, 0, 7), Rectangle.Intersect (new Rectangle (0, 0, 3, 7), new Rectangle (3, 0, 8, 14)));
+ }
+
+ [Test]
+ public void Offset ()
+ {
+ rect_0.Offset (5, 5);
+ AssertEquals ("OFS#1", new Rectangle (15, 15, 40, 40), rect_0);
+ rect_1.Offset (new Point (7, 0));
+ AssertEquals ("OFS#2", new Rectangle (12, 5, 5, 5), rect_1);
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ AssertEquals ("{X=10,Y=10,Width=40,Height=40}", rect_0.ToString ());
+ AssertEquals ("{X=5,Y=5,Width=5,Height=5}", rect_1.ToString ());
+ AssertEquals ("{X=0,Y=0,Width=0,Height=0}", rect_2.ToString ());
+ AssertEquals ("{X=25,Y=25,Width=0,Height=0}", rect_3.ToString ());
+ }
+
+ [Test]
+ public void FromTRLB ()
+ {
+ AssertEquals (rect_0, Rectangle.FromLTRB (10, 10, 50, 50));
+ AssertEquals (rect_1, Rectangle.FromLTRB (5, 5, 10, 10));
+ AssertEquals (rect_2, Rectangle.FromLTRB (0, 0, 0, 0));
+ }
+
+ [Test]
+ public void Union ()
+ {
+ AssertEquals (Rectangle.FromLTRB (5, 5, 50, 50), Rectangle.Union (rect_0, rect_1));
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestRectangleConverter.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestRectangleConverter.cs
new file mode 100644
index 00000000000..dbc36ddd779
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestRectangleConverter.cs
@@ -0,0 +1,533 @@
+//
+// Tests for System.Drawing.RectangleConverter.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Drawing;
+using System.Globalization;
+using System.Security.Permissions;
+using System.Threading;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class RectangleConverterTest
+ {
+ Rectangle rect;
+ Rectangle rectneg;
+ RectangleConverter rconv;
+ String rectStrInvariant;
+ String rectnegStrInvariant;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ rect = new Rectangle (10, 10, 20, 30);
+ rectStrInvariant = rect.X + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " +
+ rect.Y + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " +
+ rect.Width + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " +
+ rect.Height;
+
+ rectneg = new Rectangle (-10, -10, 20, 30);
+ rectnegStrInvariant = rectneg.X + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " "
+ + rectneg.Y + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " +
+ rectneg.Width + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + rectneg.Height;
+
+ rconv = (RectangleConverter) TypeDescriptor.GetConverter (rect);
+ }
+
+ [Test]
+ public void TestCanConvertFrom ()
+ {
+ Assert.IsTrue (rconv.CanConvertFrom (typeof (String)), "CCF#1");
+ Assert.IsTrue (rconv.CanConvertFrom (null, typeof (String)), "CCF#2");
+ Assert.IsFalse (rconv.CanConvertFrom (null, typeof (Rectangle)), "CCF#3");
+ Assert.IsFalse (rconv.CanConvertFrom (null, typeof (RectangleF)), "CCF#4");
+ Assert.IsFalse (rconv.CanConvertFrom (null, typeof (Point)), "CCF#5");
+ Assert.IsFalse (rconv.CanConvertFrom (null, typeof (PointF)), "CCF#6");
+ Assert.IsFalse (rconv.CanConvertFrom (null, typeof (Size)), "CCF#7");
+ Assert.IsFalse (rconv.CanConvertFrom (null, typeof (SizeF)), "CCF#8");
+ Assert.IsFalse (rconv.CanConvertFrom (null, typeof (Object)), "CCF#9");
+ Assert.IsFalse (rconv.CanConvertFrom (null, typeof (int)), "CCF#10");
+ Assert.IsTrue (rconv.CanConvertFrom (null, typeof (InstanceDescriptor)), "CCF#11");
+ }
+
+ [Test]
+ public void TestCanConvertTo ()
+ {
+ Assert.IsTrue (rconv.CanConvertTo (typeof (String)), "CCT#1");
+ Assert.IsTrue (rconv.CanConvertTo (null, typeof (String)), "CCT#2");
+ Assert.IsFalse (rconv.CanConvertTo (null, typeof (Rectangle)), "CCT#3");
+ Assert.IsFalse (rconv.CanConvertTo (null, typeof (RectangleF)), "CCT#4");
+ Assert.IsFalse (rconv.CanConvertTo (null, typeof (Point)), "CCT#5");
+ Assert.IsFalse (rconv.CanConvertTo (null, typeof (PointF)), "CCT#6");
+ Assert.IsFalse (rconv.CanConvertTo (null, typeof (Size)), "CCT#7");
+ Assert.IsFalse (rconv.CanConvertTo (null, typeof (SizeF)), "CCT#8");
+ Assert.IsFalse (rconv.CanConvertTo (null, typeof (Object)), "CCT#9");
+ Assert.IsFalse (rconv.CanConvertTo (null, typeof (int)), "CCT#10");
+ }
+
+ [Test]
+ public void TestConvertFrom ()
+ {
+ Assert.AreEqual (rect, (Rectangle) rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "10, 10, 20, 30"), "CF#1");
+ Assert.AreEqual (rectneg, (Rectangle) rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "-10, -10, 20, 30"), "CF#2");
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "10, 10");
+ Assert.Fail ("CF#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#3");
+ }
+
+ try {
+ rconv.ConvertFrom ("10");
+ Assert.Fail ("CF#3a: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#3a");
+ }
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "1, 1, 1, 1, 1");
+ Assert.Fail ("CF#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#4");
+ }
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "*1, 1, 1, 1");
+ Assert.Fail ("CF#5: must throw Exception");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "CF#5-2");
+ Assert.IsNotNull (ex.InnerException, "CF#5-3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "CF#5-4");
+ }
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Rectangle (10, 10, 100, 100));
+ Assert.Fail ("CF#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#6");
+ }
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new RectangleF (10, 10, 100, 100));
+ Assert.Fail ("CF#7: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#7");
+ }
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Point (10, 10));
+ Assert.Fail ("CF#8: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#8");
+ }
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new PointF (10, 10));
+ Assert.Fail ("CF#9: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#9");
+ }
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Size (10, 10));
+ Assert.Fail ("CF#10: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#10");
+ }
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new SizeF (10, 10));
+ Assert.Fail ("CF#11: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#11");
+ }
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Object ());
+ Assert.Fail ("CF#12: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#12");
+ }
+
+ try {
+ rconv.ConvertFrom (null, CultureInfo.InvariantCulture, 1001);
+ Assert.Fail ("CF#13: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#13");
+ }
+ }
+
+ [Test]
+ public void TestConvertTo ()
+ {
+ Assert.AreEqual (rectStrInvariant, (String) rconv.ConvertTo (null,
+ CultureInfo.InvariantCulture, rect, typeof (String)), "CT#1");
+ Assert.AreEqual (rectnegStrInvariant, (String) rconv.ConvertTo (null,
+ CultureInfo.InvariantCulture, rectneg, typeof (String)), "CT#2");
+
+ try {
+ rconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ rect, typeof (Rectangle));
+ Assert.Fail ("CT#3: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#3");
+ }
+
+ try {
+ rconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ rect, typeof (RectangleF));
+ Assert.Fail ("CT#4: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#4");
+ }
+
+ try {
+ rconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ rect, typeof (Size));
+ Assert.Fail ("CT#5: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#5");
+ }
+
+ try {
+ rconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ rect, typeof (SizeF));
+ Assert.Fail ("CT#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#6");
+ }
+
+ try {
+ rconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ rect, typeof (Point));
+ Assert.Fail ("CT#7: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#7");
+ }
+
+ try {
+ rconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ rect, typeof (PointF));
+ Assert.Fail ("CT#8: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#8");
+ }
+
+ try {
+ rconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ rect, typeof (Object));
+ Assert.Fail ("CT#9: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#9");
+ }
+
+ try {
+ rconv.ConvertTo (null, CultureInfo.InvariantCulture,
+ rect, typeof (int));
+ Assert.Fail ("CT#10: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#10");
+ }
+ }
+
+ [Test]
+ public void TestGetCreateInstanceSupported ()
+ {
+ Assert.IsTrue (rconv.GetCreateInstanceSupported (), "GCIS#1");
+ Assert.IsTrue (rconv.GetCreateInstanceSupported (null), "GCIS#2");
+ }
+
+ [Test]
+ public void TestCreateInstance ()
+ {
+ Rectangle rectInstance;
+
+ Hashtable ht = new Hashtable ();
+ ht.Add ("X", 10); ht.Add ("Y", 10);
+ ht.Add ("Width", 20); ht.Add ("Height", 30);
+
+ rectInstance = (Rectangle) rconv.CreateInstance (ht);
+ Assert.AreEqual (rect, rectInstance, "CI#1");
+
+ ht.Clear ();
+ ht.Add ("X", -10); ht.Add ("Y", -10);
+ ht.Add ("Width", 20); ht.Add ("Height", 30);
+
+ rectInstance = (Rectangle) rconv.CreateInstance (null, ht);
+ Assert.AreEqual (rectneg, rectInstance, "CI#2");
+
+ // Property names are case-sensitive. It should throw
+ // NullRefExc if any of the property names does not match
+ ht.Clear ();
+ ht.Add ("x", -10); ht.Add ("Y", -10);
+ ht.Add ("Width", 20); ht.Add ("Height", 30);
+ try {
+ rectInstance = (Rectangle) rconv.CreateInstance (null, ht);
+ Assert.Fail ("CI#3: must throw NullReferenceException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NullReferenceException, "CI#3");
+ }
+ }
+
+ [Test]
+ public void TestGetPropertiesSupported ()
+ {
+ Assert.IsTrue (rconv.GetPropertiesSupported (), "GPS#1");
+ Assert.IsTrue (rconv.GetPropertiesSupported (null), "GPS#2");
+ }
+
+ [Test]
+ public void TestGetProperties ()
+ {
+ Attribute [] attrs;
+ PropertyDescriptorCollection propsColl;
+
+ propsColl = rconv.GetProperties (rect);
+ Assert.AreEqual (4, propsColl.Count, "GP1#1");
+ Assert.AreEqual (rect.X, propsColl["X"].GetValue (rect), "GP1#2");
+ Assert.AreEqual (rect.Y, propsColl["Y"].GetValue (rect), "GP1#3");
+ Assert.AreEqual (rect.Width, propsColl["Width"].GetValue (rect), "GP1#4");
+ Assert.AreEqual (rect.Height, propsColl["Height"].GetValue (rect), "GP1#5");
+
+ propsColl = rconv.GetProperties (null, rectneg);
+ Assert.AreEqual (4, propsColl.Count, "GP2#1");
+ Assert.AreEqual (rectneg.X, propsColl["X"].GetValue (rectneg), "GP2#2");
+ Assert.AreEqual (rectneg.Y, propsColl["Y"].GetValue (rectneg), "GP2#3");
+ Assert.AreEqual (rectneg.Width, propsColl["Width"].GetValue (rectneg), "GP2#4");
+ Assert.AreEqual (rectneg.Height, propsColl["Height"].GetValue (rectneg), "GP2#5");
+
+ propsColl = rconv.GetProperties (null, rect, null);
+ Assert.AreEqual (11, propsColl.Count, "GP3#1");
+ Assert.AreEqual (rect.X, propsColl["X"].GetValue (rect), "GP3#2");
+ Assert.AreEqual (rect.Y, propsColl["Y"].GetValue (rect), "GP3#3");
+ Assert.AreEqual (rect.Width, propsColl["Width"].GetValue (rect), "GP3#4");
+ Assert.AreEqual (rect.Height, propsColl["Height"].GetValue (rect), "GP3#5");
+
+ Assert.AreEqual (rect.Top, propsColl["Top"].GetValue (rect), "GP3#6");
+ Assert.AreEqual (rect.Bottom, propsColl["Bottom"].GetValue (rect), "GP3#7");
+ Assert.AreEqual (rect.Left, propsColl["Left"].GetValue (rect), "GP3#8");
+ Assert.AreEqual (rect.Right, propsColl["Right"].GetValue (rect), "GP3#9");
+ Assert.AreEqual (rect.Location, propsColl["Location"].GetValue (rect), "GP3#10");
+ Assert.AreEqual (rect.Size, propsColl["Size"].GetValue (rect), "GP3#11");
+ Assert.AreEqual (rect.IsEmpty, propsColl["IsEmpty"].GetValue (rect), "GP3#12");
+
+ Type type = typeof (Rectangle);
+ attrs = Attribute.GetCustomAttributes (type, true);
+ propsColl = rconv.GetProperties (null, rect, attrs);
+ Assert.AreEqual (0, propsColl.Count, "GP3#13");
+ }
+
+ [Test]
+ public void ConvertFromInvariantString_string ()
+ {
+ Assert.AreEqual (rect, rconv.ConvertFromInvariantString (rectStrInvariant),
+ "CFISS#1");
+ Assert.AreEqual (rectneg, rconv.ConvertFromInvariantString (rectnegStrInvariant),
+ "CFISS#2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFromInvariantString_string_exc_1 ()
+ {
+ rconv.ConvertFromInvariantString ("1, 2, 3");
+ }
+
+ [Test]
+ public void ConvertFromInvariantString_string_exc_2 ()
+ {
+ try {
+ rconv.ConvertFromInvariantString ("hello");
+ Assert.Fail ("#1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.InnerException, "#3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
+ }
+ }
+
+ [Test]
+ public void ConvertFromString_string ()
+ {
+ // save current culture
+ CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ PerformConvertFromStringTest (new CultureInfo ("en-US"));
+ PerformConvertFromStringTest (new CultureInfo ("nl-BE"));
+ PerformConvertFromStringTest (new MyCultureInfo ());
+ } finally {
+ // restore original culture
+ Thread.CurrentThread.CurrentCulture = currentCulture;
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFromString_string_exc_1 ()
+ {
+ CultureInfo culture = CultureInfo.CurrentCulture;
+ rconv.ConvertFromString (string.Format(culture,
+ "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator));
+ }
+
+ [Test]
+ public void ConvertFromString_string_exc_2 ()
+ {
+ try {
+ rconv.ConvertFromString ("hello");
+ Assert.Fail ("#1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.InnerException, "#3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
+ }
+ }
+
+ [Test]
+ public void ConvertToInvariantString_string ()
+ {
+ Assert.AreEqual (rectStrInvariant, rconv.ConvertToInvariantString (rect),
+ "CFISS#1");
+ Assert.AreEqual (rectnegStrInvariant, rconv.ConvertToInvariantString (rectneg),
+ "CFISS#2");
+ }
+
+ [Test]
+ public void ConvertToString_string () {
+ // save current culture
+ CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ PerformConvertToStringTest (new CultureInfo ("en-US"));
+ PerformConvertToStringTest (new CultureInfo ("nl-BE"));
+ PerformConvertToStringTest (new MyCultureInfo ());
+ } finally {
+ // restore original culture
+ Thread.CurrentThread.CurrentCulture = currentCulture;
+ }
+ }
+
+ [Test]
+ public void GetStandardValuesSupported ()
+ {
+ Assert.IsFalse (rconv.GetStandardValuesSupported ());
+ }
+
+ [Test]
+ public void GetStandardValues ()
+ {
+ Assert.IsNull (rconv.GetStandardValues ());
+ }
+
+ [Test]
+ public void GetStandardValuesExclusive ()
+ {
+ Assert.IsFalse (rconv.GetStandardValuesExclusive ());
+ }
+
+ private void PerformConvertFromStringTest (CultureInfo culture)
+ {
+ // set current culture
+ Thread.CurrentThread.CurrentCulture = culture;
+
+ // perform tests
+ Assert.AreEqual (rect, rconv.ConvertFromString (CreateRectangleString (rect)),
+ "CFSS#1-" + culture.Name);
+ Assert.AreEqual (rectneg, rconv.ConvertFromString (CreateRectangleString (rectneg)),
+ "CFSS#2-" + culture.Name);
+ }
+
+ private void PerformConvertToStringTest (CultureInfo culture)
+ {
+ // set current culture
+ Thread.CurrentThread.CurrentCulture = culture;
+
+ // perform tests
+ Assert.AreEqual (CreateRectangleString (rect), rconv.ConvertToString (rect),
+ "CFISS#1-" + culture.Name);
+ Assert.AreEqual (CreateRectangleString (rectneg), rconv.ConvertToString (rectneg),
+ "CFISS#2-" + culture.Name);
+ }
+
+ private static string CreateRectangleString (Rectangle rectangle)
+ {
+ return CreateRectangleString (CultureInfo.CurrentCulture, rectangle);
+ }
+
+ private static string CreateRectangleString (CultureInfo culture, Rectangle rectangle)
+ {
+ return string.Format ("{0}{1} {2}{1} {3}{1} {4}", rectangle.X.ToString (culture),
+ culture.TextInfo.ListSeparator, rectangle.Y.ToString (culture),
+ rectangle.Width.ToString (culture), rectangle.Height.ToString (culture));
+ }
+
+ [Serializable]
+ private sealed class MyCultureInfo : CultureInfo
+ {
+ internal MyCultureInfo ()
+ : base ("en-US")
+ {
+ }
+
+ public override object GetFormat (Type formatType)
+ {
+ if (formatType == typeof (NumberFormatInfo)) {
+ NumberFormatInfo nfi = (NumberFormatInfo) ((NumberFormatInfo) base.GetFormat (formatType)).Clone ();
+
+ nfi.NegativeSign = "myNegativeSign";
+ return NumberFormatInfo.ReadOnly (nfi);
+ } else {
+ return base.GetFormat (formatType);
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestRectangleF.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestRectangleF.cs
new file mode 100644
index 00000000000..27a288b75a9
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestRectangleF.cs
@@ -0,0 +1,190 @@
+// Tests for System.Drawing.RectangleF.cs
+
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Author: Jordi Mas i Hernandez <jordi@ximian.com>
+//
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestRectangleF : Assertion
+ {
+ RectangleF rect_0;
+ RectangleF rect_1;
+ RectangleF rect_2;
+ RectangleF rect_3;
+ RectangleF rect_4;
+ RectangleF rect_5;
+ RectangleF rect_6;
+
+ [TearDown]
+ public void Clean () {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ rect_0 = new RectangleF (new PointF (10, 10), new SizeF (40, 40));
+ rect_1 = new RectangleF (5, 5, 5, 5);
+ rect_2 = RectangleF.Empty;
+ rect_3 = new RectangleF (25, 25, 0, 0);
+ rect_4 = new RectangleF (25, 252, 10, 20);
+ rect_5 = new RectangleF (40, 40, 50, 50);
+ rect_6 = new RectangleF (40, 40, 0, 50);
+ }
+
+ [Test]
+ public void Contains ()
+ {
+ AssertEquals (false, rect_0.Contains (5, 5));
+ AssertEquals (true, rect_0.Contains (12, 12));
+ AssertEquals (true, rect_0.Contains (10, 10));
+ AssertEquals (false, rect_0.Contains (10, 50));
+ AssertEquals (false, rect_0.Contains (10, 50F-float.Epsilon));
+ AssertEquals (true, rect_0.Contains (10, 49.9F));
+ AssertEquals (false, rect_0.Contains (50, 10));
+ }
+
+ [Test]
+ public void Empty ()
+ {
+ AssertEquals (rect_2.X, 0);
+ AssertEquals (rect_2.Y, 0);
+ AssertEquals (rect_2.Width, 0);
+ AssertEquals (rect_2.Height, 0);
+ }
+
+ [Test]
+ public void IsEmpty ()
+ {
+ AssertEquals (rect_0.IsEmpty, false);
+ AssertEquals (rect_2.IsEmpty, true);
+ AssertEquals (rect_3.IsEmpty, true);
+ AssertEquals (rect_6.IsEmpty, true);
+ }
+
+ [Test]
+ public void GetContents () {
+ AssertEquals (rect_4.Right, rect_4.X + rect_4.Width);
+ AssertEquals (rect_4.Left, rect_4.X);
+ AssertEquals (rect_4.Bottom, rect_4.Y + rect_4.Height);
+ AssertEquals (rect_4.Top, rect_4.Y);
+ }
+
+ [Test]
+ public void IntersectsWith () {
+ AssertEquals (rect_0.IntersectsWith (rect_1), false);
+ AssertEquals (rect_0.IntersectsWith (rect_2), false);
+ AssertEquals (rect_0.IntersectsWith (rect_5), true);
+ AssertEquals (rect_5.IntersectsWith (rect_0), true);
+ AssertEquals (rect_0.IntersectsWith (rect_4), false);
+ }
+
+ [Test]
+ public void Location () {
+ AssertEquals (new PointF (25, 252), rect_4.Location);
+ PointF p = new PointF (11, 121);
+ rect_4.Location = p;
+ AssertEquals (p, rect_4.Location);
+ AssertEquals (rect_4.X, 11);
+ AssertEquals (rect_4.Y, 121);
+ rect_4.X = 10;
+ rect_4.Y = 15;
+ AssertEquals (new PointF (10, 15), rect_4.Location);
+ }
+
+ [Test]
+ public void Size () {
+ AssertEquals (rect_4.Width, 10);
+ AssertEquals (rect_4.Height, 20);
+ rect_4.Width = 40;
+ rect_4.Height = 100;
+ AssertEquals (rect_4.Size, new SizeF (40, 100));
+ rect_4.Size = new SizeF (1, 2);
+ AssertEquals (rect_4.Width, 1);
+ AssertEquals (rect_4.Height, 2);
+ }
+
+ [Test]
+ public void GetHashCodeTest () {
+ Assert ("GHC#1", rect_0.GetHashCode () != rect_1.GetHashCode ());
+ }
+
+ [Test]
+ public void Inflate () {
+ rect_0.Inflate (new SizeF (8, 5));
+ AssertEquals ("INF#1", new RectangleF (2, 5, 56, 50), rect_0);
+ rect_1.Inflate (4, 4);
+ AssertEquals ("INF#2", new RectangleF (1, 1, 13, 13), rect_1);
+ AssertEquals ("INF#3", new RectangleF (30, 20, 70, 90),
+ RectangleF.Inflate (rect_5, 10, 20));
+ AssertEquals ("INF#4", new RectangleF (40, 40, 50, 50), rect_5);
+ }
+
+ [Test]
+ public void Intersect () {
+ AssertEquals ("INT#1", new RectangleF (40, 40, 10, 10),
+ RectangleF.Intersect (rect_0, rect_5));
+ AssertEquals ("INT#2", new RectangleF (10, 10, 40, 40), rect_0);
+ rect_0.Intersect (rect_5);
+ AssertEquals ("INT#3", new RectangleF (40, 40, 10, 10), rect_0);
+ AssertEquals ("INT#4", RectangleF.Empty, RectangleF.Intersect (rect_1, rect_5));
+ }
+
+ [Test]
+ public void Offset () {
+ rect_0.Offset (5, 5);
+ AssertEquals ("OFS#1", new RectangleF (15, 15, 40, 40), rect_0);
+ rect_1.Offset (new Point (7, 0));
+ AssertEquals ("OFS#2", new RectangleF (12, 5, 5, 5), rect_1);
+ }
+
+ [Test]
+ public void ToStringTest () {
+ AssertEquals ("{X=10,Y=10,Width=40,Height=40}", rect_0.ToString ());
+ AssertEquals ("{X=5,Y=5,Width=5,Height=5}", rect_1.ToString ());
+ AssertEquals ("{X=0,Y=0,Width=0,Height=0}", rect_2.ToString ());
+ AssertEquals ("{X=25,Y=25,Width=0,Height=0}", rect_3.ToString ());
+ }
+
+ [Test]
+ public void RectangleToRectangleF ()
+ {
+ Rectangle r = new Rectangle (1, 2, 3, 4);
+ RectangleF rf = r;
+ AssertEquals (new RectangleF (1F, 2F, 3F, 4F), rf);
+ }
+
+ [Test]
+ public void Union () {
+ AssertEquals (RectangleF.FromLTRB (5, 5, 50, 50), RectangleF.Union (rect_0, rect_1));
+ }
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestRegion.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestRegion.cs
new file mode 100644
index 00000000000..b9c08b5963f
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestRegion.cs
@@ -0,0 +1,1294 @@
+//
+// Region class testing unit
+//
+// Authors:
+// Jordi Mas, jordi@ximian.com
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing.Imaging;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Security.Permissions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing
+{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class TestRegion
+ {
+ /* For debugging */
+ public static void DumpRegion (Region rgn)
+ {
+ Matrix matrix = new Matrix ();
+ RectangleF [] rects = rgn.GetRegionScans (matrix);
+
+ for (int i = 0; i < rects.Length; i++)
+ Console.WriteLine ( rects[i]);
+ }
+
+ private Bitmap bitmap;
+ private Graphics graphic;
+
+ [TestFixtureSetUp]
+ public void FixtureSetUp ()
+ {
+ bitmap = new Bitmap (10, 10);
+ graphic = Graphics.FromImage (bitmap);
+ }
+
+ [Test]
+ public void TestBounds()
+ {
+ Bitmap bmp = new Bitmap (600, 800);
+ Graphics dc = Graphics.FromImage (bmp);
+ Rectangle rect1, rect2;
+ Region rgn1, rgn2;
+ RectangleF bounds;
+
+ rect1 = new Rectangle (500, 30, 60, 80);
+ rect2 = new Rectangle (520, 40, 60, 80);
+ rgn1 = new Region(rect1);
+ rgn2 = new Region(rect2);
+ rgn1.Union(rgn2);
+
+ bounds = rgn1.GetBounds (dc);
+
+ Assert.AreEqual (500, bounds.X);
+ Assert.AreEqual (30, bounds.Y);
+ Assert.AreEqual (80, bounds.Width);
+ Assert.AreEqual (90, bounds.Height);
+ }
+
+ [Test]
+ public void TestCloneAndEquals()
+ {
+ Bitmap bmp = new Bitmap (600, 800);
+ Graphics dc = Graphics.FromImage (bmp);
+ Rectangle rect1, rect2;
+ Region rgn1, rgn2;
+ RectangleF [] rects;
+ RectangleF [] rects2;
+ Matrix matrix = new Matrix ();
+
+ rect1 = new Rectangle (500, 30, 60, 80);
+ rect2 = new Rectangle (520, 40, 60, 80);
+ rgn1 = new Region (rect1);
+ rgn1.Union (rect2);
+ rgn2 = rgn1.Clone ();
+
+ rects = rgn1.GetRegionScans (matrix);
+ rects2 = rgn2.GetRegionScans (matrix);
+
+ Assert.AreEqual (rects.Length, rects2.Length);
+
+ for (int i = 0; i < rects.Length; i++) {
+
+ Assert.AreEqual (rects[i].X, rects[i].X);
+ Assert.AreEqual (rects[i].Y, rects[i].Y);
+ Assert.AreEqual (rects[i].Width, rects[i].Width);
+ Assert.AreEqual (rects[i].Height, rects[i].Height);
+ }
+
+ Assert.AreEqual (true, rgn1.Equals (rgn2, dc));
+ }
+
+ /*Tests infinite, empty, etc*/
+ [Test]
+ public void TestInfiniteAndEmpty()
+ {
+ Bitmap bmp = new Bitmap (600, 800);
+ Graphics dc = Graphics.FromImage (bmp);
+ Rectangle rect1, rect2;
+ Region rgn1;
+ RectangleF [] rects;
+ Matrix matrix = new Matrix ();
+
+ rect1 = new Rectangle (500, 30, 60, 80);
+ rect2 = new Rectangle (520, 40, 60, 80);
+ rgn1 = new Region (rect1);
+ rgn1.Union (rect2);
+
+ Assert.AreEqual (false, rgn1.IsEmpty (dc));
+ Assert.AreEqual (false, rgn1.IsInfinite (dc));
+
+ rgn1.MakeEmpty();
+ Assert.AreEqual (true, rgn1.IsEmpty (dc));
+
+ rgn1 = new Region (rect1);
+ rgn1.Union (rect2);
+ rgn1.MakeInfinite ();
+ rects = rgn1.GetRegionScans (matrix);
+
+ Assert.AreEqual (1, rects.Length);
+ Assert.AreEqual (-4194304, rects[0].X);
+ Assert.AreEqual (-4194304, rects[0].Y);
+ Assert.AreEqual (8388608, rects[0].Width);
+ Assert.AreEqual (8388608, rects[0].Height);
+ Assert.AreEqual (true, rgn1.IsInfinite (dc));
+ }
+
+
+ [Test]
+ public void TestUnionGroup1 ()
+ {
+ Bitmap bmp = new Bitmap (600, 800);
+ Graphics dc = Graphics.FromImage (bmp);
+ Matrix matrix = new Matrix ();
+ Rectangle rect1, rect2, rect3, rect4;
+ Region rgn1, rgn2, rgn3, rgn4;
+ RectangleF [] rects;
+
+ rect1 = new Rectangle (500, 30, 60, 80);
+ rect2 = new Rectangle (520, 40, 60, 80);
+ rgn1 = new Region(rect1);
+ rgn2 = new Region(rect2);
+ rgn1.Union(rgn2);
+ rects = rgn1.GetRegionScans (matrix);
+
+ Assert.AreEqual (3, rects.Length);
+ Assert.AreEqual (500, rects[0].X);
+ Assert.AreEqual (30, rects[0].Y);
+ Assert.AreEqual (60, rects[0].Width);
+ Assert.AreEqual (10, rects[0].Height);
+
+ Assert.AreEqual (500, rects[1].X);
+ Assert.AreEqual (40, rects[1].Y);
+ Assert.AreEqual (80, rects[1].Width);
+ Assert.AreEqual (70, rects[1].Height);
+
+ Assert.AreEqual (520, rects[2].X);
+ Assert.AreEqual (110, rects[2].Y);
+ Assert.AreEqual (60, rects[2].Width);
+ Assert.AreEqual (10, rects[2].Height);
+
+ rect1 = new Rectangle (20, 180, 40, 50);
+ rect2 = new Rectangle (50, 190, 40, 50);
+ rect3 = new Rectangle (70, 210, 30, 50);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+
+ rgn1.Union (rgn2);
+ rgn1.Union (rgn3);
+ rects = rgn1.GetRegionScans (matrix);
+ Assert.AreEqual (5, rects.Length);
+
+ Assert.AreEqual (20, rects[0].X);
+ Assert.AreEqual (180, rects[0].Y);
+ Assert.AreEqual (40, rects[0].Width);
+ Assert.AreEqual (10, rects[0].Height);
+
+ Assert.AreEqual (20, rects[1].X);
+ Assert.AreEqual (190, rects[1].Y);
+ Assert.AreEqual (70, rects[1].Width);
+ Assert.AreEqual (20, rects[1].Height);
+
+ Assert.AreEqual (20, rects[2].X);
+ Assert.AreEqual (210, rects[2].Y);
+ Assert.AreEqual (80, rects[2].Width);
+ Assert.AreEqual (20, rects[2].Height);
+
+ Assert.AreEqual (50, rects[3].X);
+ Assert.AreEqual (230, rects[3].Y);
+ Assert.AreEqual (50, rects[3].Width);
+ Assert.AreEqual (10, rects[3].Height);
+
+ Assert.AreEqual (70, rects[4].X);
+ Assert.AreEqual (240, rects[4].Y);
+ Assert.AreEqual (30, rects[4].Width);
+ Assert.AreEqual (20, rects[4].Height);
+
+ rect1 = new Rectangle (20, 330, 40, 50);
+ rect2 = new Rectangle (50, 340, 40, 50);
+ rect3 = new Rectangle (70, 360, 30, 50);
+ rect4 = new Rectangle (80, 400, 30, 10);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+ rgn4 = new Region (rect4);
+
+ rgn1.Union (rgn2);
+ rgn1.Union (rgn3);
+ rgn1.Union (rgn4);
+
+ rects = rgn1.GetRegionScans (matrix);
+
+ Assert.AreEqual (6, rects.Length);
+
+ Assert.AreEqual (20, rects[0].X);
+ Assert.AreEqual (330, rects[0].Y);
+ Assert.AreEqual (40, rects[0].Width);
+ Assert.AreEqual (10, rects[0].Height);
+
+ Assert.AreEqual (20, rects[1].X);
+ Assert.AreEqual (340, rects[1].Y);
+ Assert.AreEqual (70, rects[1].Width);
+ Assert.AreEqual (20, rects[1].Height);
+
+ Assert.AreEqual (20, rects[2].X);
+ Assert.AreEqual (360, rects[2].Y);
+ Assert.AreEqual (80, rects[2].Width);
+ Assert.AreEqual (20, rects[2].Height);
+
+ Assert.AreEqual (50, rects[3].X);
+ Assert.AreEqual (380, rects[3].Y);
+ Assert.AreEqual (50, rects[3].Width);
+ Assert.AreEqual (10, rects[3].Height);
+
+ Assert.AreEqual (70, rects[4].X);
+ Assert.AreEqual (390, rects[4].Y);
+ Assert.AreEqual (30, rects[4].Width);
+ Assert.AreEqual (10, rects[4].Height);
+
+ Assert.AreEqual (70, rects[5].X);
+ Assert.AreEqual (400, rects[5].Y);
+ Assert.AreEqual (40, rects[5].Width);
+ Assert.AreEqual (10, rects[5].Height);
+
+ rect1 = new Rectangle (10, 20, 50, 50);
+ rect2 = new Rectangle (100, 100, 60, 60);
+ rect3 = new Rectangle (200, 200, 80, 80);
+
+ rgn1 = new Region (rect1);
+ rgn1.Union (rect2);
+ rgn1.Union (rect3);
+
+ rects = rgn1.GetRegionScans (matrix);
+
+ Assert.AreEqual (3, rects.Length);
+
+ Assert.AreEqual (10, rects[0].X);
+ Assert.AreEqual (20, rects[0].Y);
+ Assert.AreEqual (50, rects[0].Width);
+ Assert.AreEqual (50, rects[0].Height);
+
+ Assert.AreEqual (100, rects[1].X);
+ Assert.AreEqual (100, rects[1].Y);
+ Assert.AreEqual (60, rects[1].Width);
+ Assert.AreEqual (60, rects[1].Height);
+
+ Assert.AreEqual (200, rects[2].X);
+ Assert.AreEqual (200, rects[2].Y);
+ Assert.AreEqual (80, rects[2].Width);
+ Assert.AreEqual (80, rects[2].Height);
+ }
+
+ void AssertEqualRectangles (RectangleF rect1, RectangleF rect2, string text)
+ {
+ Assert.AreEqual (rect1.X, rect2.X, text + ".X");
+ Assert.AreEqual (rect1.Y, rect2.Y, text + ".Y");
+ Assert.AreEqual (rect1.Width, rect2.Width, text + ".Width");
+ Assert.AreEqual (rect1.Height, rect2.Height, text + ".Height");
+ }
+
+ [Test]
+ public void TestUnionGroup2 ()
+ {
+ RectangleF[] rects;
+ Region r1 = new Region ();
+ Rectangle rect2 = Rectangle.Empty;
+ Rectangle rect1 = Rectangle.Empty;
+ Rectangle rect3 = Rectangle.Empty;
+ Rectangle rect4 = Rectangle.Empty;
+
+ { // TEST1: Not intersecting rects. Union just adds them
+
+ rect1 = new Rectangle (20, 20, 20, 20);
+ rect2 = new Rectangle (20, 80, 20, 10);
+ rect3 = new Rectangle (60, 60, 30, 10);
+
+ r1 = new Region (rect1);
+ r1.Union (rect2);
+ r1.Union (rect3);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (3, rects.Length, "TUG1Test1");
+ AssertEqualRectangles (new RectangleF (20, 20, 20, 20), rects[0], "TUG1Test2");
+ AssertEqualRectangles (new RectangleF (60, 60, 30, 10), rects[1], "TUG1Test3");
+ AssertEqualRectangles (new RectangleF (20, 80, 20, 10), rects[2], "TUG1Test4");
+ }
+
+ { // TEST2: Intersecting from the right
+ /*
+ * -----------
+ * | |
+ * | |-------- |
+ * | | |
+ * | |-------- |
+ * | |
+ * ----------|
+ *
+ */
+
+ rect1 = new Rectangle (10, 10, 100, 100);
+ rect2 = new Rectangle (40, 60, 100, 20);
+ r1 = new Region (rect1);
+ r1.Union (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (3, rects.Length, "TUG2Test1");
+ AssertEqualRectangles (new RectangleF (10, 10, 100, 50), rects[0], "TUG2Test2");
+ AssertEqualRectangles (new RectangleF (10, 60, 130, 20), rects[1], "TUG2Test3");
+ AssertEqualRectangles (new RectangleF (10, 80, 100, 30), rects[2], "TUG2Test4");
+ }
+
+ { // TEST3: Intersecting from the right
+ /*
+ * -----------
+ * | |
+ * |-------- | |
+ * | | |
+ * |-------- | |
+ * | |
+ * ----------|
+ *
+ */
+
+ rect1 = new Rectangle (70, 10, 100, 100);
+ rect2 = new Rectangle (40, 60, 100, 20);
+
+ r1 = new Region (rect1);
+ r1.Union (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (3, rects.Length, "TUG3Test1");
+ AssertEqualRectangles (new RectangleF (70, 10, 100, 50), rects[0], "TUG3Test2");
+ AssertEqualRectangles (new RectangleF (40, 60, 130, 20), rects[1], "TUG3Test3");
+ AssertEqualRectangles (new RectangleF (70, 80, 100, 30), rects[2], "TUG3Test4");
+ }
+
+ { // TEST4: Intersecting from the top
+ /*
+ * -----
+ * | |
+ * -----------
+ * | | | |
+ * | ----- |
+ * | |
+ * | |
+ * ----------|
+ *
+ */
+
+ rect1 = new Rectangle (40, 100, 100, 100);
+ rect2 = new Rectangle (70, 80, 50, 40);
+ r1 = new Region (rect1);
+ r1.Union (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (2, rects.Length, "TUG4Test1");
+ AssertEqualRectangles (new RectangleF (70, 80, 50, 20), rects[0], "TUG4Test2");
+ AssertEqualRectangles (new RectangleF (40, 100, 100, 100), rects[1], "TUG4Test3");
+ }
+
+ { // TEST5: Intersecting from the bottom
+ /*
+
+ * -----------
+ * | |
+ * | |
+ * | |
+ * | | | |
+ * |--| |--|
+ * | |
+ * -----
+ */
+
+ rect1 = new Rectangle (40, 10, 100, 100);
+ rect2 = new Rectangle (70, 80, 50, 40);
+
+ r1 = new Region (rect1);
+ r1.Union (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (2, rects.Length, "TUG5Test1");
+ AssertEqualRectangles (new RectangleF (40, 10, 100, 100), rects[0], "TUG5Test2");
+ AssertEqualRectangles (new RectangleF (70, 110, 50, 10), rects[1], "TUG5Test3");
+ }
+
+ { // TEST6: Multiple regions, two separted by zero pixels
+
+ rect1 = new Rectangle (30, 30, 80, 80);
+ rect2 = new Rectangle (45, 45, 200, 200);
+ rect3 = new Rectangle (160, 260, 10, 10);
+ rect4 = new Rectangle (170, 260, 10, 10);
+
+ r1 = new Region (rect1);
+ r1.Union (rect2);
+ r1.Union (rect3);
+ r1.Union (rect4);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (4, rects.Length, "TUG6Test1");
+ AssertEqualRectangles (new RectangleF (30, 30, 80, 15), rects[0], "TUG6Test2");
+ AssertEqualRectangles (new RectangleF (30, 45, 215, 65), rects[1], "TUG6Test3");
+ AssertEqualRectangles (new RectangleF (45, 110, 200, 135), rects[2], "TUG6Test4");
+ AssertEqualRectangles (new RectangleF (160, 260, 20, 10), rects[3], "TUG6Test5");
+ }
+ }
+
+
+ [Test]
+ public void TestComplementGroup1 ()
+ {
+ RectangleF[] rects;
+ Region r1 = new Region ();
+ Region r2 = new Region ();
+ Rectangle rect1 = Rectangle.Empty;
+ Rectangle rect2 = Rectangle.Empty;
+ Rectangle rect3 = Rectangle.Empty;
+ Rectangle rect4 = Rectangle.Empty;
+ Rectangle rect5 = Rectangle.Empty;
+ Rectangle rect6 = Rectangle.Empty;
+ Rectangle rect7 = Rectangle.Empty;
+
+
+ { // TEST1
+
+ rect1 = new Rectangle (20, 20, 20, 20);
+ rect2 = new Rectangle (20, 80, 20, 10);
+ rect3 = new Rectangle (60, 60, 30, 10);
+
+ r1 = new Region (rect1);
+ r2 = new Region (rect2);
+ r2.Union (rect3);
+ r1.Complement (r2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (2, rects.Length, "TCG1Test1");
+ AssertEqualRectangles (new RectangleF (60, 60, 30, 10), rects[0], "TCG1Test2");
+ AssertEqualRectangles (new RectangleF (20, 80, 20, 10), rects[1], "TCG1Test3");
+ }
+
+
+ { // TEST2
+
+ rect1 = new Rectangle (10, 10, 100, 100);
+ rect2 = new Rectangle (40, 60, 100, 20);
+
+ r1 = new Region (rect1);
+ r1.Complement (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (1, rects.Length, "TCG2Test1");
+ AssertEqualRectangles (new RectangleF (110, 60, 30, 20), rects[0], "TCG2Test2");
+ }
+
+ { // TEST3
+
+ rect1 = new Rectangle (70, 10, 100, 100);
+ rect2 = new Rectangle (40, 60, 100, 20);
+
+ r1 = new Region (rect1);
+ r1.Complement (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (1, rects.Length, "TCG3Test1");
+ AssertEqualRectangles (new RectangleF (40, 60, 30, 20), rects[0], "TCG3Test2");
+ }
+
+ { // TEST4
+
+ rect1 = new Rectangle (40, 100, 100, 100);
+ rect2 = new Rectangle (70, 80, 50, 40);
+
+ r1 = new Region (rect1);
+ r1.Complement (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (1, rects.Length, "TCG4Test1");
+ AssertEqualRectangles (new RectangleF (70, 80, 50, 20), rects[0], "TCG4Test2");
+ }
+
+ { // TEST5
+
+ rect1 = new Rectangle (40, 10, 100, 100);
+ rect2 = new Rectangle (70, 80, 50, 40);
+
+ r1 = new Region (rect1);
+ r1.Complement (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (1, rects.Length, "TCG5Test1");
+ AssertEqualRectangles (new RectangleF (70, 110, 50, 10), rects[0], "TCG5Test2");
+ }
+
+ { // TEST6: Multiple regions
+
+ rect1 = new Rectangle (30, 30, 80, 80);
+ rect2 = new Rectangle (45, 45, 200, 200);
+ rect3 = new Rectangle (160, 260, 10, 10);
+ rect4 = new Rectangle (170, 260, 10, 10);
+
+ r1 = new Region (rect1);
+ r1.Complement (rect2);
+ r1.Complement (rect3);
+ r1.Complement (rect4);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (1, rects.Length, "TCG6Test1");
+ AssertEqualRectangles (new RectangleF (170, 260, 10, 10), rects[0], "TCG6Test2");
+ }
+
+ }
+
+ [Test]
+ public void TestComplementGroup2 ()
+ {
+
+ Bitmap bmp = new Bitmap (600, 800);
+ Graphics dc = Graphics.FromImage (bmp);
+ Matrix matrix = new Matrix ();
+ Rectangle rect1, rect2;
+ Region rgn1, rgn2;
+ RectangleF [] rects;
+
+ rect1 = new Rectangle (20, 30, 60, 80);
+ rect2 = new Rectangle (50, 40, 60, 80);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ dc.DrawRectangle (Pens.Green, rect1);
+ dc.DrawRectangle (Pens.Red, rect2);
+ rgn1.Complement (rgn2);
+ dc.FillRegion (Brushes.Blue, rgn1);
+ dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
+
+ rects = rgn1.GetRegionScans (matrix);
+
+ Assert.AreEqual (2, rects.Length);
+
+ Assert.AreEqual (80, rects[0].X);
+ Assert.AreEqual (40, rects[0].Y);
+ Assert.AreEqual (30, rects[0].Width);
+ Assert.AreEqual (70, rects[0].Height);
+
+ Assert.AreEqual (50, rects[1].X);
+ Assert.AreEqual (110, rects[1].Y);
+ Assert.AreEqual (60, rects[1].Width);
+ Assert.AreEqual (10, rects[1].Height);
+
+ }
+
+
+ [Test]
+ public void TestExcludeGroup1 ()
+ {
+ RectangleF[] rects;
+ Region r1 = new Region ();
+ Region r2 = new Region ();
+ Rectangle rect1 = Rectangle.Empty;
+ Rectangle rect2 = Rectangle.Empty;
+ Rectangle rect3 = Rectangle.Empty;
+ Rectangle rect4 = Rectangle.Empty;
+ Rectangle rect5 = Rectangle.Empty;
+ Rectangle rect6 = Rectangle.Empty;
+ Rectangle rect7 = Rectangle.Empty;
+
+
+ { // TEST1: Not intersecting rects. Exclude just adds them
+
+ rect1 = new Rectangle (20, 20, 20, 20);
+ rect2 = new Rectangle (20, 80, 20, 10);
+ rect3 = new Rectangle (60, 60, 30, 10);
+
+ r1 = new Region (rect1);
+ r2 = new Region (rect2);
+ r2.Union (rect3);
+ r1.Exclude (r2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (1, rects.Length, "TEG1Test1");
+ AssertEqualRectangles (new RectangleF (20, 20, 20, 20), rects[0], "TEG1Test2");
+ }
+
+ { // TEST2: Excluding from the right
+ /*
+ * -----------
+ * | |
+ * | |-------- |
+ * | | |
+ * | |-------- |
+ * | |
+ * ----------|
+ *
+ */
+
+ rect1 = new Rectangle (10, 10, 100, 100);
+ rect2 = new Rectangle (40, 60, 100, 20);
+ r1 = new Region (rect1);
+ r1.Exclude (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (3, rects.Length, "TEG2Test1");
+ AssertEqualRectangles (new RectangleF (10, 10, 100, 50), rects[0], "TEG2Test2");
+ AssertEqualRectangles (new RectangleF (10, 60, 30, 20), rects[1], "TEG2Test3");
+ AssertEqualRectangles (new RectangleF (10, 80, 100, 30), rects[2], "TEG2Test4");
+ }
+
+
+ { // TEST3: Intersecting from the right
+ /*
+ * -----------
+ * | |
+ * |-------- | |
+ * | | |
+ * |-------- | |
+ * | |
+ * ----------|
+ *
+ */
+
+ rect1 = new Rectangle (70, 10, 100, 100);
+ rect2 = new Rectangle (40, 60, 100, 20);
+
+ r1 = new Region (rect1);
+ r1.Exclude (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (3, rects.Length, "TEG3Test1");
+ AssertEqualRectangles (new RectangleF (70, 10, 100, 50), rects[0], "TEG3Test2");
+ AssertEqualRectangles (new RectangleF (140, 60, 30, 20), rects[1], "TEG3Test3");
+ AssertEqualRectangles (new RectangleF (70, 80, 100, 30), rects[2], "TEG3Test4");
+ }
+
+
+ { // TEST4: Intersecting from the top
+ /*
+ * -----
+ * | |
+ * -----------
+ * | | | |
+ * | ----- |
+ * | |
+ * | |
+ * ----------|
+ *
+ */
+
+ rect1 = new Rectangle (40, 100, 100, 100);
+ rect2 = new Rectangle (70, 80, 50, 40);
+
+ r1 = new Region (rect1);
+ r1.Exclude (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (3, rects.Length, "TEG4Test1");
+ AssertEqualRectangles (new RectangleF (40, 100, 30, 20), rects[0], "TEG4Test2");
+ AssertEqualRectangles (new RectangleF (120, 100, 20, 20), rects[1], "TEG4Test3");
+ AssertEqualRectangles (new RectangleF (40, 120, 100, 80), rects[2], "TEG4Test4");
+ }
+
+
+ { // TEST5: Intersecting from the bottom
+ /*
+ * -----------
+ * | |
+ * | |
+ * | |
+ * | | | |
+ * |--| |--|
+ * | |
+ * -----
+ *
+ */
+
+ rect1 = new Rectangle (40, 10, 100, 100);
+ rect2 = new Rectangle (70, 80, 50, 40);
+
+ r1 = new Region (rect1);
+ r1.Exclude (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (3, rects.Length, "TEG5Test1");
+ AssertEqualRectangles (new RectangleF (40, 10, 100, 70), rects[0], "TEG5Test2");
+ AssertEqualRectangles (new RectangleF (40, 80, 30, 30), rects[1], "TEG5Test3");
+ AssertEqualRectangles (new RectangleF (120, 80, 20, 30), rects[2], "TEG5Test4");
+ }
+
+
+ { // TEST6: Multiple regions
+
+ rect1 = new Rectangle (30, 30, 80, 80);
+ rect2 = new Rectangle (45, 45, 200, 200);
+ rect3 = new Rectangle (160, 260, 10, 10);
+ rect4 = new Rectangle (170, 260, 10, 10);
+
+ r1 = new Region (rect1);
+ r1.Exclude (rect2);
+ r1.Exclude (rect3);
+ r1.Exclude (rect4);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (2, rects.Length, "TEG6Test1");
+ AssertEqualRectangles (new RectangleF (30, 30, 80, 15), rects[0], "TEG6Test2");
+ AssertEqualRectangles (new RectangleF (30, 45, 15, 65), rects[1], "TEG6Test3");
+ }
+
+
+ { // TEST7: Intersecting from the top with a larger rect
+ /*
+ * -----------------
+ * | |
+ * | ----------- |
+ * | | | |
+ * | ----- |
+ * | |
+ * | |
+ * ----------|
+ *
+ */
+
+ rect1 = new Rectangle (50, 100, 100, 100);
+ rect2 = new Rectangle (30, 70, 150, 40);
+
+ r1 = new Region (rect1);
+ r1.Exclude (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (1, rects.Length, "TEG7Test1");
+ AssertEqualRectangles (new RectangleF (50, 110, 100, 90), rects[0], "TEG7Test2");
+ }
+
+ { // TEST8: Intersecting from the right with a larger rect
+ /*
+ *
+ * |--------|
+ * | |
+ * | -----------
+ * | | |
+ * | | |
+ * | | |
+ * | | |
+ * | | |
+ * | ----------|
+ * |-------|
+ */
+
+ rect1 = new Rectangle (70, 60, 100, 70);
+ rect2 = new Rectangle (40, 10, 100, 150);
+
+ r1 = new Region (rect1);
+ r1.Exclude (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (1, rects.Length, "TEG8Test1");
+ AssertEqualRectangles (new RectangleF (140, 60, 30, 70), rects[0], "TEG8Test2");
+
+ }
+
+ { // TEST9: Intersecting from the left with a larger rect
+ /*
+ *
+ * |--------|
+ * | |
+ * ----------- |
+ * | | |
+ * | | |
+ * | | |
+ * | | |
+ * | | |
+ * ----------| |
+ * |--------|
+ *
+ */
+
+
+ rect1 = new Rectangle (70, 60, 100, 70);
+ rect2 = new Rectangle (100, 10, 100, 150);
+
+ r1 = new Region (rect1);
+ r1.Exclude (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (1, rects.Length, "TEG9Test1");
+ AssertEqualRectangles (new RectangleF (70, 60, 30, 70), rects[0], "TEG9Test2");
+ }
+
+
+ { // TEST10: Intersecting from the bottom with a larger rect
+ /*
+ * *
+ * |--------|
+ * | |
+ * | |
+ * | |
+ * --------------------
+ * | |
+ * | |
+ * |------------------|
+ */
+
+
+ rect1 = new Rectangle (20, 20, 100, 100);
+ rect2 = new Rectangle (10, 80, 140, 150);
+
+ r1 = new Region (rect1);
+ r1.Exclude (rect2);
+
+ rects = r1.GetRegionScans (new Matrix ());
+ Assert.AreEqual (1, rects.Length, "TEG10Test1");
+ AssertEqualRectangles (new RectangleF (20, 20, 100, 60), rects[0], "TEG10Test2");
+ }
+
+
+ }
+
+ [Test]
+ public void TestExcludeGroup2 ()
+ {
+ Bitmap bmp = new Bitmap (600, 800);
+ Graphics dc = Graphics.FromImage (bmp);
+ Matrix matrix = new Matrix ();
+ Rectangle rect1, rect2;
+ Region rgn1;
+ RectangleF [] rects;
+
+ rect1 = new Rectangle (130, 30, 60, 80);
+ rect2 = new Rectangle (170, 40, 60, 80);
+ rgn1 = new Region (rect1);
+ rgn1.Exclude (rect2);
+ rects = rgn1.GetRegionScans (matrix);
+
+ Assert.AreEqual (2, rects.Length);
+
+ Assert.AreEqual (130, rects[0].X);
+ Assert.AreEqual (30, rects[0].Y);
+ Assert.AreEqual (60, rects[0].Width);
+ Assert.AreEqual (10, rects[0].Height);
+
+ Assert.AreEqual (130, rects[1].X);
+ Assert.AreEqual (40, rects[1].Y);
+ Assert.AreEqual (40, rects[1].Width);
+ Assert.AreEqual (70, rects[1].Height);
+ }
+
+ [Test]
+ public void TestIntersect()
+ {
+
+
+ Bitmap bmp = new Bitmap (600, 800);
+ Graphics dc = Graphics.FromImage (bmp);
+ Matrix matrix = new Matrix ();
+ RectangleF [] rects;
+ RectangleF rect3, rect4;
+ Region rgn3, rgn4;
+
+ /* Two simple areas */
+ Rectangle rect1 = new Rectangle (260, 30, 60, 80);
+ Rectangle rect2 = new Rectangle (290, 40, 60, 80);
+ Region rgn1 = new Region (rect1);
+ Region rgn2 = new Region (rect2);
+ rgn1.Intersect (rgn2);
+
+ rects = rgn1.GetRegionScans (matrix);
+ Assert.AreEqual (1, rects.Length);
+
+ Assert.AreEqual (290, rects[0].X);
+ Assert.AreEqual (40, rects[0].Y);
+ Assert.AreEqual (30, rects[0].Width);
+ Assert.AreEqual (70, rects[0].Height);
+
+ /* No intersect */
+ rect1 = new Rectangle (20, 330, 40, 50);
+ rect2 = new Rectangle (50, 340, 40, 50);
+ rect3 = new Rectangle (70, 360, 30, 50);
+ rect4 = new Rectangle (80, 400, 30, 10);
+ rgn1 = new Region (rect1);
+ rgn2 = new Region (rect2);
+ rgn3 = new Region (rect3);
+ rgn4 = new Region (rect4);
+
+ rgn1.Intersect (rgn2);
+ rgn1.Intersect (rgn3);
+ rgn1.Intersect (rgn4);
+ rects = rgn1.GetRegionScans (matrix);
+ Assert.AreEqual (0, rects.Length);
+ }
+
+ [Test]
+ public void TestXor()
+ {
+ Bitmap bmp = new Bitmap (600, 800);
+ Graphics dc = Graphics.FromImage (bmp);
+ Matrix matrix = new Matrix ();
+ RectangleF [] rects;
+
+ Rectangle rect1 = new Rectangle (380, 30, 60, 80);
+ Rectangle rect2 = new Rectangle (410, 40, 60, 80);
+ Region rgn1 = new Region (rect1);
+ Region rgn2 = new Region (rect2);
+ rgn1.Xor (rgn2);
+
+
+ rects = rgn1.GetRegionScans (matrix);
+
+ Assert.AreEqual (4, rects.Length);
+
+ Assert.AreEqual (380, rects[0].X);
+ Assert.AreEqual (30, rects[0].Y);
+ Assert.AreEqual (60, rects[0].Width);
+ Assert.AreEqual (10, rects[0].Height);
+
+ Assert.AreEqual (380, rects[1].X);
+ Assert.AreEqual (40, rects[1].Y);
+ Assert.AreEqual (30, rects[1].Width);
+ Assert.AreEqual (70, rects[1].Height);
+
+ Assert.AreEqual (440, rects[2].X);
+ Assert.AreEqual (40, rects[2].Y);
+ Assert.AreEqual (30, rects[2].Width);
+ Assert.AreEqual (70, rects[2].Height);
+
+ Assert.AreEqual (410, rects[3].X);
+ Assert.AreEqual (110, rects[3].Y);
+ Assert.AreEqual (60, rects[3].Width);
+ Assert.AreEqual (10, rects[3].Height);
+ }
+
+
+ [Test]
+ public void TestIsVisible()
+ {
+ Bitmap bmp = new Bitmap (600, 800);
+ Graphics dc = Graphics.FromImage (bmp);
+ Rectangle rect1, rect2;
+ Region rgn1, rgn2;
+ Matrix matrix = new Matrix ();
+
+ rect1 = new Rectangle (500, 30, 60, 80);
+ rect2 = new Rectangle (520, 40, 60, 80);
+
+ rgn1 = new Region (new RectangleF (0, 0, 10,10));
+ Assert.AreEqual (false, rgn1.IsVisible (0,0,0,1));
+
+ rgn1 = new Region (rect1);
+ Assert.AreEqual (false, rgn1.IsVisible (500,29));
+ Assert.AreEqual (true, rgn1.IsVisible (500,30));
+ Assert.AreEqual (true, rgn1.IsVisible (rect1));
+ Assert.AreEqual (true, rgn1.IsVisible (rect2));
+ Assert.AreEqual (false, rgn1.IsVisible (new Rectangle (50,50,2,5)));
+
+ Rectangle r = new Rectangle (1,1, 2,1);
+ rgn2 = new Region (r);
+ Assert.AreEqual (true, rgn2.IsVisible (r));
+ Assert.AreEqual (true, rgn2.IsVisible (new Rectangle (1,1, 2,2)));
+ Assert.AreEqual (true, rgn2.IsVisible (new Rectangle (1,1, 10,10)));
+ Assert.AreEqual (true, rgn2.IsVisible (new Rectangle (1,1, 1,1)));
+ Assert.AreEqual (false, rgn2.IsVisible (new Rectangle (2,2, 1,1)));
+ Assert.AreEqual (false, rgn2.IsVisible (new Rectangle (0,0, 1,1)));
+ Assert.AreEqual (false, rgn2.IsVisible (new Rectangle (3,3, 1,1)));
+
+ Assert.AreEqual (false, rgn2.IsVisible (0,0));
+ Assert.AreEqual (false, rgn2.IsVisible (1,0));
+ Assert.AreEqual (false, rgn2.IsVisible (2,0));
+ Assert.AreEqual (false, rgn2.IsVisible (3,0));
+ Assert.AreEqual (false, rgn2.IsVisible (0,1));
+ Assert.AreEqual (true, rgn2.IsVisible (1,1));
+ Assert.AreEqual (true, rgn2.IsVisible (2,1));
+ Assert.AreEqual (false, rgn2.IsVisible (3,1));
+ Assert.AreEqual (false, rgn2.IsVisible (0,2));
+ Assert.AreEqual (false, rgn2.IsVisible (1,2));
+ Assert.AreEqual (false, rgn2.IsVisible (2,2));
+ Assert.AreEqual (false, rgn2.IsVisible (3,2));
+
+
+ }
+
+ [Test]
+ public void TestTranslate()
+ {
+ Region rgn1 = new Region (new RectangleF (10, 10, 120,120));
+ rgn1.Translate (30,20);
+ Matrix matrix = new Matrix ();
+
+ RectangleF [] rects = rgn1.GetRegionScans (matrix);
+
+ Assert.AreEqual (1, rects.Length);
+
+ Assert.AreEqual (40, rects[0].X);
+ Assert.AreEqual (30, rects[0].Y);
+ Assert.AreEqual (120, rects[0].Width);
+ Assert.AreEqual (120, rects[0].Height);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Constructor_GraphicsPath_Null ()
+ {
+ GraphicsPath gp = null;
+ Region r = new Region (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Constructor_RegionData_Null ()
+ {
+ RegionData rd = null;
+ Region r = new Region (rd);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Union_GraphicsPath_Null ()
+ {
+ GraphicsPath gp = null;
+ new Region ().Union (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Union_Region_Null ()
+ {
+ Region r = null;
+ new Region ().Union (r);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Intersect_GraphicsPath_Null ()
+ {
+ GraphicsPath gp = null;
+ new Region ().Intersect (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Intersect_Region_Null ()
+ {
+ Region r = null;
+ new Region ().Intersect (r);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Complement_GraphicsPath_Null ()
+ {
+ GraphicsPath gp = null;
+ new Region ().Complement (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Complement_Region_Null ()
+ {
+ Region r = null;
+ new Region ().Complement (r);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Exclude_GraphicsPath_Null ()
+ {
+ GraphicsPath gp = null;
+ new Region ().Exclude (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Exclude_Region_Null ()
+ {
+ Region r = null;
+ new Region ().Exclude (r);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Xor_GraphicsPath_Null ()
+ {
+ GraphicsPath gp = null;
+ new Region ().Xor (gp);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Xor_Region_Null ()
+ {
+ Region r = null;
+ new Region ().Xor (r);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void GetBounds_Null ()
+ {
+ new Region ().GetBounds (null);
+ }
+
+ [Test]
+ public void IsVisible_IntIntNull ()
+ {
+ Assert.IsTrue (new Region ().IsVisible (0, 0, null));
+ }
+
+ [Test]
+ public void IsVisible_IntIntIntIntNull ()
+ {
+ Assert.IsFalse (new Region ().IsVisible (0, 0, 0, 0, null));
+ }
+
+ [Test]
+ public void IsVisible_PointNull ()
+ {
+ Point p = new Point ();
+ Assert.IsTrue (new Region ().IsVisible (p, null));
+ }
+
+ [Test]
+ public void IsVisible_PointFNull ()
+ {
+ PointF p = new PointF ();
+ Assert.IsTrue (new Region ().IsVisible (p, null));
+ }
+
+ [Test]
+ public void IsVisible_RectangleNull ()
+ {
+ Rectangle r = new Rectangle ();
+ Assert.IsFalse (new Region ().IsVisible (r, null));
+ }
+
+ [Test]
+ public void IsVisible_RectangleFNull ()
+ {
+ RectangleF r = new RectangleF ();
+ Assert.IsFalse (new Region ().IsVisible (r, null));
+ }
+
+ [Test]
+ public void IsVisible_SingleSingleNull ()
+ {
+ Assert.IsTrue (new Region ().IsVisible (0f, 0f, null));
+ }
+
+ [Test]
+ public void IsVisible_SingleSingleSingleSingleNull ()
+ {
+ Assert.IsFalse (new Region ().IsVisible (0f, 0f, 0f, 0f, null));
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void IsEmpty_Null ()
+ {
+ new Region ().IsEmpty (null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void IsInfinite_Null ()
+ {
+ new Region ().IsInfinite (null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Equals_NullGraphics ()
+ {
+ new Region ().Equals (null, Graphics.FromImage (new Bitmap (10, 10)));
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Equals_RegionNull ()
+ {
+ new Region ().Equals (new Region (), null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ [Category ("NotWorking")] // caused regression in SWF
+ public void GetHrgn_Null ()
+ {
+ new Region ().GetHrgn (null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void GetRegionScans_Null ()
+ {
+ new Region ().GetRegionScans (null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void Transform_Null ()
+ {
+ new Region ().Transform (null);
+ }
+
+ // an "empty ctor" Region is infinite
+ private void CheckEmpty (string prefix, Region region)
+ {
+ Assert.IsFalse (region.IsEmpty (graphic), prefix + "IsEmpty");
+ Assert.IsTrue (region.IsInfinite (graphic), prefix + "graphic");
+
+ RectangleF rect = region.GetBounds (graphic);
+ Assert.AreEqual (-4194304f, rect.X, prefix + "GetBounds.X");
+ Assert.AreEqual (-4194304f, rect.Y, prefix + "GetBounds.Y");
+ Assert.AreEqual (8388608f, rect.Width, prefix + "GetBounds.Width");
+ Assert.AreEqual (8388608f, rect.Height, prefix + "GetBounds.Height");
+ }
+
+ [Test]
+ public void Region_Empty ()
+ {
+ Region region = new Region ();
+ CheckEmpty ("Empty.", region);
+
+ Region clone = region.Clone ();
+ CheckEmpty ("Clone.", region);
+
+ RegionData data = region.GetRegionData ();
+ Region r2 = new Region (data);
+ CheckEmpty ("RegionData.", region);
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void Region_Infinite_MultipleRectangles ()
+ {
+ Region region = new Region ();
+ Assert.IsTrue (region.IsInfinite (graphic), "Empty.IsInfinite");
+
+ GraphicsPath gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (-4194304, -4194304, 8388608, 8388608));
+ region = new Region (gp);
+ Assert.IsTrue (region.IsInfinite (graphic), "OneRectangle.IsInfinite");
+
+ gp.AddRectangle (new Rectangle (1, 1, 2, 2));
+ region = new Region (gp);
+ Assert.IsFalse (region.IsInfinite (graphic), "TwoOverlappingRectangle.IsInfinite");
+
+ gp = new GraphicsPath ();
+ gp.AddRectangle (new Rectangle (-4194304, -4194304, 4194304, 8388608));
+ gp.AddRectangle (new Rectangle (0, -4194304, 4194304, 8388608));
+ Assert.IsFalse (region.IsInfinite (graphic), "TwoSideBySideRectangle.IsInfinite");
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestSize.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestSize.cs
new file mode 100644
index 00000000000..675d4f483e4
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestSize.cs
@@ -0,0 +1,218 @@
+// Tests for System.Drawing.Size.cs
+//
+// Author: Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class SizeTest : Assertion
+ {
+ Size sz1_1;
+ Size sz1_0;
+ Size sz0_1;
+
+ [TearDown]
+ public void TearDown () {}
+
+ [SetUp]
+ public void SetUp ()
+ {
+ sz1_1 = new Size (1, 1);
+ sz1_0 = new Size (1, 0);
+ sz0_1 = new Size (0, 1);
+ }
+
+ [Test]
+ public void TestConstructors ()
+ {
+ Size sz_wh = new Size (1, 5);
+ AssertEquals ("C#1", 1, sz_wh.Width);
+ AssertEquals ("C#2", 5, sz_wh.Height);
+
+ Size sz_pt = new Size (new Point (1, 5));
+ AssertEquals ("C#3", 1, sz_pt.Width);
+ AssertEquals ("C#4", 5, sz_pt.Height);
+
+ AssertEquals ("C#5", sz_wh, sz_pt);
+ }
+
+ [Test]
+ public void TestEmptyField ()
+ {
+ Size sz = new Size (0, 0);
+ AssertEquals ("EMP#1", sz, Size.Empty);
+ }
+
+ [Test]
+ public void TestProperties ()
+ {
+ Size sz = new Size (0, 0);
+
+ Assert ("P#1", sz.IsEmpty);
+ Assert ("P#2", ! sz1_1.IsEmpty);
+ AssertEquals ("P#3", 1, sz1_0.Width);
+ AssertEquals ("P#4", 1, sz0_1.Height);
+ }
+
+ [Test]
+ public void TestCeiling ()
+ {
+ SizeF sf = new SizeF (0.5F, 0.6F);
+ AssertEquals ("CL#1", sz1_1, Size.Ceiling (sf));
+
+ sf = new SizeF (1.0F, 1.0F);
+ AssertEquals ("CL#2", sz1_1, Size.Ceiling (sf));
+ }
+
+ [Test]
+ public void TestEquals ()
+ {
+ AssertEquals ("EQ#1", sz1_1, sz1_1);
+ AssertEquals ("EQ#2", sz1_1, new Size (1, 1));
+ Assert ("EQ#3", ! sz1_1.Equals (sz1_0));
+ Assert ("EQ#4", ! sz1_1.Equals (sz0_1));
+ Assert ("EQ#5", ! sz1_0.Equals (sz0_1));
+ }
+
+ [Test]
+ public void TestRound ()
+ {
+ SizeF sf = new SizeF (0.3F, 0.7F);
+ AssertEquals ("CL#1", sz0_1, Size.Round (sf));
+
+ sf = new SizeF (0.6F, 0.6F);
+ AssertEquals ("CL#2", sz1_1, Size.Round (sf));
+
+ sf = new SizeF (1.0F, 1.0F);
+ AssertEquals ("CL#3", sz1_1, Size.Round (sf));
+ }
+
+
+ [Test]
+ public void TestTruncate ()
+ {
+ SizeF sf = new SizeF (0.8f, 1.3f);
+ AssertEquals ("TR#1", sz0_1, Size.Truncate (sf));
+
+ sf = new SizeF (1.9f, 1.9f);
+ AssertEquals ("TR#2", sz1_1, Size.Truncate (sf));
+
+ sf = new SizeF (1.0f, 1.0f);
+ AssertEquals ("TR#3", sz1_1, Size.Truncate (sf));
+ }
+
+ [Test]
+ public void TestAddition ()
+ {
+ AssertEquals ("ADD#1", sz1_1, sz1_0 + sz0_1);
+ AssertEquals ("ADD#2", sz1_1, sz1_1 + new Size (0, 0));
+ }
+
+ [Test]
+ public void TestEqualityOp ()
+ {
+ Assert ("EOP#1", sz1_1 == sz1_1);
+ Assert ("EOP#2", sz1_1 == new Size (1, 1));
+ Assert ("EOP#3", ! (sz1_1 == sz1_0));
+ Assert ("EOP#4", ! (sz1_1 == sz0_1));
+ Assert ("EOP#5", ! (sz1_0 == sz0_1));
+ }
+
+ [Test]
+ public void TestInequalityOp ()
+ {
+ Assert ("IOP#1", ! (sz1_1 != sz1_1));
+ Assert ("IOP#2", ! (sz1_1 != new Size (1, 1)));
+ Assert ("IOP#3", sz1_1 != sz1_0);
+ Assert ("IOP#4", sz1_1 != sz0_1);
+ Assert ("IOP#5", sz1_0 != sz0_1);
+ }
+
+ [Test]
+ public void TestSubtraction ()
+ {
+ AssertEquals ("SUB#1", sz1_0, sz1_1 - sz0_1);
+ AssertEquals ("SUB#2", sz0_1, sz1_1 - sz1_0);
+ }
+
+ [Test]
+ public void TestSize2Point ()
+ {
+ Point pt1 = new Point (1, 1);
+ Point pt2 = (Point) sz1_1;
+
+ AssertEquals ("SZ2PT#1", pt1, pt2);
+ }
+
+ [Test]
+ public void TestSize2SizeF ()
+ {
+ SizeF sf1 = new SizeF (1.0F, 1.0F);
+ SizeF sf2 = (SizeF) sz1_1;
+
+ AssertEquals ("SZ2SF#1", sf1, sf2);
+ }
+
+ [Test]
+ public void ToStringTest ()
+ {
+ AssertEquals ("{Width=1, Height=0}", sz1_0.ToString ());
+ AssertEquals ("{Width=0, Height=0}", Size.Empty.ToString ());
+ }
+
+ [Test]
+ public void GetHashCodeTest ()
+ {
+ AssertEquals (new Size (1, 0).GetHashCode (), sz1_0.GetHashCode ());
+ }
+
+#if NET_2_0
+ [Test]
+ public void AddTest ()
+ {
+ AssertEquals ("ADD#1", sz1_1, Size.Add (sz1_0, sz0_1));
+ AssertEquals ("ADD#2", sz1_1, Size.Add (sz1_1, new Size (0, 0)));
+ }
+
+ [Test]
+ public void SubtractTest ()
+ {
+ AssertEquals ("SUB#1", sz1_0, Size.Subtract (sz1_1, sz0_1));
+ AssertEquals ("SUB#2", sz0_1, Size.Subtract (sz1_1, sz1_0));
+ }
+#endif
+
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestSizeConverter.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestSizeConverter.cs
new file mode 100644
index 00000000000..22592590fa6
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestSizeConverter.cs
@@ -0,0 +1,462 @@
+//
+// Tests for System.Drawing.SizeConverter.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Drawing;
+using System.Globalization;
+using System.Security.Permissions;
+using System.Threading;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class SizeConverterTest
+ {
+ Size sz;
+ Size szneg;
+ SizeConverter szconv;
+ String szStrInvariant;
+ String sznegStrInvariant;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ sz = new Size (10, 20);
+ szStrInvariant = sz.Width + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + sz.Height;
+
+ szneg = new Size (-20, -30);
+ sznegStrInvariant = szneg.Width + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + szneg.Height;
+
+ szconv = (SizeConverter) TypeDescriptor.GetConverter (sz);
+ }
+
+ [Test]
+ public void TestCanConvertFrom ()
+ {
+ Assert.IsTrue (szconv.CanConvertFrom (typeof (String)), "CCF#1");
+ Assert.IsTrue (szconv.CanConvertFrom (null, typeof (String)), "CCF#2");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (Rectangle)), "CCF#3");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (RectangleF)), "CCF#4");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (Point)), "CCF#5");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (PointF)), "CCF#6");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (Size)), "CCF#7");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (SizeF)), "CCF#8");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (Object)), "CCF#9");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (int)), "CCF#10");
+ Assert.IsTrue (szconv.CanConvertFrom (null, typeof (InstanceDescriptor)), "CCF#11");
+ }
+
+ [Test]
+ public void TestCanConvertTo ()
+ {
+ Assert.IsTrue (szconv.CanConvertTo (typeof (String)), "CCT#1");
+ Assert.IsTrue (szconv.CanConvertTo (null, typeof (String)), "CCT#2");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (Rectangle)), "CCT#3");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (RectangleF)), "CCT#4");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (Point)), "CCT#5");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (PointF)), "CCT#6");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (Size)), "CCT#7");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (SizeF)), "CCT#8");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (Object)), "CCT#9");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (int)), "CCT#10");
+ }
+
+ [Test]
+ public void TestConvertFrom ()
+ {
+ Assert.AreEqual (sz, (Size) szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "10, 20"), "CF#1");
+ Assert.AreEqual (szneg, (Size) szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "-20, -30"), "CF#2");
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture, "10");
+ Assert.Fail ("CF#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#3");
+ }
+
+ try {
+ szconv.ConvertFrom ("10");
+ Assert.Fail ("CF#3a: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#3a");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "1, 1, 1");
+ Assert.Fail ("CF#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#4");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "*1, 1");
+ Assert.Fail ("CF#5-1: must throw Exception");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "CF#5-2");
+ Assert.IsNotNull (ex.InnerException, "CF#5-3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "CF#5-4");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Point (10, 10));
+ Assert.Fail ("CF#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#6");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new PointF (10, 10));
+ Assert.Fail ("CF#7: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#7");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Size (10, 10));
+ Assert.Fail ("CF#8: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#8");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new SizeF (10, 10));
+ Assert.Fail ("CF#9: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#9");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture, 0x10);
+ Assert.Fail ("CF#10: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#10");
+ }
+ }
+
+ [Test]
+ public void TestConvertTo ()
+ {
+ Assert.AreEqual (szStrInvariant, (String) szconv.ConvertTo (null,
+ CultureInfo.InvariantCulture, sz, typeof (String)), "CT#1");
+ Assert.AreEqual (sznegStrInvariant, (String) szconv.ConvertTo (null,
+ CultureInfo.InvariantCulture, szneg, typeof (String)), "CT#2");
+
+ try {
+ szconv.ConvertTo (null, CultureInfo.InvariantCulture, sz,
+ typeof (Size));
+ Assert.Fail ("CT#3: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#3");
+ }
+
+ try {
+ szconv.ConvertTo (null, CultureInfo.InvariantCulture, sz,
+ typeof (SizeF));
+ Assert.Fail ("CT#4: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#4");
+ }
+
+ try {
+ szconv.ConvertTo (null, CultureInfo.InvariantCulture, sz,
+ typeof (Point));
+ Assert.Fail ("CT#5: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#5");
+ }
+
+ try {
+ szconv.ConvertTo (null, CultureInfo.InvariantCulture, sz,
+ typeof (PointF));
+ Assert.Fail ("CT#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#6");
+ }
+
+ try {
+ szconv.ConvertTo (null, CultureInfo.InvariantCulture, sz,
+ typeof (int));
+ Assert.Fail ("CT#7: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#7");
+ }
+ }
+
+ [Test]
+ public void TestGetCreateInstanceSupported ()
+ {
+ Assert.IsTrue (szconv.GetCreateInstanceSupported (), "GCIS#1");
+ Assert.IsTrue (szconv.GetCreateInstanceSupported (null), "GCIS#2");
+ }
+
+ [Test]
+ public void TestCreateInstance ()
+ {
+ Size szInstance;
+
+ Hashtable ht = new Hashtable ();
+ ht.Add ("Width", 10); ht.Add ("Height", 20);
+
+ szInstance = (Size) szconv.CreateInstance (ht);
+ Assert.AreEqual (sz, szInstance, "CI#1");
+
+ ht.Clear ();
+ ht.Add ("Width", -20); ht.Add ("Height", -30);
+
+ szInstance = (Size) szconv.CreateInstance (null, ht);
+ Assert.AreEqual (szneg, szInstance, "CI#2");
+
+ // Property names are case-sensitive. It should throw
+ // NullRefExc if any of the property names does not match
+ ht.Clear ();
+ ht.Add ("width", 20); ht.Add ("Height", 30);
+ try {
+ szInstance = (Size) szconv.CreateInstance (null, ht);
+ Assert.Fail ("CI#3: must throw NullReferenceException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NullReferenceException, "CI#3");
+ }
+ }
+
+ [Test]
+ public void TestGetPropertiesSupported ()
+ {
+ Assert.IsTrue (szconv.GetPropertiesSupported (), "GPS#1");
+ Assert.IsTrue (szconv.GetPropertiesSupported (null), "GPS#2");
+ }
+
+ [Test]
+ public void TestGetProperties ()
+ {
+ Attribute [] attrs;
+ PropertyDescriptorCollection propsColl;
+
+ propsColl = szconv.GetProperties (sz);
+ Assert.AreEqual (2, propsColl.Count, "GP1#1");
+ Assert.AreEqual (sz.Width, propsColl["Width"].GetValue (sz), "GP1#2");
+ Assert.AreEqual (sz.Height, propsColl["Height"].GetValue (sz), "GP1#3");
+
+ propsColl = szconv.GetProperties (null, szneg);
+ Assert.AreEqual (2, propsColl.Count, "GP2#1");
+ Assert.AreEqual (szneg.Width, propsColl["Width"].GetValue (szneg), "GP2#2");
+ Assert.AreEqual (szneg.Height, propsColl["Height"].GetValue (szneg), "GP2#3");
+
+ propsColl = szconv.GetProperties (null, sz, null);
+ Assert.AreEqual (3, propsColl.Count, "GP3#1");
+ Assert.AreEqual (sz.Width, propsColl["Width"].GetValue (sz), "GP3#2");
+ Assert.AreEqual (sz.Height, propsColl["Height"].GetValue (sz), "GP3#3");
+ Assert.AreEqual (sz.IsEmpty, propsColl["IsEmpty"].GetValue (sz), "GP3#4");
+
+ Type type = typeof (Size);
+ attrs = Attribute.GetCustomAttributes (type, true);
+ propsColl = szconv.GetProperties (null, sz, attrs);
+ Assert.AreEqual (0, propsColl.Count, "GP3#5");
+ }
+
+ [Test]
+ public void ConvertFromInvariantString_string ()
+ {
+ Assert.AreEqual (sz, szconv.ConvertFromInvariantString (szStrInvariant),
+ "CFISS#1");
+ Assert.AreEqual (szneg, szconv.ConvertFromInvariantString (sznegStrInvariant),
+ "CFISS#2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFromInvariantString_string_exc_1 ()
+ {
+ szconv.ConvertFromInvariantString ("1, 2, 3");
+ }
+
+ [Test]
+ public void ConvertFromInvariantString_string_exc_2 ()
+ {
+ try {
+ szconv.ConvertFromInvariantString ("hello");
+ Assert.Fail ("#1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.InnerException, "#3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
+ }
+ }
+
+ [Test]
+ public void ConvertFromString_string ()
+ {
+ // save current culture
+ CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ PerformConvertFromStringTest (new CultureInfo ("en-US"));
+ PerformConvertFromStringTest (new CultureInfo ("nl-BE"));
+ PerformConvertFromStringTest (new MyCultureInfo ());
+ } finally {
+ // restore original culture
+ Thread.CurrentThread.CurrentCulture = currentCulture;
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFromString_string_exc_1 ()
+ {
+ CultureInfo culture = CultureInfo.CurrentCulture;
+ szconv.ConvertFromString (string.Format(culture,
+ "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator));
+ }
+
+ [Test]
+ public void ConvertFromString_string_exc_2 ()
+ {
+ try {
+ szconv.ConvertFromString ("hello");
+ Assert.Fail ("#1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.InnerException, "#3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
+ }
+ }
+
+ [Test]
+ public void ConvertToInvariantString_string ()
+ {
+ Assert.AreEqual (szStrInvariant, szconv.ConvertToInvariantString (sz),
+ "CFISS#1");
+ Assert.AreEqual (sznegStrInvariant, szconv.ConvertToInvariantString (szneg),
+ "CFISS#2");
+ }
+
+ [Test]
+ public void ConvertToString_string ()
+ {
+ // save current culture
+ CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ PerformConvertToStringTest (new CultureInfo ("en-US"));
+ PerformConvertToStringTest (new CultureInfo ("nl-BE"));
+ PerformConvertToStringTest (new MyCultureInfo ());
+ } finally {
+ // restore original culture
+ Thread.CurrentThread.CurrentCulture = currentCulture;
+ }
+ }
+
+ [Test]
+ public void GetStandardValuesSupported ()
+ {
+ Assert.IsFalse (szconv.GetStandardValuesSupported ());
+ }
+
+ [Test]
+ public void GetStandardValues ()
+ {
+ Assert.IsNull (szconv.GetStandardValues ());
+ }
+
+ [Test]
+ public void GetStandardValuesExclusive ()
+ {
+ Assert.IsFalse (szconv.GetStandardValuesExclusive ());
+ }
+
+ private void PerformConvertFromStringTest (CultureInfo culture)
+ {
+ // set current culture
+ Thread.CurrentThread.CurrentCulture = culture;
+
+ // perform tests
+ Assert.AreEqual (sz, szconv.ConvertFromString (CreateSizeString (culture, sz)),
+ "CFSS#1-" + culture.Name);
+ Assert.AreEqual (szneg, szconv.ConvertFromString (CreateSizeString (culture, szneg)),
+ "CFSS#2-" + culture.Name);
+ }
+
+ private void PerformConvertToStringTest (CultureInfo culture)
+ {
+ // set current culture
+ Thread.CurrentThread.CurrentCulture = culture;
+
+ // perform tests
+ Assert.AreEqual (CreateSizeString (culture, sz), szconv.ConvertToString (sz),
+ "CFISS#1-" + culture.Name);
+ Assert.AreEqual (CreateSizeString (culture, szneg), szconv.ConvertToString (szneg),
+ "CFISS#2-" + culture.Name);
+ }
+
+ private static string CreateSizeString (Size size)
+ {
+ return CreateSizeString (CultureInfo.CurrentCulture, size);
+ }
+
+ private static string CreateSizeString (CultureInfo culture, Size size)
+ {
+ return string.Format ("{0}{1} {2}", size.Width.ToString (culture),
+ culture.TextInfo.ListSeparator, size.Height.ToString (culture));
+ }
+
+ [Serializable]
+ private sealed class MyCultureInfo : CultureInfo
+ {
+ internal MyCultureInfo () : base ("en-US")
+ {
+ }
+
+ public override object GetFormat (Type formatType)
+ {
+ if (formatType == typeof (NumberFormatInfo)) {
+ NumberFormatInfo nfi = (NumberFormatInfo) ((NumberFormatInfo) base.GetFormat (formatType)).Clone ();
+
+ nfi.NegativeSign = "myNegativeSign";
+ return NumberFormatInfo.ReadOnly (nfi);
+ } else {
+ return base.GetFormat (formatType);
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestSizeF.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestSizeF.cs
new file mode 100644
index 00000000000..20179a9e4ab
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestSizeF.cs
@@ -0,0 +1,229 @@
+// Tests for System.Drawing.SizeF.cs
+//
+// Author: Ravindra (rkumar@novell.com)
+//
+// Modified TestPoint.cs for testing SizeF.cs.
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Drawing;
+using System.Security.Permissions;
+using System.Globalization;
+using System.Threading;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class SizeFTest
+ {
+ SizeF sz11_99;
+ SizeF sz11_0;
+ SizeF sz0_11;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ sz11_99 = new SizeF (1.1F, 9.9F);
+ sz11_0 = new SizeF (1.1F, 0F);
+ sz0_11 = new SizeF (0F, 1.1F);
+ }
+
+ [Test]
+ public void TestConstructors ()
+ {
+ SizeF sz_wh = new SizeF (1.5F, 5.8F);
+ Assert.AreEqual (1.5F, sz_wh.Width, "C#1");
+ Assert.AreEqual (5.8F, sz_wh.Height, "C#2");
+
+ SizeF sz_pf = new SizeF (new PointF (1.5F, 5.8F));
+ Assert.AreEqual (1.5F, sz_pf.Width, "C#3");
+ Assert.AreEqual (5.8F, sz_pf.Height, "C#4");
+
+ SizeF sz_sz = new SizeF (sz_wh);
+ Assert.AreEqual (1.5F, sz_sz.Width, "C#5");
+ Assert.AreEqual (5.8F, sz_sz.Height, "C#6");
+
+ Assert.AreEqual (sz_wh, sz_pf, "C#7");
+ Assert.AreEqual (sz_pf, sz_sz, "C#8");
+ Assert.AreEqual (sz_wh, sz_sz, "C#9");
+ }
+
+ [Test]
+ public void TestEmptyField ()
+ {
+ SizeF sz = new SizeF (0.0F, 0.0F);
+ Assert.AreEqual (sz, SizeF.Empty, "EMP#1");
+ }
+
+ [Test]
+ public void TestProperties ()
+ {
+ SizeF sz = new SizeF (0.0F, 0.0F);
+
+ Assert.IsTrue (sz.IsEmpty, "P#1");
+ Assert.IsFalse (sz11_99.IsEmpty, "P#2");
+ Assert.AreEqual (1.1F, sz11_0.Width, "P#3");
+ Assert.AreEqual (1.1F, sz0_11.Height, "P#4");
+ }
+
+ [Test]
+ public void TestEquals ()
+ {
+ Assert.AreEqual (sz11_99, sz11_99, "EQ#1");
+ Assert.AreEqual (sz11_99, new SizeF (1.1F, 9.9F), "EQ#2");
+ Assert.IsFalse (sz11_99.Equals (sz11_0), "EQ#3");
+ Assert.IsFalse (sz11_99.Equals (sz0_11), "EQ#4");
+ Assert.IsFalse (sz11_0.Equals (sz0_11), "EQ#5");
+ }
+
+ [Test]
+ public void Test2PointF ()
+ {
+ PointF p1 = new PointF (1.1F, 9.9F);
+ PointF p2 = sz11_99.ToPointF ();
+
+ Assert.AreEqual (p1, p2, "2PF#1");
+ }
+
+ [Test]
+ public void Test2Size ()
+ {
+ Size sz1 = new Size (1, 9);
+ Size sz2 = sz11_99.ToSize ();
+
+ Assert.AreEqual (sz1, sz2, "2SZ#1");
+ }
+
+
+ [Test]
+ public void TestAddition ()
+ {
+ Assert.AreEqual (sz11_99, sz11_0 + new SizeF (0.0F, 9.9F), "ADD#1");
+ Assert.AreEqual (sz11_99, new SizeF (0.0F, 0.0F) + new SizeF (1.1F, 9.9F), "ADD#2");
+ }
+
+ [Test]
+ public void TestEqualityOp ()
+ {
+ Assert.IsTrue (sz11_99 == sz11_99, "EOP#1");
+ Assert.IsTrue (sz11_99 == new SizeF (1.1F, 9.9F), "EOP#2");
+ Assert.IsFalse (sz11_99 == sz11_0, "EOP#3");
+ Assert.IsFalse (sz11_99 == sz0_11, "EOP#4");
+ Assert.IsFalse (sz11_0 == sz0_11, "EOP#5");
+ }
+
+ [Test]
+ public void TestInequalityOp ()
+ {
+ Assert.IsFalse (sz11_99 != sz11_99, "IOP#1");
+ Assert.IsFalse (sz11_99 != new SizeF (1.1F, 9.9F), "IOP#2");
+ Assert.IsTrue (sz11_99 != sz11_0, "IOP#3");
+ Assert.IsTrue (sz11_99 != sz0_11, "IOP#4");
+ Assert.IsTrue (sz11_0 != sz0_11, "IOP#5");
+ }
+
+ [Test]
+ public void TestSubtraction ()
+ {
+ Assert.AreEqual (sz11_0, sz11_99 - new SizeF (0.0F, 9.9F), "SUB#1");
+ Assert.AreEqual (sz0_11, new SizeF (1.1F, 1.1F) - new SizeF (1.1F, 0.0F), "SUB#2");
+ }
+
+ [Test]
+ public void TestSizeF2PointF ()
+ {
+ PointF pf1 = new PointF (1.1F, 9.9F);
+ PointF pf2 = (PointF) sz11_99;
+
+ Assert.AreEqual (pf1, pf2, "SF2PF#1");
+ }
+
+ [Test]
+ public void GetHashCodeTest ()
+ {
+ Assert.AreEqual (sz11_0.GetHashCode (), new SizeF (1.1f, 0).GetHashCode (), "GHC#1");
+ Assert.AreEqual (Size.Empty.GetHashCode (), new SizeF (0, 0).GetHashCode (), "GHC#2");
+ }
+
+ [Test]
+ public void ToStringTest () {
+ // save current culture
+ CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ PerformToStringTest (new CultureInfo ("en-US"));
+ PerformToStringTest (new CultureInfo ("nl-BE"));
+ } finally {
+ // restore original culture
+ Thread.CurrentThread.CurrentCulture = currentCulture;
+ }
+ }
+
+ private void PerformToStringTest (CultureInfo culture)
+ {
+ // set current culture
+ Thread.CurrentThread.CurrentCulture = culture;
+
+ // perform tests
+ Assert.AreEqual (GetExpectedToString (culture, sz11_0), sz11_0.ToString (),
+ "TS#1-" + culture.Name);
+ Assert.AreEqual (GetExpectedToString (culture, sz0_11), sz0_11.ToString (),
+ "TS#2-" + culture.Name);
+ Assert.AreEqual (GetExpectedToString (culture, SizeF.Empty), SizeF.Empty.ToString (),
+ "TS#3-" + culture.Name);
+ SizeF size = new SizeF (float.NaN, float.NegativeInfinity);
+ Assert.AreEqual (GetExpectedToString (culture, size), size.ToString (),
+ "TS#4-" + culture.Name);
+ }
+
+ private static string GetExpectedToString (CultureInfo culture, SizeF size)
+ {
+ return string.Format ("{{Width={0}, Height={1}}}", size.Width.ToString (culture),
+ size.Height.ToString (culture));
+ }
+
+#if NET_2_0
+ [Test]
+ public void AddTest ()
+ {
+ Assert.AreEqual (sz11_99, SizeF.Add (sz11_0, new SizeF (0.0F, 9.9F)), "ADD#1");
+ Assert.AreEqual (sz11_99, SizeF.Add (new SizeF (0.0F, 0.0F), new SizeF (1.1F, 9.9F)), "ADD#2");
+ }
+
+ [Test]
+ public void SubtractTest ()
+ {
+ Assert.AreEqual (sz11_0, SizeF.Subtract (sz11_99, new SizeF (0.0F, 9.9F)), "SUB#1");
+ Assert.AreEqual (sz0_11, SizeF.Subtract (new SizeF (1.1F, 1.1F), new SizeF (1.1F, 0.0F)), "SUB#2");
+ }
+#endif
+
+ }
+}
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestSizeFConverter.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestSizeFConverter.cs
new file mode 100644
index 00000000000..118dfb904fa
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestSizeFConverter.cs
@@ -0,0 +1,468 @@
+//
+// Tests for System.Drawing.SizeConverter.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Drawing;
+using System.Globalization;
+using System.Security.Permissions;
+using System.Threading;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class SizeFConverterTest
+ {
+ SizeF sz;
+ SizeF szneg;
+ SizeFConverter szconv;
+ String szStrInvariant;
+ String sznegStrInvariant;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ sz = new SizeF (10, 20);
+ szStrInvariant = sz.Width + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + sz.Height;
+
+ szneg = new SizeF (-20, -30);
+ sznegStrInvariant = szneg.Width + CultureInfo.InvariantCulture.TextInfo.ListSeparator + " " + szneg.Height;
+
+ szconv = (SizeFConverter) TypeDescriptor.GetConverter (sz);
+ }
+
+ [Test]
+ public void TestCanConvertFrom ()
+ {
+ Assert.IsTrue (szconv.CanConvertFrom (typeof (String)), "CCF#1");
+ Assert.IsTrue (szconv.CanConvertFrom (null, typeof (String)), "CCF#2");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (Rectangle)), "CCF#3");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (RectangleF)), "CCF#4");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (Point)), "CCF#5");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (PointF)), "CCF#6");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (Size)), "CCF#7");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (SizeF)), "CCF#8");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (Object)), "CCF#9");
+ Assert.IsFalse (szconv.CanConvertFrom (null, typeof (int)), "CCF#10");
+ Assert.IsTrue (szconv.CanConvertFrom (null, typeof (InstanceDescriptor)), "CCF#11");
+ }
+
+ [Test]
+ public void TestCanConvertTo ()
+ {
+ Assert.IsTrue (szconv.CanConvertTo (typeof (String)), "CCT#1");
+ Assert.IsTrue (szconv.CanConvertTo (null, typeof (String)), "CCT#2");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (Rectangle)), "CCT#3");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (RectangleF)), "CCT#4");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (Point)), "CCT#5");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (PointF)), "CCT#6");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (Size)), "CCT#7");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (SizeF)), "CCT#8");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (Object)), "CCT#9");
+ Assert.IsFalse (szconv.CanConvertTo (null, typeof (int)), "CCT#10");
+ }
+
+ [Test]
+ public void TestConvertFrom ()
+ {
+ Assert.AreEqual (sz, (SizeF) szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "10, 20"), "CF#1");
+ Assert.AreEqual (szneg, (SizeF) szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "-20, -30"), "CF#2");
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture, "10");
+ Assert.Fail ("CF#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#3");
+ }
+
+ try {
+ szconv.ConvertFrom ("10");
+ Assert.Fail ("CF#3a: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#3a");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "1, 1, 1");
+ Assert.Fail ("CF#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is ArgumentException, "CF#4");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ "*1, 1");
+ Assert.Fail ("CF#5-1: must throw Exception");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "CF#5-2");
+ Assert.IsNotNull (ex.InnerException, "CF#5-3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "CF#5-4");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Point (10, 10));
+ Assert.Fail ("CF#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#6");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new PointF (10, 10));
+ Assert.Fail ("CF#7: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#7");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new Size (10, 10));
+ Assert.Fail ("CF#8: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#8");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture,
+ new SizeF (10, 10));
+ Assert.Fail ("CF#9: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#9");
+ }
+
+ try {
+ szconv.ConvertFrom (null, CultureInfo.InvariantCulture, 0x10);
+ Assert.Fail ("CF#10: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CF#10");
+ }
+ }
+
+ [Test]
+ public void TestConvertTo ()
+ {
+ Assert.AreEqual (szStrInvariant, (String) szconv.ConvertTo (null,
+ CultureInfo.InvariantCulture, sz, typeof (String)), "CT#1");
+ Assert.AreEqual (sznegStrInvariant, (String) szconv.ConvertTo (null,
+ CultureInfo.InvariantCulture, szneg, typeof (String)), "CT#2");
+
+ try {
+ szconv.ConvertTo (null, CultureInfo.InvariantCulture, sz,
+ typeof (Size));
+ Assert.Fail ("CT#3: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#3");
+ }
+
+ try {
+ szconv.ConvertTo (null, CultureInfo.InvariantCulture, sz,
+ typeof (SizeF));
+ Assert.Fail ("CT#4: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#4");
+ }
+
+ try {
+ szconv.ConvertTo (null, CultureInfo.InvariantCulture, sz,
+ typeof (Point));
+ Assert.Fail ("CT#5: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#5");
+ }
+
+ try {
+ szconv.ConvertTo (null, CultureInfo.InvariantCulture, sz,
+ typeof (PointF));
+ Assert.Fail ("CT#6: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#6");
+ }
+
+ try {
+ szconv.ConvertTo (null, CultureInfo.InvariantCulture, sz,
+ typeof (int));
+ Assert.Fail ("CT#7: must throw NotSupportedException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NotSupportedException, "CT#7");
+ }
+ }
+
+ [Test]
+ public void TestGetCreateInstanceSupported ()
+ {
+ Assert.IsTrue (szconv.GetCreateInstanceSupported (), "GCIS#1");
+ Assert.IsTrue (szconv.GetCreateInstanceSupported (null), "GCIS#2");
+ }
+
+ [Test]
+ public void TestCreateInstance ()
+ {
+ SizeF szInstance;
+
+ Hashtable ht = new Hashtable ();
+ ht.Add ("Width", 10); ht.Add ("Height", 20);
+
+ szInstance = (SizeF) szconv.CreateInstance (ht);
+ Assert.AreEqual (sz, szInstance, "CI#1");
+
+ ht.Clear ();
+ ht.Add ("Width", -20); ht.Add ("Height", -30);
+
+ szInstance = (SizeF) szconv.CreateInstance (null, ht);
+ Assert.AreEqual (szneg, szInstance, "CI#2");
+
+ // Property names are case-sensitive. It should throw
+ // NullRefExc if any of the property names does not match
+ ht.Clear ();
+ ht.Add ("width", 20); ht.Add ("Height", 30);
+ try {
+ szInstance = (SizeF) szconv.CreateInstance (null, ht);
+ Assert.Fail ("CI#3: must throw NullReferenceException");
+ } catch (Exception e) {
+ Assert.IsTrue (e is NullReferenceException, "CI#3");
+ }
+ }
+
+ [Test]
+ public void TestGetPropertiesSupported ()
+ {
+ Assert.IsTrue (szconv.GetPropertiesSupported (), "GPS#1");
+ Assert.IsTrue (szconv.GetPropertiesSupported (null), "GPS#2");
+ }
+
+ [Test]
+ public void TestGetProperties ()
+ {
+ Attribute [] attrs;
+ PropertyDescriptorCollection propsColl;
+
+ propsColl = szconv.GetProperties (sz);
+ Assert.AreEqual (2, propsColl.Count, "GP1#1");
+ Assert.AreEqual (sz.Width, propsColl["Width"].GetValue (sz), "GP1#2");
+ Assert.AreEqual (sz.Height, propsColl["Height"].GetValue (sz), "GP1#3");
+
+ propsColl = szconv.GetProperties (null, szneg);
+ Assert.AreEqual (2, propsColl.Count, "GP2#1");
+ Assert.AreEqual (szneg.Width, propsColl["Width"].GetValue (szneg), "GP2#2");
+ Assert.AreEqual (szneg.Height, propsColl["Height"].GetValue (szneg), "GP2#3");
+
+ propsColl = szconv.GetProperties (null, sz, null);
+ Assert.AreEqual (3, propsColl.Count, "GP3#1");
+ Assert.AreEqual (sz.Width, propsColl["Width"].GetValue (sz), "GP3#2");
+ Assert.AreEqual (sz.Height, propsColl["Height"].GetValue (sz), "GP3#3");
+ Assert.AreEqual (sz.IsEmpty, propsColl["IsEmpty"].GetValue (sz), "GP3#4");
+
+ Type type = typeof (SizeF);
+ attrs = Attribute.GetCustomAttributes (type, true);
+ propsColl = szconv.GetProperties (null, sz, attrs);
+ Assert.AreEqual (0, propsColl.Count, "GP3#5");
+ }
+
+ [Test]
+ public void ConvertFromInvariantString_string ()
+ {
+ Assert.AreEqual (sz, szconv.ConvertFromInvariantString (szStrInvariant),
+ "CFISS#1");
+ Assert.AreEqual (szneg, szconv.ConvertFromInvariantString (sznegStrInvariant),
+ "CFISS#2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFromInvariantString_string_exc_1 ()
+ {
+ szconv.ConvertFromInvariantString ("1, 2, 3");
+ }
+
+ [Test]
+ public void ConvertFromInvariantString_string_exc_2 ()
+ {
+ try {
+ szconv.ConvertFromInvariantString ("hello");
+ Assert.Fail ("#1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.InnerException, "#3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
+ }
+ }
+
+ [Test]
+ public void ConvertFromString_string ()
+ {
+ // save current culture
+ CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ PerformConvertFromStringTest (new CultureInfo ("en-US"));
+ PerformConvertFromStringTest (new CultureInfo ("nl-BE"));
+ PerformConvertFromStringTest (new MyCultureInfo ());
+ } finally {
+ // restore original culture
+ Thread.CurrentThread.CurrentCulture = currentCulture;
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ConvertFromString_string_exc_1 ()
+ {
+ CultureInfo culture = CultureInfo.CurrentCulture;
+ szconv.ConvertFromString (string.Format(culture,
+ "1{0} 2{0} 3{0} 4{0} 5", culture.TextInfo.ListSeparator));
+ }
+
+ [Test]
+ public void ConvertFromString_string_exc_2 ()
+ {
+ try {
+ szconv.ConvertFromString ("hello");
+ Assert.Fail ("#1");
+ } catch (Exception ex) {
+ Assert.AreEqual (typeof (Exception), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.InnerException, "#3");
+ Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#3");
+ }
+ }
+
+ [Test]
+ public void ConvertToInvariantString_string ()
+ {
+ Assert.AreEqual (szStrInvariant, szconv.ConvertToInvariantString (sz),
+ "CFISS#1");
+ Assert.AreEqual (sznegStrInvariant, szconv.ConvertToInvariantString (szneg),
+ "CFISS#2");
+ }
+
+ [Test]
+ public void ConvertToString_string ()
+ {
+ // save current culture
+ CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
+
+ try {
+ PerformConvertToStringTest (new CultureInfo ("en-US"));
+ PerformConvertToStringTest (new CultureInfo ("nl-BE"));
+ PerformConvertToStringTest (new MyCultureInfo ());
+ } finally {
+ // restore original culture
+ Thread.CurrentThread.CurrentCulture = currentCulture;
+ }
+ }
+
+ [Test]
+ public void GetStandardValuesSupported ()
+ {
+ Assert.IsFalse (szconv.GetStandardValuesSupported ());
+ }
+
+ [Test]
+ public void GetStandardValues ()
+ {
+ Assert.IsNull (szconv.GetStandardValues ());
+ }
+
+ [Test]
+ public void GetStandardValuesExclusive ()
+ {
+ Assert.IsFalse (szconv.GetStandardValuesExclusive ());
+ }
+
+ private void PerformConvertFromStringTest (CultureInfo culture)
+ {
+ // set current culture
+ Thread.CurrentThread.CurrentCulture = culture;
+
+ // perform tests
+ Assert.AreEqual (sz, szconv.ConvertFromString (CreateSizeString (culture, sz)),
+ "CFSS#1-" + culture.Name);
+ Assert.AreEqual (szneg, szconv.ConvertFromString (CreateSizeString (culture, szneg)),
+ "CFSS#2-" + culture.Name);
+ }
+
+ private void PerformConvertToStringTest (CultureInfo culture)
+ {
+ // set current culture
+ Thread.CurrentThread.CurrentCulture = culture;
+
+ // perform tests
+ Assert.AreEqual (CreateSizeString (culture, sz), szconv.ConvertToString (sz),
+ "CFISS#1-" + culture.Name);
+ Assert.AreEqual (CreateSizeString (culture, szneg), szconv.ConvertToString (szneg),
+ "CFISS#2-" + culture.Name);
+ }
+
+ private static string CreateSizeString (SizeF size)
+ {
+ return CreateSizeString (CultureInfo.CurrentCulture, size);
+ }
+
+ private static string CreateSizeString (CultureInfo culture, SizeF size)
+ {
+ return string.Format ("{0}{1} {2}", size.Width.ToString (culture),
+ culture.TextInfo.ListSeparator, size.Height.ToString (culture));
+ }
+
+ [Serializable]
+ private sealed class MyCultureInfo : CultureInfo
+ {
+ internal MyCultureInfo () : base ("en-US")
+ {
+ }
+
+ public override object GetFormat (Type formatType)
+ {
+ if (formatType == typeof (NumberFormatInfo)) {
+ NumberFormatInfo nfi = (NumberFormatInfo) ((NumberFormatInfo) base.GetFormat (formatType)).Clone ();
+
+ nfi.NegativeSign = "myNegativeSign";
+ return NumberFormatInfo.ReadOnly (nfi);
+ } else {
+ return base.GetFormat (formatType);
+ }
+ }
+ }
+ }
+
+
+}
+
+#endif \ No newline at end of file
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestStringFormat.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestStringFormat.cs
new file mode 100644
index 00000000000..657cc25078c
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestStringFormat.cs
@@ -0,0 +1,116 @@
+//
+// StringFormatFlags class testing unit
+//
+// Author:
+//
+// Jordi Mas i Hernàndez (jordi@ximian.com)
+//
+// (C) 2004 Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Security.Permissions;
+using NUnit.Framework;
+
+namespace MonoTests.System.Drawing{
+
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class StringFormatTest {
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady()
+ {
+
+ }
+
+ [Test]
+ public void TestSpecialConstructors()
+ {
+ StringFormat smf = StringFormat.GenericDefault;
+ smf = StringFormat.GenericTypographic;
+ }
+
+ [Test]
+ public void TestClone()
+ {
+ StringFormat smf = new StringFormat();
+ StringFormat smfclone = (StringFormat) smf.Clone();
+
+ Assert.AreEqual (smf.LineAlignment, smfclone.LineAlignment);
+ Assert.AreEqual (smf.FormatFlags, smfclone.FormatFlags);
+ Assert.AreEqual (smf.LineAlignment, smfclone.LineAlignment);
+ Assert.AreEqual (smf.Alignment, smfclone.Alignment);
+ Assert.AreEqual (smf.Trimming, smfclone.Trimming);
+ }
+
+ [Test]
+ public void TestAlignment()
+ {
+ StringFormat smf = new StringFormat ();
+
+ smf.LineAlignment = StringAlignment.Center;
+ Assert.AreEqual (StringAlignment.Center, smf.LineAlignment);
+
+ smf.Alignment = StringAlignment.Far;
+ Assert.AreEqual (StringAlignment.Far, smf.Alignment);
+ }
+
+ [Test]
+ public void TestFormatFlags()
+ {
+ StringFormat smf = new StringFormat ();
+
+ smf.FormatFlags = StringFormatFlags.DisplayFormatControl;
+ Assert.AreEqual (StringFormatFlags.DisplayFormatControl, smf.FormatFlags);
+ }
+
+ [Test]
+ public void TabsStops()
+ {
+ StringFormat smf = new StringFormat ();
+
+ float firstTabOffset;
+ float[] tabsSrc = {100, 200, 300, 400};
+ float[] tabStops;
+
+ smf.SetTabStops(200, tabsSrc);
+ tabStops = smf.GetTabStops(out firstTabOffset);
+
+ Assert.AreEqual (200, firstTabOffset);
+ Assert.AreEqual (tabsSrc.Length, tabStops.Length);
+ Assert.AreEqual (tabsSrc[0], tabStops[0]);
+ Assert.AreEqual (tabsSrc[1], tabStops[1]);
+ Assert.AreEqual (tabsSrc[2], tabStops[2]);
+ Assert.AreEqual (tabsSrc[3], tabStops[3]);
+ }
+
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestSystemBrushes.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestSystemBrushes.cs
new file mode 100644
index 00000000000..795cdf851df
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestSystemBrushes.cs
@@ -0,0 +1,718 @@
+// Tests for System.Drawing.SystemBrushes.cs
+//
+// Author: Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class SystemBrushesTest : Assertion
+ {
+ [TearDown]
+ public void TearDown () {}
+
+ [SetUp]
+ public void SetUp () {}
+
+ [Test]
+ public void TestActiveBorder ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.ActiveBorder;
+ Assert ("P1#1", brush.Color.IsSystemColor);
+ AssertEquals ("P1#2", SystemColors.ActiveBorder, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P1#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P1#3", true);
+ }
+
+ try {
+ brush.Color = SystemColors.ActiveBorder;
+ Fail ("P1#4: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P1#4", true);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P1#5: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("P1#5", true);
+ }
+ }
+
+ [Test]
+ public void TestActiveCaption ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.ActiveCaption;
+ Assert ("P2#1", brush.Color.IsSystemColor);
+ AssertEquals ("P2#2", SystemColors.ActiveCaption, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P2#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P2#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.ActiveCaption;
+ Fail ("P2#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P2#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P2#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P2#5", e is ArgumentException);
+ }
+
+ }
+
+ [Test]
+ public void TestActiveCaptionText ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.ActiveCaptionText;
+ Assert ("P3#1", brush.Color.IsSystemColor);
+ AssertEquals ("P3#2", SystemColors.ActiveCaptionText, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P3#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P3#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.ActiveCaptionText;
+ Fail ("P3#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P3#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P3#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P3#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestAppWorkspace ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.AppWorkspace;
+ Assert ("P4#1", brush.Color.IsSystemColor);
+ AssertEquals ("P4#2", SystemColors.AppWorkspace, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P4#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P4#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.AppWorkspace;
+ Fail ("P4#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P4#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P4#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P4#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestControl ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.Control;
+ Assert ("P5#1", brush.Color.IsSystemColor);
+ AssertEquals ("P5#2", SystemColors.Control, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P5#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P5#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.Control;
+ Fail ("P5#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P5#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P5#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P5#5", e is ArgumentException);
+ }
+
+ }
+
+ [Test]
+ public void TestControlDark ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.ControlDark;
+ Assert ("P6#1", brush.Color.IsSystemColor);
+ AssertEquals ("P6#2", SystemColors.ControlDark, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P6#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P6#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.ControlDark;
+ Fail ("P6#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P6#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P6#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P6#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestControlDarkDark ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.ControlDarkDark;
+ Assert ("P7#1", brush.Color.IsSystemColor);
+ AssertEquals ("P7#2", SystemColors.ControlDarkDark, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P7#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P7#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.ControlDarkDark;
+ Fail ("P7#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P7#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P7#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P7#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestControlLight ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.ControlLight;
+ Assert ("P8#1", brush.Color.IsSystemColor);
+ AssertEquals ("P8#2", SystemColors.ControlLight, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P8#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P8#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.ControlLight;
+ Fail ("P8#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P8#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P8#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P8#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestControlLightLight ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.ControlLightLight;
+ Assert ("P9#1", brush.Color.IsSystemColor);
+ AssertEquals ("P9#2", SystemColors.ControlLightLight, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P9#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P9#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.ControlLightLight;
+ Fail ("P9#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P9#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P9#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P9#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestControlText ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.ControlText;
+ Assert ("P10#1", brush.Color.IsSystemColor);
+ AssertEquals ("P10#2", SystemColors.ControlText, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P10#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P10#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.ControlText;
+ Fail ("P10#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P10#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P10#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P10#5", e is ArgumentException);
+ }
+ }
+
+
+ [Test]
+ public void TestDesktop ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.Desktop;
+ Assert ("P11#1", brush.Color.IsSystemColor);
+ AssertEquals ("P11#2", SystemColors.Desktop, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P11#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P11#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.Desktop;
+ Fail ("P11#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P11#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P11#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P11#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestHighlight ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.Highlight;
+ Assert ("P12#1", brush.Color.IsSystemColor);
+ AssertEquals ("P12#2", SystemColors.Highlight, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P12#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P12#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.Highlight;
+ Fail ("P12#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P12#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P12#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P12#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestHighlightText ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.HighlightText;
+ Assert ("P13#1", brush.Color.IsSystemColor);
+ AssertEquals ("P13#2", SystemColors.HighlightText, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P13#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P13#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.HighlightText;
+ Fail ("P13#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P13#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P13#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P13#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestHotTrack ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.HotTrack;
+ Assert ("P14#1", brush.Color.IsSystemColor);
+ AssertEquals ("P14#2", SystemColors.HotTrack, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P14#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P14#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.HotTrack;
+ Fail ("P14#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P14#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P14#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P14#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestInactiveBorder ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.InactiveBorder;
+ Assert ("P15#1", brush.Color.IsSystemColor);
+ AssertEquals ("P15#2", SystemColors.InactiveBorder, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P15#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P15#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.InactiveBorder;
+ Fail ("P15#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P15#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P15#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P15#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestInactiveCaption ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.InactiveCaption;
+ Assert ("P16#1", brush.Color.IsSystemColor);
+ AssertEquals ("P16#2", SystemColors.InactiveCaption, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P16#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P16#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.InactiveCaption;
+ Fail ("P16#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P16#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P16#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P16#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestInfo ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.Info;
+ Assert ("P17#1", brush.Color.IsSystemColor);
+ AssertEquals ("P17#2", SystemColors.Info, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P17#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P17#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.Info;
+ Fail ("P17#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P17#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P17#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P17#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestMenu ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.Menu;
+ Assert ("P18#1", brush.Color.IsSystemColor);
+ AssertEquals ("P18#2", SystemColors.Menu, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P18#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P18#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.Menu;
+ Fail ("P18#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P18#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P18#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P18#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestScrollBar ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.ScrollBar;
+ Assert ("P19#1", brush.Color.IsSystemColor);
+ AssertEquals ("P19#2", SystemColors.ScrollBar, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P19#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P19#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.ScrollBar;
+ Fail ("P19#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P19#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P19#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P19#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestWindow ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.Window;
+ Assert ("P20#1", brush.Color.IsSystemColor);
+ AssertEquals ("P20#2", SystemColors.Window, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P20#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P20#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.Window;
+ Fail ("P20#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P20#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P20#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P20#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestWindowText ()
+ {
+ SolidBrush brush;
+ brush = (SolidBrush) SystemBrushes.WindowText;
+ Assert ("P21#1", brush.Color.IsSystemColor);
+ AssertEquals ("P21#2", SystemColors.WindowText, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("P21#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P21#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.WindowText;
+ Fail ("P21#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P21#4", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("P21#5: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("P21#5", e is ArgumentException);
+ }
+ }
+
+ [Test]
+ public void TestFromSystemColor ()
+ {
+ SolidBrush brush;
+
+ brush = (SolidBrush) SystemBrushes.FromSystemColor (SystemColors.Menu);
+ AssertEquals ("M1#1", SystemColors.Menu, brush.Color);
+
+ try {
+ brush.Color = Color.Red;
+ Fail ("M1#2: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("M1#2", e is ArgumentException);
+ }
+
+ try {
+ brush.Color = SystemColors.Menu;
+ Fail ("M1#3: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("M1#3", e is ArgumentException);
+ }
+
+ try {
+ brush.Dispose();
+ Fail ("M1#4: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("M1#4", e is ArgumentException);
+ }
+
+
+ try {
+ brush = (SolidBrush) SystemBrushes.FromSystemColor (Color.Red);
+ Fail ("M2#1: must throw ArgumentException");
+ } catch (Exception e) {
+ Assert ("M2#1", e is ArgumentException);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestSystemPens.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestSystemPens.cs
new file mode 100644
index 00000000000..1e82a8607df
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/TestSystemPens.cs
@@ -0,0 +1,364 @@
+// Tests for System.Drawing.SystemPens.cs
+//
+// Author:
+// Ravindra (rkumar@novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Security.Permissions;
+
+namespace MonoTests.System.Drawing
+{
+ [TestFixture]
+ [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+ public class SystemPensTest : Assertion
+ {
+ [TearDown]
+ public void TearDown () {}
+
+ [SetUp]
+ public void SetUp () {}
+
+ [Test]
+ public void TestActiveCaptionText ()
+ {
+ Pen pen;
+ pen = SystemPens.ActiveCaptionText;
+ CheckProperties (pen, "P1", SystemColors.ActiveCaptionText);
+ CheckMethods (pen, "M1");
+ }
+
+ [Test]
+ public void TestControl ()
+ {
+ Pen pen;
+ pen = SystemPens.Control;
+ CheckProperties (pen, "P2", SystemColors.Control);
+ CheckMethods (pen, "M2");
+ }
+
+ [Test]
+ public void TestControlDark ()
+ {
+ Pen pen;
+ pen = SystemPens.ControlDark;
+ CheckProperties (pen, "P3", SystemColors.ControlDark);
+ CheckMethods (pen, "M3");
+ }
+
+ [Test]
+ public void TestControlDarkDark ()
+ {
+ Pen pen;
+ pen = SystemPens.ControlDarkDark;
+ CheckProperties (pen, "P4", SystemColors.ControlDarkDark);
+ CheckMethods (pen, "M4");
+ }
+
+ [Test]
+ public void TestControlLight ()
+ {
+ Pen pen;
+ pen = SystemPens.ControlLight;
+ CheckProperties (pen, "P5", SystemColors.ControlLight);
+ CheckMethods (pen, "M5");
+ }
+
+ [Test]
+ public void TestControlLightLight ()
+ {
+ Pen pen;
+ pen = SystemPens.ControlLightLight;
+ CheckProperties (pen, "P6", SystemColors.ControlLightLight);
+ CheckMethods (pen, "M6");
+ }
+
+ [Test]
+ public void TestControlText ()
+ {
+ Pen pen;
+ pen = SystemPens.ControlText;
+ CheckProperties (pen, "P7", SystemColors.ControlText);
+ CheckMethods (pen, "M7");
+ }
+
+ [Test]
+ public void TestGrayText ()
+ {
+ Pen pen;
+ pen = SystemPens.GrayText;
+ CheckProperties (pen, "P8", SystemColors.GrayText);
+ CheckMethods (pen, "M8");
+ }
+
+ [Test]
+ public void TestHighlight ()
+ {
+ Pen pen;
+ pen = SystemPens.Highlight;
+ CheckProperties (pen, "P9", SystemColors.Highlight);
+ CheckMethods (pen, "M9");
+ }
+
+ [Test]
+ public void TestHighlightText ()
+ {
+ Pen pen;
+ pen = SystemPens.HighlightText;
+ CheckProperties (pen, "P10", SystemColors.HighlightText);
+ CheckMethods (pen, "M10");
+ }
+
+ [Test]
+ public void TestInactiveCaptionText ()
+ {
+ Pen pen;
+ pen = SystemPens.InactiveCaptionText;
+ CheckProperties (pen, "P11", SystemColors.InactiveCaptionText);
+ CheckMethods (pen, "M11");
+ }
+
+ [Test]
+ public void TestInfoText ()
+ {
+ Pen pen;
+ pen = SystemPens.InfoText;
+ CheckProperties (pen, "P12", SystemColors.InfoText);
+ CheckMethods (pen, "M12");
+ }
+
+ [Test]
+ public void TestMenuText ()
+ {
+ Pen pen;
+ pen = SystemPens.MenuText;
+ CheckProperties (pen, "P13", SystemColors.MenuText);
+ CheckMethods (pen, "M13");
+ }
+
+ [Test]
+ public void TestWindowFrame ()
+ {
+ Pen pen;
+ pen = SystemPens.WindowFrame;
+ CheckProperties (pen, "P14", SystemColors.WindowFrame);
+ CheckMethods (pen, "M14");
+ }
+
+ [Test]
+ public void TestWindowText ()
+ {
+ Pen pen;
+ pen = SystemPens.WindowText;
+ CheckProperties (pen, "P15", SystemColors.WindowText);
+ CheckMethods (pen, "M15");
+ }
+
+ [Test]
+ public void TestFromSystemColor ()
+ {
+ Pen pen;
+
+ pen = SystemPens.FromSystemColor (SystemColors.MenuText);
+ CheckProperties (pen, "P16", SystemColors.MenuText);
+ CheckMethods (pen, "M16");
+
+ try {
+ pen = SystemPens.FromSystemColor (Color.Red);
+ Fail ("M17: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert ("M17", true);
+ }
+ }
+
+ // helper test functions
+ void CheckProperties (Pen pen, String tag, Color sysColor)
+ {
+ // Try modifying properties of a SystemPen.
+ // ArgumentException must be thrown.
+
+ Assert (tag + "#1", pen.Color.IsSystemColor);
+ AssertEquals (tag + "#1", sysColor, pen.Color);
+
+ try {
+ pen.Alignment = PenAlignment.Center;
+ Fail (tag + "#2: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#2", true);
+ }
+
+ try {
+ pen.Brush = new SolidBrush(Color.Red);
+ Fail (tag + "#3: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#3", true);
+ }
+
+ try {
+ pen.Color = Color.Red;
+ Fail (tag + "#4: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#4", true);
+ }
+
+ try {
+ pen.Color = sysColor;
+ Fail (tag + "#5" + ": must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#5", true);
+ }
+/*
+ try {
+ // NotImplemented
+ pen.CompoundArray = new float[2];
+ Fail (tag + "#6: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#6", true);
+ }
+
+ try {
+ // NotImplemented
+ pen.CustomEndCap = null;
+ Fail (tag + "#7: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#7", true);
+ }
+
+ try {
+ // NotImplemented
+ pen.CustomStartCap = null;
+ Fail (tag + "#8: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#8", true);
+ }
+
+ try {
+ // NotImplemented
+ pen.DashCap = DashCap.Flat;
+ Fail (tag + "#9: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#9", true);
+ }
+*/
+ try {
+ pen.DashOffset = 5.5F;
+ Fail (tag + "#10: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#10", true);
+ }
+
+ try {
+ pen.DashPattern = null;
+ Fail (tag + "#11: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#11", true);
+ }
+
+ try {
+ pen.DashStyle = DashStyle.Dot; // hangs!prob
+ Fail (tag + "#12: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#12", true);
+ }
+/*
+ try {
+ // NotImplemented
+ pen.EndCap = LineCap.Round;
+ Fail (tag + "#13: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#13", true);
+ }
+*/
+ try {
+ pen.LineJoin = LineJoin.Round;
+ Fail (tag + "#14: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#14", true);
+ }
+
+ try {
+ pen.MiterLimit = 0.1f;
+ Fail (tag + "#15: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#15", true);
+ }
+/*
+ try {
+ // NotImplemented
+ pen.StartCap = LineCap.Square;
+ Fail (tag + "#16: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#16", true);
+ }
+*/
+ try {
+ pen.Transform = new Matrix (); //Matrix hangs!problem
+ Fail (tag + "#17: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#17", true);
+ }
+
+ try {
+ pen.Width = 0.5F;
+ Fail (tag + "#18: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#18", true);
+ }
+ }
+
+ void CheckMethods (Pen pen, String tag)
+ {
+ // Try modifying a SystemPen by calling methods.
+ // ArgumentException must be thrown in some cases.
+/*
+ try {
+ // NotImplemented
+ pen.SetLineCap (LineCap.Flat, LineCap.Round, DashCap.Triangle);
+ Fail (tag + "#1: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#1", true);
+ }
+*/
+ pen.ResetTransform ();
+ pen.RotateTransform (90);
+ pen.ScaleTransform (2, 1);
+ pen.TranslateTransform (10, 20);
+ pen.MultiplyTransform (new Matrix ());
+ pen.Clone ();
+
+ try {
+ pen.Dispose ();
+ Fail (tag + "#8: must throw ArgumentException");
+ } catch (ArgumentException) {
+ Assert (tag + "#8", true);
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/1bit.png b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/1bit.png
new file mode 100755
index 00000000000..b87b1cd2350
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/1bit.png
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/4bit.png b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/4bit.png
new file mode 100755
index 00000000000..46bf0761588
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/4bit.png
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/VisualPng.ico b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/VisualPng.ico
new file mode 100644
index 00000000000..68aa3719fb5
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/VisualPng.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/VisualPng1.ico b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/VisualPng1.ico
new file mode 100644
index 00000000000..68aa3719fb5
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/VisualPng1.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver-os2.bmp b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver-os2.bmp
new file mode 100644
index 00000000000..776cd9a3873
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver-os2.bmp
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver1bit.bmp b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver1bit.bmp
new file mode 100644
index 00000000000..d3a1b08f0c1
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver1bit.bmp
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver24bits.bmp b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver24bits.bmp
new file mode 100644
index 00000000000..a5117a587b9
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver24bits.bmp
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver24bits1.bmp b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver24bits1.bmp
new file mode 100644
index 00000000000..a5117a587b9
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver24bits1.bmp
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver32bits.bmp b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver32bits.bmp
new file mode 100644
index 00000000000..d57f1662447
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver32bits.bmp
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver8bits.bmp b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver8bits.bmp
new file mode 100644
index 00000000000..4249d1376f7
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/almogaver8bits.bmp
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/maketransparent.bmp b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/maketransparent.bmp
new file mode 100644
index 00000000000..b9f6a206dd2
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/maketransparent.bmp
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/nature24bits.gif b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/nature24bits.gif
new file mode 100644
index 00000000000..dfd1cd5c978
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/nature24bits.gif
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/nature24bits.jpg b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/nature24bits.jpg
new file mode 100644
index 00000000000..dc21e0de7b3
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/nature24bits.jpg
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/smiley.ico b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/smiley.ico
new file mode 100644
index 00000000000..2a585d3d88f
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/bitmaps/smiley.ico
Binary files differ
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/tests-ms.sh b/mcs/class/System.Drawing/Test/System.Drawing/tests-ms.sh
new file mode 100755
index 00000000000..6e17f270393
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/tests-ms.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+ echo "You should give a list of test names such as: "
+ echo "$0 System.Drawing.TestStringFormat"
+ echo "or"
+ echo "$0 all"
+ exit 1
+fi
+
+export MSNet=Yes
+cp ../../System.Drawing_test_default.dll .
+topdir=../../../..
+NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe
+MONO_PATH=$topdir/nunit20:$topdir/class/lib:.
+
+for i in $@; do
+ if [ "$i" = "all" ]; then
+ fixture=""
+ else
+ fixture="/fixture:MonoTests.${i}"
+ fi
+ MONO_PATH=$MONO_PATH \
+ ${NUNITCONSOLE} System.Drawing_test_default.dll $fixture
+done
+
+
+
diff --git a/mcs/class/System.Drawing/Test/System.Drawing/tests.sh b/mcs/class/System.Drawing/Test/System.Drawing/tests.sh
new file mode 100755
index 00000000000..511cfcd6ee6
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/System.Drawing/tests.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+ echo "You should give a list of test names such as: "
+ echo "$0 System.Drawing.TestStringFormat"
+ echo "or"
+ echo "$0 all"
+ exit 1
+fi
+
+cp ../../System.Drawing_test_default.dll .
+
+topdir=../../../..
+NUNITCONSOLE=$topdir/class/lib/default/nunit-console.exe
+MONO_PATH=$topdir/nunit20:$topdir/class/lib/default:.
+
+
+for i in $@; do
+ if [ "$i" = "all" ]; then
+ fixture=""
+ else
+ fixture="/fixture:MonoTests.${i}"
+ fi
+ MONO_PATH=$MONO_PATH \
+ mono --debug ${NUNITCONSOLE} System.Drawing_test_default.dll $fixture
+done
+
+
+
diff --git a/mcs/class/System.Drawing/Test/Test.dotnet.csproj b/mcs/class/System.Drawing/Test/Test.dotnet.csproj
new file mode 100644
index 00000000000..8a69b3d5816
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/Test.dotnet.csproj
@@ -0,0 +1,543 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{DFE29E81-D6A8-45D4-A627-161F462BE767}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "Test.dotnet"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "Test.dotnet"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
+ />
+ <Reference
+ Name = "System.Drawing"
+ AssemblyName = "System.Drawing"
+ HintPath = "..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"
+ />
+ <Reference
+ Name = "System.Data"
+ AssemblyName = "System.Data"
+ HintPath = "..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.Xml"
+ HintPath = "..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
+ />
+ <Reference
+ Name = "nunit.core"
+ AssemblyName = "nunit.core"
+ HintPath = "..\..\..\..\..\..\..\..\Program Files\NUnit 2.2\bin\nunit.core.dll"
+ AssemblyFolderKey = "hklm\dn\nunit.framework"
+ />
+ <Reference
+ Name = "nunit.framework"
+ AssemblyName = "nunit.framework"
+ HintPath = "..\..\..\..\..\..\..\..\Program Files\NUnit 2.2\bin\nunit.framework.dll"
+ AssemblyFolderKey = "hklm\dn\nunit.framework"
+ />
+ <Reference
+ Name = "nunit.util"
+ AssemblyName = "nunit.util"
+ HintPath = "..\..\..\..\..\..\..\..\Program Files\NUnit 2.2\bin\nunit.util.dll"
+ AssemblyFolderKey = "hklm\dn\nunit.framework"
+ />
+ <Reference
+ Name = "DrawingTestHelper"
+ Project = "{8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "DrawingTest\Test\AssemblyInfo.cs"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest\Test\Bitmap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest\Test\Bitmap1.png"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "DrawingTest\Test\Brush.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest\Test\Graphics.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest\Test\GraphicsPath.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest\Test\GraphicsPathIterator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest\Test\Image.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest\Test\Pen.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest\Test\Region.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "DrawingTest\Test\SampIcon.ico"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\ColorConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\ColorTranslator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestBitmap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestBrushes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestColor.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestFont.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestIcon.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestIconConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestImageConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestImageFormatConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestPens.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestPoint.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestPointConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestPointF.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestRectangle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestRectangleConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestRectangleF.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestRegion.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestSize.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestSizeConverter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestSizeF.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestStringFormat.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestSystemBrushes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\TestSystemPens.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\almogaver1bit.bmp"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\almogaver24bits.bmp"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\almogaver24bits1.bmp"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\almogaver32bits.bmp"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\almogaver8bits.bmp"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\almogaver-os2.bmp"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\maketransparent.bmp"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\nature24bits.gif"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\nature24bits.jpg"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\smiley.ico"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\VisualPng.ico"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\VisualPng1.ico"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\empty-file"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\entries"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\format"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\README.txt"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\almogaver1bit.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\almogaver24bits.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\almogaver24bits1.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\almogaver32bits.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\almogaver8bits.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\almogaver-os2.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\maketransparent.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\nature24bits.gif.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\nature24bits.jpg.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\smiley.ico.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\VisualPng.ico.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\prop-base\VisualPng1.ico.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\almogaver1bit.bmp.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\almogaver24bits.bmp.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\almogaver24bits1.bmp.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\almogaver32bits.bmp.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\almogaver8bits.bmp.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\almogaver-os2.bmp.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\maketransparent.bmp.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\nature24bits.gif.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\nature24bits.jpg.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\smiley.ico.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\VisualPng.ico.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\props\VisualPng1.ico.svn-work"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\almogaver1bit.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\almogaver24bits.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\almogaver24bits1.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\almogaver32bits.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\almogaver8bits.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\almogaver-os2.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\maketransparent.bmp.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\nature24bits.gif.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\nature24bits.jpg.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\smiley.ico.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\VisualPng.ico.svn-base"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Drawing\bitmaps\.svn\text-base\VisualPng1.ico.svn-base"
+ BuildAction = "None"
+ />
+ <Folder RelPath = "System.Drawing\bitmaps\.svn\tmp\prop-base\" />
+ <Folder RelPath = "System.Drawing\bitmaps\.svn\tmp\props\" />
+ <Folder RelPath = "System.Drawing\bitmaps\.svn\tmp\text-base\" />
+ <Folder RelPath = "System.Drawing\bitmaps\.svn\tmp\wcprops\" />
+ <Folder RelPath = "System.Drawing\bitmaps\.svn\wcprops\" />
+ <File
+ RelPath = "System.Drawing.Drawing2D\TestBlend.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\TestColorBlend.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Drawing2D\TestHatchBrush.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\TestBmpCodec.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\TestColorMatrix.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\TestImageAttributes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\TestImageCodecInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Drawing.Imaging\TestJpegCodec.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/System.Drawing/Test/Test.vmwcsproj b/mcs/class/System.Drawing/Test/Test.vmwcsproj
new file mode 100644
index 00000000000..c42968e055e
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/Test.vmwcsproj
@@ -0,0 +1,70 @@
+<VisualStudioProject>
+ <CSHARP ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{D92997D0-B8BD-49A8-A7D0-8B6043930A07}">
+ <Build>
+ <Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="Test" AssemblyOriginatorKeyFile="" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" PreBuildEvent="" PostBuildEvent="" RootNamespace="Test" RunPostBuildEvent="OnBuildSuccess" StartupObject="">
+ <Config Name="Debug_Java" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE;TARGET_JVM" DocumentationFile="" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="1595" Optimize="false" OutputPath="bin\Debug_Java\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ <Config Name="Release_Java" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="TRACE;JAVA" DocumentationFile="" DebugSymbols="false" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="1595" Optimize="true" OutputPath="bin\Release_Java\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ <Config Name="Debug" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE;JAVA" DocumentationFile="" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="1595" Optimize="false" OutputPath="bin\Debug\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4"/>
+ </Settings>
+ <References>
+ <Reference Name="System" AssemblyName="System" HintPath="..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"/>
+ <Reference Name="rt" AssemblyName="rt" HintPath="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\j2sdk1.4\rt.dll" Private="False"/>
+ <Reference Name="DrawingTestHelper_java" Project="{8EF9FC71-4D70-4F89-BF4D-B83EF37D4A0C}" Package="{83B010C7-76FC-4FAD-A26C-00D7EFE60256}"/>
+ <Reference Name="System.Drawing" AssemblyName="System.Drawing" HintPath="..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll" Private="False"/>
+ <Reference Name="System.Data" AssemblyName="System.Data" HintPath="..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"/>
+ <Reference Name="System.Xml" AssemblyName="System.Xml" HintPath="..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Xml.dll"/>
+ <Reference Name="nunit.core" AssemblyName="nunit.core" HintPath="..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\nunit.core.dll" Private="True"/>
+ <Reference Name="nunit.framework" AssemblyName="nunit.framework" HintPath="..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\nunit.framework.dll" Private="True"/>
+ <Reference Name="nunit.util" AssemblyName="nunit.util" HintPath="..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\nunit.util.dll" Private="True"/>
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File RelPath="DrawingTest\Test\Bitmap.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="DrawingTest\Test\Bitmap1.bmp" BuildAction="EmbeddedResource"/>
+ <File RelPath="DrawingTest\Test\Bitmap1.png" BuildAction="EmbeddedResource"/>
+ <File RelPath="DrawingTest\Test\Brush.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="DrawingTest\Test\Graphics.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="DrawingTest\Test\GraphicsPath.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="DrawingTest\Test\GraphicsPathIterator.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="DrawingTest\Test\Image.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="DrawingTest\Test\Pen.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="DrawingTest\Test\Region.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="DrawingTest\Test\SampIcon.ico" BuildAction="None"/>
+ <File RelPath="System.Drawing\ColorConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\ColorTranslator.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestBitmap.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestBrushes.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestColor.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestFont.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestIcon.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestIconConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestImageConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestImageFormatConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestPens.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestPoint.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestPointConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestPointF.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestRectangle.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestRectangleConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestRectangleF.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestRegion.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestSize.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestSizeConverter.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestSizeF.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestStringFormat.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestSystemBrushes.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing\TestSystemPens.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\TestBlend.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\TestColorBlend.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Drawing2D\TestHatchBrush.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\TestBmpCodec.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\TestColorMatrix.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\TestImageAttributes.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\TestImageCodecInfo.cs" SubType="Code" BuildAction="Compile"/>
+ <File RelPath="System.Drawing.Imaging\TestJpegCodec.cs" SubType="Code" BuildAction="Compile"/>
+ </Include>
+ </Files>
+ <UserProperties jarserver="ipa" REFS.JarPath.system.drawing="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Drawing.jar" REFS.JarPath.system="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.jar" REFS.JarPath.system.data="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Data.jar" REFS.JarPath.system.xml="..\..\..\..\..\..\..\..\..\Program Files\Mainsoft\Visual MainWin for J2EE\jgac\vmw4j2ee_110\System.Xml.jar" REFS.JarPath.rt="..\..\..\..\..\..\..\..\..\j2sdk1.4\lib\rt.jar" project.JDKType="1.4.2_05" REFS.JarPath.nunit.framework="..\..\..\..\..\..\..\..\DevQA\studio\GH\DevQA\tests\utils\nunit\nunit-2.2.0\nunit-console\bin\Debug_Java\nunit.framework.jar" REFS.JarPath.nunit.core="..\..\..\..\..\..\..\..\DevQA\studio\GH\DevQA\tests\utils\nunit\nunit-2.2.0\nunit-console\bin\Debug_Java\nunit.core.jar" REFS.JarPath.nunit.util="..\..\..\..\..\..\..\..\DevQA\studio\GH\DevQA\tests\utils\nunit\nunit-2.2.0\nunit-console\bin\Debug_Java\nunit.util.jar"/>
+ </CSHARP>
+ <VisualMainWin><Project Prop2023="1.4.2_05" Prop2024="" Prop2026="" Prop2015="" Version="1.6.0" ProjectType="1"/><References/><Configs><Config Prop2000="0" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="1" Prop2006="C:\views\DevQA\studio\GH\DevQA\tests\utils\nunit\nunit-2.2.0\nunit-console\bin\Debug_Java\nunit-console.jar" Prop2007="" Prop2008="" Prop2009="Test.jar /wait /include:test1" Prop2010="" Prop2011="-1" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="-1" Name="Debug_Java"/><Config Prop2000="1" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="1" Prop2006="C:\Program Files\NUnit 2.2\bin\nunit-gui.exe" Prop2007="" Prop2008="" Prop2009="Test.dll" Prop2010="" Prop2011="-1" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="0" Name="Debug"/><Config Prop2000="0" Prop2001="0" Prop2002="0" Prop2003="0" Prop2004="0" Prop2005="0" Prop2006="" Prop2007="" Prop2008="" Prop2009="" Prop2010="" Prop2011="-1" Prop2012="0" Prop2013="" Prop2014="0" Prop2016="" Prop2027="" Prop2019="0" Prop2020="285212672" Prop2021="4096" Prop2022="0" Prop2017="0" Prop2018="0" Name="Release_Java"/></Configs></VisualMainWin></VisualStudioProject>
diff --git a/mcs/class/System.Drawing/Test/resources/indexed.png b/mcs/class/System.Drawing/Test/resources/indexed.png
new file mode 100644
index 00000000000..2ea1fe10934
--- /dev/null
+++ b/mcs/class/System.Drawing/Test/resources/indexed.png
Binary files differ
diff --git a/mcs/class/System.Drawing/cdeclRedirector/cdeclCallback.dll b/mcs/class/System.Drawing/cdeclRedirector/cdeclCallback.dll
new file mode 100644
index 00000000000..79bd372fb2d
--- /dev/null
+++ b/mcs/class/System.Drawing/cdeclRedirector/cdeclCallback.dll
Binary files differ
diff --git a/mcs/class/System.Drawing/cdeclRedirector/cdeclCallback.il b/mcs/class/System.Drawing/cdeclRedirector/cdeclCallback.il
new file mode 100644
index 00000000000..79d9bc08221
--- /dev/null
+++ b/mcs/class/System.Drawing/cdeclRedirector/cdeclCallback.il
@@ -0,0 +1,204 @@
+//
+// cdeclCallback.il
+//
+// Author:
+// Alexandre Pigolkine (pigolkine@gmx.de)
+//
+// (C) 2002/2003 Ximian, Inc.
+.assembly extern mscorlib
+{
+}
+.assembly cdeclCallback
+{
+}
+
+.namespace cdeclCallback
+{
+ .class public auto ansi beforefieldinit cdeclRedirector
+ extends [mscorlib]System.Object
+ {
+ .class auto ansi sealed nested public MethodVoidIntPtr
+ extends [mscorlib]System.MulticastDelegate
+ {
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ } // end of method MethodVoidIntPtr::.ctor
+
+ .method public hidebysig virtual instance void modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)
+ Invoke(native int param) runtime managed
+ {
+ } // end of method MethodVoidIntPtr::Invoke
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(native int param,
+ class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ } // end of method MethodVoidIntPtr::BeginInvoke
+
+ .method public hidebysig newslot virtual
+ instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ } // end of method MethodVoidIntPtr::EndInvoke
+
+ } // end of class MethodVoidIntPtr
+
+ .class auto ansi sealed nested public MethodIntIntPtr
+ extends [mscorlib]System.MulticastDelegate
+ {
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ } // end of method MethodIntIntPtr::.ctor
+
+ .method public hidebysig virtual instance int32 modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)
+ Invoke(native int param) runtime managed
+ {
+ } // end of method MethodIntIntPtr::Invoke
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(native int param,
+ class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ } // end of method MethodIntIntPtr::BeginInvoke
+
+ .method public hidebysig newslot virtual
+ instance int32 EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ } // end of method MethodIntIntPtr::EndInvoke
+
+ } // end of class MethodIntIntPtr
+
+ .class auto ansi sealed nested public MethodVoidIntPtrInt
+ extends [mscorlib]System.MulticastDelegate
+ {
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ } // end of method MethodVoidIntPtrInt::.ctor
+
+ .method public hidebysig virtual instance void modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)
+ Invoke(native int param,
+ int32 param1) runtime managed
+ {
+ } // end of method MethodVoidIntPtrInt::Invoke
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(native int param,
+ int32 param1,
+ class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ } // end of method MethodVoidIntPtrInt::BeginInvoke
+
+ .method public hidebysig newslot virtual
+ instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ } // end of method MethodVoidIntPtrInt::EndInvoke
+
+ } // end of class MethodVoidIntPtrInt
+
+ .class auto ansi sealed nested public MethodIntIntPtrInt
+ extends [mscorlib]System.MulticastDelegate
+ {
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ } // end of method MethodIntIntPtrInt::.ctor
+
+ .method public hidebysig virtual instance int32 modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)
+ Invoke(native int param,
+ int32 param1) runtime managed
+ {
+ } // end of method MethodIntIntPtrInt::Invoke
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(native int param,
+ int32 param1,
+ class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ } // end of method MethodIntIntPtrInt::BeginInvoke
+
+ .method public hidebysig newslot virtual
+ instance int32 EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ } // end of method MethodIntIntPtrInt::EndInvoke
+
+ } // end of class MethodIntIntPtrInt
+
+ .class auto ansi sealed nested public MethodVoidIntPtrIntPtr
+ extends [mscorlib]System.MulticastDelegate
+ {
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ } // end of method MethodVoidIntPtrIntPtr::.ctor
+
+ .method public hidebysig virtual instance void modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)
+ Invoke(native int param,
+ native int param1) runtime managed
+ {
+ } // end of method MethodVoidIntPtrIntPtr::Invoke
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(native int param,
+ native int param1,
+ class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ } // end of method MethodVoidIntPtrIntPtr::BeginInvoke
+
+ .method public hidebysig newslot virtual
+ instance int32 EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ } // end of method MethodVoidIntPtrIntPtr::EndInvoke
+ } // end of class MethodVoidIntPtrIntPtr
+
+ .class auto ansi sealed nested public MethodVoidIntPtrIntPtrInt
+ extends [mscorlib]System.MulticastDelegate
+ {
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor(object 'object',
+ native int 'method') runtime managed
+ {
+ } // end of method MethodVoidIntPtrIntPtrInt::.ctor
+
+ .method public hidebysig virtual instance void modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)
+ Invoke(native int param,
+ native int param1,
+ int32 param2) runtime managed
+ {
+ } // end of method MethodVoidIntPtrIntPtrInt::Invoke
+
+ .method public hidebysig newslot virtual
+ instance class [mscorlib]System.IAsyncResult
+ BeginInvoke(native int param,
+ native int param1,
+ int32 param2,
+ class [mscorlib]System.AsyncCallback callback,
+ object 'object') runtime managed
+ {
+ } // end of method MethodVoidIntPtrIntPtrInt::BeginInvoke
+
+ .method public hidebysig newslot virtual
+ instance int32 EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
+ {
+ } // end of method MethodVoidIntPtrIntPtrInt::EndInvoke
+
+
+ } // end of class MethodVoidIntPtrIntPtrInt
+ } // end of class cdeclRedirector
+}
diff --git a/mcs/class/System.Drawing/net_1_1_java_System.Drawing.dll.exclude.sources b/mcs/class/System.Drawing/net_1_1_java_System.Drawing.dll.exclude.sources
new file mode 100644
index 00000000000..f4fe0d38a25
--- /dev/null
+++ b/mcs/class/System.Drawing/net_1_1_java_System.Drawing.dll.exclude.sources
@@ -0,0 +1,82 @@
+##files existing in both profiles
+System.Drawing.Drawing2D/AdjustableArrowCap.cs
+System.Drawing.Drawing2D/CustomLineCap.cs
+System.Drawing.Drawing2D/GraphicsContainer.cs
+System.Drawing.Drawing2D/GraphicsPath.cs
+System.Drawing.Drawing2D/GraphicsPathIterator.cs
+System.Drawing.Drawing2D/GraphicsState.cs
+System.Drawing.Drawing2D/HatchBrush.cs
+System.Drawing.Drawing2D/LinearGradientBrush.cs
+System.Drawing.Drawing2D/Matrix.cs
+System.Drawing.Drawing2D/PathGradientBrush.cs
+System.Drawing.Imaging/EncoderParameter.cs
+System.Drawing.Imaging/ImageAttributes.cs
+System.Drawing.Imaging/ImageCodecInfo.cs
+System.Drawing.Imaging/Metafile.cs
+System.Drawing.Text/FontCollection.cs
+System.Drawing.Text/InstalledFontCollection.cs
+System.Drawing.Text/PrivateFontCollection.cs
+System.Drawing/Bitmap.cs
+System.Drawing/Brush.cs
+System.Drawing/Font.cs
+System.Drawing/FontFamily.cs
+System.Drawing/Graphics.cs
+System.Drawing/Icon.cs
+System.Drawing/Image.cs
+System.Drawing/Pen.cs
+System.Drawing/Region.cs
+System.Drawing/SolidBrush.cs
+System.Drawing/StringFormat.cs
+System.Drawing/SystemColors.cs
+System.Drawing/SystemIcons.cs
+System.Drawing/TextureBrush.cs
+
+##completely different files
+System.Drawing.Design/CategoryNameCollection.cs
+System.Drawing.Design/IPropertyValueUIService.cs
+System.Drawing.Design/IToolboxService.cs
+System.Drawing.Design/IToolboxUser.cs
+System.Drawing.Design/PaintValueEventArgs.cs
+System.Drawing.Design/PropertyValueItem.cs
+System.Drawing.Design/PropertyValueUIHandler.cs
+System.Drawing.Design/PropertyValueUIItemInvokeHandler.cs
+System.Drawing.Design/ToolboxItemCollection.cs
+System.Drawing.Design/ToolboxItemCreatorCallback.cs
+System.Drawing.Imaging/PlayRecordCallback.cs
+System.Drawing.Printing/Duplex.cs
+System.Drawing.Printing/InvalidPrinterException.cs
+System.Drawing.Printing/Margins.cs
+System.Drawing.Printing/MarginsConverter.cs
+System.Drawing.Printing/PageSettings.cs
+System.Drawing.Printing/PaperKind.cs
+System.Drawing.Printing/PaperSize.cs
+System.Drawing.Printing/PaperSource.cs
+System.Drawing.Printing/PaperSourceKind.cs
+System.Drawing.Printing/PreviewPageInfo.cs
+System.Drawing.Printing/PreviewPrintController.cs
+System.Drawing.Printing/PrintController.cs
+System.Drawing.Printing/PrintDocument.cs
+System.Drawing.Printing/PrintEventArgs.cs
+System.Drawing.Printing/PrintEventHandler.cs
+System.Drawing.Printing/PrintPageEventArgs.cs
+System.Drawing.Printing/PrintPageEventHandler.cs
+System.Drawing.Printing/PrintRange.cs
+System.Drawing.Printing/PrinterResolution.cs
+System.Drawing.Printing/PrinterResolutionKind.cs
+System.Drawing.Printing/PrinterSettings.cs
+System.Drawing.Printing/PrinterUnit.cs
+System.Drawing.Printing/PrinterUnitConvert.cs
+System.Drawing.Printing/PrintingPermission.cs
+System.Drawing.Printing/PrintingPermissionAttribute.cs
+System.Drawing.Printing/PrintingPermissionLevel.cs
+System.Drawing.Printing/QueryPageSettingsEventArgs.cs
+System.Drawing.Printing/QueryPageSettingsEventHandler.cs
+System.Drawing.Printing/StandardPrintController.cs
+System.Drawing/ComIStreamMarshaler.cs
+System.Drawing/ComIStreamWrapper.cs
+System.Drawing/SRDescriptionAttribute.cs
+System.Drawing/gdipEnums.cs
+System.Drawing/gdipFunctions.cs
+System.Drawing/gdipStructs.cs
+System.Drawing/carbonFunctions.cs
+
diff --git a/mcs/class/System.Drawing/net_1_1_java_System.Drawing.dll.sources b/mcs/class/System.Drawing/net_1_1_java_System.Drawing.dll.sources
new file mode 100644
index 00000000000..9d557f864e7
--- /dev/null
+++ b/mcs/class/System.Drawing/net_1_1_java_System.Drawing.dll.sources
@@ -0,0 +1,49 @@
+#include System.Drawing.dll.sources
+
+##files existing in both profiles
+System.Drawing.Drawing2D/AdjustableArrowCap.jvm.cs
+System.Drawing.Drawing2D/CustomLineCap.jvm.cs
+System.Drawing.Drawing2D/GraphicsContainer.jvm.cs
+System.Drawing.Drawing2D/GraphicsPath.jvm.cs
+System.Drawing.Drawing2D/GraphicsPathIterator.jvm.cs
+System.Drawing.Drawing2D/GraphicsState.jvm.cs
+System.Drawing.Drawing2D/HatchBrush.jvm.cs
+System.Drawing.Drawing2D/LinearGradientBrush.jvm.cs
+System.Drawing.Drawing2D/Matrix.jvm.cs
+System.Drawing.Drawing2D/PathGradientBrush.jvm.cs
+System.Drawing.Imaging/EncoderParameter.jvm.cs
+System.Drawing.Imaging/ImageAttributes.jvm.cs
+System.Drawing.Imaging/ImageCodecInfo.jvm.cs
+System.Drawing.Imaging/Metafile.jvm.cs
+System.Drawing.Text/FontCollection.jvm.cs
+System.Drawing.Text/InstalledFontCollection.jvm.cs
+System.Drawing.Text/PrivateFontCollection.jvm.cs
+System.Drawing/Bitmap.jvm.cs
+System.Drawing/Brush.jvm.cs
+System.Drawing/Font.jvm.cs
+System.Drawing/FontFamily.jvm.cs
+System.Drawing/Graphics.jvm.cs
+System.Drawing/Icon.jvm.cs
+System.Drawing/Image.jvm.cs
+System.Drawing/Pen.jvm.cs
+System.Drawing/Region.jvm.cs
+System.Drawing/SolidBrush.jvm.cs
+System.Drawing/StringFormat.jvm.cs
+System.Drawing/SystemColors.jvm.cs
+System.Drawing/SystemIcons.jvm.cs
+System.Drawing/TextureBrush.jvm.cs
+
+##completely different files
+System.Drawing.Drawing2D/ExtendedGeneralPath.jvm.cs
+System.Drawing.Drawing2D/GeneralPathIterator.jvm.cs
+System.Drawing.Imaging/ImageCodec.jvm.cs
+Mainsoft.Drawing.Configuration.jvm/ResolutionConfiguration.cs
+Mainsoft.Drawing.Configuration.jvm/ResolutionConfigurationCollection.cs
+Mainsoft.Drawing.Configuration.jvm/ResolutionConfigurationHandler.cs
+System.Drawing.Text/LineLayout.jvm.cs
+System.Drawing.Text/TextLineIterator.jvm.cs
+System.Drawing/AdvancedStroke.jvm.cs
+System.Drawing/BasicShape.jvm.cs
+System.Drawing/PlainImage.jvm.cs
+System.Drawing/PlainImageCollection.jvm.cs
+System.Drawing/StrokeFactory.jvm.cs